mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-24 14:49:53 -06:00
3D: attempt at fixing culling. players in Madden are no longer full of holes, and that also fixes occasional missing polygons in RaymanDS, and probably others.
This commit is contained in:
@ -610,6 +610,8 @@ void SubmitPolygon()
|
|||||||
int prev, next;
|
int prev, next;
|
||||||
|
|
||||||
// culling
|
// culling
|
||||||
|
// TODO: work out how it works on the real thing
|
||||||
|
// the normalization part is a wild guess
|
||||||
|
|
||||||
Vertex *v0, *v1, *v2;
|
Vertex *v0, *v1, *v2;
|
||||||
s64 normalX, normalY, normalZ;
|
s64 normalX, normalY, normalZ;
|
||||||
@ -618,9 +620,19 @@ void SubmitPolygon()
|
|||||||
v0 = &TempVertexBuffer[0];
|
v0 = &TempVertexBuffer[0];
|
||||||
v1 = &TempVertexBuffer[1];
|
v1 = &TempVertexBuffer[1];
|
||||||
v2 = &TempVertexBuffer[2];
|
v2 = &TempVertexBuffer[2];
|
||||||
normalX = (((s64)v0->Position[1] * v2->Position[3]) - ((s64)v0->Position[3] * v2->Position[1])) >> 12;
|
normalX = ((s64)v0->Position[1] * v2->Position[3]) - ((s64)v0->Position[3] * v2->Position[1]);
|
||||||
normalY = (((s64)v0->Position[3] * v2->Position[0]) - ((s64)v0->Position[0] * v2->Position[3])) >> 12;
|
normalY = ((s64)v0->Position[3] * v2->Position[0]) - ((s64)v0->Position[0] * v2->Position[3]);
|
||||||
normalZ = (((s64)v0->Position[0] * v2->Position[1]) - ((s64)v0->Position[1] * v2->Position[0])) >> 12;
|
normalZ = ((s64)v0->Position[0] * v2->Position[1]) - ((s64)v0->Position[1] * v2->Position[0]);
|
||||||
|
|
||||||
|
while ((((normalX>>31) ^ (normalX>>63)) != 0) ||
|
||||||
|
(((normalY>>31) ^ (normalY>>63)) != 0) ||
|
||||||
|
(((normalZ>>31) ^ (normalZ>>63)) != 0))
|
||||||
|
{
|
||||||
|
normalX >>= 4;
|
||||||
|
normalY >>= 4;
|
||||||
|
normalZ >>= 4;
|
||||||
|
}
|
||||||
|
|
||||||
dot = ((s64)v1->Position[0] * normalX) + ((s64)v1->Position[1] * normalY) + ((s64)v1->Position[3] * normalZ);
|
dot = ((s64)v1->Position[0] * normalX) + ((s64)v1->Position[1] * normalY) + ((s64)v1->Position[3] * normalZ);
|
||||||
|
|
||||||
bool facingview = (dot < 0);
|
bool facingview = (dot < 0);
|
||||||
@ -807,6 +819,7 @@ void SubmitPolygon()
|
|||||||
// determine bounds of the polygon
|
// determine bounds of the polygon
|
||||||
// also determine the W shift and normalize W
|
// also determine the W shift and normalize W
|
||||||
// TODO: normalization works both ways
|
// TODO: normalization works both ways
|
||||||
|
// (ie two W's that span 12 bits or less will be brought to 16 bits)
|
||||||
|
|
||||||
u32 vtop = 0, vbot = 0;
|
u32 vtop = 0, vbot = 0;
|
||||||
s32 ytop = 192, ybot = 0;
|
s32 ytop = 192, ybot = 0;
|
||||||
|
@ -124,6 +124,8 @@ void SetIRQ14(bool forced)
|
|||||||
|
|
||||||
if (!forced)
|
if (!forced)
|
||||||
IOPORT(W_BeaconCount1) = IOPORT(W_BeaconInterval);
|
IOPORT(W_BeaconCount1) = IOPORT(W_BeaconInterval);
|
||||||
|
else
|
||||||
|
printf("wifi: weird forced IRQ14\n");
|
||||||
|
|
||||||
IOPORT(W_BeaconCount2) = 0xFFFF;
|
IOPORT(W_BeaconCount2) = 0xFFFF;
|
||||||
IOPORT(W_TXReqRead) &= 0xFFF2; // todo, eventually?
|
IOPORT(W_TXReqRead) &= 0xFFF2; // todo, eventually?
|
||||||
|
Reference in New Issue
Block a user