This commit is contained in:
Jakly 2024-11-12 12:56:34 +01:00 committed by GitHub
commit e9d061eaca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -849,6 +849,8 @@ int ClipAgainstPlane(const GPU3D& gpu, Vertex* vertices, int nverts, int clipsta
temp[1] = vertices[1];
}
Vertex holdit;
bool heldit = false;
for (int i = clipstart; i < nverts; i++)
{
prev = i-1; if (prev < 0) prev = nverts-1;
@ -861,10 +863,18 @@ int ClipAgainstPlane(const GPU3D& gpu, Vertex* vertices, int nverts, int clipsta
Vertex* vprev = &vertices[prev];
if (vprev->Position[comp] <= vprev->Position[3])
{
if (i == 0)
{
ClipSegment<comp, 1, attribs>(&holdit, &vtx, vprev);
heldit = true;
}
else
{
ClipSegment<comp, 1, attribs>(&temp[c], &vtx, vprev);
c++;
}
}
Vertex* vnext = &vertices[next];
if (vnext->Position[comp] <= vnext->Position[3])
@ -877,6 +887,12 @@ int ClipAgainstPlane(const GPU3D& gpu, Vertex* vertices, int nverts, int clipsta
temp[c++] = vtx;
}
if (heldit)
{
temp[c++] = holdit;
}
heldit = false;
nverts = c; c = clipstart;
for (int i = clipstart; i < nverts; i++)
{
@ -888,10 +904,19 @@ int ClipAgainstPlane(const GPU3D& gpu, Vertex* vertices, int nverts, int clipsta
{
Vertex* vprev = &temp[prev];
if (vprev->Position[comp] >= -vprev->Position[3])
{
if (i == 0)
{
ClipSegment<comp, -1, attribs>(&holdit, &vtx, vprev);
heldit = true;
}
else
{
ClipSegment<comp, -1, attribs>(&vertices[c], &vtx, vprev);
c++;
}
}
Vertex* vnext = &temp[next];
if (vnext->Position[comp] >= -vnext->Position[3])
@ -904,6 +929,11 @@ int ClipAgainstPlane(const GPU3D& gpu, Vertex* vertices, int nverts, int clipsta
vertices[c++] = vtx;
}
if (heldit)
{
vertices[c++] = holdit;
}
// checkme
for (int i = 0; i < c; i++)
{