Skip to content

Commit

Permalink
Fix path transform
Browse files Browse the repository at this point in the history
  • Loading branch information
Keavon committed Mar 2, 2025
1 parent 793ffaa commit ee15488
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 16 deletions.
3 changes: 1 addition & 2 deletions editor/src/messages/portfolio/portfolio_message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageData<'_>> for PortfolioMes
}
};

const REPLACEMENTS: [(&str, &str); 35] = [
const REPLACEMENTS: [(&str, &str); 34] = [
("graphene_core::AddArtboardNode", "graphene_core::graphic_element::AppendArtboardNode"),
("graphene_core::ConstructArtboardNode", "graphene_core::graphic_element::ToArtboardNode"),
("graphene_core::ToGraphicElementNode", "graphene_core::graphic_element::ToElementNode"),
Expand Down Expand Up @@ -488,7 +488,6 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageData<'_>> for PortfolioMes
("graphene_core::vector::SplinesFromPointsNode", "graphene_core::vector::SplineNode"),
("graphene_core::vector::generator_nodes::EllipseGenerator", "graphene_core::vector::generator_nodes::EllipseNode"),
("graphene_core::vector::generator_nodes::LineGenerator", "graphene_core::vector::generator_nodes::LineNode"),
("graphene_core::vector::generator_nodes::PathGenerator", "graphene_core::vector::generator_nodes::PathNode"),
("graphene_core::vector::generator_nodes::RectangleGenerator", "graphene_core::vector::generator_nodes::RectangleNode"),
(
"graphene_core::vector::generator_nodes::RegularPolygonGenerator",
Expand Down
14 changes: 1 addition & 13 deletions node-graph/gcore/src/vector/generator_nodes.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::vector::{HandleId, PointId, VectorData, VectorDataTable};
use crate::vector::{HandleId, VectorData, VectorDataTable};
use crate::Ctx;

use bezier_rs::Subpath;
Expand Down Expand Up @@ -105,15 +105,3 @@ fn star(
fn line(_: impl Ctx, _primary: (), #[default((0., -50.))] start: DVec2, #[default((0., 50.))] end: DVec2) -> VectorDataTable {
VectorDataTable::new(VectorData::from_subpath(Subpath::new_line(start, end)))
}

// TODO(TrueDoctor): I removed the Arc requirement we should think about when it makes sense to use it vs making a generic value node
#[node_macro::node(category(""))]
fn path(_: impl Ctx, path_data: Vec<Subpath<PointId>>, colinear_manipulators: Vec<PointId>) -> VectorDataTable {
let mut vector_data = VectorData::from_subpaths(path_data, false);
vector_data.colinear_manipulators = colinear_manipulators
.iter()
.filter_map(|&point| super::ManipulatorPointId::Anchor(point).get_handle_pair(&vector_data))
.collect();

VectorDataTable::new(vector_data)
}
6 changes: 5 additions & 1 deletion node-graph/gcore/src/vector/vector_data/modification.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use super::*;
use crate::transform::TransformMut;
use crate::uuid::generate_uuid;
use crate::Ctx;

Expand Down Expand Up @@ -425,11 +426,14 @@ impl core::hash::Hash for VectorModification {
/// A node that applies a procedural modification to some [`VectorData`].
#[node_macro::node(category(""))]
async fn path_modify(_ctx: impl Ctx, mut vector_data: VectorDataTable, modification: Box<VectorModification>) -> VectorDataTable {
let vector_data_transform = *vector_data.one_instance().transform;
let vector_data = vector_data.one_instance_mut().instance;

modification.apply(vector_data);

VectorDataTable::new(vector_data.clone())
let mut result = VectorDataTable::new(vector_data.clone());
*result.transform_mut() = vector_data_transform;
result
}

#[test]
Expand Down

0 comments on commit ee15488

Please sign in to comment.