Skip to content

Commit 5d19c5a

Browse files
committed
remove pathfinding stuff from bspeater
1 parent cc70da1 commit 5d19c5a

File tree

6 files changed

+20
-521
lines changed

6 files changed

+20
-521
lines changed

bspeater/src/async_pathfinding.rs

Lines changed: 0 additions & 106 deletions
This file was deleted.

bspeater/src/behavior.rs

Lines changed: 0 additions & 114 deletions
This file was deleted.

bspeater/src/debug.rs

Lines changed: 9 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
1-
use bevy::{
2-
camera_controller::free_camera::FreeCamera, input::common_conditions::input_just_pressed,
3-
prelude::*,
4-
};
1+
use bevy::{camera_controller::free_camera::FreeCamera, prelude::*};
52
use oktree::prelude::*;
6-
use std::{ops::BitAnd, sync::Arc};
3+
use std::ops::BitAnd;
74

85
use crate::{
96
ATTRIBUTE_PRIMATIVE_TYPE, ATTRIBUTE_UNIQUE_CONTENTS, CELL_SIZE, ChunkCells, EnabledFeatures,
10-
OFFSET, PrimitiveType, ProcessingStep, WorldMesh,
11-
async_pathfinding::JobMarket,
12-
behavior::{self, Behavior, init_pathfinding},
7+
OFFSET, PrimitiveType, WorldMesh,
138
};
149

10+
#[allow(unused)]
1511
pub type Octree32 = Octree<u32, TUVec3u32>;
12+
#[allow(unused)]
1613
pub struct Navmesh {
1714
pub navmesh_tree: Octree32,
1815
pub cell_size: f32,
1916
}
2017

21-
#[derive(Resource)]
22-
pub struct NavmeshRes(Behavior, JobMarket);
23-
18+
#[allow(unused)]
2419
#[derive(Resource, Default)]
2520
pub struct PathfindingPoints {
2621
building: [Option<Vec3>; 2],
@@ -34,21 +29,9 @@ struct PointsText;
3429
struct MeshInfoText;
3530

3631
pub fn debug_plugin(app: &mut App) {
37-
app.add_systems(
38-
Update,
39-
(
40-
debug_world,
41-
debug_pathfinding.run_if(resource_exists::<NavmeshRes>),
42-
update_pos_text,
43-
add_pathfinding_points.run_if(input_just_pressed(KeyCode::Enter)),
44-
add_navmesh_resource
45-
.run_if(in_state(ProcessingStep::Done))
46-
.run_if(|res: Option<Res<NavmeshRes>>| res.is_none()),
47-
debug_contents,
48-
),
49-
)
50-
.add_systems(Startup, setup_debug_ui)
51-
.init_resource::<PathfindingPoints>();
32+
app.add_systems(Update, (debug_world, update_pos_text, debug_contents))
33+
.add_systems(Startup, setup_debug_ui)
34+
.init_resource::<PathfindingPoints>();
5235
}
5336

5437
fn setup_debug_ui(mut commands: Commands) {
@@ -196,52 +179,6 @@ fn debug_world(
196179
Ok(())
197180
}
198181

199-
fn debug_pathfinding(
200-
points: Res<PathfindingPoints>,
201-
mut navmesh: ResMut<NavmeshRes>,
202-
time: Res<Time>,
203-
gizmos: Gizmos,
204-
) -> Result<(), BevyError> {
205-
if let Some(points) = points.current {
206-
let NavmeshRes(bt, job_market) = &mut *navmesh;
207-
behavior::run_behavior(bt, time.delta_secs_f64(), points, job_market, gizmos);
208-
}
209-
210-
Ok(())
211-
}
212-
213-
fn add_pathfinding_points(
214-
camera: Query<&Transform, With<FreeCamera>>,
215-
mut points: ResMut<PathfindingPoints>,
216-
) -> Result<(), BevyError> {
217-
let origin = camera.single()?.translation.trunc();
218-
219-
if points.building[0].is_none() {
220-
_ = points.building[0].replace(origin);
221-
_ = points.building[1].take();
222-
} else if points.building[1].is_none() {
223-
_ = points.building[1].replace(origin);
224-
}
225-
226-
if matches!(points.building, [Some(_), Some(_)]) {
227-
points.current = points.building[0].and_then(|point| Some([point, points.building[1]?]));
228-
points.building = default();
229-
}
230-
231-
Ok(())
232-
}
233-
234-
fn add_navmesh_resource(mut commands: Commands, cells: Res<ChunkCells>) {
235-
let navmesh = Arc::new(Navmesh {
236-
navmesh_tree: cells.tree.clone(),
237-
cell_size: CELL_SIZE,
238-
});
239-
commands.insert_resource(NavmeshRes(
240-
init_pathfinding(Arc::clone(&navmesh)),
241-
JobMarket::new(navmesh),
242-
));
243-
}
244-
245182
fn debug_contents(
246183
mut ray_cast: MeshRayCast,
247184
camera: Query<&Transform, (With<FreeCamera>, Without<WorldMesh>)>,

bspeater/src/export.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
// sligtly modified version of export.rs from https://github.com/mrclputra/bevy_WeaverGen_V3
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
//
5+
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
//
7+
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28

39
// saves the model as an obj file
410
// by iterating through all the meshes
@@ -19,8 +25,7 @@ pub fn export_obj<'a>(
1925
let mut writer = BufWriter::new(file);
2026

2127
// OBJ header
22-
writeln!(writer, "# Exported from Slum Generator")?;
23-
writeln!(writer, "Written by Marcel Putra 2025")?;
28+
writeln!(writer, "# Exported from BSPEater")?;
2429

2530
// OBJ format indices start at 1, dont ask why :)
2631
let mut vertex_offset = 1;

bspeater/src/main.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use avian3d::prelude::*;
66
#[cfg(not(feature = "graphics"))]
77
use bevy::mesh::MeshPlugin;
88
#[cfg(feature = "graphics")]
9-
use bevy::pbr::wireframe::WireframeConfig;
9+
use bevy::pbr::wireframe::{WireframeConfig, WireframePlugin};
1010
use bevy::{
1111
asset::RenderAssetUsages,
1212
mesh::{MeshVertexAttribute, VertexFormat},
@@ -31,19 +31,13 @@ use std::{
3131

3232
pub use bindings::*;
3333

34-
#[cfg(feature = "graphics")]
35-
mod async_pathfinding;
36-
#[cfg(feature = "graphics")]
37-
mod behavior;
3834
mod bindings;
3935
mod cli;
4036
#[cfg(feature = "graphics")]
4137
mod debug;
4238
mod export;
4339
mod geoset_loader;
4440
mod mdl_loader;
45-
#[cfg(feature = "graphics")]
46-
mod pathfinding;
4741
mod saving;
4842

4943
pub const UNPACK: &str = "vpk";
@@ -328,10 +322,10 @@ fn main() -> anyhow::Result<()> {
328322
..default()
329323
}),
330324
PhysicsPlugins::default(),
331-
#[cfg(feature = "graphics")]
332-
PhysicsDebugPlugin,
333325
// #[cfg(feature = "graphics")]
334-
// WireframePlugin::default(),
326+
// PhysicsDebugPlugin,
327+
#[cfg(feature = "graphics")]
328+
WireframePlugin::default(),
335329
#[cfg(feature = "graphics")]
336330
FreeCameraPlugin,
337331
))

0 commit comments

Comments
 (0)