mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-28 13:15:30 +01:00
Tune render performance
This commit is contained in:
parent
cf08f243d0
commit
9e7e333cc5
@ -96,6 +96,8 @@ public class IsoHDPerspective implements HDPerspective {
|
|||||||
Vector3D top, bottom;
|
Vector3D top, bottom;
|
||||||
int px, py;
|
int px, py;
|
||||||
BlockStep laststep = BlockStep.Y_MINUS;
|
BlockStep laststep = BlockStep.Y_MINUS;
|
||||||
|
|
||||||
|
BlockStep stepx, stepy, stepz;
|
||||||
/* Raytrace state variables */
|
/* Raytrace state variables */
|
||||||
double dx, dy, dz;
|
double dx, dy, dz;
|
||||||
int x, y, z;
|
int x, y, z;
|
||||||
@ -115,6 +117,7 @@ public class IsoHDPerspective implements HDPerspective {
|
|||||||
int subalpha;
|
int subalpha;
|
||||||
double mt;
|
double mt;
|
||||||
double mtend;
|
double mtend;
|
||||||
|
int mxout, myout, mzout;
|
||||||
|
|
||||||
int[] subblock_xyz = new int[3];
|
int[] subblock_xyz = new int[3];
|
||||||
MapIterator mapiter;
|
MapIterator mapiter;
|
||||||
@ -238,56 +241,76 @@ public class IsoHDPerspective implements HDPerspective {
|
|||||||
/* Compute number of steps and increments for each */
|
/* Compute number of steps and increments for each */
|
||||||
n = 1;
|
n = 1;
|
||||||
|
|
||||||
|
int mxout, myout, mzout;
|
||||||
|
|
||||||
/* If perpendicular to X axis */
|
/* If perpendicular to X axis */
|
||||||
if (dx == 0) {
|
if (dx == 0) {
|
||||||
x_inc = 0;
|
x_inc = 0;
|
||||||
t_next_x = Double.MAX_VALUE;
|
t_next_x = Double.MAX_VALUE;
|
||||||
|
stepx = BlockStep.X_PLUS;
|
||||||
|
mxout = modscale;
|
||||||
}
|
}
|
||||||
/* If bottom is right of top */
|
/* If bottom is right of top */
|
||||||
else if (bottom.x > top.x) {
|
else if (bottom.x > top.x) {
|
||||||
x_inc = 1;
|
x_inc = 1;
|
||||||
n += (int) (Math.floor(bottom.x)) - x;
|
n += (int) (Math.floor(bottom.x)) - x;
|
||||||
t_next_x = (Math.floor(top.x) + 1 - top.x) * dt_dx;
|
t_next_x = (Math.floor(top.x) + 1 - top.x) * dt_dx;
|
||||||
|
stepx = BlockStep.X_PLUS;
|
||||||
|
mxout = modscale;
|
||||||
}
|
}
|
||||||
/* Top is right of bottom */
|
/* Top is right of bottom */
|
||||||
else {
|
else {
|
||||||
x_inc = -1;
|
x_inc = -1;
|
||||||
n += x - (int) (Math.floor(bottom.x));
|
n += x - (int) (Math.floor(bottom.x));
|
||||||
t_next_x = (top.x - Math.floor(top.x)) * dt_dx;
|
t_next_x = (top.x - Math.floor(top.x)) * dt_dx;
|
||||||
|
stepx = BlockStep.X_MINUS;
|
||||||
|
mxout = -1;
|
||||||
}
|
}
|
||||||
/* If perpendicular to Y axis */
|
/* If perpendicular to Y axis */
|
||||||
if (dy == 0) {
|
if (dy == 0) {
|
||||||
y_inc = 0;
|
y_inc = 0;
|
||||||
t_next_y = Double.MAX_VALUE;
|
t_next_y = Double.MAX_VALUE;
|
||||||
|
stepy = BlockStep.Y_PLUS;
|
||||||
|
myout = modscale;
|
||||||
}
|
}
|
||||||
/* If bottom is above top */
|
/* If bottom is above top */
|
||||||
else if (bottom.y > top.y) {
|
else if (bottom.y > top.y) {
|
||||||
y_inc = 1;
|
y_inc = 1;
|
||||||
n += (int) (Math.floor(bottom.y)) - y;
|
n += (int) (Math.floor(bottom.y)) - y;
|
||||||
t_next_y = (Math.floor(top.y) + 1 - top.y) * dt_dy;
|
t_next_y = (Math.floor(top.y) + 1 - top.y) * dt_dy;
|
||||||
|
stepy = BlockStep.Y_PLUS;
|
||||||
|
myout = modscale;
|
||||||
}
|
}
|
||||||
/* If top is above bottom */
|
/* If top is above bottom */
|
||||||
else {
|
else {
|
||||||
y_inc = -1;
|
y_inc = -1;
|
||||||
n += y - (int) (Math.floor(bottom.y));
|
n += y - (int) (Math.floor(bottom.y));
|
||||||
t_next_y = (top.y - Math.floor(top.y)) * dt_dy;
|
t_next_y = (top.y - Math.floor(top.y)) * dt_dy;
|
||||||
|
stepy = BlockStep.Y_MINUS;
|
||||||
|
myout = -1;
|
||||||
}
|
}
|
||||||
/* If perpendicular to Z axis */
|
/* If perpendicular to Z axis */
|
||||||
if (dz == 0) {
|
if (dz == 0) {
|
||||||
z_inc = 0;
|
z_inc = 0;
|
||||||
t_next_z = Double.MAX_VALUE;
|
t_next_z = Double.MAX_VALUE;
|
||||||
|
stepz = BlockStep.Z_PLUS;
|
||||||
|
mzout = modscale;
|
||||||
}
|
}
|
||||||
/* If bottom right of top */
|
/* If bottom right of top */
|
||||||
else if (bottom.z > top.z) {
|
else if (bottom.z > top.z) {
|
||||||
z_inc = 1;
|
z_inc = 1;
|
||||||
n += (int) (Math.floor(bottom.z)) - z;
|
n += (int) (Math.floor(bottom.z)) - z;
|
||||||
t_next_z = (Math.floor(top.z) + 1 - top.z) * dt_dz;
|
t_next_z = (Math.floor(top.z) + 1 - top.z) * dt_dz;
|
||||||
|
stepz = BlockStep.Z_PLUS;
|
||||||
|
mzout = modscale;
|
||||||
}
|
}
|
||||||
/* If bottom left of top */
|
/* If bottom left of top */
|
||||||
else {
|
else {
|
||||||
z_inc = -1;
|
z_inc = -1;
|
||||||
n += z - (int) (Math.floor(bottom.z));
|
n += z - (int) (Math.floor(bottom.z));
|
||||||
t_next_z = (top.z - Math.floor(top.z)) * dt_dz;
|
t_next_z = (top.z - Math.floor(top.z)) * dt_dz;
|
||||||
|
stepz = BlockStep.Z_MINUS;
|
||||||
|
mzout = -1;
|
||||||
}
|
}
|
||||||
/* Walk through scene */
|
/* Walk through scene */
|
||||||
laststep = BlockStep.Y_MINUS; /* Last step is down into map */
|
laststep = BlockStep.Y_MINUS; /* Last step is down into map */
|
||||||
@ -363,28 +386,7 @@ public class IsoHDPerspective implements HDPerspective {
|
|||||||
|
|
||||||
return cd.ordinal();
|
return cd.ordinal();
|
||||||
}
|
}
|
||||||
/**
|
private final boolean handleSubModel(short[] model, HDShaderState[] shaderstate, boolean[] shaderdone) {
|
||||||
* Process visit of ray to block
|
|
||||||
*/
|
|
||||||
private boolean visit_block(MapIterator mapiter, HDShaderState[] shaderstate, boolean[] shaderdone) {
|
|
||||||
lastblocktypeid = blocktypeid;
|
|
||||||
blocktypeid = mapiter.getBlockTypeID();
|
|
||||||
if(skiptoair) { /* If skipping until we see air */
|
|
||||||
if(blocktypeid == 0) /* If air, we're done */
|
|
||||||
skiptoair = false;
|
|
||||||
}
|
|
||||||
else if(nonairhit || (blocktypeid != 0)) {
|
|
||||||
blockdata = mapiter.getBlockData();
|
|
||||||
if(blocktypeid == FENCE_BLKTYPEID) { /* Special case for fence - need to fake data so we can render properly */
|
|
||||||
blockdata = generateFenceBlockData(mapiter);
|
|
||||||
}
|
|
||||||
else if(blocktypeid == CHEST_BLKTYPEID) { /* Special case for chest - need to fake data so we can render */
|
|
||||||
blockdata = generateChestBlockData(mapiter);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Look up to see if block is modelled */
|
|
||||||
short[] model = scalemodels.getScaledModel(blocktypeid, blockdata);
|
|
||||||
if(model != null) {
|
|
||||||
boolean firststep = true;
|
boolean firststep = true;
|
||||||
|
|
||||||
while(!raytraceSubblock(model, firststep)) {
|
while(!raytraceSubblock(model, firststep)) {
|
||||||
@ -401,6 +403,34 @@ public class IsoHDPerspective implements HDPerspective {
|
|||||||
nonairhit = true;
|
nonairhit = true;
|
||||||
firststep = false;
|
firststep = false;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Process visit of ray to block
|
||||||
|
*/
|
||||||
|
private final boolean visit_block(MapIterator mapiter, HDShaderState[] shaderstate, boolean[] shaderdone) {
|
||||||
|
lastblocktypeid = blocktypeid;
|
||||||
|
blocktypeid = mapiter.getBlockTypeID();
|
||||||
|
if(skiptoair) { /* If skipping until we see air */
|
||||||
|
if(blocktypeid == 0) /* If air, we're done */
|
||||||
|
skiptoair = false;
|
||||||
|
}
|
||||||
|
else if(nonairhit || (blocktypeid != 0)) {
|
||||||
|
switch(blocktypeid) {
|
||||||
|
case FENCE_BLKTYPEID: /* Special case for fence - need to fake data so we can render properly */
|
||||||
|
blockdata = generateFenceBlockData(mapiter);
|
||||||
|
break;
|
||||||
|
case CHEST_BLKTYPEID: /* Special case for chest - need to fake data so we can render */
|
||||||
|
blockdata = generateChestBlockData(mapiter);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
blockdata = mapiter.getBlockData();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* Look up to see if block is modelled */
|
||||||
|
short[] model = scalemodels.getScaledModel(blocktypeid, blockdata);
|
||||||
|
if(model != null) {
|
||||||
|
return handleSubModel(model, shaderstate, shaderdone);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
boolean done = true;
|
boolean done = true;
|
||||||
@ -437,12 +467,7 @@ public class IsoHDPerspective implements HDPerspective {
|
|||||||
x += x_inc;
|
x += x_inc;
|
||||||
t = t_next_x;
|
t = t_next_x;
|
||||||
t_next_x += dt_dx;
|
t_next_x += dt_dx;
|
||||||
if(x_inc > 0) {
|
laststep = stepx;
|
||||||
laststep = BlockStep.X_PLUS;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
laststep = BlockStep.X_MINUS;
|
|
||||||
}
|
|
||||||
mapiter.stepPosition(laststep);
|
mapiter.stepPosition(laststep);
|
||||||
}
|
}
|
||||||
/* If Y step is next best */
|
/* If Y step is next best */
|
||||||
@ -450,30 +475,17 @@ public class IsoHDPerspective implements HDPerspective {
|
|||||||
y += y_inc;
|
y += y_inc;
|
||||||
t = t_next_y;
|
t = t_next_y;
|
||||||
t_next_y += dt_dy;
|
t_next_y += dt_dy;
|
||||||
if(y_inc > 0) {
|
laststep = stepy;
|
||||||
laststep = BlockStep.Y_PLUS;
|
|
||||||
mapiter.stepPosition(laststep);
|
mapiter.stepPosition(laststep);
|
||||||
if(mapiter.getY() > 127)
|
/* If outside 0-127 range */
|
||||||
return;
|
if((y & (~0x7F)) != 0) return;
|
||||||
}
|
|
||||||
else {
|
|
||||||
laststep = BlockStep.Y_MINUS;
|
|
||||||
mapiter.stepPosition(laststep);
|
|
||||||
if(mapiter.getY() < 0)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/* Else, Z step is next best */
|
/* Else, Z step is next best */
|
||||||
else {
|
else {
|
||||||
z += z_inc;
|
z += z_inc;
|
||||||
t = t_next_z;
|
t = t_next_z;
|
||||||
t_next_z += dt_dz;
|
t_next_z += dt_dz;
|
||||||
if(z_inc > 0) {
|
laststep = stepz;
|
||||||
laststep = BlockStep.Z_PLUS;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
laststep = BlockStep.Z_MINUS;
|
|
||||||
}
|
|
||||||
mapiter.stepPosition(laststep);
|
mapiter.stepPosition(laststep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -531,56 +543,32 @@ public class IsoHDPerspective implements HDPerspective {
|
|||||||
mx += x_inc;
|
mx += x_inc;
|
||||||
mt = mt_next_x;
|
mt = mt_next_x;
|
||||||
mt_next_x += mdt_dx;
|
mt_next_x += mdt_dx;
|
||||||
if(x_inc > 0) {
|
laststep = stepx;
|
||||||
laststep = BlockStep.X_PLUS;
|
if(mx == mxout)
|
||||||
if(mx >= modscale)
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
laststep = BlockStep.X_MINUS;
|
|
||||||
if(mx < 0)
|
|
||||||
//mx += modscale;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* If Y step is next best */
|
/* If Y step is next best */
|
||||||
else if((mt_next_y <= mt_next_x) && (mt_next_y <= mt_next_z)) {
|
else if((mt_next_y <= mt_next_x) && (mt_next_y <= mt_next_z)) {
|
||||||
my += y_inc;
|
my += y_inc;
|
||||||
mt = mt_next_y;
|
mt = mt_next_y;
|
||||||
mt_next_y += mdt_dy;
|
mt_next_y += mdt_dy;
|
||||||
if(y_inc > 0) {
|
laststep = stepy;
|
||||||
laststep = BlockStep.Y_PLUS;
|
if(my == myout)
|
||||||
if(my >= modscale)
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
laststep = BlockStep.Y_MINUS;
|
|
||||||
if(my < 0)
|
|
||||||
//my += modscale;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Else, Z step is next best */
|
/* Else, Z step is next best */
|
||||||
else {
|
else {
|
||||||
mz += z_inc;
|
mz += z_inc;
|
||||||
mt = mt_next_z;
|
mt = mt_next_z;
|
||||||
mt_next_z += mdt_dz;
|
mt_next_z += mdt_dz;
|
||||||
if(z_inc > 0) {
|
laststep = stepz;
|
||||||
laststep = BlockStep.Z_PLUS;
|
if(mz == mzout)
|
||||||
if(mz >= modscale)
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
laststep = BlockStep.Z_MINUS;
|
|
||||||
if(mz < 0)
|
|
||||||
//mz += modscale;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public int[] getSubblockCoord() {
|
public final int[] getSubblockCoord() {
|
||||||
double tt = t + 0.000001;
|
double tt = t + 0.000001;
|
||||||
if(subalpha >= 0)
|
if(subalpha >= 0)
|
||||||
tt = mt;
|
tt = mt;
|
||||||
|
@ -55,9 +55,10 @@ public class TexturePack {
|
|||||||
private static final String CUSTOMWATERFLOWING_PNG = "custom_water_flowing.png";
|
private static final String CUSTOMWATERFLOWING_PNG = "custom_water_flowing.png";
|
||||||
|
|
||||||
/* Color modifier codes (x1000 for value in mapping code) */
|
/* Color modifier codes (x1000 for value in mapping code) */
|
||||||
|
private static final int COLORMOD_NONE = 0;
|
||||||
private static final int COLORMOD_GRASSTONED = 1;
|
private static final int COLORMOD_GRASSTONED = 1;
|
||||||
private static final int COLORMOD_FOLIAGETONED = 2;
|
private static final int COLORMOD_FOLIAGETONED = 2;
|
||||||
// private static final int COLORMOD_WATERTONED = 3;
|
private static final int COLORMOD_WATERTONED = 3; /* Not used */
|
||||||
private static final int COLORMOD_ROT90 = 4;
|
private static final int COLORMOD_ROT90 = 4;
|
||||||
private static final int COLORMOD_ROT180 = 5;
|
private static final int COLORMOD_ROT180 = 5;
|
||||||
private static final int COLORMOD_ROT270 = 6;
|
private static final int COLORMOD_ROT270 = 6;
|
||||||
@ -703,7 +704,7 @@ public class TexturePack {
|
|||||||
/**
|
/**
|
||||||
* Read color for given subblock coordinate, with given block id and data and face
|
* Read color for given subblock coordinate, with given block id and data and face
|
||||||
*/
|
*/
|
||||||
public void readColor(HDPerspectiveState ps, MapIterator mapiter, Color rslt, int blkid, int lastblocktype, boolean biome_shaded) {
|
public final void readColor(final HDPerspectiveState ps, final MapIterator mapiter, final Color rslt, final int blkid, final int lastblocktype, final boolean biome_shaded) {
|
||||||
int blkdata = ps.getBlockData();
|
int blkdata = ps.getBlockData();
|
||||||
HDTextureMap map = HDTextureMap.getMap(blkid, blkdata);
|
HDTextureMap map = HDTextureMap.getMap(blkid, blkdata);
|
||||||
BlockStep laststep = ps.getLastBlockStep();
|
BlockStep laststep = ps.getLastBlockStep();
|
||||||
@ -749,8 +750,12 @@ public class TexturePack {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Handle U-V transorms before fetching color */
|
/* Handle U-V transorms before fetching color */
|
||||||
if(textop > 0) {
|
|
||||||
switch(textop) {
|
switch(textop) {
|
||||||
|
case COLORMOD_NONE:
|
||||||
|
case COLORMOD_GRASSTONED:
|
||||||
|
case COLORMOD_FOLIAGETONED:
|
||||||
|
case COLORMOD_WATERTONED:
|
||||||
|
break;
|
||||||
case COLORMOD_ROT90:
|
case COLORMOD_ROT90:
|
||||||
tmp = u; u = native_scale - v - 1; v = tmp;
|
tmp = u; u = native_scale - v - 1; v = tmp;
|
||||||
break;
|
break;
|
||||||
@ -764,13 +769,18 @@ public class TexturePack {
|
|||||||
u = native_scale - u - 1;
|
u = native_scale - u - 1;
|
||||||
break;
|
break;
|
||||||
case COLORMOD_SHIFTDOWNHALF:
|
case COLORMOD_SHIFTDOWNHALF:
|
||||||
|
if(v < native_scale/2) {
|
||||||
|
rslt.setTransparent();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
v -= native_scale/2;
|
||||||
|
break;
|
||||||
case COLORMOD_SHIFTDOWNHALFANDFLIPHORIZ:
|
case COLORMOD_SHIFTDOWNHALFANDFLIPHORIZ:
|
||||||
if(v < native_scale/2) {
|
if(v < native_scale/2) {
|
||||||
rslt.setTransparent();
|
rslt.setTransparent();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
v -= native_scale/2;
|
v -= native_scale/2;
|
||||||
if(textop == COLORMOD_SHIFTDOWNHALFANDFLIPHORIZ)
|
|
||||||
u = native_scale - u - 1;
|
u = native_scale - u - 1;
|
||||||
break;
|
break;
|
||||||
case COLORMOD_INCLINEDTORCH:
|
case COLORMOD_INCLINEDTORCH:
|
||||||
@ -796,11 +806,12 @@ public class TexturePack {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
case COLORMOD_CLEARINSIDE:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
/* Read color from texture */
|
/* Read color from texture */
|
||||||
rslt.setARGB(texture[v*native_scale + u]);
|
rslt.setARGB(texture[v*native_scale + u]);
|
||||||
if(textop > 0) {
|
|
||||||
LoadedImage li;
|
LoadedImage li;
|
||||||
/* Switch based on texture modifier */
|
/* Switch based on texture modifier */
|
||||||
switch(textop) {
|
switch(textop) {
|
||||||
@ -824,7 +835,6 @@ public class TexturePack {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private static final int biomeLookup(int[] argb, int width, double rainfall, double temp) {
|
private static final int biomeLookup(int[] argb, int width, double rainfall, double temp) {
|
||||||
int t = (int)((1.0-temp)*(width-1));
|
int t = (int)((1.0-temp)*(width-1));
|
||||||
|
Loading…
Reference in New Issue
Block a user