Skip to content

Commit

Permalink
Fixed up render transform handling for SceneGroups
Browse files Browse the repository at this point in the history
  • Loading branch information
Areloch committed Nov 15, 2024
1 parent 2c8adfd commit 75fb668
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions Engine/source/T3D/SceneGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,31 +192,30 @@ void SceneGroup::setTransform(const MatrixF& mat)

void SceneGroup::setRenderTransform(const MatrixF& mat)
{
MatrixF newTransform = mat;
Parent::setRenderTransform(mat);

// Update all child transforms
for (SimSetIterator itr(this); *itr; ++itr)
{
SceneObject* child = dynamic_cast<SceneObject*>(*itr);
if (child)
{
// Get the child's current world transform
MatrixF childWorldTrans = child->getRenderTransform();

MatrixF childLocalTrans;
childLocalTrans = mWorldToObj.mul(childWorldTrans);
MatrixF childOffset = child->getRenderTransform();
childOffset.mulL(newTransform.inverse());

MatrixF updatedTrans;
updatedTrans.mul(mat, childLocalTrans);
// Calculate the child's new transform
MatrixF newChildTransform = childOffset;
newChildTransform.mulL(newTransform);

// Set the child's new world transform
child->setRenderTransform(updatedTrans);
// Apply the new transform to the child
child->setRenderTransform(newChildTransform);

PhysicsShape* childPS = dynamic_cast<PhysicsShape*>(child);
if (childPS)
childPS->storeRestorePos();
}
}

Parent::setRenderTransform(mat);
}

void SceneGroup::addObject(SimObject* object)
Expand Down

0 comments on commit 75fb668

Please sign in to comment.