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

various fixes in the prepare/init_transforms system #360

Merged
merged 6 commits into from
May 15, 2024

Conversation

exoexo-dev
Copy link
Contributor

@exoexo-dev exoexo-dev commented May 11, 2024

Objective

The prepare/init_transforms system has multiple issues:

  • Returns early when !config.transform_to_position from loop so only the first item of the query is being processed
  • is_rb: Has<C> is redundant in the presence of Added<C>
    • changed is_rb: Has<C> to is_rigid_body: Has<RigidBody>
  • Where there is Position and/or Rotation and config.transform_to_position but no Transform, no new Transform is added
  • When there is no Position and/or Rotation and config.transform_to_position the new_position/new_rotation ignore the current transform and only take the global transform

Solution

Added a test to cover this system and fixed the found issues. Also refactored out some of the deep nesting in the implementation. Note that the test does not yet cover GlobalTransforms and parents transforms.


Changelog

Fixed

Fixed various issues in the prepare/init_transforms system.

@exoexo-dev exoexo-dev marked this pull request as draft May 11, 2024 21:08
@exoexo-dev exoexo-dev changed the title fix init_transforms when !transform_to_position various fixes in the prepare/init_transforms system May 12, 2024
@exoexo-dev exoexo-dev marked this pull request as ready for review May 12, 2024 10:25
@Jondolf Jondolf added C-Testing Improvements or additions to testing bugfix labels May 14, 2024
Copy link
Owner

@Jondolf Jondolf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good overall! I really like having this properly tested.

I left some small code quality suggestions, and fixes for the CI errors (mainly wrong precision for math types, ugh). The lint error seems unrelated, so you can probably ignore that.

src/plugins/prepare.rs Outdated Show resolved Hide resolved
src/plugins/prepare.rs Outdated Show resolved Hide resolved
src/plugins/prepare.rs Outdated Show resolved Hide resolved
src/plugins/prepare.rs Outdated Show resolved Hide resolved
src/plugins/prepare.rs Outdated Show resolved Hide resolved
src/plugins/prepare.rs Outdated Show resolved Hide resolved
src/plugins/prepare.rs Outdated Show resolved Hide resolved
src/plugins/prepare.rs Outdated Show resolved Hide resolved
src/plugins/prepare.rs Outdated Show resolved Hide resolved
src/plugins/prepare.rs Outdated Show resolved Hide resolved
@exoexo-dev
Copy link
Contributor Author

Should we remove the comment // TODO: This system feels very overengineered. Try to clean it up? now?

@Jondolf
Copy link
Owner

Jondolf commented May 15, 2024

Yeah, we can probably remove it. The system still isn't exactly pretty, but it's at least better and properly tested.

I think we might be able to make this and other component initialization logic a bit nicer once Bevy gets "required components" (a way to automatically insert components based on dependencies to other components, Cart is working on this), assuming it allows ECS world access. But we can experiment with that when they're actually released

@exoexo-dev
Copy link
Contributor Author

All should be resolved, thx! Lmk if I can auto-squash the fixups

Copy link
Owner

@Jondolf Jondolf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, looks good now! I generally tend to do squash merges like Bevy itself, so there's no need for you to squash things :)

(also I fixed the lint errors on the main branch so CI should now fully pass)

@Jondolf Jondolf merged commit 5a10b61 into Jondolf:main May 15, 2024
3 of 4 checks passed
@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-Testing Improvements or additions to testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants