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
Partially integrated collision groups into nphysics #58
Conversation
@@ -94,7 +94,7 @@ impl<'a> Testbed<'a> { | |||
minor_version: 1 | |||
}; | |||
let window = | |||
match RenderWindow::new(mode, "nphysics 2d demo", Close, &setting) { | |||
match RenderWindow::new(mode, "nphysics 2d demo", Close, &ContextSettings::default()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What did I have to do about that ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's best to keep your modification. I believe the setting
variable initialization just above could be removed now.
@@ -244,7 +247,7 @@ impl<N: Scalar> RigidBody<N> { | |||
} | |||
|
|||
/// Creates a new rigid body that can move. | |||
pub fn new_dynamic<G>(shape: G, density: N, restitution: N, friction: N) -> RigidBody<N> | |||
pub fn new_dynamic<G>(shape: G, density: N, restitution: N, friction: N, groups: Option<RigidBodyCollisionGroups>) -> RigidBody<N> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer not to add groups as a constructor argument. For many applications, a custom value is not needed at all.
|
||
/// Mutable reference to the collision groups of this rigid body. | ||
#[inline] | ||
pub fn collision_groups_mut(&mut self) -> &mut RigidBodyCollisionGroups { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not 100% sure but I think it is better not to return a mutable reference, but instead have something like .set_collision_groups(&mut self, new_groups: &mut RigidBodyCollisionGroups)
. In the future, the rigid body will have to know that the groups have been tempered with in order to notify the collision detectors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to keep collision_groups(&self) -> &RigidBodyCollisionGroups
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, immutable access might be useful and has no impact on the physics engine anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you want new_groups: &mut RigidBodyCollisionGroups
to be mutable ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't, sorry, my mistake ^^ It should be new_groups: RigidBodyCollisionGroups
of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! Implemented like this now ^^
@@ -272,7 +278,8 @@ impl<N: Scalar> RigidBody<N> { | |||
pub fn new(shape: Arc<Box<Repr<Point<N>, Matrix<N>>>>, | |||
mass_properties: Option<(N, Point<N>, AngularInertia<N>)>, | |||
restitution: N, | |||
friction: N) | |||
friction: N, | |||
groups: RigidBodyCollisionGroups) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That one should not have groups
on its constructor either. On this method, the static or dynamic status of the rigid body is automatically deduced from mass_properties
. If it is set to None
, then the rigid body is static. It is dynamic otherwise.
Do you think |
It is a must-have so that the user can perform queries on the As for the name, I'd say |
The function is mainly there to help |
Do you think |
Actually, it might be even clearer to name it |
Since it is directly related to rigid bodies, it should go on |
#[inline] | ||
pub fn internal_collision_groups(&self) -> &CollisionGroups { | ||
&self.collision_groups | ||
pub fn as_collision_groups(&self) -> &CollisionGroups { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to keep this function ?
// internal reserved static group id | ||
const STATIC_GROUP_ID: usize = 29; | ||
|
||
/// TODO: better explanations or redirect user to `ncollide` documentation ?!? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do I do here for the doc ? ❓ ❔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the moment I suggest you just remove the TODO line and keep your rest of your comment. I will have to reword it when sensors will be added anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Same remark about all the FIXME better documentation
bellow.)
What do I do about that too ?
|
Your current implementation already does that:
The rest is irrelevant as long as a full integration (allowing collision groups changes at any time) is not done. |
Ok, see you later for a better implementation! |
@@ -9,7 +9,7 @@ use ncollide::utils::data::hash_map::{HashMap, Entry}; | |||
use ncollide::utils::data::hash::UintTWHash; | |||
use ncollide::broad_phase::{BroadPhase, DBVTBroadPhase}; | |||
use ncollide::narrow_phase::ContactSignalHandler; | |||
use ncollide::world::{CollisionWorld, CollisionObject, CollisionGroups}; | |||
use ncollide::world::{CollisionWorld, CollisionObject/*, CollisionGroups*/}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you just remove this comment? Then I should be ready for a merge.
Thanks! This will be published with a minor version number change, namely 0.2.1, as this does not includes breaking changes. |
Thanks to you ! |
STOP ! there is a big problem ! |
Don't really know if this integration is good for you, I didn't implement this from #55: