[3.x] CPUParticles2D - fix interpolated transforms and culling#80887
Merged
akien-mga merged 1 commit intogodotengine:3.xfrom Sep 18, 2023
Merged
[3.x] CPUParticles2D - fix interpolated transforms and culling#80887akien-mga merged 1 commit intogodotengine:3.xfrom
akien-mga merged 1 commit intogodotengine:3.xfrom
Conversation
1) Physics interpolated particles in global mode are specified in global space. In VisualServer they should therefore ignore local transform. 2) Additionally, the expected final_transform should be passed on to children, rather than the identity transform used on the local item. 3) Local bounds in hierarchical culling are fixed for items using identity transform, by calculating their local bound in local space from the global space particles.
This was referenced Aug 22, 2023
akien-mga
approved these changes
Sep 18, 2023
Member
|
Thanks! |
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.
Fixes #80880
broken.mp4
fixed.mp4
Explanation
The first bug fix is that as
CPUParticles2Dare specified with vertices in global space, then the local transform of the item should not be applied during rendering. If it changes, this should reflect in the vertex positions, not be applied during rendering. For this reason the flag is renamed fromignore_parent_xformtouse_identity_xform, as that is what it now does.An additional bug was I noticed that during rendering the global transform passed to any children from such an item would be incorrect. It now calculates the
final_xformas normal (and passes to children), but substitutes in the identity transform only for rendering (which is done by substituting the camera transform only, as the camera transform is always combined in the final transform).Next, I realised that the local bound for hierarchical culling was incorrect, as it was specified in global space, whereas hierarchical culling expects bounds in local space. This was fixed by back-calculating a local bound during the local bound update pass. This isn't particularly efficient, but it should work and is not overly complex. I couldn't immediately think of a better way of doing this but perhaps it can be improved / optimized in a later PR.
Notes
Testing
Run the MRP from #80880
I also have an MRP for displaying the local bounds to verify these are correct, run with 3.6 beta 3 (to see problems), and with this PR to see fixed:
CPUPartlcles2D_LocalBounds.zip