adds naive update for light and volumes

This commit is contained in:
zomseffen 2025-03-26 11:22:22 +01:00
parent 90b16a3d5c
commit 579820334d
6 changed files with 158 additions and 52 deletions

View file

@ -17,6 +17,7 @@ use super::AppData;
use super::LightsIter;
use super::Scene;
#[derive(Clone, Debug)]
pub struct EmptyVolume {
pub memory_start: usize,
@ -49,6 +50,9 @@ pub struct EmptyVolume {
pub neighbor_front: Vec<Option<Rc<RefCell<Self>>>>,
pub scale: f32,
old_memory_size: u32,
dirty: bool,
}
impl EmptyVolume {
@ -304,6 +308,8 @@ impl EmptyVolume {
neighbor_back: vec![],
neighbor_front: vec![],
scale: tree.borrow().scale,
old_memory_size: 0,
dirty: true,
};
println!("adding neighbor references");
// MARK: fill in info in the neighbor octtree
@ -1274,7 +1280,7 @@ impl Memorizable for EmptyVolume {
mem_size
}
// MARK: insert into Memory
fn insert_into_memory(&self, mut v: Vec<u32>, data: &AppData, scene: &Scene) -> Vec<u32> {
fn insert_into_memory(&mut self, mut v: Vec<u32>, data: &AppData, scene: &Scene) -> Vec<u32> {
let mut mem_index = self.memory_start;
//pos
v[mem_index] = u32::from_ne_bytes(self.real_position.x.to_ne_bytes());
@ -1591,6 +1597,9 @@ impl Memorizable for EmptyVolume {
v[mem_index] = 0;
mem_index += 1;
}
self.dirty = false;
self.old_memory_size = self.get_buffer_mem_size(data);
//println!("last memory index of volume was {}, equivalent to {}kB", mem_index, mem_index * 32 / 8 / 1024);
v
}
@ -1602,6 +1611,13 @@ impl Memorizable for EmptyVolume {
fn set_memory_start(&mut self, memory_start: usize) {
self.memory_start = memory_start;
}
fn get_prev_buffer_mem_size(&self) -> u32 {
self.old_memory_size
}
fn is_dirty(&self) -> bool {
self.dirty
}
}
impl PartialEq for EmptyVolume {