Skip to content

Commit

Permalink
Skip sorting regions when there are no indexes.
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanSweet committed Dec 18, 2020
1 parent 2bc0a3f commit 5cfe622
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion gdx/src/com/badlogic/gdx/graphics/g2d/TextureAtlas.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public void parse (Page page) {
}
});

final boolean[] hasIndexes = {false};
ObjectMap<String, Field<Region>> regionFields = new ObjectMap(127, 0.99f); // Size needed to avoid collisions.
regionFields.put("rotate", new Field<Region>() {
public void parse (Region region) {
Expand Down Expand Up @@ -146,6 +147,7 @@ public void parse (Region region) {
regionFields.put("index", new Field<Region>() {
public void parse (Region region) {
region.index = Integer.parseInt(entry[1]);
if (region.index != -1) hasIndexes[0] = true;
}
});

Expand Down Expand Up @@ -209,7 +211,7 @@ public void parse (Region region) {
StreamUtils.closeQuietly(reader);
}

regions.sort(indexComparator);
if (hasIndexes[0]) regions.sort(indexComparator);
}

public Array<Page> getPages () {
Expand Down

0 comments on commit 5cfe622

Please sign in to comment.