diff --git a/org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/BoundsControl.cs b/org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/BoundsControl.cs index da15216c8..417e6b74c 100644 --- a/org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/BoundsControl.cs +++ b/org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/BoundsControl.cs @@ -915,6 +915,56 @@ private void TransformTarget() // transformUpdated = elasticsManager.ApplyTargetTransform(constraintTranslate, TransformFlags.Move); // } + if (!transformUpdated.IsMaskSet(TransformFlags.Move)) + { + Target.transform.position = smoothingActive ? + Smoothing.SmoothTo(Target.transform.position, constraintTranslate.Position, translateLerpTime, Time.deltaTime) : + constraintTranslate.Position; + } + } + else if (currentHandle.HandleType == HandleType.Translation2D) + { + Vector3 translateVectorOnPlane = Vector3.ProjectOnPlane(currentGrabPoint - initialGrabPoint, currentHandle.transform.forward); + + var goal = initialTransformOnGrabStart.Position + translateVectorOnPlane; + MixedRealityTransform constraintTranslate = MixedRealityTransform.NewTranslate(goal); + if (EnableConstraints && constraintsManager != null) + { + constraintsManager.ApplyTranslationConstraints(ref constraintTranslate, true, currentHandle.IsGrabSelected); + } + + // TODO: Elastics integration (soon!) + + // if (elasticsManager != null) + // { + // transformUpdated = elasticsManager.ApplyTargetTransform(constraintTranslate, TransformFlags.Move); + // } + + if (!transformUpdated.IsMaskSet(TransformFlags.Move)) + { + Target.transform.position = smoothingActive ? + Smoothing.SmoothTo(Target.transform.position, constraintTranslate.Position, translateLerpTime, Time.deltaTime) : + constraintTranslate.Position; + } + } + else if (currentHandle.HandleType == HandleType.Translation3D) + { + Vector3 translateVector = currentGrabPoint - initialGrabPoint; + + var goal = initialTransformOnGrabStart.Position + translateVector; + MixedRealityTransform constraintTranslate = MixedRealityTransform.NewTranslate(goal); + if (EnableConstraints && constraintsManager != null) + { + constraintsManager.ApplyTranslationConstraints(ref constraintTranslate, true, currentHandle.IsGrabSelected); + } + + // TODO: Elastics integration (soon!) + + // if (elasticsManager != null) + // { + // transformUpdated = elasticsManager.ApplyTargetTransform(constraintTranslate, TransformFlags.Move); + // } + if (!transformUpdated.IsMaskSet(TransformFlags.Move)) { Target.transform.position = smoothingActive ? diff --git a/org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/BoundsControlTypes.cs b/org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/BoundsControlTypes.cs index 29447d526..394f756a5 100644 --- a/org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/BoundsControlTypes.cs +++ b/org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/BoundsControlTypes.cs @@ -64,12 +64,22 @@ public enum HandleType Scale = 1 << 1, /// - /// A handle that is mounted to the face of a , and can move the object. + /// A handle that is mounted to the face of a , and can move the object along the forward axis. /// /// /// Handles of this type are currently not supported. /// Translation = 1 << 2, + + /// + /// A handle that is mounted to the face of a , and can move the object normal to the forward axis. + /// + Translation2D = 1 << 3, + + /// + /// A handle that is mounted to the face of a , and can move the object in all three dimensions. + /// + Translation3D = 1 << 4, } ///