Skip to content
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

Don't block window thread when compiling model #1244

Merged
merged 33 commits into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
71fa8ab
Clean up imports
hannobraun Oct 20, 2022
04fc3d3
Pass `Parameters` into `Model` constructor
hannobraun Oct 20, 2022
a966458
Add `Watcher::watch_model`
hannobraun Oct 20, 2022
dc2aeed
Remove `Model::load_and_watch`
hannobraun Oct 20, 2022
a09d89c
Rename `Model::from_path`
hannobraun Oct 20, 2022
9f1387f
Add `Model::src_path`
hannobraun Oct 20, 2022
ef7b738
Move `Watcher` to dedicated module
hannobraun Oct 20, 2022
fdd9931
Move `Parameters` to dedicated module
hannobraun Oct 20, 2022
2c2276c
Add `Host::take_model`
hannobraun Oct 20, 2022
9cd84ca
Add `Host::new`
hannobraun Oct 20, 2022
09edeba
Move `Host` to dedicated directory
hannobraun Oct 20, 2022
a3cd201
Move `Model` to dedicated directory
hannobraun Oct 20, 2022
c6e6352
Simplify method name
hannobraun Oct 20, 2022
70fa374
Simplify variable name
hannobraun Oct 20, 2022
69f2bff
Fix duplicate command execution
hannobraun Oct 20, 2022
3b48b28
Refactor
hannobraun Oct 20, 2022
b38ebba
Refactor
hannobraun Oct 20, 2022
d1fa537
Add dependency on `crossbeam-channel` to `fj-host`
hannobraun Oct 20, 2022
d9ba12e
Make use of `crossbeam-channel`
hannobraun Oct 20, 2022
9d3abdd
Return richer error information from `Model::load`
hannobraun Oct 20, 2022
a03ea4c
Refactor
hannobraun Oct 20, 2022
a691ea6
Return metadata from `Model::load`
hannobraun Oct 20, 2022
9292058
Create compile time status update in `Watcher`
hannobraun Oct 20, 2022
9298a35
Don't clear status before adding error
hannobraun Oct 20, 2022
8adaba8
Provide `Watcher` status updates via channel
hannobraun Oct 20, 2022
a7ceb63
Provide loaded shapes via channel
hannobraun Oct 20, 2022
bd38060
Provide `Watcher` errors via channel
hannobraun Oct 20, 2022
19bdf80
Make variable names more explicit
hannobraun Oct 20, 2022
4d88782
Expand comment
hannobraun Oct 20, 2022
16a097b
Derive `Debug` for `ProcessedShape`
hannobraun Oct 20, 2022
1164997
Be more explicit on how to init camera plances
hannobraun Oct 20, 2022
edca148
Don't block window thread when compiling model
hannobraun Oct 20, 2022
413524c
Remove unnecessary channel buffer
hannobraun Oct 20, 2022
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 Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions crates/fj-app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use std::path::PathBuf;

use anyhow::{anyhow, Context as _};
use fj_export::export;
use fj_host::{Model, Parameters};
use fj_host::{Model, Parameters, Watcher};
use fj_interop::status_report::StatusReport;
use fj_operations::shape_processor::ShapeProcessor;
use fj_window::run::run;
Expand All @@ -29,7 +29,7 @@ use tracing_subscriber::EnvFilter;
use crate::{args::Args, config::Config};

fn main() -> anyhow::Result<()> {
let mut status = StatusReport::new();
let status = StatusReport::new();
// Respect `RUST_LOG`. If that's not defined or erroneous, log warnings and
// above.
//
Expand Down Expand Up @@ -58,7 +58,7 @@ fn main() -> anyhow::Result<()> {
{
let mut model_path = path;
model_path.push(model);
Model::from_path(model_path.clone()).with_context(|| {
Model::new(model_path.clone(), parameters).with_context(|| {
if path_of_model.as_os_str().is_empty() {
format!(
"Model is not defined, can't find model defined inside the default-model also, add model like \n cargo run -- -m {}", model.display()
Expand All @@ -80,8 +80,8 @@ fn main() -> anyhow::Result<()> {
if let Some(export_path) = args.export {
// export only mode. just load model, process, export and exit

let shape = model.load_once(&parameters, &mut status)?;
let shape = shape_processor.process(&shape)?;
let shape = model.load()?;
let shape = shape_processor.process(&shape.shape)?;

export(&shape.mesh, &export_path)?;

Expand All @@ -90,7 +90,7 @@ fn main() -> anyhow::Result<()> {

let invert_zoom = config.invert_zoom.unwrap_or(false);

let watcher = model.load_and_watch(parameters)?;
let watcher = Watcher::watch_model(model)?;
run(watcher, shape_processor, status, invert_zoom)?;

Ok(())
Expand Down
1 change: 1 addition & 0 deletions crates/fj-host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ categories.workspace = true

[dependencies]
cargo_metadata = "0.15.0"
crossbeam-channel = "0.5.6"
fj.workspace = true
fj-interop.workspace = true
libloading = "0.7.2"
Expand Down
31 changes: 31 additions & 0 deletions crates/fj-host/src/host.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use crate::Parameters;

pub struct Host<'a> {
args: &'a Parameters,
model: Option<Box<dyn fj::models::Model>>,
}

impl<'a> Host<'a> {
pub fn new(parameters: &'a Parameters) -> Self {
Self {
args: parameters,
model: None,
}
}

pub fn take_model(&mut self) -> Option<Box<dyn fj::models::Model>> {
self.model.take()
}
}

impl<'a> fj::models::Host for Host<'a> {
fn register_boxed_model(&mut self, model: Box<dyn fj::models::Model>) {
self.model = Some(model);
}
}

impl<'a> fj::models::Context for Host<'a> {
fn get_argument(&self, name: &str) -> Option<&str> {
self.args.get(name).map(|s| s.as_str())
}
}
Loading