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,17 +137,32 @@ public class IsoHDPerspective implements HDPerspective {
mapiter = mi;
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
*/
private final void updateLightLevel() {
/* Look up transparency for current block */
BlockTransparency bt = HDTextureMap.getTransparency(blocktypeid);
if(bt == BlockTransparency.TRANSPARENT) {
switch(bt) {
case TRANSPARENT:
skylevel = mapiter.getBlockSkyLight();
emitlevel = mapiter.getBlockEmittedLight();
}
else if(HDTextureMap.getTransparency(lastblocktypeid) != BlockTransparency.SEMITRANSPARENT) {
break;
case OPAQUE:
if(HDTextureMap.getTransparency(lastblocktypeid) != BlockTransparency.SEMITRANSPARENT) {
mapiter.unstepPosition(laststep); /* Back up to block we entered on */
if(mapiter.getY() < 128) {
emitlevel = mapiter.getBlockEmittedLight();
@ -160,17 +175,14 @@ public class IsoHDPerspective implements HDPerspective {
}
else {
mapiter.unstepPosition(laststep); /* Back up to block we entered on */
if(mapiter.getY() < 128) {
mapiter.stepPosition(BlockStep.Y_PLUS); /* Look above */
emitlevel = mapiter.getBlockEmittedLight();
skylevel = mapiter.getBlockSkyLight();
mapiter.stepPosition(BlockStep.Y_MINUS);
} else {
emitlevel = 0;
skylevel = 15;
}
updateSemitransparentLight();
mapiter.stepPosition(laststep);
}
break;
case SEMITRANSPARENT:
updateSemitransparentLight();
break;
}
}
/**
* Get sky light level - only available if shader requested it