Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"lint": "biome check .",
"lint:fix": "biome check . --fix",
"lint:summary": "biome check --reporter=summary",
"lint:rust": "cargo clippy --manifest-path rust/Cargo.toml",
"site:build:relativeurls": "npm run build && npm run site:clean && node scripts/copy-site-files.js && mkdocs build && node scripts/rename-assets-to-static.js && node scripts/replace-urls.js",
"site:build": "npm run build && npm run site:clean && node scripts/copy-site-files.js && mkdocs build && node scripts/rename-assets-to-static.js",
"site:clean": "node scripts/clean-site-files.js && node scripts/clean-site.js",
Expand Down
4 changes: 2 additions & 2 deletions rust/build-lod/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ fn process_file_lod(filename: &str, options: &BuildLodOptions) {
}

fn process_file_lod_tsplat<TS: SplatReceiver + TsplatArray + SplatGetter>(filename: &str, options: &BuildLodOptions, splats: TS) {
let mut decoder = MultiDecoder::new(splats, None, Some(&filename));
let mut splats = match read_file_chunks(&filename, &mut decoder) {
let mut decoder = MultiDecoder::new(splats, None, Some(filename));
let mut splats = match read_file_chunks(filename, &mut decoder) {
Ok(_) => {
println!("Detected file type: {:?}", decoder.file_type.unwrap());
decoder.into_splats()
Expand Down
4 changes: 2 additions & 2 deletions rust/spark-lib/src/bhatt_lod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub fn compute_lod_tree<TA: TsplatArray>(splats: &mut TA, lod_base: f32, logger:

splats.sort_by(|s| s.feature_size());
splats.prepare_children();
logger(&format!("Sorted and prepared splats"));
logger("Sorted and prepared splats");

let mut is_active = Vec::with_capacity(splats.len() * 2 - 1);
is_active.resize(splats.len(), true);
Expand Down Expand Up @@ -235,7 +235,7 @@ pub fn compute_lod_tree<TA: TsplatArray>(splats: &mut TA, lod_base: f32, logger:
if next_frontier.is_empty() {
break;
}
limit_size = limit_size / 4.0;
limit_size /= 4.0;
frontier = next_frontier;
}

Expand Down
4 changes: 2 additions & 2 deletions rust/spark-lib/src/chunk_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ pub fn chunk_tree_size<TA: TsplatArray>(splats: &mut TA, root: usize, logger: im
println!("octant lengths: {:?}", octants.iter().map(|o| o.len()).collect::<Vec<usize>>());

// Resort into Hilbert order
let mut octants = octants.into_iter().map(|o| Some(o)).collect::<Vec<_>>();
let mut octants = octants.into_iter().map(Some).collect::<Vec<_>>();
let octants = [0, 1, 3, 2, 6, 7, 5, 4].map(|i| octants[i].take().unwrap());
for batch in octants {
batches.push_back(batch);
Expand Down Expand Up @@ -638,7 +638,7 @@ pub fn chunk_tree_morton<TA: TsplatArray>(splats: &mut TA, root: usize, logger:
println!("octant lengths: {:?}", octants.iter().map(|o| o.len()).collect::<Vec<usize>>());

// Resort into Hilbert order
let mut octants = octants.into_iter().map(|o| Some(o)).collect::<Vec<_>>();
let mut octants = octants.into_iter().map(Some).collect::<Vec<_>>();
let octants = [0, 1, 3, 2, 6, 7, 5, 4].map(|i| octants[i].take().unwrap());
for batch in octants {
batches.push_back(batch);
Expand Down
22 changes: 11 additions & 11 deletions rust/spark-lib/src/csplat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl TsplatArray for CsplatArray {
}

fn prepare_children(&mut self) {
self.children.resize_with(self.len(), || SmallVec::new());
self.children.resize_with(self.len(), SmallVec::new);
}

fn has_children(&self) -> bool {
Expand Down Expand Up @@ -324,7 +324,7 @@ impl TsplatArray for CsplatArray {
}

fn retain<F: (FnMut(CsplatRefMut<'_>) -> bool)>(&mut self, mut f: F) {
let keep: Vec<bool> = self.splats.iter_mut().map(|splat| f(CsplatRefMut { splat: splat, encoding: &self.encoding })).collect();
let keep: Vec<bool> = self.splats.iter_mut().map(|splat| f(CsplatRefMut { splat, encoding: &self.encoding })).collect();
let mut bits = keep.iter();

self.splats.retain(|_splat| *bits.next().unwrap());
Expand Down Expand Up @@ -352,9 +352,9 @@ impl TsplatArray for CsplatArray {
.map(|(i, splat)| {
if let Some(children) = self.children.get(i) {
let children: SmallVec<[usize; 4]> = children.iter().map(|&i| i as usize).collect();
f(CsplatRefMut { splat: splat, encoding: &encoding }, &children)
f(CsplatRefMut { splat, encoding: &encoding }, &children)
} else {
f(CsplatRefMut { splat: splat, encoding: &encoding }, &[])
f(CsplatRefMut { splat, encoding: &encoding }, &[])
}
})
.collect();
Expand Down Expand Up @@ -417,11 +417,11 @@ impl TsplatArray for CsplatArray {
Self {
encoding: self.encoding.clone(),
max_sh_degree: self.max_sh_degree,
splats: index_map.iter().map(|&i| self.splats[i as usize].clone()).collect(),
children: if !self.children.is_empty() { index_map.iter().map(|&i| self.children[i as usize].clone()).collect() } else { Vec::new() },
sh1: if !self.sh1.is_empty() { index_map.iter().map(|&i| self.sh1[i as usize].clone()).collect() } else { Vec::new() },
sh2: if !self.sh2.is_empty() { index_map.iter().map(|&i| self.sh2[i as usize].clone()).collect() } else { Vec::new() },
sh3: if !self.sh3.is_empty() { index_map.iter().map(|&i| self.sh3[i as usize].clone()).collect() } else { Vec::new() },
splats: index_map.iter().map(|&i| self.splats[i].clone()).collect(),
children: if !self.children.is_empty() { index_map.iter().map(|&i| self.children[i].clone()).collect() } else { Vec::new() },
sh1: if !self.sh1.is_empty() { index_map.iter().map(|&i| self.sh1[i].clone()).collect() } else { Vec::new() },
sh2: if !self.sh2.is_empty() { index_map.iter().map(|&i| self.sh2[i].clone()).collect() } else { Vec::new() },
sh3: if !self.sh3.is_empty() { index_map.iter().map(|&i| self.sh3[i].clone()).collect() } else { Vec::new() },
}
}

Expand Down Expand Up @@ -457,7 +457,7 @@ impl SplatReceiver for CsplatArray {
self.sh3.reserve(est_lod_size);
}
} else {
self.children.resize_with(init.num_splats, || SmallVec::new());
self.children.resize_with(init.num_splats, SmallVec::new);
}

self.splats.resize_with(init.num_splats, Default::default);
Expand Down Expand Up @@ -623,7 +623,7 @@ impl SplatReceiver for CsplatArray {

fn set_child_count(&mut self, base: usize, count: usize, child_count: &[u16]) {
for i in 0..count {
let mut child_index = *self.children[base + i].get(0).unwrap_or(&0);
let mut child_index = *self.children[base + i].first().unwrap_or(&0);
self.children[base + i].clear();
self.children[base + i].resize_with(child_count[i] as usize, || {
let child = child_index;
Expand Down
52 changes: 4 additions & 48 deletions rust/spark-lib/src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,13 @@ impl dyn ChunkReceiver {
pub fn into_any(self: Box<Self>) -> Box<dyn Any> { self }
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct SplatInit {
pub num_splats: usize,
pub max_sh_degree: usize,
pub lod_tree: bool,
}

impl Default for SplatInit {
fn default() -> Self {
Self {
num_splats: 0,
max_sh_degree: 0,
lod_tree: false,
}
}
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SplatEncoding {
#[serde(rename = "rgbMin")]
Expand Down Expand Up @@ -108,7 +98,7 @@ impl From<SplatEncoding> for SetSplatEncoding {
}
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct SplatProps<'a> {
pub center: &'a [f32],
pub opacity: &'a [f32],
Expand All @@ -122,23 +112,6 @@ pub struct SplatProps<'a> {
pub child_start: &'a [usize],
}

impl<'a> Default for SplatProps<'a> {
fn default() -> Self {
Self {
center: &[],
opacity: &[],
rgb: &[],
scale: &[],
quat: &[],
sh1: &[],
sh2: &[],
sh3: &[],
child_count: &[],
child_start: &[],
}
}
}

#[allow(unused)]
pub trait SplatReceiver: 'static {
fn init_splats(&mut self, init: &SplatInit) -> anyhow::Result<()> { Ok(()) }
Expand Down Expand Up @@ -239,7 +212,7 @@ impl SplatPropsArray {
}
}

#[derive(Debug)]
#[derive(Debug, Default)]
pub struct SplatPropsMut<'a> {
pub center: &'a mut [f32],
pub opacity: &'a mut [f32],
Expand All @@ -253,23 +226,6 @@ pub struct SplatPropsMut<'a> {
pub child_start: &'a mut [usize],
}

impl<'a> Default for SplatPropsMut<'a> {
fn default() -> Self {
Self {
center: &mut [],
opacity: &mut [],
rgb: &mut [],
scale: &mut [],
quat: &mut [],
sh1: &mut [],
sh2: &mut [],
sh3: &mut [],
child_count: &mut [],
child_start: &mut [],
}
}
}

#[allow(unused)]
pub trait SplatGetter: 'static {
// Source/format metadata (header-like)
Expand Down Expand Up @@ -382,7 +338,7 @@ impl SplatFileType {
let clean_path = clean_path
.split_once('#')
.map_or(clean_path, |(path, _)| path);
clean_path.split('.').last().and_then(Self::from_extension)
clean_path.split('.').next_back().and_then(Self::from_extension)
}
}

Expand Down
Loading
Loading