From f0eecc80ff12d0005bfd7f1d2bc091e440c08a55 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Wed, 27 Jul 2022 21:13:36 +0200 Subject: [PATCH] Flip vertex order for convex hull properly --- r5dev/naveditor/ConvexVolumeTool.cpp | 2 +- r5dev/naveditor/InputGeom.cpp | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/r5dev/naveditor/ConvexVolumeTool.cpp b/r5dev/naveditor/ConvexVolumeTool.cpp index 53bb041d..ecf54c8f 100644 --- a/r5dev/naveditor/ConvexVolumeTool.cpp +++ b/r5dev/naveditor/ConvexVolumeTool.cpp @@ -64,7 +64,7 @@ static int convexhull(const float* pts, int npts, int* out) out[i++] = hull; endpt = 0; for (int j = 1; j < npts; ++j) - if (hull == endpt || left(&pts[hull*3], &pts[j*3], &pts[endpt*3])) + if (hull == endpt || left(&pts[hull*3], &pts[endpt*3], &pts[j*3])) endpt = j; hull = endpt; } diff --git a/r5dev/naveditor/InputGeom.cpp b/r5dev/naveditor/InputGeom.cpp index f120acf7..4a2e9960 100644 --- a/r5dev/naveditor/InputGeom.cpp +++ b/r5dev/naveditor/InputGeom.cpp @@ -605,15 +605,17 @@ void InputGeom::drawConvexVolumes(struct duDebugDraw* dd, bool /*hilight*/) const float* va = &vol->verts[k*3]; const float* vb = &vol->verts[j*3]; + dd->vertex(va[0],va[1],vol->hmax, col); + dd->vertex(vb[0],vb[1],vol->hmax, col); dd->vertex(vol->verts[0],vol->verts[1],vol->hmax, col); + dd->vertex(vb[0],vb[1],vol->hmax, col); dd->vertex(va[0],va[1],vol->hmax, col); dd->vertex(va[0],va[1],vol->hmin, duDarkenCol(col)); - dd->vertex(va[0],va[1],vol->hmax, col); - dd->vertex(vb[0],vb[1],vol->hmax, col); - dd->vertex(va[0],va[1],vol->hmin, duDarkenCol(col)); - dd->vertex(vb[0],vb[1],vol->hmax, col); + dd->vertex(vb[0],vb[1],vol->hmin, duDarkenCol(col)); + dd->vertex(vb[0],vb[1],vol->hmax, col); + dd->vertex(va[0],va[1],vol->hmin, duDarkenCol(col)); } } @@ -634,12 +636,12 @@ void InputGeom::drawConvexVolumes(struct duDebugDraw* dd, bool /*hilight*/) { const float* va = &vol->verts[k*3]; const float* vb = &vol->verts[j*3]; - dd->vertex(va[0],va[1],vol->hmin, duDarkenCol(col)); dd->vertex(vb[0],vb[1],vol->hmin, duDarkenCol(col)); - dd->vertex(va[0],va[1],vol->hmax, col); - dd->vertex(vb[0],vb[1],vol->hmax, col); dd->vertex(va[0],va[1],vol->hmin, duDarkenCol(col)); + dd->vertex(vb[0],vb[1],vol->hmax, col); dd->vertex(va[0],va[1],vol->hmax, col); + dd->vertex(va[0],va[1],vol->hmax, col); + dd->vertex(va[0],va[1],vol->hmin, duDarkenCol(col)); } } dd->end(); @@ -657,9 +659,9 @@ void InputGeom::drawConvexVolumes(struct duDebugDraw* dd, bool /*hilight*/) for (int j = 0; j < vol->nverts; ++j) { - dd->vertex(vol->verts[j*3+0],vol->verts[j*3+1]+0.1f,vol->verts[j*3+2], col); - dd->vertex(vol->verts[j*3+0],vol->verts[j*3+1],vol->hmin, col); dd->vertex(vol->verts[j*3+0],vol->verts[j*3+1],vol->hmax, col); + dd->vertex(vol->verts[j*3+0],vol->verts[j*3+1],vol->hmin, col); + dd->vertex(vol->verts[j*3+0],vol->verts[j*3+1]+0.1f,vol->verts[j*3+2], col); } } dd->end();