mirror of https://github.com/mgba-emu/mgba.git
DS GX: Fix another polygon overflow
This commit is contained in:
parent
ec626d723f
commit
f184b8a315
|
@ -322,6 +322,7 @@ static bool _clipPolygon(struct DSGX* gx, struct DSGXPolygon* poly) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clip planes
|
||||||
struct DSGXVertex inList[10];
|
struct DSGXVertex inList[10];
|
||||||
struct DSGXVertex outList[10];
|
struct DSGXVertex outList[10];
|
||||||
int outOffscreenVerts[10] = { 0, 0, 0, 0 };
|
int outOffscreenVerts[10] = { 0, 0, 0, 0 };
|
||||||
|
@ -340,6 +341,7 @@ static bool _clipPolygon(struct DSGX* gx, struct DSGXPolygon* poly) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!(offscreenVerts[v] & (1 << plane))) {
|
if (!(offscreenVerts[v] & (1 << plane))) {
|
||||||
|
// This vertex doesn't need clipping
|
||||||
outList[newV] = inList[v];
|
outList[newV] = inList[v];
|
||||||
outOffscreenVerts[newV] = offscreenVerts[v];
|
outOffscreenVerts[newV] = offscreenVerts[v];
|
||||||
++newV;
|
++newV;
|
||||||
|
@ -369,6 +371,10 @@ static bool _clipPolygon(struct DSGX* gx, struct DSGXPolygon* poly) {
|
||||||
iv = 0;
|
iv = 0;
|
||||||
}
|
}
|
||||||
if (!(offscreenVerts[iv] & (1 << plane))) {
|
if (!(offscreenVerts[iv] & (1 << plane))) {
|
||||||
|
if (newV >= 10) {
|
||||||
|
mLOG(DS_GX, ERROR, "Polygon clipping invariant failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
in2 = &inList[iv];
|
in2 = &inList[iv];
|
||||||
out = &outList[newV];
|
out = &outList[newV];
|
||||||
if (_lerpVertexP(in, in2, out, plane >> 1, -1 + (plane & 1) * 2)) {
|
if (_lerpVertexP(in, in2, out, plane >> 1, -1 + (plane & 1) * 2)) {
|
||||||
|
|
Loading…
Reference in New Issue