mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 16:14:38 +00:00
Fixed up render transform handling for SceneGroups
This commit is contained in:
parent
2c8adfdf93
commit
75fb6683f5
1 changed files with 10 additions and 11 deletions
|
|
@ -192,31 +192,30 @@ void SceneGroup::setTransform(const MatrixF& mat)
|
||||||
|
|
||||||
void SceneGroup::setRenderTransform(const MatrixF& mat)
|
void SceneGroup::setRenderTransform(const MatrixF& mat)
|
||||||
{
|
{
|
||||||
|
MatrixF newTransform = mat;
|
||||||
|
Parent::setRenderTransform(mat);
|
||||||
|
|
||||||
// Update all child transforms
|
// Update all child transforms
|
||||||
for (SimSetIterator itr(this); *itr; ++itr)
|
for (SimSetIterator itr(this); *itr; ++itr)
|
||||||
{
|
{
|
||||||
SceneObject* child = dynamic_cast<SceneObject*>(*itr);
|
SceneObject* child = dynamic_cast<SceneObject*>(*itr);
|
||||||
if (child)
|
if (child)
|
||||||
{
|
{
|
||||||
// Get the child's current world transform
|
MatrixF childOffset = child->getRenderTransform();
|
||||||
MatrixF childWorldTrans = child->getRenderTransform();
|
childOffset.mulL(newTransform.inverse());
|
||||||
|
|
||||||
MatrixF childLocalTrans;
|
// Calculate the child's new transform
|
||||||
childLocalTrans = mWorldToObj.mul(childWorldTrans);
|
MatrixF newChildTransform = childOffset;
|
||||||
|
newChildTransform.mulL(newTransform);
|
||||||
|
|
||||||
MatrixF updatedTrans;
|
// Apply the new transform to the child
|
||||||
updatedTrans.mul(mat, childLocalTrans);
|
child->setRenderTransform(newChildTransform);
|
||||||
|
|
||||||
// Set the child's new world transform
|
|
||||||
child->setRenderTransform(updatedTrans);
|
|
||||||
|
|
||||||
PhysicsShape* childPS = dynamic_cast<PhysicsShape*>(child);
|
PhysicsShape* childPS = dynamic_cast<PhysicsShape*>(child);
|
||||||
if (childPS)
|
if (childPS)
|
||||||
childPS->storeRestorePos();
|
childPS->storeRestorePos();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Parent::setRenderTransform(mat);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneGroup::addObject(SimObject* object)
|
void SceneGroup::addObject(SimObject* object)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue