Remove the useless manifold.data.pair field.
This commit is contained in:
@@ -134,30 +134,17 @@ impl ContactPair {
|
|||||||
let coll2 = &colliders[self.pair.collider2];
|
let coll2 = &colliders[self.pair.collider2];
|
||||||
|
|
||||||
if self.manifolds.len() == 0 {
|
if self.manifolds.len() == 0 {
|
||||||
let manifold_data = ContactManifoldData::from_colliders(self.pair, coll1, coll2, flags);
|
let manifold_data = ContactManifoldData::from_colliders(coll1, coll2, flags);
|
||||||
self.manifolds
|
self.manifolds
|
||||||
.push(ContactManifold::with_data((0, 0), manifold_data));
|
.push(ContactManifold::with_data((0, 0), manifold_data));
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have to make sure the order of the returned collider
|
(
|
||||||
// match the order of the pair stored inside of the manifold.
|
coll1,
|
||||||
// (This order can be modified by the contact determination algorithm).
|
coll2,
|
||||||
let manifold = &mut self.manifolds[0];
|
&mut self.manifolds[0],
|
||||||
if manifold.data.pair.collider1 == self.pair.collider1 {
|
self.workspace.as_mut().map(|w| &mut *w.0),
|
||||||
(
|
)
|
||||||
coll1,
|
|
||||||
coll2,
|
|
||||||
manifold,
|
|
||||||
self.workspace.as_mut().map(|w| &mut *w.0),
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
(
|
|
||||||
coll2,
|
|
||||||
coll1,
|
|
||||||
manifold,
|
|
||||||
self.workspace.as_mut().map(|w| &mut *w.0),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,8 +156,6 @@ impl ContactPair {
|
|||||||
/// part of the same contact manifold share the same contact normal and contact kinematics.
|
/// part of the same contact manifold share the same contact normal and contact kinematics.
|
||||||
pub struct ContactManifoldData {
|
pub struct ContactManifoldData {
|
||||||
// The following are set by the narrow-phase.
|
// The following are set by the narrow-phase.
|
||||||
/// The pair of colliders involved in this contact manifold.
|
|
||||||
pub pair: ColliderPair,
|
|
||||||
/// The pair of body involved in this contact manifold.
|
/// The pair of body involved in this contact manifold.
|
||||||
pub body_pair: BodyPair,
|
pub body_pair: BodyPair,
|
||||||
pub(crate) warmstart_multiplier: f32,
|
pub(crate) warmstart_multiplier: f32,
|
||||||
@@ -196,7 +181,6 @@ pub struct ContactManifoldData {
|
|||||||
impl Default for ContactManifoldData {
|
impl Default for ContactManifoldData {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::new(
|
Self::new(
|
||||||
ColliderPair::new(ColliderSet::invalid_handle(), ColliderSet::invalid_handle()),
|
|
||||||
BodyPair::new(
|
BodyPair::new(
|
||||||
RigidBodySet::invalid_handle(),
|
RigidBodySet::invalid_handle(),
|
||||||
RigidBodySet::invalid_handle(),
|
RigidBodySet::invalid_handle(),
|
||||||
@@ -212,7 +196,6 @@ impl Default for ContactManifoldData {
|
|||||||
|
|
||||||
impl ContactManifoldData {
|
impl ContactManifoldData {
|
||||||
pub(crate) fn new(
|
pub(crate) fn new(
|
||||||
pair: ColliderPair,
|
|
||||||
body_pair: BodyPair,
|
body_pair: BodyPair,
|
||||||
delta1: Isometry<f32>,
|
delta1: Isometry<f32>,
|
||||||
delta2: Isometry<f32>,
|
delta2: Isometry<f32>,
|
||||||
@@ -221,7 +204,6 @@ impl ContactManifoldData {
|
|||||||
solver_flags: SolverFlags,
|
solver_flags: SolverFlags,
|
||||||
) -> ContactManifoldData {
|
) -> ContactManifoldData {
|
||||||
Self {
|
Self {
|
||||||
pair,
|
|
||||||
body_pair,
|
body_pair,
|
||||||
warmstart_multiplier: Self::min_warmstart_multiplier(),
|
warmstart_multiplier: Self::min_warmstart_multiplier(),
|
||||||
friction,
|
friction,
|
||||||
@@ -234,23 +216,16 @@ impl ContactManifoldData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn from_colliders(
|
pub(crate) fn from_colliders(coll1: &Collider, coll2: &Collider, flags: SolverFlags) -> Self {
|
||||||
pair: ColliderPair,
|
Self::with_subshape_indices(coll1, coll2, flags)
|
||||||
coll1: &Collider,
|
|
||||||
coll2: &Collider,
|
|
||||||
flags: SolverFlags,
|
|
||||||
) -> Self {
|
|
||||||
Self::with_subshape_indices(pair, coll1, coll2, flags)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn with_subshape_indices(
|
pub(crate) fn with_subshape_indices(
|
||||||
pair: ColliderPair,
|
|
||||||
coll1: &Collider,
|
coll1: &Collider,
|
||||||
coll2: &Collider,
|
coll2: &Collider,
|
||||||
solver_flags: SolverFlags,
|
solver_flags: SolverFlags,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self::new(
|
Self::new(
|
||||||
pair,
|
|
||||||
BodyPair::new(coll1.parent, coll2.parent),
|
BodyPair::new(coll1.parent, coll2.parent),
|
||||||
*coll1.position_wrt_parent(),
|
*coll1.position_wrt_parent(),
|
||||||
*coll2.position_wrt_parent(),
|
*coll2.position_wrt_parent(),
|
||||||
|
|||||||
@@ -526,8 +526,7 @@ impl NarrowPhase {
|
|||||||
|
|
||||||
// TODO: don't write this everytime?
|
// TODO: don't write this everytime?
|
||||||
for manifold in &mut pair.manifolds {
|
for manifold in &mut pair.manifolds {
|
||||||
manifold.data =
|
manifold.data = ContactManifoldData::from_colliders(co1, co2, solver_flags);
|
||||||
ContactManifoldData::from_colliders(pair.pair, co1, co2, solver_flags);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1521,8 +1521,8 @@ fn draw_contacts(window: &mut Window, nf: &NarrowPhase, colliders: &ColliderSet)
|
|||||||
} else {
|
} else {
|
||||||
Point3::new(1.0, 0.0, 0.0)
|
Point3::new(1.0, 0.0, 0.0)
|
||||||
};
|
};
|
||||||
let pos1 = colliders[manifold.data.pair.collider1].position();
|
let pos1 = colliders[pair.pair.collider1].position();
|
||||||
let pos2 = colliders[manifold.data.pair.collider2].position();
|
let pos2 = colliders[pair.pair.collider2].position();
|
||||||
let start = pos1 * pt.local_p1;
|
let start = pos1 * pt.local_p1;
|
||||||
let end = pos2 * pt.local_p2;
|
let end = pos2 * pt.local_p2;
|
||||||
let n = pos1 * manifold.local_n1;
|
let n = pos1 * manifold.local_n1;
|
||||||
|
|||||||
Reference in New Issue
Block a user