-
-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #300 from rustsim/ccd
Implement nonlinear TOI + refactor the query and world modules.
- Loading branch information
Showing
200 changed files
with
4,571 additions
and
3,635 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,34 @@ | ||
extern crate nalgebra as na; | ||
extern crate ncollide2d; | ||
|
||
use ncollide2d::broad_phase::BroadPhasePairFilter; | ||
use ncollide2d::shape::{Ball, ShapeHandle}; | ||
use ncollide2d::world::{CollisionGroups, CollisionObject, CollisionWorld, GeometricQueryType}; | ||
|
||
struct ParityFilter; | ||
|
||
impl BroadPhasePairFilter<f32, ()> for ParityFilter { | ||
fn is_pair_valid(&self, b1: &CollisionObject<f32, ()>, b2: &CollisionObject<f32, ()>) -> bool { | ||
b1.handle().uid() % 2 == b2.handle().uid() % 2 | ||
} | ||
} | ||
//extern crate nalgebra as na; | ||
//extern crate ncollide2d; | ||
// | ||
//use ncollide2d::broad_phase::BroadPhasePairFilter; | ||
//use ncollide2d::shape::{Ball, ShapeHandle}; | ||
//use ncollide2d::world::{CollisionGroups, CollisionObject, CollisionWorld, GeometricQueryType}; | ||
// | ||
//struct ParityFilter; | ||
// | ||
//impl BroadPhasePairFilter<f32, ()> for ParityFilter { | ||
// fn is_pair_valid(&self, b1: &CollisionObject<f32, ()>, b2: &CollisionObject<f32, ()>) -> bool { | ||
// b1.handle().uid() % 2 == b2.handle().uid() % 2 | ||
// } | ||
//} | ||
|
||
fn main() { | ||
let shape = ShapeHandle::new(Ball::new(0.5f32)); | ||
let groups = CollisionGroups::new(); | ||
let query = GeometricQueryType::Contacts(0.0, 0.0); | ||
|
||
let mut world = CollisionWorld::new(0.02); | ||
|
||
world.register_broad_phase_pair_filter("Parity filter", ParityFilter); | ||
|
||
world.add(na::one(), shape.clone(), groups, query, ()); | ||
world.add(na::one(), shape.clone(), groups, query, ()); | ||
world.add(na::one(), shape.clone(), groups, query, ()); | ||
world.add(na::one(), shape.clone(), groups, query, ()); | ||
|
||
world.update(); | ||
|
||
// There will be only 2 contact pairs instead of 6. | ||
assert!(world.contact_pairs(true).count() == 2); | ||
// let shape = ShapeHandle::new(Ball::new(0.5f32)); | ||
// let groups = CollisionGroups::new(); | ||
// let query = GeometricQueryType::Contacts(0.0, 0.0); | ||
// | ||
// let mut world = CollisionWorld::new(0.02); | ||
// | ||
// world.register_broad_phase_pair_filter("Parity filter", ParityFilter); | ||
// | ||
// world.add(na::one(), shape.clone(), groups, query, ()); | ||
// world.add(na::one(), shape.clone(), groups, query, ()); | ||
// world.add(na::one(), shape.clone(), groups, query, ()); | ||
// world.add(na::one(), shape.clone(), groups, query, ()); | ||
// | ||
// world.update(); | ||
// | ||
// // There will be only 2 contact pairs instead of 6. | ||
// assert!(world.contact_pairs(true).count() == 2); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,34 @@ | ||
extern crate nalgebra as na; | ||
extern crate ncollide3d; | ||
|
||
use ncollide3d::broad_phase::BroadPhasePairFilter; | ||
use ncollide3d::shape::{Ball, ShapeHandle}; | ||
use ncollide3d::world::{CollisionGroups, CollisionObject, CollisionWorld, GeometricQueryType}; | ||
|
||
struct ParityFilter; | ||
|
||
impl BroadPhasePairFilter<f32, ()> for ParityFilter { | ||
fn is_pair_valid(&self, b1: &CollisionObject<f32, ()>, b2: &CollisionObject<f32, ()>) -> bool { | ||
b1.handle().uid() % 2 == b2.handle().uid() % 2 | ||
} | ||
} | ||
//extern crate nalgebra as na; | ||
//extern crate ncollide3d; | ||
// | ||
//use ncollide3d::broad_phase::BroadPhasePairFilter; | ||
//use ncollide3d::shape::{Ball, ShapeHandle}; | ||
//use ncollide3d::pipeline::{CollisionGroups, CollisionObject, CollisionObjectSlabHandle, CollisionWorld, GeometricQueryType}; | ||
// | ||
//struct ParityFilter; | ||
// | ||
//impl BroadPhasePairFilter<f32, CollisionObject<f32, ()>, CollisionObjectSlabHandle> for ParityFilter { | ||
// fn is_pair_valid(&self, _: &CollisionObject<f32, ()>, _: &CollisionObject<f32, ()>, handle1: CollisionObjectSlabHandle, handle2: CollisionObjectSlabHandle) -> bool { | ||
// handle1.uid() % 2 == handle2.uid() % 2 | ||
// } | ||
//} | ||
|
||
fn main() { | ||
let shape = ShapeHandle::new(Ball::new(0.5f32)); | ||
let groups = CollisionGroups::new(); | ||
let query = GeometricQueryType::Contacts(0.0, 0.0); | ||
|
||
let mut world = CollisionWorld::new(0.02); | ||
|
||
world.register_broad_phase_pair_filter("Parity filter", ParityFilter); | ||
|
||
world.add(na::one(), shape.clone(), groups, query, ()); | ||
world.add(na::one(), shape.clone(), groups, query, ()); | ||
world.add(na::one(), shape.clone(), groups, query, ()); | ||
world.add(na::one(), shape.clone(), groups, query, ()); | ||
|
||
world.update(); | ||
|
||
// There will be only 2 contacts instead of 6. | ||
assert!(world.contact_pairs(true).count() == 2); | ||
// let shape = ShapeHandle::new(Ball::new(0.5f32)); | ||
// let groups = CollisionGroups::new(); | ||
// let query = GeometricQueryType::Contacts(0.0, 0.0); | ||
// | ||
// let mut world = CollisionWorld::new(0.02); | ||
// | ||
// world.register_broad_phase_pair_filter("Parity filter", ParityFilter); | ||
// | ||
// world.add(na::one(), shape.clone(), groups, query, ()); | ||
// world.add(na::one(), shape.clone(), groups, query, ()); | ||
// world.add(na::one(), shape.clone(), groups, query, ()); | ||
// world.add(na::one(), shape.clone(), groups, query, ()); | ||
// | ||
// world.update(); | ||
// | ||
// // There will be only 2 contacts instead of 6. | ||
// assert!(world.contact_pairs(true).count() == 2); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.