diff --git a/com.microsoft.mrtk.spatialmanipulation/ObjectManipulator/ObjectManipulator.cs b/com.microsoft.mrtk.spatialmanipulation/ObjectManipulator/ObjectManipulator.cs index f005eaf0448..476d8168edb 100644 --- a/com.microsoft.mrtk.spatialmanipulation/ObjectManipulator/ObjectManipulator.cs +++ b/com.microsoft.mrtk.spatialmanipulation/ObjectManipulator/ObjectManipulator.cs @@ -585,6 +585,8 @@ protected override void OnSelectExited(SelectExitEventArgs args) private static readonly ProfilerMarker ObjectManipulatorProcessInteractableMarker = new ProfilerMarker("[MRTK] ObjectManipulator.ProcessInteractable"); + private MixedRealityTransform lastFrameInput; + /// public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase) { @@ -611,36 +613,38 @@ public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase up { if (allowedManipulations.IsMaskSet(TransformFlags.Scale)) { - targetTransform.Scale = ManipulationLogic.scaleLogic.Update(interactorsSelecting, this, targetTransform, useCenteredAnchor); + targetTransform.Scale = ManipulationLogic.scaleLogic.Update(interactorsSelecting, this, lastFrameInput, useCenteredAnchor); } } - // Immediately apply scale constraints after computing the user's desired scale input. - if (EnableConstraints && constraintsManager != null) + using (RotateLogicMarker.Auto()) { - constraintsManager.ApplyScaleConstraints(ref targetTransform, isOneHanded, IsGrabSelected); + if (allowedManipulations.IsMaskSet(TransformFlags.Rotate)) + { + targetTransform.Rotation = ManipulationLogic.rotateLogic.Update(interactorsSelecting, this, lastFrameInput, useCenteredAnchor); + } } - using (RotateLogicMarker.Auto()) + using (MoveLogicMarker.Auto()) { - if (allowedManipulations.IsMaskSet(TransformFlags.Rotate)) + if (allowedManipulations.IsMaskSet(TransformFlags.Move)) { - targetTransform.Rotation = ManipulationLogic.rotateLogic.Update(interactorsSelecting, this, targetTransform, useCenteredAnchor); + targetTransform.Position = ManipulationLogic.moveLogic.Update(interactorsSelecting, this, lastFrameInput, useCenteredAnchor); } } - // Immediately apply rotation constraints after computing the user's desired rotation input. + lastFrameInput = targetTransform; + + // Immediately apply scale constraints after computing the user's desired scale input. if (EnableConstraints && constraintsManager != null) { - constraintsManager.ApplyRotationConstraints(ref targetTransform, isOneHanded, IsGrabSelected); + constraintsManager.ApplyScaleConstraints(ref targetTransform, isOneHanded, IsGrabSelected); } - using (MoveLogicMarker.Auto()) + // Immediately apply rotation constraints after computing the user's desired rotation input. + if (EnableConstraints && constraintsManager != null) { - if (allowedManipulations.IsMaskSet(TransformFlags.Move)) - { - targetTransform.Position = ManipulationLogic.moveLogic.Update(interactorsSelecting, this, targetTransform, useCenteredAnchor); - } + constraintsManager.ApplyRotationConstraints(ref targetTransform, isOneHanded, IsGrabSelected); } // Immediately apply translation constraints after computing the user's desired scale input. @@ -709,7 +713,7 @@ private void ApplyTargetPose(MixedRealityTransform targetPose) /// own modifications to the object's pose. /// /// - /// The target position, rotation, and scale, pre-smoothing/constraints/etc. Modified by-reference. + /// The target position, rotation, and scale, pre-smoothing. Modified by-reference. /// /// /// Flags which parts of the transform (position, rotation, scale) have been altered by an external source (like Elastics).