Skip to content
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

Fix Transform initialization for children and refactor prepare.rs #140

Merged
merged 1 commit into from
Sep 1, 2023

Conversation

Jondolf
Copy link
Owner

@Jondolf Jondolf commented Aug 31, 2023

Problem

Currently, the transforms of bodies and colliders that are children are initialized incorrectly by the PreparePlugin. The Transform is assumed to be the same as GlobalTransform when updating Transform based on Position and Rotation.

Solution

This PR fixes the issue by computing the correct local transform based on the difference between the parent's and child's global positions/rotations.

Other changes

  • Moved the transform initialization, which was previously in both init_rigid_bodies and init_colliders, into a separate system init_transforms
  • apply_deferred is now called before the initialization systems
  • Transform propagation is run if either rigid bodies or colliders have been added instead of just for new rigid bodies
  • Added more comments for systems
  • Removed some separate type aliases of component bundles (like RigidBodyComponents) and added the component types to the systems themselves. Each type alias was only used for a specific system, so they were unnecessary and made things longer.

@Jondolf Jondolf added C-Enhancement New feature or request bugfix labels Aug 31, 2023
@Jondolf Jondolf merged commit b71328e into main Sep 1, 2023
@Jondolf Jondolf deleted the init-transforms-fix branch September 1, 2023 14:03
RJ pushed a commit to RJ/avian that referenced this pull request Sep 3, 2023
@Jondolf Jondolf added C-Bug Something isn't working and removed bugfix labels Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Bug Something isn't working C-Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant