From 0519d1069bd82376597995cedbee68845ed97ba3 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sun, 26 Apr 2026 15:32:19 -0500 Subject: [PATCH 1/2] adress https://github.com/TorqueGameEngines/Torque3D/issues/97 this laregly occured due to adding ribbon nodes in smaller increments than the size of a given quad. we therefore skip adding new ribbon nodes if velocity, as determined by the point deltas, would be below 10% of the largest scale a given quad for that link in the ribbon would be. as this will result in lower than a max length ribbon, also adds a timeout mechanism of removing a link every TickMS (32 ticks/second, or roughly how often one would also be aded when in a growth state) for full finalization do still need to circle back and adress why there remains 1 quad spawned after motion. --- Engine/source/T3D/fx/ribbon.cpp | 33 +++++++++++++++++++++++++++++---- Engine/source/T3D/fx/ribbon.h | 2 +- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/Engine/source/T3D/fx/ribbon.cpp b/Engine/source/T3D/fx/ribbon.cpp index d3a00c25b2..6eae42672b 100644 --- a/Engine/source/T3D/fx/ribbon.cpp +++ b/Engine/source/T3D/fx/ribbon.cpp @@ -195,6 +195,7 @@ Ribbon::Ribbon() mSegmentIdx = 0; mTravelledDistance = 0; + mImmobileTicks = 0; } Ribbon::~Ribbon() @@ -346,7 +347,7 @@ void Ribbon::addSegmentPoint(Point3F &point, MatrixF &mat) { xform.setColumn(3, point); setTransform(xform); - if(mSegmentIdx < mDataBlock->mSegmentSkipAmount) + if (mSegmentIdx < mDataBlock->mSegmentSkipAmount) { mSegmentIdx++; return; @@ -356,7 +357,26 @@ void Ribbon::addSegmentPoint(Point3F &point, MatrixF &mat) { U32 segmentsToDelete = checkRibbonDistance(mDataBlock->segmentsPerUpdate); - for (U32 i = 0; i < segmentsToDelete; i++) { + U32 i; + + F32 maxSize = mDataBlock->mSizes[0]; + for (i = 1; i < RibbonData::NumFields; ++i) { + if (mDataBlock->mSizes[i] > 0.0f && mDataBlock->mSizes[i] > maxSize) + maxSize = mDataBlock->mSizes[i]; + } + F32 movementThreshold = maxSize * 0.1f; + if (mSegmentPoints.size() && ((point - mSegmentPoints[0]).lenSquared() < movementThreshold * movementThreshold)) + { + mImmobileTicks++; + if (mImmobileTicks > TickMs) + { + segmentsToDelete = mMax(segmentsToDelete, 1); + mImmobileTicks = 0; + } + } + else mImmobileTicks = 0; + + for (i = 0; i < segmentsToDelete; i++) { S32 last = mSegmentPoints.size() - 1; if (last < 0) break; @@ -374,10 +394,13 @@ void Ribbon::addSegmentPoint(Point3F &point, MatrixF &mat) { return; } + if (mImmobileTicks > 0) + return; + Point3F startPoint = mSegmentPoints[0]; //add X points based on how many segments Per Update from last point to current point - for (U32 i = 0; i < mDataBlock->segmentsPerUpdate; i++) { + for (i = 0; i < mDataBlock->segmentsPerUpdate; i++) { F32 interp = (F32(i+1) / (F32)mDataBlock->segmentsPerUpdate); //(end - start) * percentage) + start @@ -450,7 +473,7 @@ U32 Ribbon::checkRibbonDistance(S32 segments) { if (difference < 0) return mAbs(difference); - return 0; //do not delete any points + return 0; } void Ribbon::setShaderParams() { @@ -585,6 +608,8 @@ void Ribbon::createBuffers(SceneRenderState *state, GFXVertexBufferHandle segments - 2) tRadius = POINT_EPSILON * POINT_EPSILON; + Point3F diff; F32 length; if (i == 0) { diff --git a/Engine/source/T3D/fx/ribbon.h b/Engine/source/T3D/fx/ribbon.h index 3eba7720d8..ff4bd45830 100644 --- a/Engine/source/T3D/fx/ribbon.h +++ b/Engine/source/T3D/fx/ribbon.h @@ -90,7 +90,7 @@ class Ribbon : public GameBase F32 mFadeAwayStep; ///< How quickly the ribbons is faded away after deletion. F32 mFadeOut; F32 mTravelledDistance; ///< How far the ribbon has travelled in it's lifetime. - + U32 mImmobileTicks; Vector mSegmentPoints; ///< The points in space where the ribbon has spawned segments. U32 mSegmentOffset; U32 mSegmentIdx; From c07f68a0a06256dcc523627a4a441e250f1d9a80 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sun, 26 Apr 2026 15:57:42 -0500 Subject: [PATCH 2/2] remove forceably shrinking the first and last pair of links. it doesn't fix the last quad emission issue, and it actively fights designer values --- Engine/source/T3D/fx/ribbon.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Engine/source/T3D/fx/ribbon.cpp b/Engine/source/T3D/fx/ribbon.cpp index 6eae42672b..5838d20ca4 100644 --- a/Engine/source/T3D/fx/ribbon.cpp +++ b/Engine/source/T3D/fx/ribbon.cpp @@ -608,8 +608,6 @@ void Ribbon::createBuffers(SceneRenderState *state, GFXVertexBufferHandle segments - 2) tRadius = POINT_EPSILON * POINT_EPSILON; - Point3F diff; F32 length; if (i == 0) {