From 8cb6f4c0cde72c87c8bbe282d880b602f41e13a7 Mon Sep 17 00:00:00 2001 From: Daniel4144 <49939834+Daniel4144@users.noreply.github.com> Date: Tue, 2 Apr 2024 12:13:27 +0200 Subject: [PATCH 1/2] added handle types Translation2D and Translation3D --- .../BoundsControl/BoundsControl.cs | 50 +++++++++++++++++++ .../BoundsControl/BoundsControlTypes.cs | 12 ++++- 2 files changed, 61 insertions(+), 1 deletion(-) 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..7d8b6fd4a 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 << 2, + + /// + /// A handle that is mounted to the face of a , and can move the object in all three dimensions. + /// + Translation3D = 1 << 2, } /// From 2edbc095b1fb345100bf62f2a9289097b7be9980 Mon Sep 17 00:00:00 2001 From: Daniel4144 <49939834+Daniel4144@users.noreply.github.com> Date: Tue, 2 Apr 2024 12:27:50 +0200 Subject: [PATCH 2/2] fixed enum values --- .../BoundsControl/BoundsControlTypes.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/BoundsControlTypes.cs b/org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/BoundsControlTypes.cs index 7d8b6fd4a..394f756a5 100644 --- a/org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/BoundsControlTypes.cs +++ b/org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/BoundsControlTypes.cs @@ -74,12 +74,12 @@ public enum HandleType /// /// A handle that is mounted to the face of a , and can move the object normal to the forward axis. /// - Translation2D = 1 << 2, + Translation2D = 1 << 3, /// /// A handle that is mounted to the face of a , and can move the object in all three dimensions. /// - Translation3D = 1 << 2, + Translation3D = 1 << 4, } ///