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:
Nathan Vegdahl 2020-03-13 19:28:12 +09:00
parent 66dcbc2e7f
commit 946a1860e0
3 changed files with 12 additions and 16 deletions

View File

@ -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",

View File

@ -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<usize>,
// accel: BVH,
// }
pub fn parse_mesh_surface<'a>(
arena: &'a Arena,
instance_xform_idxs: &[std::ops::Range<usize>],
xforms: &[Matrix4x4],
events: &mut DataTreeReader<impl BufRead>,
) -> PsyResult<TriangleMesh<'a>> {
let mut verts = Vec::new(); // Vec of vecs, one for each time sample

View File

@ -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<String, Object<'a>>, // 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<Range<usize>>,
}
@ -30,5 +32,4 @@ pub enum ObjectData<'a> {
Empty,
Surface(Box<dyn Surface + 'a>),
Light(Box<dyn SurfaceLight + 'a>),
Assembly(Box<Assembly<'a>>),
}