Skip to content
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

Add a basic lines-based debug-renderer #315

Merged
merged 9 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ resolver = "2"
#parry3d-f64 = { path = "../parry/crates/parry3d-f64" }
# nalgebra = { path = "../nalgebra" }


#kiss3d = { git = "https://github.com/sebcrozet/kiss3d" }
#nalgebra = { git = "https://github.com/dimforge/nalgebra", branch = "dev" }
parry2d = { git = "https://github.com/dimforge/parry", branch = "split-and-qbvh" }
parry3d = { git = "https://github.com/dimforge/parry", branch = "split-and-qbvh" }
parry2d-f64 = { git = "https://github.com/dimforge/parry", branch = "split-and-qbvh" }
parry3d-f64 = { git = "https://github.com/dimforge/parry", branch = "split-and-qbvh" }
parry2d = { git = "https://github.com/dimforge/parry", branch = "master" }
parry3d = { git = "https://github.com/dimforge/parry", branch = "master" }
parry2d-f64 = { git = "https://github.com/dimforge/parry", branch = "master" }
parry3d-f64 = { git = "https://github.com/dimforge/parry", branch = "master" }

[profile.release]
#debug = true
Expand Down
1 change: 1 addition & 0 deletions crates/rapier2d-f64/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ simd-is-enabled = [ "vec_map" ]
wasm-bindgen = [ "instant/wasm-bindgen" ]
serde-serialize = [ "nalgebra/serde-serialize", "parry2d-f64/serde-serialize", "serde", "bit-vec/serde", "arrayvec/serde" ]
enhanced-determinism = [ "simba/libm_force", "parry2d-f64/enhanced-determinism", "indexmap" ]
debug-render = [ ]

# Feature used for debugging only.
debug-disable-legitimate-fe-exceptions = [ ]
Expand Down
1 change: 1 addition & 0 deletions crates/rapier2d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ simd-is-enabled = [ "vec_map" ]
wasm-bindgen = [ "instant/wasm-bindgen" ]
serde-serialize = [ "nalgebra/serde-serialize", "parry2d/serde-serialize", "serde", "bit-vec/serde", "arrayvec/serde" ]
enhanced-determinism = [ "simba/libm_force", "parry2d/enhanced-determinism", "indexmap" ]
debug-render = [ ]

# Feature used for debugging only.
debug-disable-legitimate-fe-exceptions = [ ]
Expand Down
1 change: 1 addition & 0 deletions crates/rapier3d-f64/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ simd-is-enabled = [ "vec_map" ]
wasm-bindgen = [ "instant/wasm-bindgen" ]
serde-serialize = [ "nalgebra/serde-serialize", "parry3d-f64/serde-serialize", "serde", "bit-vec/serde" ]
enhanced-determinism = [ "simba/libm_force", "parry3d-f64/enhanced-determinism" ]
debug-render = []

# Feature used for debugging only.
debug-disable-legitimate-fe-exceptions = [ ]
Expand Down
1 change: 1 addition & 0 deletions crates/rapier3d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ simd-is-enabled = [ "vec_map" ]
wasm-bindgen = [ "instant/wasm-bindgen" ]
serde-serialize = [ "nalgebra/serde-serialize", "parry3d/serde-serialize", "serde", "bit-vec/serde" ]
enhanced-determinism = [ "simba/libm_force", "parry3d/enhanced-determinism" ]
debug-render = [ ]

# Feature used for debugging only.
debug-disable-legitimate-fe-exceptions = [ ]
Expand Down
11 changes: 6 additions & 5 deletions crates/rapier_testbed2d-f64/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,21 @@ bincode = "1"
Inflector = "0.11"
md5 = "0.7"

bevy_egui = "0.10"
bevy_ecs = "0.6"
bevy_egui = "0.13"
bevy_ecs = "0.7"
#bevy_prototype_debug_lines = "0.7"

# Dependencies for native only.
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
bevy = {version = "0.6", default-features = false, features = ["bevy_winit", "render", "x11"]}
bevy = {version = "0.7", default-features = false, features = ["bevy_winit", "render", "x11"]}

# Dependencies for WASM only.
[target.'cfg(target_arch = "wasm32")'.dependencies]
bevy = {version = "0.6", default-features = false, features = ["bevy_winit", "render"]}
bevy = {version = "0.7", default-features = false, features = ["bevy_winit", "render"]}
#bevy_webgl2 = "0.5"

[dependencies.rapier]
package = "rapier2d-f64"
path = "../rapier2d-f64"
version = "0.12.0-alpha.1"
features = [ "serde-serialize" ]
features = [ "serde-serialize", "debug-render" ]
11 changes: 6 additions & 5 deletions crates/rapier_testbed2d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,21 @@ bincode = "1"
Inflector = "0.11"
md5 = "0.7"

bevy_egui = "0.10"
bevy_ecs = "0.6"
bevy_egui = "0.13"
bevy_ecs = "0.7"
#bevy_prototype_debug_lines = "0.7"

# Dependencies for native only.
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
bevy = {version = "0.6", default-features = false, features = ["bevy_winit", "render", "x11"]}
bevy = {version = "0.7", default-features = false, features = ["bevy_winit", "render", "x11"]}

