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

Allow interpolation of scales #512

Merged
merged 12 commits into from
Sep 26, 2024

Conversation

janhohenheim
Copy link
Contributor

Objective

For avian_interpolation, I want to have a clean separation between gameplay transforms and render transforms. Avian's best version of a gameplay scale is currently Collider::scale. However, this is not ergonomically interpolatable due to two reasons:

  • Collider::scale is not initialized with the right scale, meaning that my observers that listen for its insertion will read wrong initial data, and
  • It is automatically synced to the GlobalTransform, making it hard to change the Transform according to the Collider::scale without affecting it back in turn

Related to #444

Solution

  • Set the Collider::scale correctly in its on_add hook
  • Allow an opt-out via SyncConfig

Changelog

  • You can now opt-out of Transform to Collider::scale syncing by using the new SyncConfig::transform_to_collider_scale field.

@janhohenheim
Copy link
Contributor Author

@Jondolf could you help me out with the CI failure? With the .into it says that it is not needed for some features, but without it, we get this:
image
ofc I could just ignore the clippy lint, but I'd like to know how the rest of the Avian codebase does this. This is not a case of .adjust_precision, is it?

@Jondolf
Copy link
Owner

Jondolf commented Sep 18, 2024

This is not a case of .adjust_precision, is it?

It most likely is; set_scale currently takes a Vector, so you need to convert the transform's Vec2/Vec3 scale to it using .adjust_precision.

@janhohenheim
Copy link
Contributor Author

Yep, you were right :D

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.

Looks good, thanks!

src/collision/collider/backend.rs Outdated Show resolved Hide resolved
src/collision/collider/backend.rs Outdated Show resolved Hide resolved
src/collision/collider/backend.rs Outdated Show resolved Hide resolved
@Jondolf Jondolf added the C-Enhancement New feature or request label Sep 26, 2024
@Jondolf Jondolf enabled auto-merge (squash) September 26, 2024 11:16
@Jondolf Jondolf merged commit 39a7480 into Jondolf:main Sep 26, 2024
4 checks passed
@janhohenheim janhohenheim deleted the scale-interpolation-support branch September 26, 2024 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants