1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-07-12 16:57:44 +00:00

Begin integrating recastnavigation-sys

This commit is contained in:
Joshua Goins 2025-07-09 15:58:57 -04:00
parent 85cec9f092
commit e269806248
3 changed files with 75 additions and 21 deletions

73
Cargo.lock generated
View file

@ -1167,6 +1167,26 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "bindgen"
version = "0.72.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f72209734318d0b619a5e0f5129918b848c416e122a3c4ce054e03cb87b726f"
dependencies = [
"bitflags 2.9.1",
"cexpr",
"clang-sys",
"itertools 0.13.0",
"log",
"prettyplease",
"proc-macro2",
"quote",
"regex",
"rustc-hash 2.1.1",
"shlex",
"syn",
]
[[package]] [[package]]
name = "binrw" name = "binrw"
version = "0.15.0" version = "0.15.0"
@ -1332,21 +1352,11 @@ checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a"
[[package]] [[package]]
name = "bzip2" name = "bzip2"
version = "0.5.2" version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49ecfb22d906f800d4fe833b6282cf4dc1c298f5057ca0b5445e5c209735ca47" checksum = "bea8dcd42434048e4f7a304411d9273a411f647446c1234a65ce0554923f4cff"
dependencies = [ dependencies = [
"bzip2-sys", "libbz2-rs-sys",
]
[[package]]
name = "bzip2-sys"
version = "0.1.13+1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "225bff33b2141874fe80d71e07d6eec4f85c5c216453dd96388240f96e1acc14"
dependencies = [
"cc",
"pkg-config",
] ]
[[package]] [[package]]
@ -1412,6 +1422,15 @@ dependencies = [
"libloading", "libloading",
] ]
[[package]]
name = "cmake"
version = "0.1.54"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0"
dependencies = [
"cc",
]
[[package]] [[package]]
name = "codespan-reporting" name = "codespan-reporting"
version = "0.11.1" version = "0.11.1"
@ -2529,6 +2548,7 @@ dependencies = [
"minijinja", "minijinja",
"mlua", "mlua",
"physis", "physis",
"recastnavigation-sys",
"reqwest", "reqwest",
"rkon", "rkon",
"rusqlite", "rusqlite",
@ -2575,6 +2595,12 @@ version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]]
name = "libbz2-rs-sys"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "775bf80d5878ab7c2b1080b5351a48b2f737d9f6f8b383574eebcc22be0dfccb"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.174" version = "0.2.174"
@ -3571,6 +3597,17 @@ version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539"
[[package]]
name = "recastnavigation-sys"
version = "1.0.3"
source = "git+https://github.com/redstrate/recastnavigation-rs-sys#e24975b0bfac9014b2c33bdeb011f3c7107286fc"
dependencies = [
"bindgen 0.72.0",
"cc",
"cmake",
"static_assertions",
]
[[package]] [[package]]
name = "rectangle-pack" name = "rectangle-pack"
version = "0.4.2" version = "0.4.2"
@ -4317,7 +4354,7 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "528bdd1f0e27b5dd9a4ededf154e824b0532731e4af73bb531de46276e0aab1e" checksum = "528bdd1f0e27b5dd9a4ededf154e824b0532731e4af73bb531de46276e0aab1e"
dependencies = [ dependencies = [
"bindgen", "bindgen 0.70.1",
"cc", "cc",
"cfg-if", "cfg-if",
"once_cell", "once_cell",
@ -5214,9 +5251,9 @@ checksum = "b9cc00251562a284751c9973bace760d86c0276c471b4be569fe6b068ee97a56"
[[package]] [[package]]
name = "xml-rs" name = "xml-rs"
version = "0.8.26" version = "0.8.27"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a62ce76d9b56901b19a74f19431b0d8b3bc7ca4ad685a746dfd78ca8f4fc6bda" checksum = "6fd8403733700263c6eb89f192880191f1b83e332f7a20371ddcf421c4a337c7"
[[package]] [[package]]
name = "yoke" name = "yoke"
@ -5318,9 +5355,9 @@ dependencies = [
[[package]] [[package]]
name = "zip" name = "zip"
version = "4.2.0" version = "4.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95ab361742de920c5535880f89bbd611ee62002bf11341d16a5f057bb8ba6899" checksum = "9aed4ac33e8eb078c89e6cbb1d5c4c7703ec6d299fc3e7c3695af8f8b423468b"
dependencies = [ dependencies = [
"arbitrary", "arbitrary",
"bzip2", "bzip2",

View file

@ -53,7 +53,7 @@ default = []
oodle = [] oodle = []
# Navmesh visualizer # Navmesh visualizer
visualizer = ["dep:bevy"] visualizer = ["dep:bevy", "dep:recastnavigation-sys"]
[build-dependencies] [build-dependencies]
# Serialization of IPC opcodes # Serialization of IPC opcodes
@ -97,6 +97,9 @@ bevy = { version = "0.16", features = ["std",
"tonemapping_luts", "tonemapping_luts",
"x11"], default-features = false, optional = true } "x11"], default-features = false, optional = true }
# for navimesh generation
recastnavigation-sys = { git = "https://github.com/redstrate/recastnavigation-rs-sys", features = ["recast"], optional = true }
[target.'cfg(not(target_family = "wasm"))'.dependencies] [target.'cfg(not(target_family = "wasm"))'.dependencies]
# Used for the web servers # Used for the web servers
axum = { version = "0.8", features = ["json", "tokio", "http1", "form", "query", "multipart"], default-features = false } axum = { version = "0.8", features = ["json", "tokio", "http1", "form", "query", "multipart"], default-features = false }

View file

@ -12,6 +12,7 @@ use physis::{
pcb::{Pcb, ResourceNode}, pcb::{Pcb, ResourceNode},
resource::{Resource, SqPackResource}, resource::{Resource, SqPackResource},
}; };
use recastnavigation_sys::rcAllocPolyMesh;
#[derive(Resource)] #[derive(Resource)]
struct ZoneToLoad(u16); struct ZoneToLoad(u16);
@ -36,6 +37,7 @@ fn walk_node(
meshes: &mut ResMut<Assets<Mesh>>, meshes: &mut ResMut<Assets<Mesh>>,
materials: &mut ResMut<Assets<StandardMaterial>>, materials: &mut ResMut<Assets<StandardMaterial>>,
transform: &Transformation, transform: &Transformation,
//tile_input_builder: &mut TileInputBuilder,
) { ) {
if !node.vertices.is_empty() { if !node.vertices.is_empty() {
let mut mesh = Mesh::new( let mut mesh = Mesh::new(
@ -48,7 +50,7 @@ fn walk_node(
positions.push(vec.clone()); positions.push(vec.clone());
} }
mesh.insert_attribute(Mesh::ATTRIBUTE_POSITION, positions); mesh.insert_attribute(Mesh::ATTRIBUTE_POSITION, positions.clone());
let mut indices = Vec::new(); let mut indices = Vec::new();
for polygon in &node.polygons { for polygon in &node.polygons {
@ -60,8 +62,9 @@ fn walk_node(
indices.append(&mut vec); indices.append(&mut vec);
} }
mesh.insert_indices(Indices::U32(indices)); mesh.insert_indices(Indices::U32(indices.clone()));
// insert into 3d scene
commands.spawn(( commands.spawn((
Mesh3d(meshes.add(mesh)), Mesh3d(meshes.add(mesh)),
MeshMaterial3d(materials.add(Color::srgb( MeshMaterial3d(materials.add(Color::srgb(
@ -80,6 +83,12 @@ fn walk_node(
scale: Vec3::from_array(transform.scale), scale: Vec3::from_array(transform.scale),
}, },
)); ));
// insert into navmesh builder
//let tile_vertices: Vec<DtVector> = positions.iter().map(|vec| DtVector::new(vec[0], vec[1], vec[2])).collect();
//let tile_indices: Vec<i32> = indices.iter().map(|x| *x as i32).collect();
//tile_input_builder.append(&tile_vertices, &tile_indices, 0);
} }
for child in &node.children { for child in &node.children {
@ -114,6 +123,10 @@ fn setup(
let lvb_file = sqpack_resource.read(&path).unwrap(); let lvb_file = sqpack_resource.read(&path).unwrap();
let lvb = Lvb::from_existing(&lvb_file).unwrap(); let lvb = Lvb::from_existing(&lvb_file).unwrap();
unsafe {
let poly_mesh = rcAllocPolyMesh();
}
for path in &lvb.scns[0].header.path_layer_group_resources { for path in &lvb.scns[0].header.path_layer_group_resources {
if path.contains("bg.lgb") { if path.contains("bg.lgb") {
tracing::info!("Processing {path}..."); tracing::info!("Processing {path}...");
@ -150,6 +163,7 @@ fn setup(
&mut meshes, &mut meshes,
&mut materials, &mut materials,
&object.transform, &object.transform,
//&mut tile_input_builder,
); );
} }
} }