Use Box instead of Arc in BoundingVolumeHierarchy
This commit is contained in:
parent
bbeb39ba5d
commit
cf8f5e646b
|
|
@ -12,8 +12,8 @@ use std::sync::Arc;
|
||||||
pub enum BoundingVolumeHierarchy<T: Real> {
|
pub enum BoundingVolumeHierarchy<T: Real> {
|
||||||
Node {
|
Node {
|
||||||
bounds: BoundingBox<T>,
|
bounds: BoundingBox<T>,
|
||||||
left: Arc<BoundingVolumeHierarchy<T>>,
|
left: Box<BoundingVolumeHierarchy<T>>,
|
||||||
right: Arc<BoundingVolumeHierarchy<T>>,
|
right: Box<BoundingVolumeHierarchy<T>>,
|
||||||
},
|
},
|
||||||
Leaf {
|
Leaf {
|
||||||
bounds: BoundingBox<T>,
|
bounds: BoundingBox<T>,
|
||||||
|
|
@ -60,8 +60,8 @@ impl<T: Real> BoundingVolumeHierarchy<T> {
|
||||||
fn from_sorted_nodes(nodes: &[(BoundingBox<T>, Arc<dyn Primitive<T>>)]) -> Self {
|
fn from_sorted_nodes(nodes: &[(BoundingBox<T>, Arc<dyn Primitive<T>>)]) -> Self {
|
||||||
if nodes.len() >= 2 {
|
if nodes.len() >= 2 {
|
||||||
let midpoint = nodes.len() / 2;
|
let midpoint = nodes.len() / 2;
|
||||||
let left = Arc::new(Self::from_sorted_nodes(&nodes[..midpoint]));
|
let left = Box::new(Self::from_sorted_nodes(&nodes[..midpoint]));
|
||||||
let right = Arc::new(Self::from_sorted_nodes(&nodes[midpoint..]));
|
let right = Box::new(Self::from_sorted_nodes(&nodes[midpoint..]));
|
||||||
let bounds = left.get_bounds().union(&right.get_bounds());
|
let bounds = left.get_bounds().union(&right.get_bounds());
|
||||||
BoundingVolumeHierarchy::Node {
|
BoundingVolumeHierarchy::Node {
|
||||||
bounds,
|
bounds,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue