Skip to content

Commit

Permalink
Remove line rendering plugin because it does not support Bevy 0.12. See
Browse files Browse the repository at this point in the history
  • Loading branch information
janhohenheim committed Jan 21, 2024
1 parent 5c5a959 commit d24d341
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 111 deletions.
45 changes: 4 additions & 41 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ homepage = "https://janhohenheim.github.io/foxtrot/"

[features]
default = ["dev"]
dev = ["dep:bevy_editor_pls", "dep:bevy_prototype_debug_lines"]
dev = ["dep:bevy_editor_pls"]
tracing = ["bevy/trace_chrome"]

[dependencies]
Expand Down Expand Up @@ -51,7 +51,6 @@ bevy_mod_sysfail = "5"
seldom_fn_plugin = "0.5"
bevy_rapier3d = { version = "0.23", features = [ "serde-serialize", "simd-stable" ] }
bevy_editor_pls = { version = "0.7", optional = true }
bevy_prototype_debug_lines = { version = "0.11", optional = true, features = [ "3d" ] }

# keep the following in sync with Bevy's dependencies
## https://github.com/bevyengine/bevy/blob/v0.12.1/crates/bevy_winit/Cargo.toml#L31
Expand Down
2 changes: 0 additions & 2 deletions src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::dev::dev_editor::dev_editor_plugin;
use bevy::diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin};
use bevy::prelude::*;
use bevy_editor_pls::prelude::*;
use bevy_prototype_debug_lines::DebugLinesPlugin;
use bevy_rapier3d::prelude::*;
use seldom_fn_plugin::FnPluginExt;

Expand All @@ -15,7 +14,6 @@ pub(crate) fn dev_plugin(app: &mut App) {
app.add_plugin(EditorPlugin::new())
.insert_resource(default_editor_controls())
.add_plugin(FrameTimeDiagnosticsPlugin)
.add_plugin(DebugLinesPlugin::default())
.fn_plugin(dev_editor_plugin)
.add_plugin(LogDiagnosticsPlugin::filtered(vec![]))
.add_plugin(RapierDebugRenderPlugin {
Expand Down
50 changes: 1 addition & 49 deletions src/dev/dev_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use bevy_editor_pls::{
use bevy_egui::egui;
use bevy_egui::egui::ScrollArea;
use bevy_mod_sysfail::*;
use bevy_prototype_debug_lines::DebugLines;
use bevy_rapier3d::prelude::*;
use oxidized_navigation::NavMesh;
use serde::{Deserialize, Serialize};
Expand All @@ -25,12 +24,7 @@ pub(crate) fn dev_editor_plugin(app: &mut App) {
app.init_resource::<DevEditorState>()
.add_editor_window::<DevEditorWindow>()
.add_systems(
(
handle_debug_render,
handle_navmesh_render,
set_cursor_grab_mode,
)
.run_if(in_state(GameState::Playing)),
(handle_debug_render, set_cursor_grab_mode).run_if(in_state(GameState::Playing)),
);
}

Expand Down Expand Up @@ -173,45 +167,3 @@ fn set_cursor_grab_mode(
}
}
}

#[sysfail(log(level = "error"))]
fn handle_navmesh_render(
state: Res<Editor>,
nav_mesh: Res<NavMesh>,
mut lines: ResMut<DebugLines>,
) -> Result<()> {
if !state
.window_state::<DevEditorWindow>()
.context("Failed to read dev window state")?
.navmesh_render_enabled
{
return Ok(());
}

if let Ok(nav_mesh) = nav_mesh.get().read() {
for (tile_coord, tile) in nav_mesh.get_tiles().iter() {
let tile_color = Color::Rgba {
red: 0.0,
green: (tile_coord.x % 10) as f32 / 10.0,
blue: (tile_coord.y % 10) as f32 / 10.0,
alpha: 1.0,
};
// Draw polygons.
for poly in tile.polygons.iter() {
let indices = &poly.indices;
for i in 0..indices.len() {
let a = tile.vertices[indices[i] as usize];
let b = tile.vertices[indices[(i + 1) % indices.len()] as usize];

lines.line_colored(a, b, 0.0, tile_color);
}
}

// Draw vertex points.
for vertex in tile.vertices.iter() {
lines.line_colored(*vertex, *vertex + Vec3::Y, 0.0, tile_color);
}
}
}
Ok(())
}
17 changes: 0 additions & 17 deletions src/movement/navigation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use anyhow::Result;
use bevy::prelude::*;
use bevy_mod_sysfail::*;
#[cfg(feature = "dev")]
use bevy_prototype_debug_lines::DebugLines;
use oxidized_navigation::{
query::{find_path, perform_string_pulling_on_path},
NavMesh, NavMeshSettings, OxidizedNavigationPlugin,
Expand Down Expand Up @@ -57,7 +56,6 @@ fn query_mesh(
with_player: Query<&Transform, (With<Player>, Without<Follower>)>,
nav_mesh_settings: Res<NavMeshSettings>,
nav_mesh: Res<NavMesh>,
#[cfg(feature = "dev")] mut lines: ResMut<DebugLines>,
#[cfg(feature = "dev")] editor_state: Res<bevy_editor_pls::editor::Editor>,
) -> Result<()> {
#[cfg(feature = "tracing")]
Expand All @@ -74,14 +72,6 @@ fn query_mesh(
if let Ok(path) = find_path(&nav_mesh, &nav_mesh_settings, from, to, None, None) {
let path = perform_string_pulling_on_path(&nav_mesh, from, to, &path)
.map_err(|e| anyhow::Error::msg(format!("{e:?}")))?;
#[cfg(feature = "dev")]
if editor_state
.window_state::<DevEditorWindow>()
.context("Failed to get dev window state")?
.navmesh_render_enabled
{
draw_path(&path, &mut lines, Color::RED);
}
let dir = path
.into_iter()
.map(|next_point| {
Expand All @@ -100,10 +90,3 @@ fn query_mesh(

Ok(())
}

#[cfg(feature = "dev")]
fn draw_path(path: &[Vec3], lines: &mut DebugLines, color: Color) {
for (a, b) in path.iter().zip(path.iter().skip(1)) {
lines.line_colored(*a, *b, 0.1, color);
}
}

0 comments on commit d24d341

Please sign in to comment.