-
Notifications
You must be signed in to change notification settings - Fork 154
Added handle types for 2d/3d translation #711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
765b942
74199ca
ea75af1
9ed906e
49a37a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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); | ||
| // } | ||
|
Comment on lines
+961
to
+966
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for your contribution, this change looks great. We are trying to keep the codebase as clean as possible so we encourage contributors to avoid leaving commented code out of main branch. Could you please remove the commented code?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same commented code is in all other if-branches, so I decided to keep it in the two branches I added. I think removing the comments only here would cause more headache, in case that code is still relevant in the future.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand your point of view, I too leave commented sections in my personal branches. However, since this is an open-source project I think it is best to leave the code as clean as possible because not everyone in the community may have the same context as the author. @MixedRealityToolkit/mixedrealitytoolkit-unity-maintainers What are your thoughts on this? |
||
|
|
||
| if (!transformUpdated.IsMaskSet(TransformFlags.Move)) | ||
| { | ||
| Target.transform.position = smoothingActive ? | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution, this change looks great. We are trying to keep the codebase as clean as possible so we encourage contributors to avoid leaving commented code out of main branch. Could you please remove the commented code?