mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 08:04:40 +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)
|
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())
|
if (isServerObject())
|
||||||
{
|
{
|
||||||
setMaskBits(TransformMask);
|
setMaskBits(TransformMask);
|
||||||
|
|
@ -177,15 +168,17 @@ void SceneGroup::setTransform(const MatrixF& mat)
|
||||||
SceneObject* child = dynamic_cast<SceneObject*>(*itr);
|
SceneObject* child = dynamic_cast<SceneObject*>(*itr);
|
||||||
if (child)
|
if (child)
|
||||||
{
|
{
|
||||||
// Get the child's current transform
|
// Get the child's current world transform
|
||||||
MatrixF childTransform = child->getTransform();
|
MatrixF childWorldTrans = child->getTransform();
|
||||||
|
|
||||||
// Apply the delta transformation (ignoring scale)
|
MatrixF childLocalTrans;
|
||||||
MatrixF updatedTransform = childTransform;
|
childLocalTrans = mWorldToObj.mul(childWorldTrans);
|
||||||
updatedTransform.mul(deltaTransform);
|
|
||||||
|
|
||||||
// Update the child's transform
|
MatrixF updatedTrans;
|
||||||
child->setTransform(updatedTransform);
|
updatedTrans.mul(mat, childLocalTrans);
|
||||||
|
|
||||||
|
// Set the child's new world transform
|
||||||
|
child->setTransform(updatedTrans);
|
||||||
|
|
||||||
PhysicsShape* childPS = dynamic_cast<PhysicsShape*>(child);
|
PhysicsShape* childPS = dynamic_cast<PhysicsShape*>(child);
|
||||||
if (childPS)
|
if (childPS)
|
||||||
|
|
@ -193,40 +186,37 @@ void SceneGroup::setTransform(const MatrixF& mat)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Parent::setTransform(mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneGroup::setRenderTransform(const MatrixF& 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
|
// 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 transform
|
// Get the child's current world transform
|
||||||
MatrixF childTransform = child->getTransform();
|
MatrixF childWorldTrans = child->getRenderTransform();
|
||||||
|
|
||||||
// Apply the delta transformation (ignoring scale)
|
MatrixF childLocalTrans;
|
||||||
MatrixF updatedTransform = childTransform;
|
childLocalTrans = mWorldToObj.mul(childWorldTrans);
|
||||||
updatedTransform.mul(deltaTransform);
|
|
||||||
|
|
||||||
// Update the child's transform
|
MatrixF updatedTrans;
|
||||||
child->setTransform(updatedTransform);
|
updatedTrans.mul(mat, childLocalTrans);
|
||||||
|
|
||||||
|
// 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