[UUM-138261] Fix move handle exponentially moving the selected elements#676
Open
lopezt-unity wants to merge 3 commits into
Open
[UUM-138261] Fix move handle exponentially moving the selected elements#676lopezt-unity wants to merge 3 commits into
lopezt-unity wants to merge 3 commits into
Conversation
| s_HandleOrientation.SetValue(Tools.pivotRotation == PivotRotation.Global | ||
| ? HandleOrientation.World | ||
| : HandleOrientation.ActiveObject); | ||
| s_HandleOrientation.SetValue(Tools.pivotRotation == PivotRotation.Local |
Contributor
There was a problem hiding this comment.
Have you considered caching Tools.pivotRotation into a local variable at the beginning of SyncPivotRotation()?
Since Tools is a Unity class, accessing Tools.pivotRotation repeatedly (up to 7 times in this method) likely involves native-to-managed bridge transitions. Caching it once makes the code cleaner, guarantees consistency throughout the method execution, and avoids redundant native property lookups.
For example:
static void SyncPivotRotation()
{
var activePivotRotation = Tools.pivotRotation;
if (s_PivotRotation != activePivotRotation)
{
s_HandleOrientation.SetValue(activePivotRotation == PivotRotation.Local
? HandleOrientation.ActiveObject
: HandleOrientation.World);
s_PivotRotation = activePivotRotation;
MeshSelection.InvalidateCaches();
pivotRotationChanged?.Invoke();
return;
}
// ... use activePivotRotation below
}🤖 Helpful? 👍/👎 by guardian
Codecov ReportAll modified and coverable lines are covered by tests ✅ @@ Coverage Diff @@
## master #676 +/- ##
==========================================
+ Coverage 37.96% 38.05% +0.08%
==========================================
Files 278 278
Lines 38851 38915 +64
==========================================
+ Hits 14751 14808 +57
- Misses 24100 24107 +7
Flags with carried forward coverage won't be shown. Click here to find out more.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose of this PR
This PR fixes an issue with the Move handle, creating a accumulation of the move deltas when using the handles. This was resulting in an exponential motion of the selected element.
This was caused by a wrong test in the rotation handle type, causing a cache invalidation in the middle of the process. This PR fixes that and focuses on getting PivotRotation.Local and World from unity as they are the only valid ones. This prevent that the use of new pivot types (such as grid or custom) messes up with ProBuilder state.
This PR also added tests to validate that PB pivot types are aligned with these changes.
Links
Jira: https://jira.unity3d.com/browse/UUM-138261
Comments to Reviewers
[List known issues, planned work, provide any extra context for your code.]