You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TL;DR: round_cuboid border radius does not scale correctly with GlobalTransform.
In the following example, I spawn a parent entity that is scaled down to 0.1 unit. Then, I spawn two children for that parent, one with a Collider::round_cuboid(0.0, 0.0, 0.5) and another with Collider::ball(0.5). In this case, I expect both colliders to be basically the same, however the round_cuboid is 10x larger than the ball.
Then, when I spawn another child of the parent entity, but now with Collider::round_cuboid(0.25, 0.25, 0.25), we can see that the collider is nearly half as small as the first round_cuboid.
That shows me that the border radius of Collider::round_cuboid does not scale correctly with the GlobalTransform of an entity.
To show that this does not affect only the debug renderer, I added a dynamic rigidbody (in red) that sits on top of the other colliders.
The following code produces the example of which the attached screenshot was taken.
use bevy::{prelude::*, render::camera::ScalingMode};use bevy_rapier2d::prelude::*;fnmain(){App::new().add_plugins(DefaultPlugins).add_plugins((RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(1.0),RapierDebugRenderPlugin::default(),)).add_systems(Startup, setup).run();}fnsetup(mutcommands:Commands){// Setup the camera.letmut cam = Camera2dBundle::default();// Makes the height of the unit exactly one window, for easy reference.
cam.projection.scaling_mode = ScalingMode::FixedVertical(1.0);
commands.spawn(cam);// Spawn the scaled-down parent entity.
commands
.spawn(SpatialBundle::from_transform(Transform::from_scale(Vec3::splat(0.1),)))// Spawn the three children..with_children(|commands| {
commands.spawn((SpriteBundle{transform:Transform::from_xyz(-4.0,0.0,0.0),
..default()},Collider::round_cuboid(0.0,0.0,0.5),// Expect this...));
commands.spawn((SpriteBundle{transform:Transform::from_xyz(0.0,0.0,0.0),
..default()},Collider::ball(0.5),// ... to be effectively the same as this.));
commands.spawn((SpriteBundle{transform:Transform::from_xyz(4.0,0.0,0.0),
..default()},Collider::round_cuboid(0.25,0.25,0.25),// Compare this to the first child.));});// The following entity shows that it not only affects the debug renderer, but also the// simulation.
commands.spawn((SpatialBundle::from_transform(Transform::from_xyz(0.0,1.0,0.0)),RigidBody::Dynamic,Collider::ball(0.1),));}
The text was updated successfully, but these errors were encountered:
TL;DR:
round_cuboid
border radius does not scale correctly withGlobalTransform
.In the following example, I spawn a parent entity that is scaled down to 0.1 unit. Then, I spawn two children for that parent, one with a
Collider::round_cuboid(0.0, 0.0, 0.5)
and another withCollider::ball(0.5)
. In this case, I expect both colliders to be basically the same, however theround_cuboid
is 10x larger than theball
.Then, when I spawn another child of the parent entity, but now with
Collider::round_cuboid(0.25, 0.25, 0.25)
, we can see that the collider is nearly half as small as the firstround_cuboid
.That shows me that the border radius of
Collider::round_cuboid
does not scale correctly with theGlobalTransform
of an entity.To show that this does not affect only the debug renderer, I added a dynamic rigidbody (in red) that sits on top of the other colliders.
The following code produces the example of which the attached screenshot was taken.
The text was updated successfully, but these errors were encountered: