From 8f75a228f799224a133fb17bda21191a5176c7bb Mon Sep 17 00:00:00 2001 From: David Wyand Date: Thu, 4 Oct 2012 16:38:49 -0400 Subject: [PATCH] Fix for Issue #62 for Large decal disappears --- Engine/source/T3D/decal/decalManager.cpp | 19 ++++++++++++++----- .../gui/worldEditor/guiDecalEditorCtrl.cpp | 14 +++++++++++++- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/Engine/source/T3D/decal/decalManager.cpp b/Engine/source/T3D/decal/decalManager.cpp index 9d4d3f826..153209933 100644 --- a/Engine/source/T3D/decal/decalManager.cpp +++ b/Engine/source/T3D/decal/decalManager.cpp @@ -361,19 +361,28 @@ bool DecalManager::clipDecal( DecalInstance *decal, Vector *edgeVerts, mClipper.cullUnusedVerts(); mClipper.triangulate(); + const U32 numVerts = mClipper.mVertexList.size(); + const U32 numIndices = mClipper.mIndexList.size(); + + if ( !numVerts || !numIndices ) + return false; + + // Fail if either of the buffer metrics exceeds our limits + // on dynamic geometry buffers. + if ( numVerts > smMaxVerts || + numIndices > smMaxIndices ) + return false; + if ( !decalData->skipVertexNormals ) mClipper.generateNormals(); - if ( mClipper.mVertexList.empty() ) - return false; - #ifdef DECALMANAGER_DEBUG mDebugPlanes.clear(); mDebugPlanes.merge( mClipper.mPlaneList ); #endif - decal->mVertCount = mClipper.mVertexList.size(); - decal->mIndxCount = mClipper.mIndexList.size(); + decal->mVertCount = numVerts; + decal->mIndxCount = numIndices; Vector tmpPoints; diff --git a/Engine/source/gui/worldEditor/guiDecalEditorCtrl.cpp b/Engine/source/gui/worldEditor/guiDecalEditorCtrl.cpp index d90e3f00b..93192a155 100644 --- a/Engine/source/gui/worldEditor/guiDecalEditorCtrl.cpp +++ b/Engine/source/gui/worldEditor/guiDecalEditorCtrl.cpp @@ -394,7 +394,19 @@ void GuiDecalEditorCtrl::on3DMouseDragged(const Gui3DMouseEvent & event) // Assign the appropriate changed value back to the decal. if ( mGizmo->getMode() == ScaleMode ) - mSELDecal->mSize = (scale.x + scale.y) * 0.5f; + { + // Save old size. + const F32 oldSize = mSELDecal->mSize; + + // Set new size. + mSELDecal->mSize = ( scale.x + scale.y ) * 0.5f; + + // See if the decal properly clips/projects at this size. If not, + // stick to the old size. + mSELEdgeVerts.clear(); + if ( !gDecalManager->clipDecal( mSELDecal, &mSELEdgeVerts ) ) + mSELDecal->mSize = oldSize; + } else if ( mGizmo->getMode() == MoveMode ) mSELDecal->mPosition = gizmoPos; else if ( mGizmo->getMode() == RotateMode )