mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 03:33:48 +00:00
Fixed child relative transforms for when SceneGroups are updated
This commit is contained in:
parent
9ff2a56466
commit
2c8adfdf93
1 changed files with 22 additions and 32 deletions
|
|
@ -158,15 +158,6 @@ void SceneGroup::onInspect(GuiInspector* inspector)
|
|||
|
||||
void SceneGroup::setTransform(const MatrixF& mat)
|
||||
{
|
||||
//transform difference
|
||||
MatrixF oldTransform = getTransform();
|
||||
|
||||
Parent::setTransform(mat);
|
||||
|
||||
// Calculate the delta transformation
|
||||
MatrixF deltaTransform = mat;
|
||||
deltaTransform.mul(oldTransform.inverse());
|
||||
|
||||
if (isServerObject())
|
||||
{
|
||||
setMaskBits(TransformMask);
|
||||
|
|
@ -177,15 +168,17 @@ void SceneGroup::setTransform(const MatrixF& mat)
|
|||
SceneObject* child = dynamic_cast<SceneObject*>(*itr);
|
||||
if (child)
|
||||
{
|
||||
// Get the child's current transform
|
||||
MatrixF childTransform = child->getTransform();
|
||||
// Get the child's current world transform
|
||||
MatrixF childWorldTrans = child->getTransform();
|
||||
|
||||
// Apply the delta transformation (ignoring scale)
|
||||
MatrixF updatedTransform = childTransform;
|
||||
updatedTransform.mul(deltaTransform);
|
||||
MatrixF childLocalTrans;
|
||||
childLocalTrans = mWorldToObj.mul(childWorldTrans);
|
||||
|
||||
// Update the child's transform
|
||||
child->setTransform(updatedTransform);
|
||||
MatrixF updatedTrans;
|
||||
updatedTrans.mul(mat, childLocalTrans);
|
||||
|
||||
// Set the child's new world transform
|
||||
child->setTransform(updatedTrans);
|
||||
|
||||
PhysicsShape* childPS = dynamic_cast<PhysicsShape*>(child);
|
||||
if (childPS)
|
||||
|
|
@ -193,40 +186,37 @@ void SceneGroup::setTransform(const MatrixF& mat)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Parent::setTransform(mat);
|
||||
}
|
||||
|
||||
void SceneGroup::setRenderTransform(const MatrixF& mat)
|
||||
{
|
||||
//transform difference
|
||||
MatrixF oldTransform = getRenderTransform();
|
||||
|
||||
Parent::setRenderTransform(mat);
|
||||
|
||||
// Calculate the delta transformation
|
||||
MatrixF deltaTransform = mat;
|
||||
deltaTransform.mul(oldTransform.inverse());
|
||||
|
||||
// Update all child transforms
|
||||
for (SimSetIterator itr(this); *itr; ++itr)
|
||||
{
|
||||
SceneObject* child = dynamic_cast<SceneObject*>(*itr);
|
||||
if (child)
|
||||
{
|
||||
// Get the child's current transform
|
||||
MatrixF childTransform = child->getTransform();
|
||||
// Get the child's current world transform
|
||||
MatrixF childWorldTrans = child->getRenderTransform();
|
||||
|
||||
// Apply the delta transformation (ignoring scale)
|
||||
MatrixF updatedTransform = childTransform;
|
||||
updatedTransform.mul(deltaTransform);
|
||||
MatrixF childLocalTrans;
|
||||
childLocalTrans = mWorldToObj.mul(childWorldTrans);
|
||||
|
||||
// Update the child's transform
|
||||
child->setTransform(updatedTransform);
|
||||
MatrixF updatedTrans;
|
||||
updatedTrans.mul(mat, childLocalTrans);
|
||||
|
||||
// Set the child's new world transform
|
||||
child->setRenderTransform(updatedTrans);
|
||||
|
||||
PhysicsShape* childPS = dynamic_cast<PhysicsShape*>(child);
|
||||
if (childPS)
|
||||
childPS->storeRestorePos();
|
||||
}
|
||||
}
|
||||
|
||||
Parent::setRenderTransform(mat);
|
||||
}
|
||||
|
||||
void SceneGroup::addObject(SimObject* object)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue