mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2024-11-14 21:37:42 -07:00
3D: opaque polygons are sorted by winding order
the Sands of Destruction character menu relies on this, it mixes and matches polygon windings to thwart Y-sorting
This commit is contained in:
parent
d357b1c2ac
commit
dc32613028
@ -858,7 +858,8 @@ void SubmitPolygon()
|
|||||||
poly->XTop = xtop; poly->XBottom = xbot;
|
poly->XTop = xtop; poly->XBottom = xbot;
|
||||||
|
|
||||||
poly->SortKey = (ybot << 8) | ytop;
|
poly->SortKey = (ybot << 8) | ytop;
|
||||||
if (poly->Translucent) poly->SortKey |= 0x10000;
|
if (poly->Translucent) poly->SortKey |= 0x20000;
|
||||||
|
else if (!poly->FacingView) poly->SortKey |= 0x10000;
|
||||||
|
|
||||||
poly->WShift = wshift;
|
poly->WShift = wshift;
|
||||||
poly->WBuffer = (FlushAttributes & 0x2);
|
poly->WBuffer = (FlushAttributes & 0x2);
|
||||||
@ -873,7 +874,7 @@ void SubmitPolygon()
|
|||||||
z = w << wshift;
|
z = w << wshift;
|
||||||
else
|
else
|
||||||
z = (((s64)vtx->Position[2] * 0x800000) / (w << wshift)) + 0x7FFEFF;
|
z = (((s64)vtx->Position[2] * 0x800000) / (w << wshift)) + 0x7FFEFF;
|
||||||
|
//printf("poly%d v%d: %d %d Z=%08X (%08X %08X)\n", NumPolygons-1, i, vtx->FinalPosition[0], vtx->FinalPosition[1], z, vtx->Position[2], vtx->Position[3]);
|
||||||
// checkme
|
// checkme
|
||||||
if (z < 0) z = 0;
|
if (z < 0) z = 0;
|
||||||
else if (z > 0xFFFFFF) z = 0xFFFFFF;
|
else if (z > 0xFFFFFF) z = 0xFFFFFF;
|
||||||
@ -1339,7 +1340,7 @@ void ExecuteCommand()
|
|||||||
|
|
||||||
if (PosMatrixStackPointer < 0 || PosMatrixStackPointer > 30)
|
if (PosMatrixStackPointer < 0 || PosMatrixStackPointer > 30)
|
||||||
{
|
{
|
||||||
printf("!! POS MATRIX STACK UNDER/OVERFLOW %d\n", PosMatrixStackPointer);
|
//printf("!! POS MATRIX STACK UNDER/OVERFLOW %d\n", PosMatrixStackPointer);
|
||||||
PosMatrixStackPointer += offset;
|
PosMatrixStackPointer += offset;
|
||||||
GXStat |= (1<<15);
|
GXStat |= (1<<15);
|
||||||
break;
|
break;
|
||||||
@ -1798,10 +1799,13 @@ void VCount144()
|
|||||||
|
|
||||||
bool YSort(Polygon* a, Polygon* b)
|
bool YSort(Polygon* a, Polygon* b)
|
||||||
{
|
{
|
||||||
// Y-sorting rules:
|
// polygon sorting rules:
|
||||||
|
// * opaque polygons come first
|
||||||
|
// * opaque polygons are sorted by winding, front-facing polygons come first
|
||||||
// * polygons with lower bottom Y come first
|
// * polygons with lower bottom Y come first
|
||||||
// * upon equal bottom Y, polygons with lower top Y come first
|
// * upon equal bottom Y, polygons with lower top Y come first
|
||||||
// * upon equal bottom AND top Y, original ordering is used
|
// * upon equal bottom AND top Y, original ordering is used
|
||||||
|
// the SortKey is calculated as to implement these rules
|
||||||
|
|
||||||
return a->SortKey < b->SortKey;
|
return a->SortKey < b->SortKey;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user