diff --git a/src/parse/psy_assembly.rs b/src/parse/psy_assembly.rs index 4a1eae6..adced2a 100644 --- a/src/parse/psy_assembly.rs +++ b/src/parse/psy_assembly.rs @@ -73,15 +73,15 @@ pub fn parse_assembly<'a>( // Get object data. let object_data = match events.next_event()? { - Event::InnerOpen { - type_name: "Assembly", - .. - } => ObjectData::Assembly(Box::new(parse_assembly(arena, events)?)), - Event::InnerOpen { type_name: "MeshSurface", .. - } => ObjectData::Surface(Box::new(parse_mesh_surface(arena, events)?)), + } => ObjectData::Surface(Box::new(parse_mesh_surface( + arena, + &instance_xform_idxs[..], + &assembly.xforms[..], + events, + )?)), Event::InnerOpen { type_name: "SphereLight", diff --git a/src/parse/psy_mesh_surface.rs b/src/parse/psy_mesh_surface.rs index 0bd7cbd..069df75 100644 --- a/src/parse/psy_mesh_surface.rs +++ b/src/parse/psy_mesh_surface.rs @@ -9,7 +9,7 @@ use kioku::Arena; use data_tree::{DataTreeReader, Event}; use crate::{ - math::{Normal, Point}, + math::{Matrix4x4, Normal, Point}, surface::triangle_mesh::TriangleMesh, }; @@ -18,15 +18,10 @@ use super::{ psy::{PsyError, PsyResult}, }; -// pub struct TriangleMesh { -// time_samples: usize, -// geo: Vec<(Point, Point, Point)>, -// indices: Vec, -// accel: BVH, -// } - pub fn parse_mesh_surface<'a>( arena: &'a Arena, + instance_xform_idxs: &[std::ops::Range], + xforms: &[Matrix4x4], events: &mut DataTreeReader, ) -> PsyResult> { let mut verts = Vec::new(); // Vec of vecs, one for each time sample diff --git a/src/scene/assembly.rs b/src/scene/assembly.rs index dff79f5..87c177d 100644 --- a/src/scene/assembly.rs +++ b/src/scene/assembly.rs @@ -2,6 +2,7 @@ use std::{collections::HashMap, ops::Range}; use crate::{light::SurfaceLight, math::Matrix4x4, surface::Surface}; +/// Stores the objects of a scene and its acceleration structures. #[derive(Debug)] pub struct Assembly<'a> { pub objects: HashMap>, // Name, Object. @@ -21,7 +22,8 @@ impl<'a> Assembly<'a> { pub struct Object<'a> { pub data: ObjectData<'a>, - // One range per instance, indexing into the assembly's xforms array. + // One range per instance, indexing into the assembly's xforms + // array. An empty Vec means a single instance with no transforms. pub instance_xform_idxs: Vec>, } @@ -30,5 +32,4 @@ pub enum ObjectData<'a> { Empty, Surface(Box), Light(Box), - Assembly(Box>), }