Improve biome generator performance (sync) efficiency

This commit is contained in:
Daniel Mills
2021-07-17 00:29:09 -04:00
parent 7cd0070d90
commit bcdd470567
3 changed files with 33 additions and 8 deletions

View File

@@ -212,6 +212,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
private final transient AtomicCache<CNG> childrenCell = new AtomicCache<>();
private final transient AtomicCache<CNG> biomeGenerator = new AtomicCache<>();
private final transient AtomicCache<Integer> maxHeight = new AtomicCache<>();
private final transient AtomicCache<Integer> maxWithObjectHeight = new AtomicCache<>();
private final transient AtomicCache<IrisBiome> realCarveBiome = new AtomicCache<>();
private final transient AtomicCache<KList<IrisBiome>> realChildren = new AtomicCache<>();
private final transient AtomicCache<KList<CNG>> layerHeightGenerators = new AtomicCache<>();
@@ -425,7 +426,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
return real;
}
private int getMaxHeight() {
public int getMaxHeight() {
return maxHeight.aquire(() ->
{
int maxHeight = 0;
@@ -438,6 +439,29 @@ public class IrisBiome extends IrisRegistrant implements IRare {
});
}
public int getMaxWithObjectHeight(IrisDataManager data) {
return maxWithObjectHeight.aquire(() ->
{
int maxHeight = 0;
for (IrisBiomeGeneratorLink i : getGenerators()) {
maxHeight += i.getMax();
}
int gg = 0;
for(IrisObjectPlacement i : getObjects())
{
for(IrisObject j : data.getObjectLoader().loadAll(i.getPlace()))
{
gg = Math.max(gg, j.getH());
}
}
return maxHeight + gg+3;
});
}
public IrisBiome infer(InferredType t, InferredType type) {
setInferredType(t.equals(InferredType.DEFER) ? type : t);
return this;