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(); int blocktype = ps.getBlockTypeID();
switch (blocktype) { switch (blocktype) {
case 0: case 0:
case 20:
case 18:
case 17: case 17:
case 18:
case 20:
case 64:
case 71:
case 78: case 78:
case 79: case 79:
blocktype = 0;
break; break;
default: default:
air = false; air = false;
return false; return false;
} }
if (!air) { if ((blocktype == 0) && !air) {
if(iflit && (ps.getEmittedLightLevel() == 0)) { if(iflit && (ps.getMapIterator().getBlockEmittedLight() == 0)) {
return false; return false;
} }
int cr, cg, cb; int cr, cg, cb;

View File

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

View File

@ -240,6 +240,10 @@ public class IsoHDPerspective implements HDPerspective {
* Get pixel Y coordinate * Get pixel Y coordinate
*/ */
public final int getPixelY() { return py; } public final int getPixelY() { return py; }
/**
* Get map iterator
*/
public final MapIterator getMapIterator() { return mapiter; }
/** /**
* Return submodel alpha value (-1 if no submodel rendered) * 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, protected void scan(World world, int seq, boolean isnether, final Color result, final Color result_day,
MapIterator mapiter) { MapIterator mapiter) {
boolean air = true; boolean air = true;
int emitted = 0;
result.setTransparent(); result.setTransparent();
for (;;) { for (;;) {
if (mapiter.getY() < 0) if (mapiter.getY() < 0)
@ -31,6 +32,8 @@ public class CaveTileRenderer extends DefaultTileRenderer {
else else
isnether = false; isnether = false;
} }
if(iflit && (!air))
emitted = mapiter.getBlockEmittedLight();
switch (seq) { switch (seq) {
case 0: case 0:
@ -48,9 +51,11 @@ public class CaveTileRenderer extends DefaultTileRenderer {
seq = (seq + 1) & 3; seq = (seq + 1) & 3;
switch (id) { switch (id) {
case 20:
case 18:
case 17: case 17:
case 18:
case 20:
case 64:
case 71:
case 78: case 78:
case 79: case 79:
id = 0; id = 0;
@ -64,8 +69,9 @@ public class CaveTileRenderer extends DefaultTileRenderer {
} }
if (id == 0 && !air) { if (id == 0 && !air) {
if(iflit && (mapiter.getBlockEmittedLight() == 0)) if(iflit && (emitted == 0)) {
continue; continue;
}
int cr, cg, cb; int cr, cg, cb;
int mult = 256; int mult = 256;