Game Development Community

Updating decals real-time

by Matt Huston · in Torque 3D Professional · 06/26/2009 (5:18 pm) · 4 replies

I am trying to create a decal that I can control in real-time like you can do with the Decal Editor.

You create a decal by calling the following with the position, etc that you want. This part works fine.
DecalInstance *decalInst = gDecalManager->addDecal( ri.point, ri.normal, 0.0f, mCurrentDecalData, 1.0f, 0, flags );

However, I would like to update the position and I call something similar to.
mSELDecal->mSize = (scale.x + scale.y) * 0.5f;
   mSELDecal->mPosition = gizmoPos;
   mSELDecal->mNormal   = upVec;
   mSELDecal->mTangent  = rightVec;
   gDecalManager->notifyDecalModified( mSELDecal );

Nothing seems to happen. Is there anything else special going on with the Decal Editor that allows moving/updating decals in real time?

#1
06/26/2009 (8:37 pm)
You need to also do this so that it will be reclipped.
decalInst->mFlags |= ClipDecal;
#2
06/27/2009 (1:06 am)
@James - What about fixing notifyDecalModified() to do that internally? Is there cases where they are modified and don't need to be reclipped? Or maybe add a notifyDecalModified( bool reclip = true )?
#3
06/27/2009 (1:44 am)
Great, that works James. I did not realize you needed to set to ClipDecal before each call to update nofifyDecalModified. I had previously tried putting ClipDecal in the addDecal line.

Might be a good idea to add a reclip to notifyDecalModified as Tom has suggested as I would think that actually updating the decal would be the most used reason for notifyDecalModified.
#4
06/27/2009 (10:48 am)
Since the decalEditor renders the outline of the selected decal it actually reclips it each frame (only the one selected). Since this is done by the editor itself if we raise the clipDecal flag the manager is actually going to do an extra unnecessary clip.

Honestly I think that reclipping each frame is going to need to be removed, since this slows to a crawl even for a single decal if it happens to be very very large. At which point it would be appropriate to add the reclip flag in notifyDecalModified.