gfx3d: fiddle with poly sorting. break some things, fix more things. broken things I think are due to floating point gfx3d math

This commit is contained in:
zeromus 2010-03-31 19:19:39 +00:00
parent 08714ea7f2
commit cf0cde6108
1 changed files with 5 additions and 4 deletions

View File

@ -1978,8 +1978,8 @@ static bool gfx3d_ysort_compare(int num1, int num2)
//also the buttons in the knights in the nightmare frontend depend on this and the perspective division //also the buttons in the knights in the nightmare frontend depend on this and the perspective division
if (poly1.maxy < poly2.maxy) return true; if (poly1.maxy < poly2.maxy) return true;
if (poly1.maxy > poly2.maxy) return false; if (poly1.maxy > poly2.maxy) return false;
if (poly1.miny > poly2.miny) return true; if (poly1.miny < poly2.miny) return true;
if (poly1.miny < poly2.miny) return false; if (poly1.miny > poly2.miny) return false;
//notably, the main shop interface in harvest moon will not have a correct RTN button //notably, the main shop interface in harvest moon will not have a correct RTN button
//i think this is due to a math error rounding its position to one pixel too high and it popping behind //i think this is due to a math error rounding its position to one pixel too high and it popping behind
//the bar that it sits on. //the bar that it sits on.
@ -2031,17 +2031,18 @@ static void gfx3d_doFlush()
POLY &poly = polylist->list[i]; POLY &poly = polylist->list[i];
float verty = vertlist->list[poly.vertIndexes[0]].y; float verty = vertlist->list[poly.vertIndexes[0]].y;
float vertw = vertlist->list[poly.vertIndexes[0]].w; float vertw = vertlist->list[poly.vertIndexes[0]].w;
verty = (verty+vertw)/(2*vertw); verty = 1.0f-(verty+vertw)/(2*vertw);
poly.miny = poly.maxy = verty; poly.miny = poly.maxy = verty;
for(int j=1; j<poly.type; j++) for(int j=1; j<poly.type; j++)
{ {
verty = vertlist->list[poly.vertIndexes[j]].y; verty = vertlist->list[poly.vertIndexes[j]].y;
vertw = vertlist->list[poly.vertIndexes[j]].w; vertw = vertlist->list[poly.vertIndexes[j]].w;
verty = (verty+vertw)/(2*vertw); verty = 1.0f-(verty+vertw)/(2*vertw);
poly.miny = min(poly.miny, verty); poly.miny = min(poly.miny, verty);
poly.maxy = max(poly.maxy, verty); poly.maxy = max(poly.maxy, verty);
} }
} }
//we need to sort the poly list with alpha polys last //we need to sort the poly list with alpha polys last