diff --git a/editor/src/messages/portfolio/document/document_message_handler.rs b/editor/src/messages/portfolio/document/document_message_handler.rs index 6402f609fd..d3fa3f0f4c 100644 --- a/editor/src/messages/portfolio/document/document_message_handler.rs +++ b/editor/src/messages/portfolio/document/document_message_handler.rs @@ -1401,17 +1401,11 @@ impl MessageHandler> for DocumentMes self.network_interface.update_first_element_source_id(first_element_source_id); } DocumentMessage::UpdateClickTargets { click_targets } => { - // TODO: Allow non layer nodes to have click targets let layer_click_targets = click_targets .into_iter() - .filter(|(node_id, _)| - // Ensure that the layer is in the document network to prevent logging an error - self.network_interface.document_network().nodes.contains_key(node_id)) - .filter_map(|(node_id, click_targets)| { - self.network_interface.is_layer(&node_id, &[]).then(|| { - let layer = LayerNodeIdentifier::new(node_id, &self.network_interface); - (layer, click_targets) - }) + .map(|(node_id, click_targets)| { + let layer = LayerNodeIdentifier::new_unchecked(node_id); + (layer, click_targets) }) .collect(); self.network_interface.update_click_targets(layer_click_targets); diff --git a/editor/src/messages/portfolio/document/utility_types/network_interface.rs b/editor/src/messages/portfolio/document/utility_types/network_interface.rs index a44c790207..58c415ef0f 100644 --- a/editor/src/messages/portfolio/document/utility_types/network_interface.rs +++ b/editor/src/messages/portfolio/document/utility_types/network_interface.rs @@ -1168,7 +1168,8 @@ impl NodeNetworkInterface { /// Calculates the document bounds in document space pub fn document_bounds_document_space(&self, include_artboards: bool) -> Option<[DVec2; 2]> { - self.document_metadata + let all_layers_bounds = self + .document_metadata .all_layers() .filter(|layer| include_artboards || !self.is_artboard(&layer.to_node(), &[])) .filter_map(|layer| { @@ -1190,7 +1191,34 @@ impl NodeNetworkInterface { } self.document_metadata.bounding_box_document(layer) }) - .reduce(Quad::combine_bounds) + .reduce(Quad::combine_bounds); + + let root_artwork_bounds = self.document_metadata().bounding_box_document(LayerNodeIdentifier::ROOT_PARENT); + + let non_layer_export_bounds = self + .document_network() + .exports + .iter() + .filter_map(|export| { + if let NodeInput::Node { node_id, .. } = export { + if !self.is_layer(node_id, &[]) { + return self.document_metadata().bounding_box_document(LayerNodeIdentifier::new_unchecked(*node_id)); + } + } + None + }) + .reduce(Quad::combine_bounds); + + match (all_layers_bounds, root_artwork_bounds, non_layer_export_bounds) { + (Some(a), Some(b), Some(c)) => Some(Quad::combine_bounds(Quad::combine_bounds(a, b), c)), + (Some(a), Some(b), None) => Some(Quad::combine_bounds(a, b)), + (Some(a), None, Some(c)) => Some(Quad::combine_bounds(a, c)), + (None, Some(b), Some(c)) => Some(Quad::combine_bounds(b, c)), + (Some(a), None, None) => Some(a), + (None, Some(b), None) => Some(b), + (None, None, Some(c)) => Some(c), + (None, None, None) => None, + } } /// Calculates the selected layer bounds in document space diff --git a/node-graph/nodes/gstd/src/render_node.rs b/node-graph/nodes/gstd/src/render_node.rs index 6f09b8835c..775b6a98aa 100644 --- a/node-graph/nodes/gstd/src/render_node.rs +++ b/node-graph/nodes/gstd/src/render_node.rs @@ -57,7 +57,7 @@ async fn render_intermediate<'a: 'n, T: 'static + Render + WasmNotSend + Send + let footprint = Footprint::default(); let mut metadata = RenderMetadata::default(); - data.collect_metadata(&mut metadata, footprint, None); + data.collect_metadata(&mut metadata, footprint, Some(graph_craft::document::NodeId(0))); let contains_artboard = data.contains_artboard(); match &render_params.render_output_type {