Game Development Community

TGEA 1.7 Bug - Bad pointer in Player eye transform

by David Wyand · in Torque Game Engine Advanced · 05/11/2008 (8:54 pm) · 1 replies

Greetings!

Player::getEyeTransform() and Player::getRenderEyeTransform() both have very similar code, and both can potentially make use of a corrupt pointer. Here is a common code block with the problem area bolded:

F32* sp;
   if (mDataBlock->eyeNode != -1)
   {
      sp = mShapeInstance->mNodeTransforms[mDataBlock->eyeNode];
   }
   else
   {
      Point3F center;
      mObjBox.getCenter(&center);
      [b]MatrixF eyeMat(true);[/b]
      eyeMat.setPosition(center);

      [b]sp = eyeMat;[/b]
   }

The sp variable is later used in some calculations. Because of the scope of the eyeMat matrix any future calculations come into question. Of course, this only shows up if your player shape doesn't have an eye node defined -- which I'm sure is rare.

- LightWave Dave

About the author

A long time Associate of the GarageGames' community and author of the Torque 3D Game Development Cookbook. Buy it today from Packt Publishing!