`set_position` has no effect on collider after calling `step`
- Dominant language
- Rust
- Stars
- 1.6k
- Forks
- 120
- PR merge metrics
- No merged PRs in 30d
Description
To demonstrate the issue I made the following test, which should be self-explaining.
Notice the use of `position` in the collider description builder vs. `set_position`.
```
#[test]
pub fn test() {
use nalgebra::{Isometry3, Vector3};
use ncollide3d::shape::{Cuboid, ShapeHandle};
use nphysics3d::{
force_generator::DefaultForceGeneratorSet,
joint::DefaultJointConstraintSet,
object::{BodyPartHandle, ColliderDesc, DefaultBodySet, DefaultColliderSet, Ground},
world::{DefaultGeometricalWorld, DefaultMechanicalWorld},
};
// world
let mut mechanical_world = DefaultMechanicalWorld::new(Vector3::new(0.0, -9.81, 0.0));
let mut geometrical_world = DefaultGeometricalWorld::::new();
let mut bodies = DefaultBodySet::::new();
let mut colliders = DefaultColliderSet::new();
let mut joint_constraints = DefaultJointConstraintSet::::new();
let mut force_generators = DefaultForceGeneratorSet::::new();
// ground
let ground_thickness = 0.2;
let ground_shape = ShapeHandle::new(Cuboid::new(Vector3::new(3.0, ground_thickness, 3.0)));
let ground_handle = bodies.insert(Ground::new());
let co = ColliderDesc::new(ground_shape)
.translation(Vector3::y() * -ground_thickness)
.build(BodyPartHandle(ground_handle, 0));
colliders.insert(co);
let cuboid = ShapeHandle::new(Cuboid::new(Vector3::repeat(0.2)));
let isometry = Isometry3::translation(1.0, 1.0, 1.0);
// collider 1
let co_1 = ColliderDesc::new(cuboid.clone())
.position(Isometry3::translation(1.0, 1.0, 1.0))
.build(BodyPartHandle(ground_handle, 0));
let co_handle_1 = colliders.insert(co_1);
assert_eq!(colliders.get(co_handle_1).unwrap().position(), &isometry);
// collider 2
let mut co_2 = ColliderDesc::new(cuboid.clone()).build(BodyPartHandle(ground_handle, 0));
co_2.set_position(Isometry3::translation(1.0, 1.0, 1.0));
let co_handle_2 = colliders.insert(co_2);
assert_eq!(colliders.get(co_handle_2).unwrap().position(), &isometry);
mechanical_world.step(
&mut geometrical_world,
&mut bodies,
&mut colliders,
&mut joint_constraints,
&mut force_generators,
);
// passes
assert_eq!(colliders.get(co_handle_1).unwrap().position(), &isometry);
// fails!
assert_eq!(colliders.get(co_handle_2).unwrap().position(), &isometry);
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.