Skip to content

Commit

Permalink
Fix graph compile error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
TrueDoctor committed Aug 9, 2024
1 parent d69cbc7 commit ec4bab1
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2065,7 +2065,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
DocumentNode {
manual_composition: Some(concrete!(Footprint)),
inputs: vec![NodeInput::node(NodeId(1), 0)],
implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("graphene_core::memo::ImpureMemoNode<_, _, _>")),
implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("graphene_core::memo::MemoNode<_, _>")),
..Default::default()
},
]
Expand Down
5 changes: 5 additions & 0 deletions editor/src/node_graph_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,11 @@ impl NodeGraphExecutor {
document.network_interface.document_metadata_mut().update_from_monitor(HashMap::new(), HashMap::new());
log::trace!("{e}");

responses.add(NodeGraphMessage::UpdateTypes {
resolved_types: ResolvedDocumentNodeTypesDelta::default(),
node_graph_errors,
});
responses.add(NodeGraphMessage::SendGraph);
return Err("Node graph evaluation failed".to_string());
}
Ok(result) => result,
Expand Down
3 changes: 2 additions & 1 deletion node-graph/gcore/src/graphic_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,9 @@ async fn construct_artboard(
let intersection = viewport_bounds.intersect(&artboard_bounds);
let offset = intersection.start;
let scale = footprint.scale();
let intersection = intersection.transformed(footprint.transform);
// let intersection = intersection.transformed(footprint.transform);
let resolution = (scale * intersection.size()).as_uvec2();
log::debug!("intersection: {intersection:?}");
log::debug!("offset: {offset:?}, resolution: {resolution:?}");

if clip {
Expand Down
8 changes: 5 additions & 3 deletions node-graph/gstd/src/raster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,15 +656,17 @@ fn noise_pattern(

// If the image would not be visible, return an empty image
if size.x <= 0. || size.y <= 0. {
log::debug!("empty size, aborting");
return ImageFrame::empty();
}

let footprint_scale = footprint.scale();
let width = (size.x * footprint_scale.x) as u32;
let height = (size.y * footprint_scale.y) as u32;
log::debug!("resolution: {:?}", footprint.resolution());
let width = footprint.resolution().x;
let height = footprint.resolution().y;
log::debug!("w: {width} h: {height}");
// log::debug!("resolution: {:?}", footprint.resolution());
// let width = footprint.resolution().x;
// let height = footprint.resolution().y;

// All
let mut image = Image::new(width, height, Color::from_luminance(0.5));
Expand Down
1 change: 0 additions & 1 deletion node-graph/gstd/src/wasm_application_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ async fn render_canvas(render_config: RenderConfig, data: impl GraphicElementRen
// TODO: Instead of applying the transform here, pass the transform during the translation to avoid the O(Nr cost
scene.append(&child, Some(kurbo::Affine::new(footprint.transform.to_cols_array())));
let resolution = footprint.resolution();
log::debug!("rendering using resolution: {resolution:?}");

exec.render_vello_scene(&scene, &surface_handle, resolution.x, resolution.y, &context)
.await
Expand Down
1 change: 1 addition & 0 deletions node-graph/interpreted-executor/src/node_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
async_node!(graphene_core::memo::MemoNode<_, _>, input: (), output: RenderOutput, params: [RenderOutput]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Footprint, output: Image<Color>, fn_params: [Footprint => Image<Color>]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Footprint, output: ImageFrame<Color>, fn_params: [Footprint => ImageFrame<Color>]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Footprint, output: TextureFrame, fn_params: [Footprint => TextureFrame]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Footprint, output: QuantizationChannels, fn_params: [Footprint => QuantizationChannels]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Footprint, output: Vec<DVec2>, fn_params: [Footprint => Vec<DVec2>]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Footprint, output: Arc<WasmSurfaceHandle>, fn_params: [Footprint => Arc<WasmSurfaceHandle>]),
Expand Down

0 comments on commit ec4bab1

Please sign in to comment.