# Dependencies for WASM only.
[target.'cfg(target_arch = "wasm32")'.dependencies]
bevy = {version = "0.6", default-features = false, features = ["bevy_winit", "render"]}
bevy = {version = "0.7", default-features = false, features = ["bevy_winit", "render"]}
#bevy_webgl2 = "0.5"

[dependencies.rapier]
package = "rapier2d"
path = "../rapier2d"
version = "0.12.0-alpha.1"
features = [ "serde-serialize" ]
features = [ "serde-serialize", "debug-render" ]
11 changes: 6 additions & 5 deletions crates/rapier_testbed3d-f64/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,21 @@ md5 = "0.7"
Inflector = "0.11"
serde = { version = "1", features = [ "derive" ] }

bevy_egui = "0.10"
bevy_ecs = "0.6"
bevy_egui = "0.13"
bevy_ecs = "0.7"
#bevy_prototype_debug_lines = { version = "0.7", features = [ "3d" ] }

# Dependencies for native only.
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
bevy = {version = "0.6", default-features = false, features = ["bevy_winit", "render", "x11"]}
bevy = {version = "0.7", default-features = false, features = ["bevy_winit", "render", "x11"]}

# Dependencies for WASM only.
[target.'cfg(target_arch = "wasm32")'.dependencies]
bevy = {version = "0.6", default-features = false, features = ["bevy_winit", "render"]}
bevy = {version = "0.7", default-features = false, features = ["bevy_winit", "render"]}
#bevy_webgl2 = "0.5"

[dependencies.rapier]
package = "rapier3d-f64"
path = "../rapier3d-f64"
version = "0.12.0-alpha.1"
features = [ "serde-serialize" ]
features = [ "serde-serialize", "debug-render" ]
11 changes: 6 additions & 5 deletions crates/rapier_testbed3d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,21 @@ md5 = "0.7"
Inflector = "0.11"
serde = { version = "1", features = [ "derive" ] }

bevy_egui = "0.10"
bevy_ecs = "0.6"
bevy_egui = "0.13"
bevy_ecs = "0.7"
#bevy_prototype_debug_lines = { version = "0.7", features = [ "3d" ] }

# Dependencies for native only.
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
bevy = {version = "0.6", default-features = false, features = ["bevy_winit", "render", "x11"]}
bevy = {version = "0.7", default-features = false, features = ["bevy_winit", "render", "x11"]}

# Dependencies for WASM only.
[target.'cfg(target_arch = "wasm32")'.dependencies]
bevy = {version = "0.6", default-features = false, features = ["bevy_winit", "render"]}
bevy = {version = "0.7", default-features = false, features = ["bevy_winit", "render"]}
#bevy_webgl2 = "0.5"

