add feature to enable/disable rapier debug render

This commit is contained in:
Joe Ardent 2023-01-25 17:10:23 -08:00
parent 738dd6569a
commit 651f471b97
2 changed files with 20 additions and 9 deletions

View file

@ -13,7 +13,7 @@ bevy-inspector-egui = "0.17.0"
# wgpu = "0.12"
[features]
debug_render = []
inspector = []
[dependencies.bevy]
version = "0.9"

View file

@ -1,5 +1,4 @@
use bevy::prelude::*;
use bevy_rapier3d::render::{DebugRenderMode, DebugRenderStyle, RapierDebugRenderPlugin};
use crate::{bike::CyberBikeModel, input::InputState};
@ -118,8 +117,11 @@ fn cycle_cam_state(mut state: ResMut<State<CyberCameras>>, mut keys: ResMut<Inpu
}
pub struct CyberCamPlugin;
impl Plugin for CyberCamPlugin {
#[cfg(feature = "inspector")]
fn build(&self, app: &mut bevy::prelude::App) {
use bevy_rapier3d::render::{DebugRenderMode, DebugRenderStyle, RapierDebugRenderPlugin};
let style = DebugRenderStyle {
collider_dynamic_color: Color::RED.as_rgba_f32(),
multibody_joint_anchor_color: Color::GREEN.as_rgba_f32(),
@ -138,12 +140,21 @@ impl Plugin for CyberCamPlugin {
mode,
};
app.insert_resource(DebugCamOffset::default())
.add_plugin(rplugin)
.add_startup_system(setup_cybercams)
.add_state(CyberCameras::Hero)
.add_system(cycle_cam_state)
.add_system(update_active_camera)
.add_system(follow_cyberbike);
app.add_plugin(rplugin);
common(app);
}
#[cfg(not(feature = "inspector"))]
fn build(&self, app: &mut bevy::prelude::App) {
common(app);
}
}
fn common(app: &mut bevy::prelude::App) {
app.insert_resource(DebugCamOffset::default())
.add_startup_system(setup_cybercams)
.add_state(CyberCameras::Hero)
.add_system(cycle_cam_state)
.add_system(update_active_camera)
.add_system(follow_cyberbike);
}