Remove hierarchical instancing.
After thinking about this and after some discussion with other people, I now believe that hierarchical instancing isn't actually that useful in practice for rendering. Single-level instancing is still supported, of course.
This commit is contained in:
parent
66dcbc2e7f
commit
946a1860e0
|
@ -73,15 +73,15 @@ pub fn parse_assembly<'a>(
|
||||||
|
|
||||||
// Get object data.
|
// Get object data.
|
||||||
let object_data = match events.next_event()? {
|
let object_data = match events.next_event()? {
|
||||||
Event::InnerOpen {
|
|
||||||
type_name: "Assembly",
|
|
||||||
..
|
|
||||||
} => ObjectData::Assembly(Box::new(parse_assembly(arena, events)?)),
|
|
||||||
|
|
||||||
Event::InnerOpen {
|
Event::InnerOpen {
|
||||||
type_name: "MeshSurface",
|
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 {
|
Event::InnerOpen {
|
||||||
type_name: "SphereLight",
|
type_name: "SphereLight",
|
||||||
|
|
|
@ -9,7 +9,7 @@ use kioku::Arena;
|
||||||
use data_tree::{DataTreeReader, Event};
|
use data_tree::{DataTreeReader, Event};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
math::{Normal, Point},
|
math::{Matrix4x4, Normal, Point},
|
||||||
surface::triangle_mesh::TriangleMesh,
|
surface::triangle_mesh::TriangleMesh,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -18,15 +18,10 @@ use super::{
|
||||||
psy::{PsyError, PsyResult},
|
psy::{PsyError, PsyResult},
|
||||||
};
|
};
|
||||||
|
|
||||||
// pub struct TriangleMesh {
|
|
||||||
// time_samples: usize,
|
|
||||||
// geo: Vec<(Point, Point, Point)>,
|
|
||||||
// indices: Vec<usize>,
|
|
||||||
// accel: BVH,
|
|
||||||
// }
|
|
||||||
|
|
||||||
pub fn parse_mesh_surface<'a>(
|
pub fn parse_mesh_surface<'a>(
|
||||||
arena: &'a Arena,
|
arena: &'a Arena,
|
||||||
|
instance_xform_idxs: &[std::ops::Range<usize>],
|
||||||
|
xforms: &[Matrix4x4],
|
||||||
events: &mut DataTreeReader<impl BufRead>,
|
events: &mut DataTreeReader<impl BufRead>,
|
||||||
) -> PsyResult<TriangleMesh<'a>> {
|
) -> PsyResult<TriangleMesh<'a>> {
|
||||||
let mut verts = Vec::new(); // Vec of vecs, one for each time sample
|
let mut verts = Vec::new(); // Vec of vecs, one for each time sample
|
||||||
|
|
|
@ -2,6 +2,7 @@ use std::{collections::HashMap, ops::Range};
|
||||||
|
|
||||||
use crate::{light::SurfaceLight, math::Matrix4x4, surface::Surface};
|
use crate::{light::SurfaceLight, math::Matrix4x4, surface::Surface};
|
||||||
|
|
||||||
|
/// Stores the objects of a scene and its acceleration structures.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Assembly<'a> {
|
pub struct Assembly<'a> {
|
||||||
pub objects: HashMap<String, Object<'a>>, // Name, Object.
|
pub objects: HashMap<String, Object<'a>>, // Name, Object.
|
||||||
|
@ -21,7 +22,8 @@ impl<'a> Assembly<'a> {
|
||||||
pub struct Object<'a> {
|
pub struct Object<'a> {
|
||||||
pub data: ObjectData<'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<Range<usize>>,
|
pub instance_xform_idxs: Vec<Range<usize>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,5 +32,4 @@ pub enum ObjectData<'a> {
|
||||||
Empty,
|
Empty,
|
||||||
Surface(Box<dyn Surface + 'a>),
|
Surface(Box<dyn Surface + 'a>),
|
||||||
Light(Box<dyn SurfaceLight + 'a>),
|
Light(Box<dyn SurfaceLight + 'a>),
|
||||||
Assembly(Box<Assembly<'a>>),
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user