From 765b94250563d2ef1c369a5b01f6b14818af3804 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 b7358ebcb..36c342b36 100644
--- a/org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/BoundsControl.cs
+++ b/org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/BoundsControl.cs
@@ -868,6 +868,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 388a64eea..ce49c51a4 100644
--- a/org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/BoundsControlTypes.cs
+++ b/org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/BoundsControlTypes.cs
@@ -63,12 +63,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 74199ca67f4b82301a4d1c2555d2df347d226a1c 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 ce49c51a4..280dbe16c 100644
--- a/org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/BoundsControlTypes.cs
+++ b/org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/BoundsControlTypes.cs
@@ -73,12 +73,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,
}
///