From 727dbbfd8db542ff7a4dc0e084bdec7f6efb2d8f Mon Sep 17 00:00:00 2001 From: Azaezel Date: Tue, 19 Feb 2019 16:34:30 -0600 Subject: [PATCH] rolled in more of https://github.com/GarageGames/Torque3D/pull/2315 + set the mProbeShapeType(s) for the two derivative classes --- .../T3D/lighting/boxEnvironmentProbe.cpp | 1 + .../T3D/lighting/sphereEnvironmentProbe.cpp | 1 + Engine/source/gfx/gfxDrawUtil.cpp | 70 ++++++++++++------- 3 files changed, 46 insertions(+), 26 deletions(-) diff --git a/Engine/source/T3D/lighting/boxEnvironmentProbe.cpp b/Engine/source/T3D/lighting/boxEnvironmentProbe.cpp index e710edf30..dd4e0980e 100644 --- a/Engine/source/T3D/lighting/boxEnvironmentProbe.cpp +++ b/Engine/source/T3D/lighting/boxEnvironmentProbe.cpp @@ -77,6 +77,7 @@ ConsoleDocClass(BoxEnvironmentProbe, BoxEnvironmentProbe::BoxEnvironmentProbe() : ReflectionProbe() { mCaptureMask = REFLECTION_PROBE_CAPTURE_TYPEMASK; + mProbeShapeType = ProbeRenderInst::Box; } BoxEnvironmentProbe::~BoxEnvironmentProbe() diff --git a/Engine/source/T3D/lighting/sphereEnvironmentProbe.cpp b/Engine/source/T3D/lighting/sphereEnvironmentProbe.cpp index 151d96424..c0588b31b 100644 --- a/Engine/source/T3D/lighting/sphereEnvironmentProbe.cpp +++ b/Engine/source/T3D/lighting/sphereEnvironmentProbe.cpp @@ -77,6 +77,7 @@ ConsoleDocClass(SphereEnvironmentProbe, SphereEnvironmentProbe::SphereEnvironmentProbe() : ReflectionProbe() { mCaptureMask = REFLECTION_PROBE_CAPTURE_TYPEMASK; + mProbeShapeType = ProbeRenderInst::Sphere; } SphereEnvironmentProbe::~SphereEnvironmentProbe() diff --git a/Engine/source/gfx/gfxDrawUtil.cpp b/Engine/source/gfx/gfxDrawUtil.cpp index 688de6bcf..357e48a5e 100644 --- a/Engine/source/gfx/gfxDrawUtil.cpp +++ b/Engine/source/gfx/gfxDrawUtil.cpp @@ -1153,9 +1153,9 @@ void GFXDrawUtil::_drawSolidCapsule( const GFXStateBlockDesc &desc, const Point3 for (S32 i=0; ipushWorldMatrix(); - mDevice->multWorld(mat); - - S32 numPoints = sizeof(circlePoints)/sizeof(Point2F); - GFXVertexBufferHandle verts(mDevice, numPoints, GFXBufferTypeVolatile); + S32 numPoints = sizeof(circlePoints) / sizeof(Point2F); + GFXVertexBufferHandle verts(mDevice, numPoints * 2 + 2, GFXBufferTypeVolatile); verts.lock(); - for (S32 i=0; i< numPoints; i++) + for (S32 i = 0; i < numPoints + 1; i++) { - S32 idx = i & (~1); // just draw the even ones - F32 z = i & 1 ? 1.0f : -1.0f; - verts[i].point = Point3F(circlePoints[idx].x,circlePoints[idx].y, z); - verts[i].color = color; + S32 imod = i % numPoints; + verts[2 * i].point = Point3F(circlePoints[imod].x * radius, circlePoints[imod].y * radius, height / 2); + verts[2 * i].color = color; + verts[2 * i + 1].point = Point3F(circlePoints[imod].x * radius, circlePoints[imod].y * radius, -height / 2); + verts[2 * i + 1].color = color; } + + S32 totalNumPnts = numPoints * 2 + 2; + + // Apply xfm if we were passed one. + for (U32 i = 0; i < totalNumPnts; i++) + mat.mulV(verts[i].point); + + // Apply position offset + for (U32 i = 0; i < totalNumPnts; i++) + verts[i].point += center; + verts.unlock(); - mDevice->setStateBlockByDesc( desc ); + mDevice->setStateBlockByDesc(desc); - mDevice->setVertexBuffer( verts ); + mDevice->setVertexBuffer(verts); mDevice->setupGenericShaders(); - for (S32 i=0; idrawPrimitive(GFXLineStrip, i, 1); - - mDevice->popWorldMatrix(); + mDevice->drawPrimitive(GFXTriangleStrip, 0, 2 * numPoints); Point3F sphereCenter; - sphereCenter.z = center.z + 0.5f * height; - drawSphere( desc, radius,sphereCenter,color,true,false); - sphereCenter.z = center.z - 0.5f * height; - drawSphere( desc, radius,sphereCenter,color,false,true); + MatrixF sphereMat; + + if (xfm) + sphereMat = *xfm; + else + sphereMat = MatrixF::Identity; + + sphereCenter.set(0, 0, 0.5f * height); + mat.mulV(sphereCenter); + sphereCenter += center; + + drawSphere(desc, radius, sphereCenter, color, true, false, &sphereMat); + + sphereCenter.set(0, 0, -0.5f * height); + mat.mulV(sphereCenter); + sphereCenter += center; + + drawSphere(desc, radius, sphereCenter, color, false, true, &sphereMat); } void GFXDrawUtil::drawCone( const GFXStateBlockDesc &desc, const Point3F &basePnt, const Point3F &tipPnt, F32 baseRadius, const ColorI &color )