Skip to content

Commit 8cb6f4c

Browse files
Daniel4144keveleigh
authored andcommitted
added handle types Translation2D and Translation3D
1 parent c105fef commit 8cb6f4c

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/BoundsControl.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,56 @@ private void TransformTarget()
915915
// transformUpdated = elasticsManager.ApplyTargetTransform(constraintTranslate, TransformFlags.Move);
916916
// }
917917

918+
if (!transformUpdated.IsMaskSet(TransformFlags.Move))
919+
{
920+
Target.transform.position = smoothingActive ?
921+
Smoothing.SmoothTo(Target.transform.position, constraintTranslate.Position, translateLerpTime, Time.deltaTime) :
922+
constraintTranslate.Position;
923+
}
924+
}
925+
else if (currentHandle.HandleType == HandleType.Translation2D)
926+
{
927+
Vector3 translateVectorOnPlane = Vector3.ProjectOnPlane(currentGrabPoint - initialGrabPoint, currentHandle.transform.forward);
928+
929+
var goal = initialTransformOnGrabStart.Position + translateVectorOnPlane;
930+
MixedRealityTransform constraintTranslate = MixedRealityTransform.NewTranslate(goal);
931+
if (EnableConstraints && constraintsManager != null)
932+
{
933+
constraintsManager.ApplyTranslationConstraints(ref constraintTranslate, true, currentHandle.IsGrabSelected);
934+
}
935+
936+
// TODO: Elastics integration (soon!)
937+
938+
// if (elasticsManager != null)
939+
// {
940+
// transformUpdated = elasticsManager.ApplyTargetTransform(constraintTranslate, TransformFlags.Move);
941+
// }
942+
943+
if (!transformUpdated.IsMaskSet(TransformFlags.Move))
944+
{
945+
Target.transform.position = smoothingActive ?
946+
Smoothing.SmoothTo(Target.transform.position, constraintTranslate.Position, translateLerpTime, Time.deltaTime) :
947+
constraintTranslate.Position;
948+
}
949+
}
950+
else if (currentHandle.HandleType == HandleType.Translation3D)
951+
{
952+
Vector3 translateVector = currentGrabPoint - initialGrabPoint;
953+
954+
var goal = initialTransformOnGrabStart.Position + translateVector;
955+
MixedRealityTransform constraintTranslate = MixedRealityTransform.NewTranslate(goal);
956+
if (EnableConstraints && constraintsManager != null)
957+
{
958+
constraintsManager.ApplyTranslationConstraints(ref constraintTranslate, true, currentHandle.IsGrabSelected);
959+
}
960+
961+
// TODO: Elastics integration (soon!)
962+
963+
// if (elasticsManager != null)
964+
// {
965+
// transformUpdated = elasticsManager.ApplyTargetTransform(constraintTranslate, TransformFlags.Move);
966+
// }
967+
918968
if (!transformUpdated.IsMaskSet(TransformFlags.Move))
919969
{
920970
Target.transform.position = smoothingActive ?

org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/BoundsControlTypes.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,22 @@ public enum HandleType
6464
Scale = 1 << 1,
6565

6666
/// <summary>
67-
/// A handle that is mounted to the face of a <see cref="BoundsControl"/>, and can move the object.
67+
/// A handle that is mounted to the face of a <see cref="BoundsControl"/>, and can move the object along the forward axis.
6868
/// </summary>
6969
/// <remarks>
7070
/// Handles of this type are currently not supported.
7171
/// </remarks>
7272
Translation = 1 << 2,
73+
74+
/// <summary>
75+
/// A handle that is mounted to the face of a <see cref="BoundsControl"/>, and can move the object normal to the forward axis.
76+
/// </summary>
77+
Translation2D = 1 << 2,
78+
79+
/// <summary>
80+
/// A handle that is mounted to the face of a <see cref="BoundsControl"/>, and can move the object in all three dimensions.
81+
/// </summary>
82+
Translation3D = 1 << 2,
7383
}
7484

7585
/// <summary>

0 commit comments

Comments
 (0)