Fix crashes on MacOS

This commit is contained in:
Sébastien Crozet
2023-10-29 18:59:47 +01:00
parent 780ba4a216
commit 23a7ed5beb
11 changed files with 19 additions and 838 deletions

View File

@@ -1,5 +1,5 @@
use crate::harness::Harness;
use crate::lines::DebugLines;
use bevy::gizmos::gizmos::Gizmos;
use bevy::prelude::*;
use rapier::math::{Point, Real};
use rapier::pipeline::{
@@ -22,10 +22,7 @@ impl Default for RapierDebugRenderPlugin {
}
impl Plugin for RapierDebugRenderPlugin {
fn build(&self, app: &mut App) {
app.add_plugins(crate::lines::DebugLinesPlugin::with_depth_test(
self.depth_test,
))
.insert_resource(DebugRenderPipelineResource(DebugRenderPipeline::new(
app.insert_resource(DebugRenderPipelineResource(DebugRenderPipeline::new(
Default::default(),
!DebugRenderMode::RIGID_BODY_AXES & !DebugRenderMode::COLLIDER_AABBS,
)))
@@ -34,25 +31,23 @@ impl Plugin for RapierDebugRenderPlugin {
}
struct BevyLinesRenderBackend<'a> {
lines: &'a mut DebugLines,
gizmos: Gizmos<'a>,
}
impl<'a> DebugRenderBackend for BevyLinesRenderBackend<'a> {
#[cfg(feature = "dim2")]
fn draw_line(&mut self, _: DebugRenderObject, a: Point<Real>, b: Point<Real>, color: [f32; 4]) {
self.lines.line_colored(
self.gizmos.line(
[a.x as f32, a.y as f32, 1.0e-8 as f32].into(),
[b.x as f32, b.y as f32, 1.0e-8 as f32].into(),
0.0,
Color::hsla(color[0], color[1], color[2], color[3]),
)
}
#[cfg(feature = "dim3")]
fn draw_line(&mut self, _: DebugRenderObject, a: Point<Real>, b: Point<Real>, color: [f32; 4]) {
self.lines.line_colored(
self.gizmos.line(
[a.x as f32, a.y as f32, a.z as f32].into(),
[b.x as f32, b.y as f32, b.z as f32].into(),
0.0,
Color::hsla(color[0], color[1], color[2], color[3]),
)
}
@@ -61,9 +56,9 @@ impl<'a> DebugRenderBackend for BevyLinesRenderBackend<'a> {
fn debug_render_scene(
mut pipeline: ResMut<DebugRenderPipelineResource>,
harness: NonSend<Harness>,
mut lines: ResMut<DebugLines>,
gizmos: Gizmos,
) {
let mut backend = BevyLinesRenderBackend { lines: &mut *lines };
let mut backend = BevyLinesRenderBackend { gizmos };
pipeline.0.render(
&mut backend,
&harness.physics.bodies,