aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Crozet <developer@crozet.re>2023-12-09 23:47:48 +0100
committerGitHub <noreply@github.com>2023-12-09 23:47:48 +0100
commit6246bb3ff642130f547617e9b887e576da69e7b0 (patch)
treec79ac5a7f1d9dff0ae3536f9abfb06974989d977
parente9ea2ca10b3058a6ac2d7f4b79d351ef18ad3c06 (diff)
parentbfd3884d3663bbb7990f694f67283297ca9cefb6 (diff)
downloadrapier-6246bb3ff642130f547617e9b887e576da69e7b0.tar.gz
rapier-6246bb3ff642130f547617e9b887e576da69e7b0.tar.bz2
rapier-6246bb3ff642130f547617e9b887e576da69e7b0.zip
Merge pull request #515 from Soham1803/feat/disabled_object_color_change
feat/Color of disabled object will change
-rw-r--r--CHANGELOG.md1
-rw-r--r--src/pipeline/debug_render_pipeline/debug_render_pipeline.rs12
-rw-r--r--src/pipeline/debug_render_pipeline/debug_render_style.rs5
3 files changed, 15 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8fd84ce..3224880 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@
- Add `EffectiveCharacterMovement::is_sliding_down_slope` to indicate if the character controlled by the kinematic
character controller is sliding on a slope that is too steep.
- Add `Wheel::side_friction_stiffness` to customize the side friction applied to the vehicle controller’s wheel.
+- Add `DebugRenderStyle::disabled_color_multiplier` to make the debug-renderer color disabled object differently.
### Modified
- Make `Wheel::friction_slip` public to customize the front friction applied to the vehicle controller’s wheels.
diff --git a/src/pipeline/debug_render_pipeline/debug_render_pipeline.rs b/src/pipeline/debug_render_pipeline/debug_render_pipeline.rs
index 2f1c737..f214b8c 100644
--- a/src/pipeline/debug_render_pipeline/debug_render_pipeline.rs
+++ b/src/pipeline/debug_render_pipeline/debug_render_pipeline.rs
@@ -175,7 +175,9 @@ impl DebugRenderPipeline {
}
if let (Some(rb1), Some(rb2)) = (bodies.get(body1), bodies.get(body2)) {
- let coeff = if (rb1.is_fixed() || rb1.is_sleeping())
+ let coeff = if !data.is_enabled() || !rb1.is_enabled() || !rb2.is_enabled() {
+ self.style.disabled_color_multiplier
+ } else if (rb1.is_fixed() || rb1.is_sleeping())
&& (rb2.is_fixed() || rb2.is_sleeping())
{
self.style.sleep_color_multiplier
@@ -250,7 +252,9 @@ impl DebugRenderPipeline {
&& backend.filter_object(object)
{
let basis = rb.rotation().to_rotation_matrix().into_inner();
- let coeff = if rb.is_sleeping() {
+ let coeff = if !rb.is_enabled() {
+ self.style.disabled_color_multiplier
+ } else if rb.is_sleeping() {
self.style.sleep_color_multiplier
} else {
[1.0; 4]
@@ -283,7 +287,9 @@ impl DebugRenderPipeline {
if backend.filter_object(object) {
let color = if let Some(parent) = co.parent().and_then(|p| bodies.get(p)) {
- let coeff = if parent.is_sleeping() {
+ let coeff = if !parent.is_enabled() || !co.is_enabled() {
+ self.style.disabled_color_multiplier
+ } else if parent.is_sleeping() {
self.style.sleep_color_multiplier
} else {
[1.0; 4]
diff --git a/src/pipeline/debug_render_pipeline/debug_render_style.rs b/src/pipeline/debug_render_pipeline/debug_render_style.rs
index 33630aa..c977cab 100644
--- a/src/pipeline/debug_render_pipeline/debug_render_style.rs
+++ b/src/pipeline/debug_render_pipeline/debug_render_style.rs
@@ -36,6 +36,10 @@ pub struct DebugRenderStyle {
/// multiplied by this array. (For a joint, both attached rigid-bodies must be sleeping
/// or non-dynamic for this multiplier to be applied).
pub sleep_color_multiplier: [f32; 4],
+ /// If a rigid-body is disabled, its attached entities will have their colors
+ /// multiplied by this array. (For a joint, both attached rigid-bodies must be disabled
+ /// for this multiplier to be applied).
+ pub disabled_color_multiplier: [f32; 4],
/// The length of the local coordinate axes rendered for a rigid-body.
pub rigid_body_axes_length: Real,
/// The collor for the segments joining the two contact points.
@@ -62,6 +66,7 @@ impl Default for DebugRenderStyle {
multibody_joint_anchor_color: [300.0, 1.0, 0.4, 1.0],
multibody_joint_separation_color: [0.0, 1.0, 0.4, 1.0],
sleep_color_multiplier: [1.0, 1.0, 0.2, 1.0],
+ disabled_color_multiplier: [0.0, 0.0, 1.0, 1.0],
rigid_body_axes_length: 0.5,
contact_depth_color: [120.0, 1.0, 0.4, 1.0],
contact_normal_color: [0.0, 1.0, 1.0, 1.0],