Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -1401,17 +1401,11 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand All @@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The transform_to_viewport doesn't work for the LayerNodeIdentifier::ROOT_PARENT for legacy reasons. This causes the bounds here to be incorrect.

pub fn transform_to_viewport(&self, layer: LayerNodeIdentifier) -> DAffine2 {
// We're not allowed to convert the root parent to a node id
if layer == LayerNodeIdentifier::ROOT_PARENT {
return self.document_to_viewport;
}


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);
Comment on lines +1198 to +1210
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't do anything since only layers are put into the bounding box. This is always None.


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
Expand Down
2 changes: 1 addition & 1 deletion node-graph/nodes/gstd/src/render_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down