Possible texture packing hang fix
This commit is contained in:
@@ -182,10 +182,9 @@ public class Mods implements Loadable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.debug("Total sprites: @", totalSprites[0]);
|
Log.debug("Total sprites: @", totalSprites[0]);
|
||||||
|
|
||||||
TextureFilter filter = Core.settings.getBool("linear", true) ? TextureFilter.linear : TextureFilter.nearest;
|
TextureFilter filter = Core.settings.getBool("linear", true) ? TextureFilter.linear : TextureFilter.nearest;
|
||||||
Texture[] whiteToDispose = {null};
|
|
||||||
|
|
||||||
class RegionEntry{
|
class RegionEntry{
|
||||||
String name;
|
String name;
|
||||||
@@ -232,15 +231,20 @@ public class Mods implements Loadable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Pixmap[] whitePixmap = {null};
|
||||||
|
Texture[] whiteTex = {null};
|
||||||
|
|
||||||
waitForMain(() -> {
|
waitForMain(() -> {
|
||||||
|
whitePixmap[0] = Pixmaps.blankPixmap();
|
||||||
|
whiteTex[0] = new Texture(whitePixmap[0]);
|
||||||
|
var whiteRegion = new AtlasRegion(whiteTex[0], 0, 0, 1, 1);
|
||||||
|
|
||||||
Core.atlas.dispose();
|
Core.atlas.dispose();
|
||||||
|
|
||||||
//dead shadow-atlas for getting regions, but not pixmaps
|
//dead shadow-atlas for getting regions, but not pixmaps
|
||||||
var shadow = Core.atlas;
|
var shadow = Core.atlas;
|
||||||
//dummy texture atlas that returns the 'shadow' regions; used for mod loading
|
//dummy texture atlas that returns the 'shadow' regions; used for mod loading
|
||||||
Core.atlas = new TextureAtlas(){
|
Core.atlas = new TextureAtlas(){
|
||||||
boolean foundWhite;
|
|
||||||
AtlasRegion whiteRegion;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
//needed for the correct operation of the found() method in the TextureRegion
|
//needed for the correct operation of the found() method in the TextureRegion
|
||||||
@@ -249,13 +253,7 @@ public class Mods implements Loadable{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AtlasRegion white(){
|
public AtlasRegion white(){
|
||||||
if(Core.app.isOnMainThread() && !foundWhite){
|
return whiteRegion;
|
||||||
Pixmap pixmap = Pixmaps.blankPixmap();
|
|
||||||
Texture tex = new Texture(pixmap);
|
|
||||||
whiteToDispose[0] = tex;
|
|
||||||
return whiteRegion = new AtlasRegion(tex, 0, 0, 1, 1);
|
|
||||||
}
|
|
||||||
return super.white();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -312,9 +310,8 @@ public class Mods implements Loadable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
waitForMain(() -> {
|
waitForMain(() -> {
|
||||||
if(whiteToDispose[0] != null){
|
whitePixmap[0].dispose();
|
||||||
whiteToDispose[0].dispose();
|
whiteTex[0].dispose();
|
||||||
}
|
|
||||||
|
|
||||||
//replace old atlas data
|
//replace old atlas data
|
||||||
Core.atlas = packer.flush(filter, new TextureAtlas(){
|
Core.atlas = packer.flush(filter, new TextureAtlas(){
|
||||||
|
|||||||
Reference in New Issue
Block a user