Fix fill tool on raster image temporarily breaking the graph (#2398)

* Fix fill tool on raster image temporarily breaks the graph

* Avoid vector filling raster layer via checking node category

* check raster image using input type instead

* Add additional check for TextureFrameTable

* Enable the ignore raster test

---------

Co-authored-by: hypercube <0hypercube@gmail.com>
This commit is contained in:
Ellen Gu
2025-03-09 19:18:42 +00:00
committed by GitHub
co-authored by hypercube
parent 56662339cc
commit 74b6abbb97
11 changed files with 35 additions and 13 deletions
@@ -5,6 +5,7 @@ use crate::messages::portfolio::document::utility_types::network_interface::{Flo
use crate::messages::prelude::*;
use bezier_rs::Subpath;
use graph_craft::concrete;
use graph_craft::document::{value::TaggedValue, NodeId, NodeInput};
use graphene_core::raster::image::ImageFrameTable;
use graphene_core::raster::BlendMode;
@@ -417,4 +418,16 @@ impl<'a> NodeGraphLayer<'a> {
// TODO: Find a better way to accept a node input rather than using its index (which is quite unclear and fragile)
self.find_node_inputs(node_name)?.get(index)?.as_value()
}
/// Check if a layer is a raster layer
pub fn is_raster_layer(layer: LayerNodeIdentifier, network_interface: &mut NodeNetworkInterface) -> bool {
let layer_input_type = network_interface.input_type(&InputConnector::node(layer.to_node(), 1), &[]).0.nested_type();
if layer_input_type == concrete!(graphene_core::raster::image::ImageFrameTable<graphene_core::Color>)
|| layer_input_type == concrete!(graphene_core::application_io::TextureFrameTable)
|| layer_input_type == concrete!(graphene_std::RasterFrame)
{
return true;
}
false
}
}
@@ -89,7 +89,7 @@ impl AlignmentSnapper {
if let Some(point_on_x) = point_on_x {
let distance_to_snapped = point.document_point.distance(point_on_x);
let distance_to_align_target = point_on_x.distance(target_position);
if distance_to_snapped < tolerance && snap_x.as_ref().map_or(true, |point| distance_to_align_target < point.distance_to_align_target) {
if distance_to_snapped < tolerance && snap_x.as_ref().is_none_or(|point| distance_to_align_target < point.distance_to_align_target) {
snap_x = Some(SnappedPoint {
snapped_point_document: point_on_x,
source: point.source, // TODO(0Hypercube): map source
@@ -108,7 +108,7 @@ impl AlignmentSnapper {
if let Some(point_on_y) = point_on_y {
let distance_to_snapped = point.document_point.distance(point_on_y);
let distance_to_align_target = point_on_y.distance(target_position);
if distance_to_snapped < tolerance && snap_y.as_ref().map_or(true, |point| distance_to_align_target < point.distance_to_align_target) {
if distance_to_snapped < tolerance && snap_y.as_ref().is_none_or(|point| distance_to_align_target < point.distance_to_align_target) {
snap_y = Some(SnappedPoint {
snapped_point_document: point_on_y,
source: point.source, // TODO(0Hypercube): map source