Game Development Community

Decals and TSStatic Collision Meshes

by Richard Marrevee · in Torque 3D Professional · 08/21/2011 (11:24 am) · 4 replies

It seems that decals render on the TSStatic collision meshes no mather what setting you use (Visible Mesh vs Collision Mesh) for the decalType in the collision part in the Inspector when CollisionType is set to Collision Mesh. The only way to get decals render on the visible mesh is to set CollisionType to visible mesh.

Is somebody experiencing the same?

Thanks.

About the author

Started programming in 1984 on an Oric, when time progressed switched to MSX, Amiga and finally the Windows PC with T3D. Now developing an epic fantasy game: The Master's Eye. Creator of the DoorClass pack and VolumetricFog pack @ richardsgamestudio.com


#1
08/21/2011 (11:33 am)
Yeah, the decalType setting for TSStatics is useless.
If collision type is VisibleMesh or CollisionMesh it is used for the decals too irrespective of what you have set for decalType.
#2
08/21/2011 (11:48 am)
if you want to get things working,
in TSStatic.h
after
Vector<S32> mCollisionDetails;
   Vector<S32> mLOSDetails;
add
Vector<S32> mDecalDetails;

then in TSStatic.cpp, function TSStatic::_createShape()
after
mCollisionDetails.clear();
   mLOSDetails.clear();
add
mDecalDetails.clear();

then in TSStatic::prepCollision()
after
mCollisionDetails.clear();
   mLOSDetails.clear();
add
mDecalDetails.clear();

and a little further down, still in prepCollision()
after
if ( mCollisionType == CollisionMesh || mCollisionType == VisibleMesh )
      mShape->findColDetails( mCollisionType == VisibleMesh, &mCollisionDetails, &mLOSDetails );
add
if( mDecalType == CollisionMesh || mDecalType == VisibleMesh && mDecalType != mCollisionType )
      mShape->findColDetails( mDecalType == VisibleMesh, &mDecalDetails, NULL );

then in TSStatic::buildPolylist
change
if ( meshType == None )
         return false;
      else if ( meshType == Bounds )
         polyList->addBox( mObjBox );
      else       
      {
         // Everything else is done from the collision meshes
         // which may be built from either the visual mesh or
         // special collision geometry.
         for ( U32 i = 0; i < mCollisionDetails.size(); i++ )
            mShapeInstance->buildPolyListOpcode( mCollisionDetails[i], polyList, box );
      }
to
if ( meshType == None )
         return false;
      else if ( meshType == Bounds )
         polyList->addBox( mObjBox );
      else if (meshType == mCollisionType)      
      {
         // Everything else is done from the collision meshes
         // which may be built from either the visual mesh or
         // special collision geometry.
         for ( U32 i = 0; i < mCollisionDetails.size(); i++ )
            mShapeInstance->buildPolyListOpcode( mCollisionDetails[i], polyList, box );
      }
      else // mDecalType
      {
         for ( U32 i = 0; i < mDecalDetails.size(); i++ )
            mShapeInstance->buildPolyListOpcode( mDecalDetails[i], polyList, box );
      }


A couple of potential gotchas for using different meshes for decals and collision are that you add some extra memory overhead to each static.

The other issue is that if your collision geometry and visible geometry don't line up well, you might find that projectile decals don't get added, because the explosion upon impact with the collision mesh is not close enough to the visible mesh for the decal to be placed.
#3
08/21/2011 (12:09 pm)
I found my self walking thru collision meshes in StaticShapes while in First Person...then when I switched to Third Person, I was stopped by the collision mesh. Vanilla proT3DFinal... Very odd.
#4
08/21/2011 (1:41 pm)
Thanks guys.