Improve cave render - finish 'onlyiflit' support

This commit is contained in:
Mike Primm 2011-10-13 21:01:41 +08:00 committed by mikeprimm
parent 96a2978548
commit 2c3ec9e001
4 changed files with 25 additions and 7 deletions

View File

@ -102,18 +102,21 @@ public class CaveHDShader implements HDShader {
int blocktype = ps.getBlockTypeID();
switch (blocktype) {
case 0:
case 20:
case 18:
case 17:
case 18:
case 20:
case 64:
case 71:
case 78:
case 79:
blocktype = 0;
break;
default:
air = false;
return false;
}
if (!air) {
if(iflit && (ps.getEmittedLightLevel() == 0)) {
if ((blocktype == 0) && !air) {
if(iflit && (ps.getMapIterator().getBlockEmittedLight() == 0)) {
return false;
}
int cr, cg, cb;

View File

@ -1,5 +1,6 @@
package org.dynmap.hdmap;
import org.dynmap.utils.MapIterator;
import org.dynmap.utils.MapIterator.BlockStep;
import org.dynmap.utils.Vector3D;
@ -56,4 +57,8 @@ public interface HDPerspectiveState {
* Return subblock coordinates of current ray position
*/
int[] getSubblockCoord();
/**
* Get map iterator
*/
MapIterator getMapIterator();
}

View File

@ -240,6 +240,10 @@ public class IsoHDPerspective implements HDPerspective {
* Get pixel Y coordinate
*/
public final int getPixelY() { return py; }
/**
* Get map iterator
*/
public final MapIterator getMapIterator() { return mapiter; }
/**
* Return submodel alpha value (-1 if no submodel rendered)
*/

View File

@ -19,6 +19,7 @@ public class CaveTileRenderer extends DefaultTileRenderer {
protected void scan(World world, int seq, boolean isnether, final Color result, final Color result_day,
MapIterator mapiter) {
boolean air = true;
int emitted = 0;
result.setTransparent();
for (;;) {
if (mapiter.getY() < 0)
@ -31,6 +32,8 @@ public class CaveTileRenderer extends DefaultTileRenderer {
else
isnether = false;
}
if(iflit && (!air))
emitted = mapiter.getBlockEmittedLight();
switch (seq) {
case 0:
@ -48,9 +51,11 @@ public class CaveTileRenderer extends DefaultTileRenderer {
seq = (seq + 1) & 3;
switch (id) {
case 20:
case 18:
case 17:
case 18:
case 20:
case 64:
case 71:
case 78:
case 79:
id = 0;
@ -64,8 +69,9 @@ public class CaveTileRenderer extends DefaultTileRenderer {
}
if (id == 0 && !air) {
if(iflit && (mapiter.getBlockEmittedLight() == 0))
if(iflit && (emitted == 0)) {
continue;
}
int cr, cg, cb;
int mult = 256;