Game Development Community

T3D 1.2 - Bug in TSShapeInstance::MaskNodeHandsOff

by Tim Newell · in Torque 3D Professional · 10/12/2012 (9:56 am) · 2 replies

Figured i should start using the bug form since I'm posting so much here.

Build: 1.2
Platform: Windows 7
Target: Game

Issues: When using TSShapeInstance::MaskNodeHandsOff to manually control a nodes rotation and position, you will get garbage data which will cause weird popping specially when switching animations.

Steps to Repeat:
In our mech game we do torso twist by manually rotating a node in code. So our mech class uses:
mShapeInstance->setNodeAnimationState(mDataBlock->twistNode,TSShapeInstance::MaskNodeHandsOff);
Even though we update the mNodeTrasform, there is still the occasional wrong info getting set and causes popping. in out case the torso would do random movements and rotations for a split second then fix itself. This usually occured when switching animations.


Suggested Fix: This is what I did to fix it in our game. in ts/tsAnimate.cpp at the end of the function TSShapeInstance::animateNodes(S32 ss) you should see the following code:

// multiply transforms...
   for (i=a; i<b; i++)
   {
      S32 parentIdx = mShape->nodes[i].parentIndex;
	  if (parentIdx < 0) 
		mNodeTransforms[i] = smNodeLocalTransforms[i]; 
	  else 
		mNodeTransforms[i].mul(mNodeTransforms[parentIdx],smNodeLocalTransforms[i]);  
   }

replace it with:

// multiply transforms...
   for (i=a; i<b; i++)
   {
      S32 parentIdx = mShape->nodes[i].parentIndex;
	  if (parentIdx < 0) {
		  if (!mHandsOffNodes.test(i)) {
			mNodeTransforms[i] = smNodeLocalTransforms[i];
		  }
	  }
	  else {
		  if (!mHandsOffNodes.test(i)) {
			mNodeTransforms[i].mul(mNodeTransforms[parentIdx],smNodeLocalTransforms[i]);
		  } else {
			MatrixF localMat = mNodeTransforms[i];
			mNodeTransforms[i].mul(mNodeTransforms[parentIdx],localMat);
		  }
	  }
   }

So far this seems to have fixed all issues caused by the bug.