Optimizations

This commit is contained in:
Daniel Mills 2020-10-13 04:27:25 -04:00
parent 80b1374a61
commit 74e59fa47b
3 changed files with 61 additions and 26 deletions

View File

@ -41,15 +41,15 @@ public class IrisSettings
@DontObfuscate
@Desc("Useful information when creating iris worlds. Shows object loads & more.")
public boolean verbose = false;
@DontObfuscate
@Desc("System Effects")
public boolean systemEffects = true;
@DontObfuscate
@Desc("System Spawn Overrides")
public boolean systemEntitySpawnOverrides = true;
@DontObfuscate
@Desc("System Spawn Initials")
public boolean systemEntityInitialSpawns = true;
@ -96,6 +96,11 @@ public class IrisSettings
public static IrisSettings get()
{
if(settings != null)
{
return settings;
}
IrisSettings defaults = new IrisSettings();
JSONObject def = new JSONObject(new Gson().toJson(defaults));
if(settings == null)
@ -157,7 +162,7 @@ public class IrisSettings
catch(JSONException | IOException e)
{
e.printStackTrace();
//noinspection ResultOfMethodCallIgnored
// noinspection ResultOfMethodCallIgnored
s.delete();
}
}

View File

@ -20,7 +20,6 @@ import com.volmit.iris.object.DecorationPart;
import com.volmit.iris.object.InferredType;
import com.volmit.iris.object.IrisBiome;
import com.volmit.iris.object.IrisBiomeDecorator;
import com.volmit.iris.object.IrisBiomeGeneratorLink;
import com.volmit.iris.object.IrisDepositGenerator;
import com.volmit.iris.object.IrisDimension;
import com.volmit.iris.object.IrisGenerator;
@ -781,16 +780,7 @@ public abstract class TopographicTerrainProvider extends ParallelTerrainProvider
{
try
{
IrisBiome b = sampleBiome((int) xx, (int) zz);
for(int j = 0; j < b.getGenerators().size(); j++)
{
IrisBiomeGeneratorLink i = b.getGenerators().get(j);
if(i.getGenerator().equals(gen.getLoadKey()))
{
return i.getMax();
}
}
return sampleBiome((int) xx, (int) zz).getGenLinkMax(gen.getLoadKey());
}
catch(Throwable e)
@ -805,16 +795,7 @@ public abstract class TopographicTerrainProvider extends ParallelTerrainProvider
{
try
{
IrisBiome b = sampleBiome((int) xx, (int) zz);
for(int j = 0; j < b.getGenerators().size(); j++)
{
IrisBiomeGeneratorLink i = b.getGenerators().get(j);
if(i.getGenerator().equals(gen.getLoadKey()))
{
return i.getMin();
}
}
return sampleBiome((int) xx, (int) zz).getGenLinkMin(gen.getLoadKey());
}
catch(Throwable e)

View File

@ -17,6 +17,7 @@ import com.volmit.iris.util.Desc;
import com.volmit.iris.util.DontObfuscate;
import com.volmit.iris.util.IRare;
import com.volmit.iris.util.KList;
import com.volmit.iris.util.KMap;
import com.volmit.iris.util.KSet;
import com.volmit.iris.util.MaxNumber;
import com.volmit.iris.util.MinNumber;
@ -190,6 +191,9 @@ public class IrisBiome extends IrisRegistrant implements IRare
private transient InferredType inferredType;
private final transient AtomicCache<KMap<String, IrisBiomeGeneratorLink>> genCache = new AtomicCache<>();
private final transient AtomicCache<KMap<String, Integer>> genCacheMax = new AtomicCache<>();
private final transient AtomicCache<KMap<String, Integer>> genCacheMin = new AtomicCache<>();
private final transient AtomicCache<KList<IrisObjectPlacement>> surfaceObjectsCache = new AtomicCache<>(false);
private final transient AtomicCache<KList<IrisObjectPlacement>> carveObjectsCache = new AtomicCache<>(false);
private final transient AtomicCache<Color> cacheColor = new AtomicCache<>(true);
@ -201,6 +205,51 @@ public class IrisBiome extends IrisRegistrant implements IRare
private final transient AtomicCache<KList<CNG>> layerHeightGenerators = new AtomicCache<>();
private final transient AtomicCache<KList<CNG>> layerSeaHeightGenerators = new AtomicCache<>();
public double getGenLinkMax(String loadKey)
{
return genCacheMax.aquire(() ->
{
KMap<String, Integer> l = new KMap<>();
for(IrisBiomeGeneratorLink i : getGenerators())
{
l.put(i.getGenerator(), i.getMax());
}
return l;
}).compute(loadKey, (k, v) -> v != null ? v : 0);
}
public double getGenLinkMin(String loadKey)
{
return genCacheMin.aquire(() ->
{
KMap<String, Integer> l = new KMap<>();
for(IrisBiomeGeneratorLink i : getGenerators())
{
l.put(i.getGenerator(), i.getMin());
}
return l;
}).compute(loadKey, (k, v) -> v != null ? v : 0);
}
public IrisBiomeGeneratorLink getGenLink(String loadKey)
{
return genCache.aquire(() ->
{
KMap<String, IrisBiomeGeneratorLink> l = new KMap<>();
for(IrisBiomeGeneratorLink i : getGenerators())
{
l.put(i.getGenerator(), i);
}
return l;
}).get(loadKey);
}
public IrisBiome getRealCarvingBiome(IrisDataManager data)
{
return realCarveBiome.aquire(() ->
@ -617,7 +666,7 @@ public class IrisBiome extends IrisRegistrant implements IRare
{
return B.get("AIR");
}
return getLayers().get(0).get(rng, x, 0, z, idm);
}
}