Fix lighting quirks with stairs and slabs

This commit is contained in:
Mike Primm 2011-09-13 06:49:07 +08:00 committed by mikeprimm
parent ebfe2a004b
commit e81564c1ae

View File

@ -137,39 +137,51 @@ public class IsoHDPerspective implements HDPerspective {
mapiter = mi; mapiter = mi;
this.isnether = isnether; this.isnether = isnether;
} }
private final void updateSemitransparentLight() {
BlockStep [] steps = { BlockStep.Y_PLUS, BlockStep.X_MINUS, BlockStep.X_PLUS,
BlockStep.Z_MINUS, BlockStep.Z_PLUS };
emitlevel = skylevel = 0;
for(BlockStep s : steps) {
mapiter.stepPosition(s);
int v = mapiter.getBlockEmittedLight();
if(v > emitlevel) emitlevel = v;
v = mapiter.getBlockSkyLight();
if(v > skylevel) skylevel = v;
mapiter.unstepPosition(s);
}
}
/** /**
* Update sky and emitted light * Update sky and emitted light
*/ */
private final void updateLightLevel() { private final void updateLightLevel() {
/* Look up transparency for current block */ /* Look up transparency for current block */
BlockTransparency bt = HDTextureMap.getTransparency(blocktypeid); BlockTransparency bt = HDTextureMap.getTransparency(blocktypeid);
if(bt == BlockTransparency.TRANSPARENT) { switch(bt) {
skylevel = mapiter.getBlockSkyLight(); case TRANSPARENT:
emitlevel = mapiter.getBlockEmittedLight(); skylevel = mapiter.getBlockSkyLight();
} emitlevel = mapiter.getBlockEmittedLight();
else if(HDTextureMap.getTransparency(lastblocktypeid) != BlockTransparency.SEMITRANSPARENT) { break;
mapiter.unstepPosition(laststep); /* Back up to block we entered on */ case OPAQUE:
if(mapiter.getY() < 128) { if(HDTextureMap.getTransparency(lastblocktypeid) != BlockTransparency.SEMITRANSPARENT) {
emitlevel = mapiter.getBlockEmittedLight(); mapiter.unstepPosition(laststep); /* Back up to block we entered on */
skylevel = mapiter.getBlockSkyLight(); if(mapiter.getY() < 128) {
} else { emitlevel = mapiter.getBlockEmittedLight();
emitlevel = 0; skylevel = mapiter.getBlockSkyLight();
skylevel = 15; } else {
} emitlevel = 0;
mapiter.stepPosition(laststep); skylevel = 15;
} }
else { mapiter.stepPosition(laststep);
mapiter.unstepPosition(laststep); /* Back up to block we entered on */ }
if(mapiter.getY() < 128) { else {
mapiter.stepPosition(BlockStep.Y_PLUS); /* Look above */ mapiter.unstepPosition(laststep); /* Back up to block we entered on */
emitlevel = mapiter.getBlockEmittedLight(); updateSemitransparentLight();
skylevel = mapiter.getBlockSkyLight(); mapiter.stepPosition(laststep);
mapiter.stepPosition(BlockStep.Y_MINUS); }
} else { break;
emitlevel = 0; case SEMITRANSPARENT:
skylevel = 15; updateSemitransparentLight();
} break;
mapiter.stepPosition(laststep);
} }
} }
/** /**