mirror of
https://gitlab.com/GaryOderNichts/re3-wiiu.git
synced 2024-11-27 03:24:15 +01:00
fixed CRenderer::ScanSectorPoly again
This commit is contained in:
parent
537b63acb5
commit
23c52c1c86
@ -889,6 +889,12 @@ CalcNewDelta(RwV2d *a, RwV2d *b)
|
||||
return (b->x - a->x) / (b->y - a->y);
|
||||
}
|
||||
|
||||
#ifdef FIX_BUGS
|
||||
#define TOINT(x) ((int)Floor(x))
|
||||
#else
|
||||
#define TOINT(x) ((int)(x))
|
||||
#endif
|
||||
|
||||
void
|
||||
CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrList *))
|
||||
{
|
||||
@ -914,13 +920,8 @@ CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrL
|
||||
a2 = i;
|
||||
}
|
||||
}
|
||||
#ifdef FIX_BUGS
|
||||
y = Floor(miny);
|
||||
yend = Floor(maxy);
|
||||
#else
|
||||
y = miny;
|
||||
yend = maxy;
|
||||
#endif
|
||||
y = TOINT(miny);
|
||||
yend = TOINT(maxy);
|
||||
|
||||
// Go left in poly to find first edge b
|
||||
b2 = a2;
|
||||
@ -928,8 +929,8 @@ CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrL
|
||||
b1 = b2--;
|
||||
if(b2 < 0) b2 = numVertices-1;
|
||||
if(poly[b1].x < xstart)
|
||||
xstart = poly[b1].x;
|
||||
if((int)poly[b1].y != (int)poly[b2].y)
|
||||
xstart = TOINT(poly[b1].x);
|
||||
if(TOINT(poly[b1].y) != TOINT(poly[b2].y))
|
||||
break;
|
||||
}
|
||||
// Go right to find first edge a
|
||||
@ -937,8 +938,8 @@ CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrL
|
||||
a1 = a2++;
|
||||
if(a2 == numVertices) a2 = 0;
|
||||
if(poly[a1].x > xend)
|
||||
xend = poly[a1].x;
|
||||
if((int)poly[a1].y != (int)poly[a2].y)
|
||||
xend = TOINT(poly[a1].x);
|
||||
if(TOINT(poly[a1].y) != TOINT(poly[a2].y))
|
||||
break;
|
||||
}
|
||||
|
||||
@ -949,10 +950,10 @@ CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrL
|
||||
xB = deltaB * (Ceil(poly[b1].y) - poly[b1].y) + poly[b1].x;
|
||||
|
||||
if(y != yend){
|
||||
if(deltaB < 0.0f && (int)xB < xstart)
|
||||
xstart = xB;
|
||||
if(deltaA >= 0.0f && (int)xA > xend)
|
||||
xend = xA;
|
||||
if(deltaB < 0.0f && TOINT(xB) < xstart)
|
||||
xstart = TOINT(xB);
|
||||
if(deltaA >= 0.0f && TOINT(xA) > xend)
|
||||
xend = TOINT(xA);
|
||||
}
|
||||
|
||||
while(y <= yend && y < NUMSECTORS_Y){
|
||||
@ -968,74 +969,74 @@ CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrL
|
||||
xB += deltaB;
|
||||
|
||||
// update left side
|
||||
if(y == (int)poly[b2].y){
|
||||
if(y == TOINT(poly[b2].y)){
|
||||
// reached end of edge
|
||||
if(y == yend){
|
||||
if(deltaB < 0.0f){
|
||||
do{
|
||||
xstart = poly[b2--].x;
|
||||
xstart = TOINT(poly[b2--].x);
|
||||
if(b2 < 0) b2 = numVertices-1;
|
||||
}while(xstart > (int)poly[b2].x);
|
||||
}while(xstart > TOINT(poly[b2].x));
|
||||
}else
|
||||
xstart = xB - deltaB;
|
||||
xstart = TOINT(xB - deltaB);
|
||||
}else{
|
||||
// switch edges
|
||||
if(deltaB < 0.0f)
|
||||
xstart = poly[b2].x;
|
||||
xstart = TOINT(poly[b2].x);
|
||||
else
|
||||
xstart = xB - deltaB;
|
||||
xstart = TOINT(xB - deltaB);
|
||||
do{
|
||||
b1 = b2--;
|
||||
if(b2 < 0) b2 = numVertices-1;
|
||||
if((int)poly[b1].x < xstart)
|
||||
xstart = poly[b1].x;
|
||||
}while(y == (int)poly[b2].y);
|
||||
if(TOINT(poly[b1].x) < xstart)
|
||||
xstart = TOINT(poly[b1].x);
|
||||
}while(y == TOINT(poly[b2].y));
|
||||
deltaB = CalcNewDelta(&poly[b1], &poly[b2]);
|
||||
xB = deltaB * (Ceil(poly[b1].y) - poly[b1].y) + poly[b1].x;
|
||||
if(deltaB < 0.0f && (int)xB < xstart)
|
||||
xstart = xB;
|
||||
if(deltaB < 0.0f && TOINT(xB) < xstart)
|
||||
xstart = TOINT(xB);
|
||||
}
|
||||
}else{
|
||||
if(deltaB < 0.0f)
|
||||
xstart = xB;
|
||||
xstart = TOINT(xB);
|
||||
else
|
||||
xstart = xB - deltaB;
|
||||
xstart = TOINT(xB - deltaB);
|
||||
}
|
||||
|
||||
// update right side
|
||||
if(y == (int)poly[a2].y){
|
||||
if(y == TOINT(poly[a2].y)){
|
||||
// reached end of edge
|
||||
if(y == yend){
|
||||
if(deltaA < 0.0f)
|
||||
xend = xA - deltaA;
|
||||
xend = TOINT(xA - deltaA);
|
||||
else{
|
||||
do{
|
||||
xend = poly[a2++].x;
|
||||
xend = TOINT(poly[a2++].x);
|
||||
if(a2 == numVertices) a2 = 0;
|
||||
}while(xend < (int)poly[a2].x);
|
||||
}while(xend < TOINT(poly[a2].x));
|
||||
}
|
||||
}else{
|
||||
// switch edges
|
||||
if(deltaA < 0.0f)
|
||||
xend = xA - deltaA;
|
||||
xend = TOINT(xA - deltaA);
|
||||
else
|
||||
xend = poly[a2].x;
|
||||
xend = TOINT(poly[a2].x);
|
||||
do{
|
||||
a1 = a2++;
|
||||
if(a2 == numVertices) a2 = 0;
|
||||
if((int)poly[a1].x > xend)
|
||||
xend = poly[a1].x;
|
||||
}while(y == (int)poly[a2].y);
|
||||
if(TOINT(poly[a1].x) > xend)
|
||||
xend = TOINT(poly[a1].x);
|
||||
}while(y == TOINT(poly[a2].y));
|
||||
deltaA = CalcNewDelta(&poly[a1], &poly[a2]);
|
||||
xA = deltaA * (Ceil(poly[a1].y) - poly[a1].y) + poly[a1].x;
|
||||
if(deltaA >= 0.0f && (int)xA > xend)
|
||||
xend = xA;
|
||||
if(deltaA >= 0.0f && TOINT(xA) > xend)
|
||||
xend = TOINT(xA);
|
||||
}
|
||||
}else{
|
||||
if(deltaA < 0.0f)
|
||||
xend = xA - deltaA;
|
||||
xend = TOINT(xA - deltaA);
|
||||
else
|
||||
xend = xA;
|
||||
xend = TOINT(xA);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user