Fix another culling bug
This commit is contained in:
parent
dfd1393dba
commit
2c2f1a4c9f
8 changed files with 130 additions and 15 deletions
34
renderer.h
34
renderer.h
|
@ -550,14 +550,16 @@ int _LCR_rendererQuadCoversTri(const S3L_Unit quad[8], const S3L_Unit tri[6])
|
|||
|
||||
for (int k = 0; k < 3; ++k) // for each subtriangle side
|
||||
{
|
||||
S3L_Unit w = // triangle winding
|
||||
(quad[(2 * (j + ((k + 1) % 3))) % 8 + 1] -
|
||||
quad[(2 * (j + k)) % 8 + 1]) *
|
||||
(tri[2 * i] - quad[(2 * (j + (k + 1) % 3)) % 8]) -
|
||||
(quad[(2 * (j + ((k + 1) % 3))) % 8] - quad[(2 * (j + k)) % 8])
|
||||
* (tri[2 * i + 1] - quad[(2 * (j + (k + 1) % 3)) % 8 + 1]);
|
||||
char w =
|
||||
_LCR_triangleWinding(
|
||||
quad[(2 * (j + (k + 1) % 3)) % 8],
|
||||
quad[(2 * (j + ((k + 1) % 3))) % 8 + 1],
|
||||
quad[(2 * (j + k)) % 8],
|
||||
quad[(2 * (j + k)) % 8 + 1],
|
||||
tri[2 * i],
|
||||
tri[2 * i + 1]);
|
||||
|
||||
winds |= (w > 0) | ((w < 0) << 1 );
|
||||
winds |= (w > 0) | ((w < 0) << 1);
|
||||
}
|
||||
|
||||
if (winds != 3) // no opposite winds?
|
||||
|
@ -631,7 +633,7 @@ uint8_t _LCR_rendererCheckMapTriCover(const S3L_Index *t1, const S3L_Index *t2)
|
|||
points2D[13] = (4 * points2D[7] + 3 * points2D[9] + points2D[11]) / 8;
|
||||
|
||||
// first: does the triangle alone cover the other one?
|
||||
if (_LCR_rendererQuadLooksConvex(points2D +6) &&
|
||||
if (_LCR_rendererQuadLooksConvex(points2D + 6) &&
|
||||
_LCR_rendererQuadCoversTri(points2D + 6,points2D))
|
||||
result |= 1 << j;
|
||||
else
|
||||
|
@ -654,9 +656,19 @@ uint8_t _LCR_rendererCheckMapTriCover(const S3L_Index *t1, const S3L_Index *t2)
|
|||
LCR_renderer.mapVerts[3 * t3[1] + plane] ==
|
||||
LCR_renderer.mapVerts[3 * t3[2] + plane] &&
|
||||
LCR_renderer.mapVerts[3 * t3[0] + plane] ==
|
||||
LCR_renderer.mapVerts[3 * t1[0] + plane])
|
||||
LCR_renderer.mapVerts[3 * t1[0] + plane] &&
|
||||
_LCR_triangleWinding(
|
||||
points2D[6],points2D[7],points2D[8],points2D[9],
|
||||
points2D[10],points2D[11]) ==
|
||||
_LCR_triangleWinding(
|
||||
LCR_renderer.mapVerts[3 * t3[0] + coordX],
|
||||
LCR_renderer.mapVerts[3 * t3[0] + coordY],
|
||||
LCR_renderer.mapVerts[3 * t3[1] + coordX],
|
||||
LCR_renderer.mapVerts[3 * t3[1] + coordY],
|
||||
LCR_renderer.mapVerts[3 * t3[2] + coordX],
|
||||
LCR_renderer.mapVerts[3 * t3[2] + coordY]))
|
||||
{
|
||||
// here shares exactly two vertices and is in the same plane
|
||||
// here shares exactly 2 verts + is in the same plane + same winding
|
||||
|
||||
uint8_t freeVert =
|
||||
sharedVerts == 3 ? 2 : (sharedVerts == 5 ? 1 : 0);
|
||||
|
@ -664,7 +676,7 @@ uint8_t _LCR_rendererCheckMapTriCover(const S3L_Index *t1, const S3L_Index *t2)
|
|||
points2D[12] = LCR_renderer.mapVerts[3 * t3[freeVert] + coordX];
|
||||
points2D[13] = LCR_renderer.mapVerts[3 * t3[freeVert] + coordY];
|
||||
|
||||
if (_LCR_rendererQuadLooksConvex(points2D +6) &&
|
||||
if (_LCR_rendererQuadLooksConvex(points2D + 6) &&
|
||||
_LCR_rendererQuadCoversTri(points2D + 6,points2D))
|
||||
{
|
||||
result |= 1 << j;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue