Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. Additionally, make sure you've done all of these things:
[x] I've formatted my code according to Natron's code style
[x] I've searched the pull requests tracker to ensure that this PR is not a duplicate
PR Description
What type of PR is this? (Check one of the boxes below)
[ ] Bug fix (non-breaking change which fixes an issue)
[ ] New feature (non-breaking change which adds functionality)
[x] Improvement (non-breaking change which does not add functionality nor fixes a bug but improves Natron in some way)
[ ] Breaking change (fix or feature that would cause existing functionality to change)
[ ] My change requires a change to the documentation
[ ] I have updated the documentation accordingly
What does this pull request do?
The main goal of this change is to simplify the code and improve readability for some RectI and RectD usage. It does not
change any existing functionality, but it changes some key function signatures and adds a few helpers to make the code
simpler and a little easier to follow. The new signatures also make it easier to declare various variables const now, which
makes it a lot easier to reason about behavior in some of the large functions in the rendering path.
Here is a summary of the changes made:
Changed RectI::toCanonical(), RectI::toCanonical_noClip() and RectD::toPixelEnclosing() to return their value instead if using an out pointer param. This simplifies a lot of callers, avoids default construction in a lot of cases, and allows many variables to be marked const which makes it easier to ensure values don't change unexpectedly in large functions.
Added RectI::toNewMipMapLevel() helper function to reduce duplicate code and make the code a little more readable.
Added RectI::intersect() and RectD::intersect() methods that return the intersection or a null rect. Updated a few places where this form simplifies or makes the code more clear.
Added RectI::clipIfOverlaps() and RectD::clipIfOverlaps() helper functions to replace a common usage of the existing intersect() method. The intent is to make it a little more clear that the intersection only happens if there is an overlap and it avoids having to specify a variable name twice.
Renamed the original intersect() to intersectInternal() and made it private. The intersect() and clipIfOverlaps() changes above made it so there were no callers outside of RectI and RectD that needed this.
Removed some comment out code and a few variables/computations that weren't actually used for anything.
Added documentation for a few methods to make their behavior a little more clear.
Updated python wrapper type definitions to reflect the changes above. The intersect modifications could be removed because the new intersect() signature and semantics match the desired python signature and semantics.
Have you tested your changes (if applicable)? If so, how?
Yes. I've build this locally, verified the tests still run and Natron appears to work as expected. No change in behavior has been observed.
Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. Additionally, make sure you've done all of these things:
PR Description
What type of PR is this? (Check one of the boxes below)
What does this pull request do?
The main goal of this change is to simplify the code and improve readability for some RectI and RectD usage. It does not change any existing functionality, but it changes some key function signatures and adds a few helpers to make the code simpler and a little easier to follow. The new signatures also make it easier to declare various variables const now, which makes it a lot easier to reason about behavior in some of the large functions in the rendering path.
Here is a summary of the changes made:
Changed RectI::toCanonical(), RectI::toCanonical_noClip() and RectD::toPixelEnclosing() to return their value instead if using an out pointer param. This simplifies a lot of callers, avoids default construction in a lot of cases, and allows many variables to be marked const which makes it easier to ensure values don't change unexpectedly in large functions.
Added RectI::toNewMipMapLevel() helper function to reduce duplicate code and make the code a little more readable.
Added RectI::intersect() and RectD::intersect() methods that return the intersection or a null rect. Updated a few places where this form simplifies or makes the code more clear.
Added RectI::clipIfOverlaps() and RectD::clipIfOverlaps() helper functions to replace a common usage of the existing intersect() method. The intent is to make it a little more clear that the intersection only happens if there is an overlap and it avoids having to specify a variable name twice.
Renamed the original intersect() to intersectInternal() and made it private. The intersect() and clipIfOverlaps() changes above made it so there were no callers outside of RectI and RectD that needed this.
Removed some comment out code and a few variables/computations that weren't actually used for anything.
Added documentation for a few methods to make their behavior a little more clear.
Updated python wrapper type definitions to reflect the changes above. The intersect modifications could be removed because the new intersect() signature and semantics match the desired python signature and semantics.
Have you tested your changes (if applicable)? If so, how?
Yes. I've build this locally, verified the tests still run and Natron appears to work as expected. No change in behavior has been observed.