mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 15:44:36 +00:00
Fixed issue of mis-transforming child objects so rotation would be weird when rotating subscenes
Fixed issue of action buttons breaking with subscenes when going between child-object manip modes and not
This commit is contained in:
parent
e2d0cc1981
commit
9ff2a56466
2 changed files with 45 additions and 36 deletions
|
|
@ -164,9 +164,8 @@ void SceneGroup::setTransform(const MatrixF& mat)
|
||||||
Parent::setTransform(mat);
|
Parent::setTransform(mat);
|
||||||
|
|
||||||
// Calculate the delta transformation
|
// Calculate the delta transformation
|
||||||
MatrixF deltaTransform;
|
MatrixF deltaTransform = mat;
|
||||||
oldTransform.inverse();
|
deltaTransform.mul(oldTransform.inverse());
|
||||||
deltaTransform.mul(oldTransform, getTransform());
|
|
||||||
|
|
||||||
if (isServerObject())
|
if (isServerObject())
|
||||||
{
|
{
|
||||||
|
|
@ -178,11 +177,19 @@ 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
|
||||||
MatrixF childTransform = child->getTransform();
|
MatrixF childTransform = child->getTransform();
|
||||||
MatrixF relativeTransform;
|
|
||||||
relativeTransform.mul(deltaTransform, childTransform);
|
// Apply the delta transformation (ignoring scale)
|
||||||
child->setTransform(relativeTransform);
|
MatrixF updatedTransform = childTransform;
|
||||||
child->setScale(childTransform.getScale()); //we don't modify scale
|
updatedTransform.mul(deltaTransform);
|
||||||
|
|
||||||
|
// Update the child's transform
|
||||||
|
child->setTransform(updatedTransform);
|
||||||
|
|
||||||
|
PhysicsShape* childPS = dynamic_cast<PhysicsShape*>(child);
|
||||||
|
if (childPS)
|
||||||
|
childPS->storeRestorePos();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -196,9 +203,8 @@ void SceneGroup::setRenderTransform(const MatrixF& mat)
|
||||||
Parent::setRenderTransform(mat);
|
Parent::setRenderTransform(mat);
|
||||||
|
|
||||||
// Calculate the delta transformation
|
// Calculate the delta transformation
|
||||||
MatrixF deltaTransform;
|
MatrixF deltaTransform = mat;
|
||||||
oldTransform.inverse();
|
deltaTransform.mul(oldTransform.inverse());
|
||||||
deltaTransform.mul(oldTransform, getRenderTransform());
|
|
||||||
|
|
||||||
// Update all child transforms
|
// Update all child transforms
|
||||||
for (SimSetIterator itr(this); *itr; ++itr)
|
for (SimSetIterator itr(this); *itr; ++itr)
|
||||||
|
|
@ -206,11 +212,19 @@ void SceneGroup::setRenderTransform(const MatrixF& mat)
|
||||||
SceneObject* child = dynamic_cast<SceneObject*>(*itr);
|
SceneObject* child = dynamic_cast<SceneObject*>(*itr);
|
||||||
if (child)
|
if (child)
|
||||||
{
|
{
|
||||||
MatrixF childTransform = child->getRenderTransform();
|
// Get the child's current transform
|
||||||
MatrixF relativeTransform;
|
MatrixF childTransform = child->getTransform();
|
||||||
relativeTransform.mul(deltaTransform, childTransform);
|
|
||||||
child->setRenderTransform(relativeTransform);
|
// Apply the delta transformation (ignoring scale)
|
||||||
child->setScale(childTransform.getScale()); //we don't modify scale
|
MatrixF updatedTransform = childTransform;
|
||||||
|
updatedTransform.mul(deltaTransform);
|
||||||
|
|
||||||
|
// Update the child's transform
|
||||||
|
child->setTransform(updatedTransform);
|
||||||
|
|
||||||
|
PhysicsShape* childPS = dynamic_cast<PhysicsShape*>(child);
|
||||||
|
if (childPS)
|
||||||
|
childPS->storeRestorePos();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,33 +1,28 @@
|
||||||
function SubScene::onSelected(%this)
|
function SubScene::onSelected(%this)
|
||||||
{
|
{
|
||||||
echo("SELECTED SUBSCENE");
|
EWToolsPaletteWindow.clearButtons();
|
||||||
|
|
||||||
|
//Adds a button to the pallete stack
|
||||||
|
EWToolsPaletteWindow.addButton("Select", "ToolsModule:arrow_n_image", "EWorldEditorNoneModeBtn::onClick();", "", "Select Arrow", "1");
|
||||||
|
EWToolsPaletteWindow.addButton("Move", "ToolsModule:translate_n_image", "SubSceneMoveModeBtn::onClick();", "", "Move Selection", "2");
|
||||||
|
EWToolsPaletteWindow.addButton("Rotate", "ToolsModule:rotate_n_image", "SubSceneRotateModeBtn::onClick();", "", "Rotate Selection", "3");
|
||||||
|
EWToolsPaletteWindow.addButton("Scale", "ToolsModule:Scale_n_image", "EWorldEditorScaleModeBtn::onClick();", "", "Scale Selection", "4");
|
||||||
|
|
||||||
%moveButton = EWToolsPaletteWindow.findButton("Move");
|
EWToolsPaletteWindow.addButton("SubSceneMove", "ToolsModule:translate_n_image", "SubSceneChildMoveModeBtn::onClick();", "", "Move SubScene + Children", "5");
|
||||||
%rotateButton = EWToolsPaletteWindow.findButton("Rotate");
|
EWToolsPaletteWindow.addButton("SubSceneRotate", "ToolsModule:rotate_n_image", "SubSceneChildRotateModeBtn::onClick();", "", "Rotate SubScene + Children", "6");
|
||||||
|
|
||||||
%moveButton.originalCommand = %moveButton.command;
|
|
||||||
%moveButton.command = "SubSceneMoveModeBtn::onClick();";
|
|
||||||
|
|
||||||
%rotateButton.originalCommand = %rotateButton.command;
|
|
||||||
%rotateButton.command = "SubSceneRotateModeBtn::onClick();";
|
|
||||||
|
|
||||||
EWToolsPaletteWindow.addButton("SubSceneMove", "ToolsModule:translate_n_image", "SubSceneChildMoveModeBtn::onClick();", "", "Move SubScene + Children", "1");
|
|
||||||
EWToolsPaletteWindow.addButton("SubSceneRotate", "ToolsModule:rotate_n_image", "SubSceneChildRotateModeBtn::onClick();", "", "Rotate SubScene + Children", "2");
|
|
||||||
|
|
||||||
EWToolsPaletteWindow.refresh();
|
EWToolsPaletteWindow.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
function SubScene::onUnselected(%this)
|
function SubScene::onUnselected(%this)
|
||||||
{
|
{
|
||||||
echo("UN-SELECTED SUBSCENE");
|
EWToolsPaletteWindow.clearButtons();
|
||||||
EWToolsPaletteWindow.removeButton("SubSceneMove");
|
|
||||||
EWToolsPaletteWindow.removeButton("SubSceneRotate");
|
//Adds a button to the pallete stack
|
||||||
|
EWToolsPaletteWindow.addButton("Select", "ToolsModule:arrow_n_image", "EWorldEditorNoneModeBtn::onClick();", "", "Select Arrow", "1");
|
||||||
%moveButton = EWToolsPaletteWindow.findButton("Move");
|
EWToolsPaletteWindow.addButton("Move", "ToolsModule:translate_n_image", "EWorldEditorMoveModeBtn::onClick();", "", "Move Selection", "2");
|
||||||
%rotateButton = EWToolsPaletteWindow.findButton("Rotate");
|
EWToolsPaletteWindow.addButton("Rotate", "ToolsModule:rotate_n_image", "EWorldEditorRotateModeBtn::onClick();", "", "Rotate Selection", "3");
|
||||||
|
EWToolsPaletteWindow.addButton("Scale", "ToolsModule:Scale_n_image", "EWorldEditorScaleModeBtn::onClick();", "", "Scale Selection", "4");
|
||||||
%moveButton.command = %moveButton.originalCommand;
|
|
||||||
%rotateButton.command = %rotateButton.originalCommand;
|
|
||||||
|
|
||||||
$SubScene::transformChildren = false;
|
$SubScene::transformChildren = false;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue