Skip to content

Commit 3cc9dd7

Browse files
authored
Rename the Coordinate data type to Vec2 (#2959)
1 parent 4391f88 commit 3cc9dd7

File tree

7 files changed

+31
-26
lines changed

7 files changed

+31
-26
lines changed

demo-artwork/parametric-dunescape.graphite

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
851851
properties: None,
852852
},
853853
DocumentNodeDefinition {
854-
identifier: "Split Coordinate",
854+
identifier: "Split Vec2",
855855
category: "Math: Vector",
856856
node_template: NodeTemplate {
857857
document_node: DocumentNode {
@@ -882,7 +882,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
882882
..Default::default()
883883
},
884884
persistent_node_metadata: DocumentNodePersistentMetadata {
885-
input_metadata: vec![("Coordinate", "TODO").into()],
885+
input_metadata: vec![("Vec2", "TODO").into()],
886886
output_names: vec!["X".to_string(), "Y".to_string()],
887887
has_primary_output: false,
888888
network_metadata: Some(NodeNetworkMetadata {
@@ -917,7 +917,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
917917
},
918918
},
919919
description: Cow::Borrowed(
920-
"Decomposes the X and Y components of a 2D coordinate.\n\nThe inverse of this node is \"Coordinate Value\", which can have either or both its X and Y exposed as graph inputs.",
920+
"Decomposes the X and Y components of a vec2.\n\nThe inverse of this node is \"Vec2 Value\", which can have either or both its X and Y parameters exposed as graph inputs.",
921921
),
922922
properties: None,
923923
},
@@ -2042,7 +2042,7 @@ fn static_input_properties() -> InputProperties {
20422042
.and_then(|value| value.as_bool())
20432043
.unwrap_or_default();
20442044

2045-
Ok(vec![node_properties::coordinate_widget(
2045+
Ok(vec![node_properties::vec2_widget(
20462046
ParameterWidgetsInfo::new(node_id, index, true, context),
20472047
&x,
20482048
&y,
@@ -2298,7 +2298,7 @@ fn static_input_properties() -> InputProperties {
22982298
"spline_input".to_string(),
22992299
Box::new(|node_id, index, context| {
23002300
Ok(vec![LayoutGroup::Row {
2301-
widgets: node_properties::array_of_coordinates_widget(ParameterWidgetsInfo::new(node_id, index, true, context), TextInput::default().centered(true)),
2301+
widgets: node_properties::array_of_vec2_widget(ParameterWidgetsInfo::new(node_id, index, true, context), TextInput::default().centered(true)),
23022302
}])
23032303
}),
23042304
);

editor/src/messages/portfolio/document/node_graph/node_properties.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ pub(crate) fn property_from_type(
160160
Some("Fraction") => number_widget(default_info, number_input.mode_range().min(min(0.)).max(max(1.))).into(),
161161
Some("IntegerCount") => number_widget(default_info, number_input.int().min(min(1.))).into(),
162162
Some("SeedValue") => number_widget(default_info, number_input.int().min(min(0.))).into(),
163-
Some("PixelSize") => coordinate_widget(default_info, "X", "Y", unit.unwrap_or(" px"), None, false),
163+
Some("PixelSize") => vec2_widget(default_info, "X", "Y", unit.unwrap_or(" px"), None, false),
164164
Some("TextArea") => text_area_widget(default_info).into(),
165165

166166
// For all other types, use TypeId-based matching
@@ -175,13 +175,13 @@ pub(crate) fn property_from_type(
175175
Some(x) if x == TypeId::of::<u64>() => number_widget(default_info, number_input.int().min(min(0.))).into(),
176176
Some(x) if x == TypeId::of::<bool>() => bool_widget(default_info, CheckboxInput::default()).into(),
177177
Some(x) if x == TypeId::of::<String>() => text_widget(default_info).into(),
178-
Some(x) if x == TypeId::of::<DVec2>() => coordinate_widget(default_info, "X", "Y", "", None, false),
178+
Some(x) if x == TypeId::of::<DVec2>() => vec2_widget(default_info, "X", "Y", "", None, false),
179179
Some(x) if x == TypeId::of::<DAffine2>() => transform_widget(default_info, &mut extra_widgets),
180180
// ==========================
181181
// PRIMITIVE COLLECTION TYPES
182182
// ==========================
183183
Some(x) if x == TypeId::of::<Vec<f64>>() => array_of_number_widget(default_info, TextInput::default()).into(),
184-
Some(x) if x == TypeId::of::<Vec<DVec2>>() => array_of_coordinates_widget(default_info, TextInput::default()).into(),
184+
Some(x) if x == TypeId::of::<Vec<DVec2>>() => array_of_vec2_widget(default_info, TextInput::default()).into(),
185185
// ====================
186186
// GRAPHICAL DATA TYPES
187187
// ====================
@@ -626,7 +626,7 @@ pub fn transform_widget(parameter_widgets_info: ParameterWidgetsInfo, extra_widg
626626
}
627627
}
628628

629-
pub fn coordinate_widget(parameter_widgets_info: ParameterWidgetsInfo, x: &str, y: &str, unit: &str, min: Option<f64>, is_integer: bool) -> LayoutGroup {
629+
pub fn vec2_widget(parameter_widgets_info: ParameterWidgetsInfo, x: &str, y: &str, unit: &str, min: Option<f64>, is_integer: bool) -> LayoutGroup {
630630
let ParameterWidgetsInfo { document_node, node_id, index, .. } = parameter_widgets_info;
631631

632632
let mut widgets = start_widgets(parameter_widgets_info);
@@ -723,7 +723,7 @@ pub fn array_of_number_widget(parameter_widgets_info: ParameterWidgetsInfo, text
723723
widgets
724724
}
725725

726-
pub fn array_of_coordinates_widget(parameter_widgets_info: ParameterWidgetsInfo, text_props: TextInput) -> Vec<WidgetHolder> {
726+
pub fn array_of_vec2_widget(parameter_widgets_info: ParameterWidgetsInfo, text_props: TextInput) -> Vec<WidgetHolder> {
727727
let ParameterWidgetsInfo { document_node, node_id, index, .. } = parameter_widgets_info;
728728

729729
let mut widgets = start_widgets(parameter_widgets_info);
@@ -1249,7 +1249,7 @@ pub(crate) fn grid_properties(node_id: NodeId, context: &mut NodePropertiesConte
12491249
if let Some(&TaggedValue::GridType(grid_type)) = grid_type_input.as_non_exposed_value() {
12501250
match grid_type {
12511251
GridType::Rectangular => {
1252-
let spacing = coordinate_widget(ParameterWidgetsInfo::new(node_id, SpacingInput::<f64>::INDEX, true, context), "W", "H", " px", Some(0.), false);
1252+
let spacing = vec2_widget(ParameterWidgetsInfo::new(node_id, SpacingInput::<f64>::INDEX, true, context), "W", "H", " px", Some(0.), false);
12531253
widgets.push(spacing);
12541254
}
12551255
GridType::Isometric => {
@@ -1259,7 +1259,7 @@ pub(crate) fn grid_properties(node_id: NodeId, context: &mut NodePropertiesConte
12591259
NumberInput::default().label("H").min(0.).unit(" px"),
12601260
),
12611261
};
1262-
let angles = coordinate_widget(ParameterWidgetsInfo::new(node_id, AnglesInput::INDEX, true, context), "", "", "°", None, false);
1262+
let angles = vec2_widget(ParameterWidgetsInfo::new(node_id, AnglesInput::INDEX, true, context), "", "", "°", None, false);
12631263
widgets.extend([spacing, angles]);
12641264
}
12651265
}

editor/src/messages/portfolio/document_migration.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,18 @@ const NODE_REPLACEMENTS: &[NodeReplacement<'static>] = &[
186186
aliases: &["graphene_core::ops::PercentageValueNode"],
187187
},
188188
NodeReplacement {
189-
node: graphene_std::math_nodes::coordinate_value::IDENTIFIER,
189+
node: graphene_std::math_nodes::vec_2_value::IDENTIFIER,
190190
aliases: &[
191-
"graphene_core::ops::CoordinateValueNode",
192191
"graphene_core::ops::ConstructVector2",
193192
"graphene_core::ops::Vector2ValueNode",
193+
"graphene_core::ops::CoordinateValueNode",
194+
"graphene_math_nodes::CoordinateValueNode",
194195
],
195196
},
197+
NodeReplacement {
198+
node: graphene_std::vector::vec_2_to_point::IDENTIFIER,
199+
aliases: &["graphene_core::vector::PositionToPointNode"],
200+
},
196201
NodeReplacement {
197202
node: graphene_std::math_nodes::color_value::IDENTIFIER,
198203
aliases: &["graphene_core::ops::ColorValueNode"],

node-graph/gcore/src/extract_xy.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ use crate::Ctx;
22
use dyn_any::DynAny;
33
use glam::{DVec2, IVec2, UVec2};
44

5-
/// Obtains the X or Y component of a coordinate point.
5+
/// Obtains the X or Y component of a vec2.
66
///
7-
/// The inverse of this node is "Coordinate Value", which can have either or both its X and Y exposed as graph inputs.
7+
/// The inverse of this node is "Vec2 Value", which can have either or both its X and Y parameters exposed as graph inputs.
88
#[node_macro::node(name("Extract XY"), category("Math: Vector"))]
99
fn extract_xy<T: Into<DVec2>>(_: impl Ctx, #[implementations(DVec2, IVec2, UVec2)] vector: T, axis: XY) -> f64 {
1010
match axis {
@@ -13,7 +13,7 @@ fn extract_xy<T: Into<DVec2>>(_: impl Ctx, #[implementations(DVec2, IVec2, UVec2
1313
}
1414
}
1515

16-
/// The X or Y component of a coordinate.
16+
/// The X or Y component of a vec2.
1717
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, DynAny, node_macro::ChoiceType, specta::Type, serde::Serialize, serde::Deserialize)]
1818
#[widget(Dropdown)]
1919
pub enum XY {

node-graph/gcore/src/vector/vector_nodes.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -931,13 +931,13 @@ async fn dimensions(_: impl Ctx, vector_data: VectorDataTable) -> DVec2 {
931931
.unwrap_or_default()
932932
}
933933

934-
/// Converts a coordinate value into a vector anchor point.
934+
/// Converts a vec2 value into a vector path composed of a single anchor point.
935935
///
936936
/// This is useful in conjunction with nodes that repeat it, followed by the "Points to Polyline" node to string together a path of the points.
937-
#[node_macro::node(category("Vector"), name("Coordinate to Point"), path(graphene_core::vector))]
938-
async fn position_to_point(_: impl Ctx, coordinate: DVec2) -> VectorDataTable {
937+
#[node_macro::node(category("Vector"), name("Vec2 to Point"), path(graphene_core::vector))]
938+
async fn vec2_to_point(_: impl Ctx, vec2: DVec2) -> VectorDataTable {
939939
let mut point_domain = PointDomain::new();
940-
point_domain.push(PointId::generate(), coordinate);
940+
point_domain.push(PointId::generate(), vec2);
941941

942942
VectorDataTable::new_instance(Instance {
943943
instance: VectorData { point_domain, ..Default::default() },

node-graph/gmath-nodes/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ fn cosine_inverse<U: num_traits::float::Float>(
286286

287287
/// The inverse tangent trigonometric function (atan or atan2, depending on input type) calculates:
288288
/// atan: the angle whose tangent is the specified scalar number.
289-
/// atan2: the angle of a ray from the origin to the specified coordinate.
289+
/// atan2: the angle of a ray from the origin to the specified vec2.
290290
///
291291
/// The resulting angle is always in the range [0°, 180°] or, in radians, [-π/2, π/2].
292292
#[node_macro::node(category("Math: Trig"))]
@@ -651,9 +651,9 @@ fn percentage_value(_: impl Ctx, _primary: (), percentage: Percentage) -> f64 {
651651
percentage
652652
}
653653

654-
/// Constructs a two-dimensional vector value which may be set to any XY coordinate.
655-
#[node_macro::node(category("Value"))]
656-
fn coordinate_value(_: impl Ctx, _primary: (), x: f64, y: f64) -> DVec2 {
654+
/// Constructs a two-dimensional vector value which may be set to any XY pair.
655+
#[node_macro::node(category("Value"), name("Vec2 Value"))]
656+
fn vec2_value(_: impl Ctx, _primary: (), x: f64, y: f64) -> DVec2 {
657657
DVec2::new(x, y)
658658
}
659659

0 commit comments

Comments
 (0)