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
8 changes: 5 additions & 3 deletions rust/build-lod/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ fn process_file_lod_tsplat<TS: SplatReceiver + TsplatArray + SplatGetter>(filena
}

if let Some(max_sh) = options.max_sh {
splats.set_max_sh_degree(max_sh);
description.insert("max_sh_degree".to_string(), serde_json::Value::Number(max_sh.into()));
splats.clamp_sh_degree(max_sh);
description.insert("clamp_sh_degree".to_string(), serde_json::Value::Number(max_sh.into()));
}

if let Some(min_box) = options.min_box {
Expand Down Expand Up @@ -242,7 +242,9 @@ fn process_file_lod_tsplat<TS: SplatReceiver + TsplatArray + SplatGetter>(filena
let chunk_duration = start_time.elapsed();
description.insert("chunk_duration".to_string(), serde_json::Number::from_f64(chunk_duration.as_secs_f64()).into());

let num_sh = TsplatArray::max_sh_degree(&splats).min(options.max_sh.unwrap_or(3));
let num_sh = TsplatArray::max_sh_degree(&splats);
description.insert("max_sh_degree".to_string(), serde_json::Value::Number(num_sh.into()));

let mut sh_clusters = None;
if let Some(num_iterations) = options.cluster_sh {
if num_sh > 0 {
Expand Down
5 changes: 3 additions & 2 deletions rust/spark-lib/src/csplat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ impl TsplatArray for CsplatArray {
self.max_sh_degree
}

fn set_max_sh_degree(&mut self, max_sh_degree: usize) {
fn clamp_sh_degree(&mut self, max_sh_degree: usize) {
assert!(max_sh_degree <= 3, "SH degrees must be between 0 and 3");
self.max_sh_degree = max_sh_degree;
let max_sh_degree = max_sh_degree.min(self.max_sh_degree);

if max_sh_degree < 3 {
self.sh3.clear();
Expand All @@ -176,6 +176,7 @@ impl TsplatArray for CsplatArray {
if max_sh_degree < 1 {
self.sh1.clear();
}
self.max_sh_degree = max_sh_degree;
}

fn len(&self) -> usize {
Expand Down
5 changes: 3 additions & 2 deletions rust/spark-lib/src/gsplat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,9 @@ impl TsplatArray for GsplatArray {
self.max_sh_degree
}

fn set_max_sh_degree(&mut self, max_sh_degree: usize) {
fn clamp_sh_degree(&mut self, max_sh_degree: usize) {
assert!(max_sh_degree <= 3, "SH degrees must be between 0 and 3");
self.max_sh_degree = max_sh_degree;
let max_sh_degree = max_sh_degree.min(self.max_sh_degree);

if max_sh_degree < 3 {
self.sh3.clear();
Expand All @@ -266,6 +266,7 @@ impl TsplatArray for GsplatArray {
if max_sh_degree < 1 {
self.sh1.clear();
}
self.max_sh_degree = max_sh_degree;
}

fn len(&self) -> usize {
Expand Down
2 changes: 1 addition & 1 deletion rust/spark-lib/src/tsplat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub trait TsplatArray {
fn new_capacity(capacity: usize, max_sh_degree: usize) -> Self;

fn max_sh_degree(&self) -> usize;
fn set_max_sh_degree(&mut self, max_sh_degree: usize);
fn clamp_sh_degree(&mut self, max_sh_degree: usize);

fn len(&self) -> usize;
fn get(&self, index: usize) -> Self::Splat<'_>;
Expand Down
Loading