From 25d6ee5372cbbef252315534ee9d19d9bb6b58da Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Mon, 20 May 2024 12:21:37 +0100 Subject: [PATCH] backup backup commit --- Engine/source/T3D/groundPlane.cpp | 6 ++-- Engine/source/collision/concretePolyList.cpp | 31 ++++++++++++++++++-- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/Engine/source/T3D/groundPlane.cpp b/Engine/source/T3D/groundPlane.cpp index 061ec5d78..08898c3b5 100644 --- a/Engine/source/T3D/groundPlane.cpp +++ b/Engine/source/T3D/groundPlane.cpp @@ -299,10 +299,8 @@ void GroundPlane::buildConvex( const Box3F& box, Convex* convex ) { Point3F queryCenter = box.getCenter(); - planeConvex->mCenter = Point3F( queryCenter.x, queryCenter.y, 0 ); - planeConvex->mSize = Point3F( box.getExtents().x, - box.getExtents().y, - 0 ); + planeConvex->mCenter = Point3F( queryCenter.x, queryCenter.y, 0 ); + planeConvex->mSize = Point3F( box.getExtents().x, box.getExtents().y, 0 ); } } diff --git a/Engine/source/collision/concretePolyList.cpp b/Engine/source/collision/concretePolyList.cpp index ab6688151..8f21fe154 100644 --- a/Engine/source/collision/concretePolyList.cpp +++ b/Engine/source/collision/concretePolyList.cpp @@ -150,13 +150,13 @@ void ConcretePolyList::render() GFXStateBlockRef sb = GFX->createStateBlock( solidZDisable ); GFX->setStateBlock( sb ); - PrimBuild::color3i( 255, 0, 255 ); - Poly *p; Point3F *pnt; for ( p = mPolyList.begin(); p < mPolyList.end(); p++ ) { + PrimBuild::color3i(255, 0, 255); + PrimBuild::begin( GFXLineStrip, p->vertexCount + 1 ); for ( U32 i = 0; i < p->vertexCount; i++ ) @@ -169,6 +169,31 @@ void ConcretePolyList::render() PrimBuild::vertex3fv( pnt ); PrimBuild::end(); + + // Calculate the center of the polygon + Point3F centroid(0, 0, 0); + for (U32 i = 0; i < p->vertexCount; i++) + { + pnt = &mVertexList[mIndexList[p->vertexStart + i]]; + centroid += *pnt; + } + centroid /= p->vertexCount; + + // Calculate the end point of the normal line + Point3F norm = p->plane.getNormal(); + + U8 red = static_cast((norm.x + 1.0f) * 0.5f * 255); + U8 green = static_cast((norm.y + 1.0f) * 0.5f * 255); + U8 blue = static_cast((norm.z + 1.0f) * 0.5f * 255); + + PrimBuild::color3i(red, green, blue); + Point3F normalEnd = centroid + norm; + + // Draw the normal line + PrimBuild::begin(GFXLineList, 2); + PrimBuild::vertex3fv(centroid); + PrimBuild::vertex3fv(normalEnd); + PrimBuild::end(); } } @@ -220,4 +245,4 @@ void ConcretePolyList::triangulate() mPolyList = polyList; mIndexList = indexList; -} \ No newline at end of file +}