-
-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #540 from johnny-smitherson/bevy-0.11
update bevy 0.11 - fix compile errors
- Loading branch information
Showing
19 changed files
with
124 additions
and
917 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,70 @@ | ||
use crate::harness::Harness; | ||
use crate::lines::DebugLines; | ||
use bevy::gizmos::gizmos::Gizmos; | ||
use bevy::prelude::*; | ||
use rapier::math::{Point, Real}; | ||
use rapier::pipeline::{ | ||
DebugRenderBackend, DebugRenderMode, DebugRenderObject, DebugRenderPipeline, | ||
}; | ||
|
||
#[derive(Resource)] | ||
pub struct DebugRenderPipelineResource(pub DebugRenderPipeline); | ||
|
||
pub struct RapierDebugRenderPlugin { | ||
depth_test: bool, | ||
pub struct DebugRenderPipelineResource { | ||
pub pipeline: DebugRenderPipeline, | ||
pub enabled: bool, | ||
} | ||
|
||
impl Default for RapierDebugRenderPlugin { | ||
fn default() -> Self { | ||
Self { | ||
depth_test: cfg!(feature = "dim3"), | ||
} | ||
} | ||
} | ||
#[derive(Default)] | ||
pub struct RapierDebugRenderPlugin {} | ||
|
||
impl Plugin for RapierDebugRenderPlugin { | ||
fn build(&self, app: &mut App) { | ||
app.add_plugin(crate::lines::DebugLinesPlugin::with_depth_test( | ||
self.depth_test, | ||
)) | ||
.insert_resource(DebugRenderPipelineResource(DebugRenderPipeline::new( | ||
Default::default(), | ||
!DebugRenderMode::RIGID_BODY_AXES & !DebugRenderMode::COLLIDER_AABBS, | ||
))) | ||
.add_system_to_stage(CoreStage::Update, debug_render_scene); | ||
app.insert_resource(DebugRenderPipelineResource { | ||
pipeline: DebugRenderPipeline::new( | ||
Default::default(), | ||
!DebugRenderMode::RIGID_BODY_AXES & !DebugRenderMode::COLLIDER_AABBS, | ||
), | ||
enabled: false, | ||
}) | ||
.add_systems(Update, debug_render_scene); | ||
} | ||
} | ||
|
||
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]), | ||
) | ||
} | ||
} | ||
|
||
fn debug_render_scene( | ||
mut pipeline: ResMut<DebugRenderPipelineResource>, | ||
mut debug_render: ResMut<DebugRenderPipelineResource>, | ||
harness: NonSend<Harness>, | ||
mut lines: ResMut<DebugLines>, | ||
gizmos: Gizmos, | ||
) { | ||
let mut backend = BevyLinesRenderBackend { lines: &mut *lines }; | ||
pipeline.0.render( | ||
&mut backend, | ||
&harness.physics.bodies, | ||
&harness.physics.colliders, | ||
&harness.physics.impulse_joints, | ||
&harness.physics.multibody_joints, | ||
&harness.physics.narrow_phase, | ||
); | ||
if debug_render.enabled { | ||
let mut backend = BevyLinesRenderBackend { gizmos }; | ||
debug_render.pipeline.render( | ||
&mut backend, | ||
&harness.physics.bodies, | ||
&harness.physics.colliders, | ||
&harness.physics.impulse_joints, | ||
&harness.physics.multibody_joints, | ||
&harness.physics.narrow_phase, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.