aboutsummaryrefslogtreecommitdiff
path: root/src_testbed
diff options
context:
space:
mode:
authorSébastien Crozet <developer@crozet.re>2022-05-30 18:27:52 +0200
committerSébastien Crozet <developer@crozet.re>2022-05-30 18:29:18 +0200
commit0d05536ab66052af0dfc153e966c82b4e6d27075 (patch)
treee648a85865d711a6133b2a9f2b31be16d7955c7a /src_testbed
parentab8833f275ea5576ef2c1a3039459e81fcdb6f4d (diff)
downloadrapier-0d05536ab66052af0dfc153e966c82b4e6d27075.tar.gz
rapier-0d05536ab66052af0dfc153e966c82b4e6d27075.tar.bz2
rapier-0d05536ab66052af0dfc153e966c82b4e6d27075.zip
Debug-renderer: add rendering of contacts, solver contacts, and collider AABBs
Diffstat (limited to 'src_testbed')
-rw-r--r--src_testbed/debug_render.rs3
-rw-r--r--src_testbed/lines/debuglines.wgsl8
-rw-r--r--src_testbed/lines/debuglines2d.wgsl9
-rw-r--r--src_testbed/lines/mod.rs11
4 files changed, 19 insertions, 12 deletions
diff --git a/src_testbed/debug_render.rs b/src_testbed/debug_render.rs
index 913663e..047793d 100644
--- a/src_testbed/debug_render.rs
+++ b/src_testbed/debug_render.rs
@@ -25,7 +25,7 @@ impl Plugin for RapierDebugRenderPlugin {
))
.insert_resource(DebugRenderPipeline::new(
Default::default(),
- !DebugRenderMode::RIGID_BODY_AXES,
+ !DebugRenderMode::RIGID_BODY_AXES & !DebugRenderMode::COLLIDER_AABBS,
))
.add_system_to_stage(CoreStage::Update, debug_render_scene);
}
@@ -68,5 +68,6 @@ fn debug_render_scene(
&harness.physics.colliders,
&harness.physics.impulse_joints,
&harness.physics.multibody_joints,
+ &harness.physics.narrow_phase,
);
}
diff --git a/src_testbed/lines/debuglines.wgsl b/src_testbed/lines/debuglines.wgsl
index 0987839..364d9ac 100644
--- a/src_testbed/lines/debuglines.wgsl
+++ b/src_testbed/lines/debuglines.wgsl
@@ -25,9 +25,13 @@ struct FragmentOutput {
fn vertex(vertex: Vertex) -> VertexOutput {
var out: VertexOutput;
out.clip_position = view.view_proj * vec4<f32>(vertex.pos, 1.0);
- //out.color = vertex.color;
// https://github.com/bevyengine/bevy/blob/328c26d02c50de0bc77f0d24a376f43ba89517b1/examples/2d/mesh2d_manual.rs#L234
- out.color = vec4<f32>((vec4<u32>(vertex.color) >> vec4<u32>(8u, 8u, 16u, 24u)) & vec4<u32>(255u)) / 255.0;
+ // ... except the above doesn't seem to work in 3d. Not sure what's going on there.
+ var r = f32(vertex.color & 255u) / 255.0;
+ var g = f32(vertex.color >> 8u & 255u) / 255.0;
+ var b = f32(vertex.color >> 16u & 255u) / 255.0;
+ var a = f32(vertex.color >> 24u & 255u) / 255.0;
+ out.color = vec4<f32>(r, g, b, a);
return out;
}
diff --git a/src_testbed/lines/debuglines2d.wgsl b/src_testbed/lines/debuglines2d.wgsl
index 9316531..b722d8a 100644
--- a/src_testbed/lines/debuglines2d.wgsl
+++ b/src_testbed/lines/debuglines2d.wgsl
@@ -17,10 +17,11 @@ struct VertexOutput {
fn vertex(vertex: Vertex) -> VertexOutput {
var out: VertexOutput;
out.clip_position = view.view_proj * vec4<f32>(vertex.place, 1.0);
- // What is this craziness?
- out.color = vec4<f32>((vec4<u32>(vertex.color) >> vec4<u32>(0u, 8u, 16u, 24u)) & vec4<u32>(255u)) / 255.0;
- //out.color = vertex.color;
- //out.color = vec4<f32>(1.0, 0.0, 0.0, 1.0);
+ var r = f32(vertex.color & 255u) / 255.0;
+ var g = f32(vertex.color >> 8u & 255u) / 255.0;
+ var b = f32(vertex.color >> 16u & 255u) / 255.0;
+ var a = f32(vertex.color >> 24u & 255u) / 255.0;
+ out.color = vec4<f32>(r, g, b, a);
return out;
}
diff --git a/src_testbed/lines/mod.rs b/src_testbed/lines/mod.rs
index 7e78ee9..a7dd7bb 100644
--- a/src_testbed/lines/mod.rs
+++ b/src_testbed/lines/mod.rs
@@ -1,4 +1,5 @@
#![allow(warnings)]
+use bevy::render::view::NoFrustumCulling;
/**
*
* NOTE: this module and its submodules are only temporary. It is a copy-paste of the bevy-debug-lines
@@ -33,7 +34,7 @@ mod render_dim;
// gates-specific code.
#[cfg(feature = "dim3")]
mod dim {
- pub(crate) use crate::lines::render_dim::r3d::{queue, DebugLinePipeline, DrawDebugLines};
+ pub(crate) use super::render_dim::r3d::{queue, DebugLinePipeline, DrawDebugLines};
pub(crate) use bevy::core_pipeline::Opaque3d as Phase;
use bevy::{asset::Handle, render::mesh::Mesh};
@@ -49,7 +50,7 @@ mod dim {
}
#[cfg(feature = "dim2")]
mod dim {
- pub(crate) use crate::lines::render_dim::r2d::{queue, DebugLinePipeline, DrawDebugLines};
+ pub(crate) use super::render_dim::r2d::{queue, DebugLinePipeline, DrawDebugLines};
pub(crate) use bevy::core_pipeline::Transparent2d as Phase;
use bevy::{asset::Handle, render::mesh::Mesh, sprite::Mesh2dHandle};
@@ -172,6 +173,7 @@ fn setup(mut cmds: Commands, mut meshes: ResMut<Assets<Mesh>>) {
dim::into_handle(meshes.add(mesh)),
NotShadowCaster,
NotShadowReceiver,
+ NoFrustumCulling,
Transform::default(),
GlobalTransform::default(),
Visibility::default(),
@@ -190,7 +192,7 @@ fn update(
// For each debug line mesh, fill its buffers with the relevant positions/colors chunks.
for (mesh_handle, debug_lines_idx) in debug_line_meshes.iter() {
let mesh = meshes.get_mut(dim::from_handle(mesh_handle)).unwrap();
- use VertexAttributeValues::{Float32x3, Float32x4, Uint32};
+ use VertexAttributeValues::{Float32x3, Uint32};
if let Some(Float32x3(vbuffer)) = mesh.attribute_mut(Mesh::ATTRIBUTE_POSITION) {
vbuffer.clear();
if let Some(new_content) = lines
@@ -238,7 +240,7 @@ fn extract(mut commands: Commands, query: Query<Entity, With<DebugLinesMesh>>) {
}
#[derive(Component)]
-struct DebugLinesMesh(usize);
+pub(crate) struct DebugLinesMesh(usize);
#[derive(Component)]
pub(crate) struct RenderDebugLinesMesh;
@@ -320,7 +322,6 @@ impl DebugLines {
end_color: Color,
) {
if self.positions.len() >= MAX_POINTS {
- warn!("Tried to add a new line when existing number of lines was already at maximum, ignoring.");
return;
}