Fixed random offset not working properly for flatly-lit models.

This commit is contained in:
RainWarrior 2016-01-04 12:04:30 +03:00
parent 3c08c104cc
commit 686b32bfd0
3 changed files with 9 additions and 4 deletions

View File

@ -35,11 +35,15 @@ public class BlockInfo
public void updateShift() public void updateShift()
{ {
shx = shy = shz = 0; updateShift(false);
}
public void updateShift(boolean ignoreY)
{
long rand = 0; long rand = 0;
if(block.getOffsetType() != EnumOffsetType.NONE) if(block.getOffsetType() != EnumOffsetType.NONE)
{ {
rand = MathHelper.getPositionRandom(blockPos); rand = MathHelper.getCoordinateRandom(blockPos.getX(), ignoreY ? 0 : blockPos.getY(), blockPos.getZ());
shx = ((float)((rand >> 16) & 0xF) / 0xF - .5f) * .5f; shx = ((float)((rand >> 16) & 0xF) / 0xF - .5f) * .5f;
shz = ((float)((rand >> 24) & 0xF) / 0xF - .5f) * .5f; shz = ((float)((rand >> 24) & 0xF) / 0xF - .5f) * .5f;
if(block.getOffsetType() == EnumOffsetType.XYZ) if(block.getOffsetType() == EnumOffsetType.XYZ)
@ -68,6 +72,7 @@ public class BlockInfo
this.blockPos = blockPos; this.blockPos = blockPos;
cachedTint = -1; cachedTint = -1;
cachedMultiplier = -1; cachedMultiplier = -1;
shx = shy = shz = 0;
} }
private float combine(int c, int s1, int s2, int s3) private float combine(int c, int s1, int s2, int s3)

View File

@ -243,6 +243,6 @@ public class VertexLighterFlat extends QuadGatheringTransformer
public void updateBlockInfo() public void updateBlockInfo()
{ {
blockInfo.updateShift(); blockInfo.updateShift(true);
} }
} }

View File

@ -154,7 +154,7 @@ public class VertexLighterSmoothAo extends VertexLighterFlat
@Override @Override
public void updateBlockInfo() public void updateBlockInfo()
{ {
super.updateBlockInfo(); blockInfo.updateShift(false);
blockInfo.updateLightMatrix(); blockInfo.updateLightMatrix();
} }
} }