From 7c2666fdf5d83fa27400be2feafd4923c821d8f9 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 26 Sep 2023 14:25:44 -0700 Subject: [PATCH] file loader multiplexer, pass dom to load_roblox --- src/load_roblox.rs | 4 +--- src/main.rs | 45 ++++++++++++++++++++++++++++++++++++--------- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/load_roblox.rs b/src/load_roblox.rs index 1fe10e2..d555879 100644 --- a/src/load_roblox.rs +++ b/src/load_roblox.rs @@ -10,10 +10,8 @@ fn class_is_a(class: &str, superclass: &str) -> bool { } return false } -pub fn get_objects(buf_thing: R, superclass: &str) -> Result, Box> { - // Using buffered I/O is recommended with rbx_binary - let dom = rbx_binary::from_reader(buf_thing)?; +pub fn get_objects(dom:rbx_dom_weak::WeakDom, superclass: &str) -> Result, Box> { let mut objects = std::vec::Vec::::new(); //move matching instances into objects let (_,mut instances) = dom.into_raw(); diff --git a/src/main.rs b/src/main.rs index 4871c2c..1aaf2d9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -161,9 +161,9 @@ impl GraphicsData { depth_texture.create_view(&wgpu::TextureViewDescriptor::default()) } - fn generate_modeldatas_roblox(&self,input:R) -> Vec{ + fn generate_modeldatas_roblox(&self,dom:rbx_dom_weak::WeakDom) -> Vec{ let mut modeldatas=generate_modeldatas(self.handy_unit_cube.clone(),ModelData::COLOR_FLOATS_WHITE); - match load_roblox::get_objects(input, "BasePart") { + match load_roblox::get_objects(dom, "BasePart") { Ok(objects)=>{ for object in objects.iter() { if let ( @@ -830,13 +830,40 @@ impl framework::Example for GraphicsData { println!("opening file: {:?}", &path); //oh boy! let's load the map! if let Ok(file)=std::fs::File::open(path){ - let input = std::io::BufReader::new(file); - let modeldatas=self.generate_modeldatas_roblox(input); - //if generate_modeldatas succeeds, clear the previous ones - self.models.clear(); - self.physics.models.clear(); - self.generate_model_physics(&modeldatas); - self.generate_model_graphics(device,modeldatas); + let mut input = std::io::BufReader::new(file); + let mut first_8=[0u8;8]; + //.rbxm roblox binary = "