[dependencies.rapier]
package = "rapier3d"
path = "../rapier3d"
version = "0.12.0-alpha.1"
features = [ "serde-serialize" ]
features = [ "serde-serialize", "debug-render" ]
156 changes: 78 additions & 78 deletions examples3d/joints3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,33 +578,33 @@ fn do_init_world(testbed: &mut Testbed, use_articulations: bool) {
let mut impulse_joints = ImpulseJointSet::new();
let mut multibody_joints = MultibodyJointSet::new();

// create_prismatic_joints(
// &mut bodies,
// &mut colliders,
// &mut impulse_joints,
// &mut multibody_joints,
// point![20.0, 5.0, 0.0],
// 4,
// use_articulations,
// );
// create_actuated_prismatic_joints(
// &mut bodies,
// &mut colliders,
// &mut impulse_joints,
// &mut multibody_joints,
// point![25.0, 5.0, 0.0],
// 4,
// use_articulations,
// );
// create_revolute_joints(
// &mut bodies,
// &mut colliders,
// &mut impulse_joints,
// &mut multibody_joints,
// point![20.0, 0.0, 0.0],
// 3,
// use_articulations,
// );
create_prismatic_joints(
&mut bodies,
&mut colliders,
&mut impulse_joints,
&mut multibody_joints,
point![20.0, 5.0, 0.0],
4,
use_articulations,
);
create_actuated_prismatic_joints(
&mut bodies,
&mut colliders,
&mut impulse_joints,
&mut multibody_joints,
point![25.0, 5.0, 0.0],
4,
use_articulations,
);
create_revolute_joints(
&mut bodies,
&mut colliders,
&mut impulse_joints,
&mut multibody_joints,
point![20.0, 0.0, 0.0],
3,
use_articulations,
);
create_revolute_joints_with_limits(
&mut bodies,
&mut colliders,
Expand All @@ -613,57 +613,57 @@ fn do_init_world(testbed: &mut Testbed, use_articulations: bool) {
point![34.0, 0.0, 0.0],
use_articulations,
);
// create_fixed_joints(
// &mut bodies,
// &mut colliders,
// &mut impulse_joints,
// &mut multibody_joints,
// point![0.0, 10.0, 0.0],
// 10,
// use_articulations,
// );
// create_actuated_revolute_joints(
// &mut bodies,
// &mut colliders,
// &mut impulse_joints,
// &mut multibody_joints,
// point![20.0, 10.0, 0.0],
// 6,
// use_articulations,
// );
// create_actuated_spherical_joints(
// &mut bodies,
// &mut colliders,
// &mut impulse_joints,
// &mut multibody_joints,
// point![13.0, 10.0, 0.0],
// 3,
// use_articulations,
// );
// create_spherical_joints(
// &mut bodies,
// &mut colliders,
// &mut impulse_joints,
// &mut multibody_joints,
// 15,
// use_articulations,
// );
// create_spherical_joints_with_limits(
// &mut bodies,
// &mut colliders,
// &mut impulse_joints,
// &mut multibody_joints,
// point![-5.0, 0.0, 0.0],
// use_articulations,
// );
// create_coupled_joints(
// &mut bodies,
// &mut colliders,
// &mut impulse_joints,
// &mut multibody_joints,
// point![0.0, 20.0, 0.0],
// use_articulations,
// );
create_fixed_joints(
&mut bodies,
&mut colliders,
&mut impulse_joints,
&mut multibody_joints,
point![0.0, 10.0, 0.0],
10,
use_articulations,
);
create_actuated_revolute_joints(
&mut bodies,
&mut colliders,
&mut impulse_joints,
&mut multibody_joints,
point![20.0, 10.0, 0.0],
6,
use_articulations,
);
create_actuated_spherical_joints(
&mut bodies,
&mut colliders,
&mut impulse_joints,
&mut multibody_joints,
point![13.0, 10.0, 0.0],
3,
use_articulations,
);
create_spherical_joints(
&mut bodies,
&mut colliders,
&mut impulse_joints,
&mut multibody_joints,
15,
use_articulations,
);
create_spherical_joints_with_limits(
&mut bodies,
&mut colliders,
&mut impulse_joints,
&mut multibody_joints,
point![-5.0, 0.0, 0.0],
use_articulations,
);
create_coupled_joints(
&mut bodies,
&mut colliders,
&mut impulse_joints,
&mut multibody_joints,
point![0.0, 20.0, 0.0],
use_articulations,
);

/*
* Set up the testbed.
Expand Down
16 changes: 13 additions & 3 deletions src/dynamics/ccd/ccd_solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::geometry::{ColliderParent, ColliderSet, CollisionEvent, NarrowPhase};
use crate::math::Real;
use crate::parry::utils::SortedPair;
use crate::pipeline::{EventHandler, QueryPipeline, QueryPipelineMode};
use crate::prelude::ActiveEvents;
use crate::prelude::{ActiveEvents, CollisionEventFlags};
use parry::query::{DefaultQueryDispatcher, QueryDispatcher};
use parry::utils::hashmap::HashMap;
use std::collections::BinaryHeap;
Expand Down Expand Up @@ -529,8 +529,18 @@ impl CCDSolver {
.contains(ActiveEvents::COLLISION_EVENTS)
{
// Emit one intersection-started and one intersection-stopped event.
events.handle_collision_event(CollisionEvent::Started(toi.c1, toi.c2), None);
events.handle_collision_event(CollisionEvent::Stopped(toi.c1, toi.c2, false), None);
events.handle_collision_event(
bodies,
colliders,
CollisionEvent::Started(toi.c1, toi.c2, CollisionEventFlags::SENSOR),
None,
);
events.handle_collision_event(
bodies,
colliders,
CollisionEvent::Stopped(toi.c1, toi.c2, CollisionEventFlags::SENSOR),
None,
);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/dynamics/integration_parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ impl IntegrationParameters {

/// The ERP coefficient, multiplied by the inverse timestep length.
pub fn erp_inv_dt(&self) -> Real {
self.erp / self.dt
self.erp * self.inv_dt()
}

/// The joint ERP coefficient, multiplied by the inverse timestep length.
pub fn joint_erp_inv_dt(&self) -> Real {
self.joint_erp / self.dt
self.joint_erp * self.inv_dt()
}

/// The CFM factor to be used in the constraints resolution.
Expand Down
10 changes: 10 additions & 0 deletions src/dynamics/joint/multibody_joint/multibody_joint_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,20 @@ impl MultibodyJointSet {
}

/// Gets a mutable reference to the multibody identified by its `handle`.
pub fn get_mut(&mut self, handle: MultibodyJointHandle) -> Option<(&mut Multibody, usize)> {
let link = self.rb2mb.get(handle.0)?;
let multibody = self.multibodies.get_mut(link.multibody.0)?;
Some((multibody, link.id))
}

/// Gets a mutable reference to the multibody identified by its `handle`.
///
/// This method will bypass any modification-detection automatically done by the MultibodyJointSet.
pub fn get_mut_internal(
&mut self,
handle: MultibodyJointHandle,
) -> Option<(&mut Multibody, usize)> {
// TODO: modification tracking?
let link = self.rb2mb.get(handle.0)?;
let multibody = self.multibodies.get_mut(link.multibody.0)?;
Some((multibody, link.id))
Expand Down
Loading