Added 2D support through axis masking (Issue #49) #316
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.
I added a function
void SetAxisMask(bool x, bool y, bool z)
which allows the user to permanently hide whichever axis is set totrue
, multiple axes can be hidden (although it's kind of pointless).As suggested in Issue #49, I used the
belowAxisLimit
boolean to hide the given axes for translation and scale, for rotation, however, theDrawRotationGizmo
function was edited in order to show the rotation widget on whichever plane is perpendicular to the masked axis (no widget is shown if 2 or more axes are masked), the same was done for plane movement with the translation gizmo. Aditionally, in the case ofMT_ROTATE_SCREEN
, it is completely removed should any axis be masked (It didn't make much sense to me to be able to rotate it in any given direction when it's supposed to be masked), however bothMT_SCALE_XYZ
and 'MT_MOVE_SCREEN' were left as is (It made more sense for these to have an "override" of sorts, but that's just personal opinion)I'm quite new to ImGuizmo and did this for a personal project and thought it could be handy, which is why I made a pull request, but since I'm not very familiar with it I may have put the checks for masking in suboptimal places, however I believe the checks themselves are quite efficient since they consist solely of bit operations.
Keep in mind I have NOT tested this as thoroughly as I probably should have, and it may cause unforseen issues, but for my personal usecase it seems to cause no problems