mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-28 13:15:30 +01:00
Merge pull request #383 from mikeprimm/master
Fix subblock rendering of scaled down models (esp flat ones like rails, redstone) (for 0.20.1)
This commit is contained in:
commit
4fd3382493
@ -242,8 +242,6 @@ public class IsoHDPerspective implements HDPerspective {
|
|||||||
t = 0;
|
t = 0;
|
||||||
/* 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) {
|
||||||
@ -552,9 +550,11 @@ public class IsoHDPerspective implements HDPerspective {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean logit = false;
|
||||||
|
|
||||||
private boolean raytraceSubblock(short[] model, boolean firsttime) {
|
private boolean raytraceSubblock(short[] model, boolean firsttime) {
|
||||||
if(firsttime) {
|
if(firsttime) {
|
||||||
mt = t + 0.0000001;
|
mt = t + 0.00000001;
|
||||||
xx = top.x + mt *(bottom.x - top.x);
|
xx = top.x + mt *(bottom.x - top.x);
|
||||||
yy = top.y + mt *(bottom.y - top.y);
|
yy = top.y + mt *(bottom.y - top.y);
|
||||||
zz = top.z + mt *(bottom.z - top.z);
|
zz = top.z + mt *(bottom.z - top.z);
|
||||||
@ -583,7 +583,7 @@ public class IsoHDPerspective implements HDPerspective {
|
|||||||
}
|
}
|
||||||
subalpha = -1;
|
subalpha = -1;
|
||||||
boolean skip = !firsttime; /* Skip first block on continue */
|
boolean skip = !firsttime; /* Skip first block on continue */
|
||||||
while(mt < mtend) {
|
while(mt <= mtend) {
|
||||||
if(!skip) {
|
if(!skip) {
|
||||||
try {
|
try {
|
||||||
int blkalpha = model[modscale*modscale*my + modscale*mz + mx];
|
int blkalpha = model[modscale*modscale*my + modscale*mz + mx];
|
||||||
@ -605,8 +605,9 @@ public class IsoHDPerspective implements HDPerspective {
|
|||||||
mt = mt_next_x;
|
mt = mt_next_x;
|
||||||
mt_next_x += mdt_dx;
|
mt_next_x += mdt_dx;
|
||||||
laststep = stepx;
|
laststep = stepx;
|
||||||
if(mx == mxout)
|
if(mx == mxout) {
|
||||||
return true;
|
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)) {
|
||||||
@ -614,8 +615,9 @@ public class IsoHDPerspective implements HDPerspective {
|
|||||||
mt = mt_next_y;
|
mt = mt_next_y;
|
||||||
mt_next_y += mdt_dy;
|
mt_next_y += mdt_dy;
|
||||||
laststep = stepy;
|
laststep = stepy;
|
||||||
if(my == myout)
|
if(my == myout) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* Else, Z step is next best */
|
/* Else, Z step is next best */
|
||||||
else {
|
else {
|
||||||
@ -623,22 +625,28 @@ public class IsoHDPerspective implements HDPerspective {
|
|||||||
mt = mt_next_z;
|
mt = mt_next_z;
|
||||||
mt_next_z += mdt_dz;
|
mt_next_z += mdt_dz;
|
||||||
laststep = stepz;
|
laststep = stepz;
|
||||||
if(mz == mzout)
|
if(mz == mzout) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public final int[] getSubblockCoord() {
|
public final int[] getSubblockCoord() {
|
||||||
double tt = t + 0.000001;
|
if(subalpha < 0) {
|
||||||
if(subalpha >= 0)
|
double tt = t + 0.0000001;
|
||||||
tt = mt;
|
double xx = top.x + tt * (bottom.x - top.x);
|
||||||
double xx = top.x + tt * (bottom.x - top.x);
|
double yy = top.y + tt * (bottom.y - top.y);
|
||||||
double yy = top.y + tt * (bottom.y - top.y);
|
double zz = top.z + tt * (bottom.z - top.z);
|
||||||
double zz = top.z + tt * (bottom.z - top.z);
|
subblock_xyz[0] = (int)((xx - Math.floor(xx)) * modscale);
|
||||||
subblock_xyz[0] = (int)((xx - Math.floor(xx)) * modscale);
|
subblock_xyz[1] = (int)((yy - Math.floor(yy)) * modscale);
|
||||||
subblock_xyz[1] = (int)((yy - Math.floor(yy)) * modscale);
|
subblock_xyz[2] = (int)((zz - Math.floor(zz)) * modscale);
|
||||||
subblock_xyz[2] = (int)((zz - Math.floor(zz)) * modscale);
|
}
|
||||||
|
else {
|
||||||
|
subblock_xyz[0] = mx;
|
||||||
|
subblock_xyz[1] = my;
|
||||||
|
subblock_xyz[2] = mz;
|
||||||
|
}
|
||||||
return subblock_xyz;
|
return subblock_xyz;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,6 +131,7 @@ public class TexturePackHDShader implements HDShader {
|
|||||||
if(blocktype == 0) {
|
if(blocktype == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get color from textures */
|
/* Get color from textures */
|
||||||
scaledtp.readColor(ps, mapiter, c, blocktype, lastblocktype, do_biome_shading);
|
scaledtp.readColor(ps, mapiter, c, blocktype, lastblocktype, do_biome_shading);
|
||||||
|
|
||||||
@ -155,13 +156,14 @@ public class TexturePackHDShader implements HDShader {
|
|||||||
/* Handle light level, if needed */
|
/* Handle light level, if needed */
|
||||||
lighting.applyLighting(ps, this, c, tmpcolor);
|
lighting.applyLighting(ps, this, c, tmpcolor);
|
||||||
/* If we got alpha from subblock model, use it instead if it is lower */
|
/* If we got alpha from subblock model, use it instead if it is lower */
|
||||||
if(subalpha >= 0) {
|
/* (disable for now: weighting is wrong, as crosssection is 2D, not 3D based) */
|
||||||
for(Color clr : tmpcolor) {
|
// if(subalpha >= 0) {
|
||||||
int a = clr.getAlpha();
|
// for(Color clr : tmpcolor) {
|
||||||
if(subalpha < a)
|
// int a = clr.getAlpha();
|
||||||
clr.setAlpha(subalpha);
|
// if(subalpha < a)
|
||||||
}
|
// clr.setAlpha(subalpha);
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
/* If no previous color contribution, use new color */
|
/* If no previous color contribution, use new color */
|
||||||
if(color[0].isTransparent()) {
|
if(color[0].isTransparent()) {
|
||||||
for(int i = 0; i < color.length; i++)
|
for(int i = 0; i < color.length; i++)
|
||||||
|
Loading…
Reference in New Issue
Block a user