Add internal edges debug examples.
This commit is contained in:
@@ -49,7 +49,7 @@ vec_map = { version = "0.8", optional = true }
|
|||||||
instant = { version = "0.1", features = [ "now" ], optional = true }
|
instant = { version = "0.1", features = [ "now" ], optional = true }
|
||||||
num-traits = "0.2"
|
num-traits = "0.2"
|
||||||
nalgebra = "0.31"
|
nalgebra = "0.31"
|
||||||
parry2d-f64 = "0.11"
|
parry2d-f64 = "^0.11.1"
|
||||||
simba = "0.7"
|
simba = "0.7"
|
||||||
approx = "0.5"
|
approx = "0.5"
|
||||||
rayon = { version = "1", optional = true }
|
rayon = { version = "1", optional = true }
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ vec_map = { version = "0.8", optional = true }
|
|||||||
instant = { version = "0.1", features = [ "now" ], optional = true }
|
instant = { version = "0.1", features = [ "now" ], optional = true }
|
||||||
num-traits = "0.2"
|
num-traits = "0.2"
|
||||||
nalgebra = "0.31"
|
nalgebra = "0.31"
|
||||||
parry2d = "0.11"
|
parry2d = "^0.11.1"
|
||||||
simba = "0.7"
|
simba = "0.7"
|
||||||
approx = "0.5"
|
approx = "0.5"
|
||||||
rayon = { version = "1", optional = true }
|
rayon = { version = "1", optional = true }
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ vec_map = { version = "0.8", optional = true }
|
|||||||
instant = { version = "0.1", features = [ "now" ], optional = true }
|
instant = { version = "0.1", features = [ "now" ], optional = true }
|
||||||
num-traits = "0.2"
|
num-traits = "0.2"
|
||||||
nalgebra = "0.31"
|
nalgebra = "0.31"
|
||||||
parry3d-f64 = "0.11"
|
parry3d-f64 = "^0.11.1"
|
||||||
simba = "0.7"
|
simba = "0.7"
|
||||||
approx = "0.5"
|
approx = "0.5"
|
||||||
rayon = { version = "1", optional = true }
|
rayon = { version = "1", optional = true }
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ vec_map = { version = "0.8", optional = true }
|
|||||||
instant = { version = "0.1", features = [ "now" ], optional = true }
|
instant = { version = "0.1", features = [ "now" ], optional = true }
|
||||||
num-traits = "0.2"
|
num-traits = "0.2"
|
||||||
nalgebra = "0.31"
|
nalgebra = "0.31"
|
||||||
parry3d = "0.11"
|
parry3d = "^0.11.1"
|
||||||
simba = "0.7"
|
simba = "0.7"
|
||||||
approx = "0.5"
|
approx = "0.5"
|
||||||
rayon = { version = "1", optional = true }
|
rayon = { version = "1", optional = true }
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ mod heightfield3;
|
|||||||
mod joints3;
|
mod joints3;
|
||||||
// mod joints3;
|
// mod joints3;
|
||||||
mod character_controller3;
|
mod character_controller3;
|
||||||
|
mod debug_internal_edges3;
|
||||||
mod keva3;
|
mod keva3;
|
||||||
mod locked_rotations3;
|
mod locked_rotations3;
|
||||||
mod newton_cradle3;
|
mod newton_cradle3;
|
||||||
@@ -114,6 +115,7 @@ pub fn main() {
|
|||||||
debug_dynamic_collider_add3::init_world,
|
debug_dynamic_collider_add3::init_world,
|
||||||
),
|
),
|
||||||
("(Debug) friction", debug_friction3::init_world),
|
("(Debug) friction", debug_friction3::init_world),
|
||||||
|
("(Debug) internal edges", debug_internal_edges3::init_world),
|
||||||
("(Debug) triangle", debug_triangle3::init_world),
|
("(Debug) triangle", debug_triangle3::init_world),
|
||||||
("(Debug) trimesh", debug_trimesh3::init_world),
|
("(Debug) trimesh", debug_trimesh3::init_world),
|
||||||
("(Debug) cylinder", debug_cylinder3::init_world),
|
("(Debug) cylinder", debug_cylinder3::init_world),
|
||||||
|
|||||||
60
examples3d/debug_internal_edges3.rs
Normal file
60
examples3d/debug_internal_edges3.rs
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
use rapier3d::prelude::*;
|
||||||
|
use rapier_testbed3d::Testbed;
|
||||||
|
|
||||||
|
pub fn init_world(testbed: &mut Testbed) {
|
||||||
|
/*
|
||||||
|
* World
|
||||||
|
*/
|
||||||
|
let mut bodies = RigidBodySet::new();
|
||||||
|
let mut colliders = ColliderSet::new();
|
||||||
|
let impulse_joints = ImpulseJointSet::new();
|
||||||
|
let multibody_joints = MultibodyJointSet::new();
|
||||||
|
|
||||||
|
let heights = DMatrix::zeros(100, 100);
|
||||||
|
let heightfield = HeightField::new(heights, vector![60.0, 1.0, 60.0]);
|
||||||
|
let rotation = vector![0.0, 0.0, 0.0]; // vector![-0.1, 0.0, 0.0];
|
||||||
|
colliders
|
||||||
|
.insert(ColliderBuilder::new(SharedShape::new(heightfield.clone())).rotation(rotation));
|
||||||
|
|
||||||
|
// let mut trimesh = TriMesh::from(heightfield);
|
||||||
|
// trimesh.set_flags(TriMeshFlags::MERGE_DUPLICATE_VERTICES)
|
||||||
|
// colliders.insert(ColliderBuilder::new(SharedShape::new(trimesh.clone())).rotation(rotation));
|
||||||
|
// // NOTE: we add a sensor just because we want the testbed to display the mesh’s wireframe.
|
||||||
|
// colliders.insert(
|
||||||
|
// ColliderBuilder::new(SharedShape::new(trimesh))
|
||||||
|
// .sensor(true)
|
||||||
|
// .rotation(rotation),
|
||||||
|
// );
|
||||||
|
|
||||||
|
// Dynamic rigid bodies.
|
||||||
|
let rigid_body = RigidBodyBuilder::dynamic()
|
||||||
|
.translation(vector![4.0, 0.5, 0.0])
|
||||||
|
.linvel(vector![0.0, -40.0, 20.0])
|
||||||
|
.can_sleep(false);
|
||||||
|
let handle = bodies.insert(rigid_body);
|
||||||
|
let collider = ColliderBuilder::ball(0.5);
|
||||||
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|
||||||
|
let rigid_body = RigidBodyBuilder::dynamic()
|
||||||
|
.translation(vector![0.0, 0.5, 0.0])
|
||||||
|
.linvel(vector![0.0, -4.0, 20.0])
|
||||||
|
.can_sleep(false);
|
||||||
|
let handle = bodies.insert(rigid_body);
|
||||||
|
let collider = ColliderBuilder::cuboid(0.5, 0.5, 0.5);
|
||||||
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|
||||||
|
let rigid_body = RigidBodyBuilder::dynamic()
|
||||||
|
.translation(vector![8.0, 0.2, 0.0])
|
||||||
|
.linvel(vector![0.0, -4.0, 20.0])
|
||||||
|
.can_sleep(false);
|
||||||
|
let handle = bodies.insert(rigid_body);
|
||||||
|
let collider =
|
||||||
|
ColliderBuilder::cylinder(0.5, 0.2).rotation(vector![0.0, 0.0, std::f32::consts::PI / 2.0]);
|
||||||
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set up the testbed.
|
||||||
|
*/
|
||||||
|
testbed.set_world(bodies, colliders, impulse_joints, multibody_joints);
|
||||||
|
testbed.look_at(point![10.0, 10.0, 10.0], Point::origin());
|
||||||
|
}
|
||||||
@@ -38,7 +38,11 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::fixed();
|
let rigid_body = RigidBodyBuilder::fixed();
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::trimesh(vertices, indices);
|
let collider = ColliderBuilder::trimesh_with_flags(
|
||||||
|
vertices,
|
||||||
|
indices,
|
||||||
|
TriMeshFlags::MERGE_DUPLICATE_VERTICES,
|
||||||
|
);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use crate::parry::transformation::vhacd::VHACDParameters;
|
|||||||
use crate::pipeline::{ActiveEvents, ActiveHooks};
|
use crate::pipeline::{ActiveEvents, ActiveHooks};
|
||||||
use na::Unit;
|
use na::Unit;
|
||||||
use parry::bounding_volume::Aabb;
|
use parry::bounding_volume::Aabb;
|
||||||
use parry::shape::Shape;
|
use parry::shape::{Shape, TriMeshFlags};
|
||||||
|
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@@ -550,6 +550,16 @@ impl ColliderBuilder {
|
|||||||
Self::new(SharedShape::trimesh(vertices, indices))
|
Self::new(SharedShape::trimesh(vertices, indices))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Initializes a collider builder with a triangle mesh shape defined by its vertex and index buffers and
|
||||||
|
/// flags controlling its pre-processing.
|
||||||
|
pub fn trimesh_with_flags(
|
||||||
|
vertices: Vec<Point<Real>>,
|
||||||
|
indices: Vec<[u32; 3]>,
|
||||||
|
flags: TriMeshFlags,
|
||||||
|
) -> Self {
|
||||||
|
Self::new(SharedShape::trimesh_with_flags(vertices, indices, flags))
|
||||||
|
}
|
||||||
|
|
||||||
/// Initializes a collider builder with a compound shape obtained from the decomposition of
|
/// Initializes a collider builder with a compound shape obtained from the decomposition of
|
||||||
/// the given trimesh (in 3D) or polyline (in 2D) into convex parts.
|
/// the given trimesh (in 3D) or polyline (in 2D) into convex parts.
|
||||||
pub fn convex_decomposition(vertices: &[Point<Real>], indices: &[[u32; DIM]]) -> Self {
|
pub fn convex_decomposition(vertices: &[Point<Real>], indices: &[[u32; DIM]]) -> Self {
|
||||||
|
|||||||
Reference in New Issue
Block a user