-
-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Objective Depends on #154, which needs to be merged first. Currently, modifying the transform scale of an entity has no effect on its collider. This means that people need to set the collider size to match the size of the scaled mesh, which is often inconvenient. Colliders should get scaled by their transforms like in other game engines such as Godot, Unity and so on. ## Solution Extend `Collider` to support scaling: ```rust pub struct Collider { /// The raw unscaled collider shape. shape: SharedShape, /// The scaled version of the collider shape. /// /// If the scale is `Vector::ONE`, this will be `None` and `unscaled_shape` /// will be used instead. scaled_shape: SharedShape, /// The global scale used for the collider shape. scale: Vector, } ``` Transform scale works in hierarchies the same way as it does for meshes, so scale is propagated to children. --- ## Migration Guide This: ```rust let mesh = meshes.add(Mesh::from(shape::Cube { size: 1.0 })); commands.spawn(( PbrBundle { mesh, transform: Transform::from_scale(Vec3::new(10.0, 1.0, 10.0)), ..default() }, Collider::cuboid(10.0, 1.0, 10.0), RigidBody::Static, )); ``` becomes this: (collider size matches unscaled mesh size) ```rust let mesh = meshes.add(Mesh::from(shape::Cube { size: 1.0 })); commands.spawn(( PbrBundle { mesh, transform: Transform::from_scale(Vec3::new(10.0, 1.0, 10.0)), ..default() }, Collider::cuboid(1.0, 1.0, 1.0), RigidBody::Static, )); ```
- Loading branch information
Showing
17 changed files
with
369 additions
and
84 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.