Game Development Community

LOD Fix for TGEA 1.7.1

by Matt Kronyak · in Torque Game Engine Advanced · 02/13/2009 (10:25 pm) · 0 replies

For anyone using TGEA 1.7.1 that has noticed their LODs not working I have found a quick fix.

LODs work fine in 1.8.1 so this change is not necessary in the later engines.

In engine\ts\tsShapeInstance.cpp find:
S32 TSShapeInstance::selectCurrentDetail2(F32 adjustedDist)

Inside of that locate:
if (mShape->mSmallestVisibleDL>=0 && mShape->details[0].maxError>=0)
      // use new scheme
      return selectCurrentDetail2Ex(adjustedDist);

and completely comment out that block of code.

When you are done this method should look like this:
S32 TSShapeInstance::selectCurrentDetail2(F32 adjustedDist)
{
   /*if (mShape->mSmallestVisibleDL>=0 && mShape->details[0].maxError>=0)
      // use new scheme
      return selectCurrentDetail2Ex(adjustedDist);*/

   RectI viewport = GFX->getViewport();
   F32 pixelScale = viewport.extent.x * 1.6f / 640.0f;
   F32 pixelRadius = GFX->projectRadius(adjustedDist,mShape->radius) * pixelScale;
   F32 adjustedPR = pixelRadius * smDetailAdjust;
   if(adjustedPR <= mShape->mSmallestVisibleSize)
      adjustedPR = mShape->mSmallestVisibleSize + 0.01f;

   return selectCurrentDetail(adjustedPR);
}

Enjoy your working LODs. ;)