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

Simplify transform_to_position and fix rotation denormalization #620

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Jondolf
Copy link
Owner

@Jondolf Jondolf commented Jan 10, 2025

Objective

Fixes #573 (hopefully)
Fixes #618

The transform_to_position system is currently doing some rather complicated computations that appear to be prone to causing error and rotation denormalization.

It is somewhat difficult to understand what exactly the system is even doing (it has been a long time since I wrote it), but it essentially seems to apply the change between PreviousGlobalTransform and GlobalTransform, with several seemingly unnecessary extra steps, instead of simply setting Position and Rotation to match GlobalTransform.

Solution

Significantly simplify transform_to_position, and simply set Position and Rotation to match GlobalTransform.

In my testing, this fixes the denormalization issue in #618, and I suspect that it may have also helped with #573. Confirmation from @coreh or someone else struggling with the runtime panic would be appreciated!

Additional Information

I'm not entirely sure why I originally wrote this the way I did. This commit implies that it was done to fix some problem with change detection (maybe for sleeping?) but the version in this PR seems to work perfectly fine based on my brief testing.

I haven't noticed this breaking anything else, and I don't see why it would have, but if someone does notice regressions, please let me know!

@Jondolf Jondolf added C-Bug Something isn't working A-Transform Relates to transforms or physics positions labels Jan 10, 2025
@matjlars
Copy link

I tested this branch with my game and it works! Thanks again!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Transform Relates to transforms or physics positions C-Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

non-normalized rotations Error: The vector given to Dir3::new_unchecked is not normalized
2 participants