Debug-renderer: add rendering of contacts, solver contacts, and collider AABBs
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user