Parallax optimization for jigsaw radii

This commit is contained in:
Daniel Mills 2021-01-14 08:37:40 -05:00
parent 031601bfa6
commit 46d810eddf
2 changed files with 40 additions and 10 deletions

View File

@ -65,6 +65,8 @@ public class IrisJigsawPiece extends IrisRegistrant
});
}
public IrisJigsawPieceConnector getConnector(IrisPosition relativePosition) {
for(IrisJigsawPieceConnector i : connectors)
{

View File

@ -31,6 +31,10 @@ public class IrisJigsawStructure extends IrisRegistrant
@Desc("The maximum pieces that can step out from the center piece")
private int maxDepth = 9;
@DontObfuscate
@Desc("Jigsaw grows the parallax layer which slows iris down a bit. Since there are so many pieces, Iris takes the avg piece size and calculates the parallax radius from that. Unless your structures are using only the biggest pieces, your structure should fit in the chosen size fine. If you are seeing cut-off parts of your structures or broken terrain, turn this option on. This option will pick the biggest piece dimensions and multiply it by your (maxDepth+1) * 2 as the size to grow the parallax layer by. But typically kepp this off.")
private boolean useMaxPieceSizeForParallaxRadius = false;
@Desc("Add a noise feature to this village")
@DontObfuscate
private IrisFeature feature = null;
@ -85,21 +89,45 @@ public class IrisJigsawStructure extends IrisRegistrant
public int getMaxDimension()
{
return maxDimension.aquire(() -> {
int max = 0;
KList<String> pools = new KList<>();
KList<String> pieces = new KList<>();
for(String i : getPieces())
if(useMaxPieceSizeForParallaxRadius)
{
loadPiece(i, pools, pieces);
int max = 0;
KList<String> pools = new KList<>();
KList<String> pieces = new KList<>();
for(String i : getPieces())
{
loadPiece(i, pools, pieces);
}
for(String i : pieces)
{
max = Math.max(max, getLoader().getJigsawPieceLoader().load(i).getMax3dDimension());
}
return max * (((getMaxDepth() + 1) * 2) + 1);
}
for(String i : pieces)
else
{
max = Math.max(max, getLoader().getJigsawPieceLoader().load(i).getMax3dDimension());
}
int max = 0;
KList<String> pools = new KList<>();
KList<String> pieces = new KList<>();
return max * (((getMaxDepth() + 1) * 2) + 1);
for(String i : getPieces())
{
loadPiece(i, pools, pieces);
}
int avg = 0;
for(String i : pieces)
{
avg += getLoader().getJigsawPieceLoader().load(i).getMax2dDimension();
}
return (avg/pieces.size()) * (((getMaxDepth() + 1) * 2) + 1);
}
});
}
}