dimforge / dimforge/nphysics

Static bodies' positions aren't propagated to collision world

Open
#81 0 comments 0 reactions 0 assignees View on GitHub
bug good first issue P-medium
Dominant language
Rust
Stars
1.6k
Forks
120
PR merge metrics
No merged PRs in 30d

Description

Changing the position of a static body using `set_transformation` and related methods has no apparent effect, as its position in the collision world remains unchanged. A simple workaround is to add this method to the `World` class:

/// Acknowledge changes to a static rigid body's position.
pub fn update_static_body_position(&mut self, b: &RigidBodyHandle) {
let rb = b.borrow_mut();
self.cworld.deferred_set_position(&**b as *const RefCell> as usize,
rb.position().clone());
}

However, this may be considered a bit of a hack. On the other hand, I'm not sure what a better solution would be. Adding a branch to `set_transformation` to check if the body is static (and if so, add it to a list of objects that need to be updated) might be slow for many physics objects. If sensors and rigid bodies are now distinct objects, though, maybe it would be worth it to have type-level distinction between dynamic and static bodies. For now, the hack does just fine.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.