Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,20 @@ private Matrix GetWorldMatrix(IEditorGameCameraService cameraService)
worldMatrix.TranslationVector = AnchorEntity.Transform.WorldMatrix.TranslationVector;
break;
case TransformationSpace.ObjectSpace:
var parentMatrix = Matrix.Identity;
Matrix parentMatrix;
if (AnchorEntity.GetParent() != null)
{
parentMatrix = AnchorEntity.TransformValue.Parent.WorldMatrix;

}
else
{
// Root entity in subscene — use Scene.Offset as parent matrix
var scene = AnchorEntity.Scene;
parentMatrix = (scene != null && scene.Offset != Vector3.Zero)
? Matrix.Translation(scene.Offset)
: Matrix.Identity;
}

// We don't use the entity's "WorldMatrix" because its scale could be zero, which would break the gizmo.
worldMatrix = Matrix.RotationQuaternion(AnchorEntity.Transform.Rotation) *
Matrix.Translation(AnchorEntity.Transform.Position) *
Expand Down Expand Up @@ -335,12 +345,25 @@ protected virtual void OnTransformationStarted(Vector2 mouseDragPixel)
// Ensure world matrix is computed
entity.Transform.UpdateWorldMatrix();

Matrix inverseParent;
if (entity.Transform.Parent != null)
{
inverseParent = Matrix.Invert(entity.Transform.Parent.WorldMatrix);
}
else
{
var scene = entity.Scene;
inverseParent = (scene != null && scene.Offset != Vector3.Zero)
? Matrix.Invert(Matrix.Translation(scene.Offset))
: Matrix.Identity;
}

InitialTransformations[entity] = new InitialTransformation
{
Scale = entity.Transform.Scale,
Translation = entity.Transform.Position,
Rotation = entity.Transform.Rotation,
InverseParentMatrix = entity.Transform.Parent != null ? Matrix.Invert(entity.Transform.Parent.WorldMatrix) : Matrix.Identity
InverseParentMatrix = inverseParent
};
}
}
Expand Down