attempt at re-implementing algorithm
maybe better explains the weird behavior with the 3rd vertex (vtx2)
This commit is contained in:
parent
0e6235a7c4
commit
0a908dd49d
|
@ -978,40 +978,38 @@ void GPU3D::SubmitPolygon() noexcept
|
||||||
v2 = &TempVertexBuffer[2];
|
v2 = &TempVertexBuffer[2];
|
||||||
v3 = &TempVertexBuffer[3];
|
v3 = &TempVertexBuffer[3];
|
||||||
|
|
||||||
normalX = ((s64)(v0->Position[1]-v1->Position[1]) * (v2->Position[3]-v1->Position[3]))
|
s32 vector[4];
|
||||||
- ((s64)(v0->Position[3]-v1->Position[3]) * (v2->Position[1]-v1->Position[1]));
|
vector[0] = v0->Position[0] - v2->Position[0];
|
||||||
normalY = ((s64)(v0->Position[3]-v1->Position[3]) * (v2->Position[0]-v1->Position[0]))
|
vector[1] = v0->Position[1] - v2->Position[1];
|
||||||
- ((s64)(v0->Position[0]-v1->Position[0]) * (v2->Position[3]-v1->Position[3]));
|
vector[2] = v1->Position[0] - v2->Position[0];
|
||||||
normalZ = ((s64)(v0->Position[0]-v1->Position[0]) * (v2->Position[1]-v1->Position[1]))
|
vector[3] = v1->Position[1] - v2->Position[1];
|
||||||
- ((s64)(v0->Position[1]-v1->Position[1]) * (v2->Position[0]-v1->Position[0]));
|
|
||||||
|
|
||||||
while ((((normalX>>31) ^ (normalX>>63)) != 0) ||
|
bool facingview;
|
||||||
(((normalY>>31) ^ (normalY>>63)) != 0) ||
|
if ((vector[0] | vector[1]) == 0 || (vector[2] | vector[3]) == 0) // if either vector is 0 the polygon is accepted and treated as front facing.
|
||||||
(((normalZ>>31) ^ (normalZ>>63)) != 0))
|
|
||||||
{
|
{
|
||||||
normalX >>= 4;
|
facingview = true;
|
||||||
normalY >>= 4;
|
|
||||||
normalZ >>= 4;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
dot = ((s64)v1->Position[0] * normalX) + ((s64)v1->Position[1] * normalY) + ((s64)v1->Position[3] * normalZ);
|
|
||||||
|
|
||||||
bool facingview = (dot <= 0);
|
|
||||||
|
|
||||||
if (dot < 0)
|
|
||||||
{
|
{
|
||||||
if (!(CurPolygonAttr & (1<<7)))
|
s64 cross = (vector[0] * vector[3]) - (vector[1] * vector[2]);
|
||||||
|
|
||||||
|
facingview = (cross >= 0);
|
||||||
|
|
||||||
|
if (cross >= 0)
|
||||||
{
|
{
|
||||||
LastStripPolygon = NULL;
|
if (!(CurPolygonAttr & (1<<7)))
|
||||||
return;
|
{
|
||||||
|
LastStripPolygon = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
else if (cross <= 0)
|
||||||
else if (dot > 0)
|
|
||||||
{
|
|
||||||
if (!(CurPolygonAttr & (1<<6)))
|
|
||||||
{
|
{
|
||||||
LastStripPolygon = NULL;
|
if (!(CurPolygonAttr & (1<<6)))
|
||||||
return;
|
{
|
||||||
|
LastStripPolygon = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue