-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add 'proper' argument parsing #71
Closed
Closed
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
bebc234
feat: add 'proper' argument parsing
cs50victor 620804d
Merge branch 'mosure:main' into feat/clap
cs50victor 07d81d0
chore: update details and add minor docs
cs50victor 487507b
Merge branch 'main' into feat/clap
mosure efc63c9
Merge branch 'main' into feat/clap
mosure File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,35 @@ | ||
// #[cfg(target_arch = "wasm32")] | ||
// pub use wasm_bindgen_rayon::init_thread_pool; | ||
use clap::Parser; | ||
|
||
#[cfg(target_arch = "wasm32")] | ||
use wasm_bindgen::prelude::*; | ||
#[cfg(target_arch = "wasm32")] | ||
use std::collections::HashMap; | ||
#[cfg(target_arch = "wasm32")] | ||
use wasm_bindgen::prelude::*; | ||
|
||
#[cfg(not(target_arch = "wasm32"))] | ||
#[derive(Debug, Parser)] | ||
#[command(about = "bevy gaussian splatting render pipeline plugin", version, long_about = None)] | ||
struct CliArgs { | ||
/// number of random gaussians to generate | ||
#[arg(short, long)] | ||
num_of_gaussians: Option<usize>, | ||
|
||
/// number of random particle behaviors to generate | ||
#[arg(short = 'p', long)] | ||
num_of_particle_behaviors: Option<usize>, | ||
|
||
/// .gcloud or .ply file to load | ||
#[arg(short = 'f', long)] | ||
filename: Option<String>, | ||
} | ||
|
||
#[derive(Debug, Clone, Copy)] | ||
pub enum MainArgs { | ||
NumOfGaussians = 1, | ||
NumOfParticleBehaviors, | ||
Filename, | ||
} | ||
|
||
pub fn setup_hooks() { | ||
#[cfg(debug_assertions)] | ||
|
@@ -15,14 +39,18 @@ pub fn setup_hooks() { | |
} | ||
} | ||
|
||
|
||
#[cfg(not(target_arch = "wasm32"))] | ||
pub fn get_arg(n: usize) -> Option<String> { | ||
std::env::args().nth(n) | ||
pub fn get_arg(arg: MainArgs) -> Option<String> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. converting this function to: |
||
let args = CliArgs::parse(); | ||
match arg { | ||
MainArgs::NumOfGaussians => args.num_of_gaussians.map(|n| n.to_string()), | ||
MainArgs::NumOfParticleBehaviors => args.num_of_particle_behaviors.map(|n| n.to_string()), | ||
MainArgs::Filename => args.filename, | ||
} | ||
} | ||
|
||
#[cfg(target_arch = "wasm32")] | ||
pub fn get_arg(n: usize) -> Option<String> { | ||
pub fn get_arg(arg: MainArgs) -> Option<String> { | ||
let window = web_sys::window()?; | ||
let location = window.location(); | ||
let search = location.search().ok()?; | ||
|
@@ -35,5 +63,11 @@ pub fn get_arg(n: usize) -> Option<String> { | |
.map(|v| (v[0].to_string(), v[1].to_string())) | ||
.collect::<std::collections::HashMap<_, _>>(); | ||
|
||
args.get(&format!("arg{}", n)).cloned() | ||
let arg_value = args.get(&format!("arg{}", arg as u8)).cloned(); | ||
match arg { | ||
MainArgs::NumOfGaussians | MainArgs::NumOfParticleBehaviors => { | ||
arg_value.and_then(|a| a.parse::<usize>().ok().map(|_| a)) | ||
} | ||
_ => arg_value, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think merging
CliArgs
andGaussianSplattingViewer
structs would be great (can happen in a future PR though, let me know your bandwidth):bevy_gaussian_splatting/viewer/viewer.rs
Line 47 in 0c28bac
e.g. this allows args like
--height
,--width
,--hide_fps
,--hide_editor
, etc.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as for bandwidth, I plan on working / contributing on this project long term. I'll play around with merging the structs and see how it goes.