From 746032df34840a841e9419f2839a92d3723556a6 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Sun, 10 Dec 2023 22:49:40 -0800 Subject: [PATCH] Add the data path to Engine configuration --- src/config.rs | 1 + src/lib.rs | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/config.rs b/src/config.rs index f79238c6..204fc5d9 100644 --- a/src/config.rs +++ b/src/config.rs @@ -83,4 +83,5 @@ pub struct Object { #[derive(serde::Deserialize)] pub struct Engine { pub shader_path: String, + pub data_path: String, } diff --git a/src/lib.rs b/src/lib.rs index bb36c6f2..b76aa8ab 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -196,6 +196,7 @@ pub struct Engine { track_hot_reloads: bool, workers: Vec, choir: Arc, + data_path: String, } impl ops::Index for Engine { @@ -326,6 +327,7 @@ impl Engine { track_hot_reloads: false, workers, choir, + data_path: config.data_path.clone(), } } @@ -617,7 +619,7 @@ impl Engine { let mut visuals = Vec::new(); for visual in config.visuals.iter() { let (model, task) = self.asset_hub.models.load( - format!("data/{}", visual.model), + format!("{}/{}", self.data_path, visual.model), blade_render::model::Meta { generate_tangents: true, }, @@ -673,7 +675,7 @@ impl Engine { convex, border_radius, } => { - let trimesh = trimesh::load(&format!("data/{}", model)); + let trimesh = trimesh::load(&format!("{}/{}", self.data_path, model)); if convex && border_radius != 0.0 { ColliderBuilder::round_convex_mesh( trimesh.points, @@ -758,7 +760,7 @@ impl Engine { if path.is_empty() { self.environment_map = None; } else { - let full = format!("data/{}", path); + let full = format!("{}/{}", self.data_path, path); let (handle, task) = self.asset_hub.textures.load( full, blade_render::texture::Meta {