Skip to content

Commit 7256a28

Browse files
committed
Final code review
1 parent a913b21 commit 7256a28

3 files changed

Lines changed: 27 additions & 28 deletions

File tree

editor/src/messages/portfolio/document/graph_operation/utility_types.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,6 @@ impl<'a> ModifyInputsContext<'a> {
175175
.node_template_input_override([
176176
Some(NodeInput::value(TaggedValue::Graphic(Default::default()), true)),
177177
Some(NodeInput::value(TaggedValue::F64(0.5), false)),
178-
None,
179-
None,
180-
Some(NodeInput::value(TaggedValue::Vector(Default::default()), false)),
181178
]);
182179

183180
let morph_id = NodeId::new();

editor/src/messages/portfolio/document_migration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1744,7 +1744,7 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
17441744
let count_elements_template = count_elements_def.default_node_template();
17451745
let count_elements_id = NodeId::new();
17461746

1747-
// Create Subtract node: N - 1 → N-1
1747+
// Create Subtract node: N → N-1
17481748
let Some(subtract_def) = resolve_document_node_type(&DefinitionIdentifier::ProtoNode(graphene_std::math_nodes::subtract::IDENTIFIER)) else {
17491749
log::error!("Could not get subtract node from definition when upgrading morph");
17501750
document.network_interface.set_input(&InputConnector::node(*node_id, 1), old_inputs[1].clone(), network_path);

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

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -364,13 +364,13 @@ async fn round_corners(
364364
}
365365

366366
// Not the prettiest, but it makes the rest of the logic more readable
367-
let prev_idx = if i == 0 { if is_closed { manipulator_groups.len() - 1 } else { 0 } } else { i - 1 };
368-
let curr_idx = i;
369-
let next_idx = if i == manipulator_groups.len() - 1 { if is_closed { 0 } else { i } } else { i + 1 };
367+
let prev_index = if i == 0 { if is_closed { manipulator_groups.len() - 1 } else { 0 } } else { i - 1 };
368+
let curr_index = i;
369+
let next_index = if i == manipulator_groups.len() - 1 { if is_closed { 0 } else { i } } else { i + 1 };
370370

371-
let prev = manipulator_groups[prev_idx].anchor;
372-
let curr = manipulator_groups[curr_idx].anchor;
373-
let next = manipulator_groups[next_idx].anchor;
371+
let prev = manipulator_groups[prev_index].anchor;
372+
let curr = manipulator_groups[curr_index].anchor;
373+
let next = manipulator_groups[next_index].anchor;
374374

375375
let dir1 = (curr - prev).normalize_or(DVec2::X);
376376
let dir2 = (next - curr).normalize_or(DVec2::X);
@@ -379,7 +379,7 @@ async fn round_corners(
379379

380380
// Skip near-straight corners
381381
if theta > PI - min_angle_threshold.to_radians() {
382-
new_manipulator_groups.push(manipulator_groups[curr_idx]);
382+
new_manipulator_groups.push(manipulator_groups[curr_index]);
383383
continue;
384384
}
385385

@@ -2032,22 +2032,22 @@ async fn offset_points(
20322032

20332033
/// Interpolates the geometry, appearance, and transform between multiple vector layers, producing a single morphed vector shape.
20342034
///
2035-
/// Progression [0, 1) morphs through all objects at uniform speed. A path may be provided to control the trajectory between key objects. The **Origins to Polyline** node may be used to create a path with anchor points corresponding to each object. Other nodes can modify its path segments.
2035+
/// *Progression* morphs through all objects. Interpolation is linear unless *Path* geometry is provided to control the trajectory between key objects. The **Origins to Polyline** node may be used to create a path with anchor points corresponding to each object. Other nodes can modify its path segments.
20362036
#[node_macro::node(category("Vector: Modifier"), path(core_types::vector))]
20372037
async fn morph<I: IntoGraphicTable + 'n + Send + Clone>(
20382038
_: impl Ctx,
20392039
/// The vector objects to interpolate between. Mixed graphic content is deeply flattened to keep only vector elements.
20402040
#[implementations(Table<Graphic>, Table<Vector>)]
20412041
content: I,
2042-
/// The fractional part [0, 1) traverses the morph uniformly along the path. If the control path has multiple subpaths, each added integer selects the next subpath.
2042+
/// The fractional part `[0, 1)` traverses the morph uniformly along the path. If the control path has multiple subpaths, each added integer selects the next subpath.
20432043
progression: Progression,
20442044
/// Swap the direction of the progression between objects or along the control path.
20452045
reverse: bool,
20462046
/// The parameter of change that influences the interpolation speed between each object. Equal slices in this parameter correspond to the rate of progression through the morph. This must be set to a parameter that changes.
20472047
///
20482048
/// "Objects" morphs through each group element at an equal rate. "Distances" keeps constant speed with time between objects proportional to their distances. "Angles" keeps constant rotational speed. "Sizes" keeps constant shrink/growth speed. "Slants" keeps constant shearing angle speed.
20492049
distribution: InterpolationDistribution,
2050-
/// An optional control path whose anchor points correspond to each object. Curved segments between points will shape the morph trajectory instead of traveling straight. If there is a break between path segments, the separate subpaths are selected by index from the integer part of the progression value. For example, [1, 2) morphs along the segments of the second subpath, and so on.
2050+
/// An optional control path whose anchor points correspond to each object. Curved segments between points will shape the morph trajectory instead of traveling straight. If there is a break between path segments, the separate subpaths are selected by index from the integer part of the progression value. For example, `[1, 2)` morphs along the segments of the second subpath, and so on.
20512051
path: Table<Vector>,
20522052
) -> Table<Vector> {
20532053
/// Promotes a segment's handle pair to cubic-equivalent Bézier control points.
@@ -2074,11 +2074,11 @@ async fn morph<I: IntoGraphicTable + 'n + Send + Clone>(
20742074
return;
20752075
}
20762076

2077-
let (prev_idx, next_idx) = if closed { (len - 1, 0) } else { (len - 2, len - 1) };
2077+
let (prev_index, next_index) = if closed { (len - 1, 0) } else { (len - 2, len - 1) };
20782078

2079-
let prev_anchor = manips[prev_idx].anchor;
2080-
let next_anchor = manips[next_idx].anchor;
2081-
let (h1, h2) = promote_handles_to_cubic(prev_anchor, manips[prev_idx].out_handle, manips[next_idx].in_handle, next_anchor);
2079+
let prev_anchor = manips[prev_index].anchor;
2080+
let next_anchor = manips[next_index].anchor;
2081+
let (h1, h2) = promote_handles_to_cubic(prev_anchor, manips[prev_index].out_handle, manips[next_index].in_handle, next_anchor);
20822082

20832083
// De Casteljau subdivision at t=0.5
20842084
let m01 = prev_anchor.lerp(h1, 0.5);
@@ -2088,8 +2088,8 @@ async fn morph<I: IntoGraphicTable + 'n + Send + Clone>(
20882088
let m123 = m12.lerp(m23, 0.5);
20892089
let mid = m012.lerp(m123, 0.5);
20902090

2091-
manips[prev_idx].out_handle = Some(m01);
2092-
manips[next_idx].in_handle = Some(m23);
2091+
manips[prev_index].out_handle = Some(m01);
2092+
manips[next_index].in_handle = Some(m23);
20932093

20942094
let mid_manip = ManipulatorGroup {
20952095
anchor: mid,
@@ -2101,7 +2101,7 @@ async fn morph<I: IntoGraphicTable + 'n + Send + Clone>(
21012101
if closed {
21022102
manips.push(mid_manip);
21032103
} else {
2104-
manips.insert(next_idx, mid_manip);
2104+
manips.insert(next_index, mid_manip);
21052105
}
21062106
}
21072107

@@ -2235,16 +2235,18 @@ async fn morph<I: IntoGraphicTable + 'n + Send + Clone>(
22352235
InterpolationDistribution::Distances => segment_lengths.clone(),
22362236
InterpolationDistribution::Angles | InterpolationDistribution::Sizes | InterpolationDistribution::Slants => (0..segment_count)
22372237
.map(|i| {
2238-
let src_idx = (content_offset + i).min(max_content_index);
2239-
let tgt_idx = if is_closed && i >= subpath_anchors - 1 {
2238+
let source_index = (content_offset + i).min(max_content_index);
2239+
let target_index = if is_closed && i >= subpath_anchors - 1 {
22402240
content_offset
22412241
} else {
22422242
(content_offset + i + 1).min(max_content_index)
22432243
};
22442244

2245-
let (Some(src), Some(tgt)) = (content.get(src_idx), content.get(tgt_idx)) else { return 0. };
2246-
let (s_angle, s_scale, s_skew) = src.transform.decompose_rotation_scale_skew();
2247-
let (t_angle, t_scale, t_skew) = tgt.transform.decompose_rotation_scale_skew();
2245+
let (Some(source), Some(target)) = (content.get(source_index), content.get(target_index)) else {
2246+
return 0.;
2247+
};
2248+
let (s_angle, s_scale, s_skew) = source.transform.decompose_rotation_scale_skew();
2249+
let (t_angle, t_scale, t_skew) = target.transform.decompose_rotation_scale_skew();
22482250

22492251
match distribution {
22502252
InterpolationDistribution::Angles => {
@@ -2291,8 +2293,8 @@ async fn morph<I: IntoGraphicTable + 'n + Send + Clone>(
22912293
// Convert the blend time to a parametric t for evaluating spatial position on the control path
22922294
let path_segment_index = local_source_index;
22932295
let parametric_t = {
2294-
let seg_idx = path_segment_index.min(segment_count - 1);
2295-
let segment = control_bezpath.get_seg(seg_idx + 1).unwrap();
2296+
let segment_index = path_segment_index.min(segment_count - 1);
2297+
let segment = control_bezpath.get_seg(segment_index + 1).unwrap();
22962298
eval_pathseg_euclidean(segment, time, DEFAULT_ACCURACY)
22972299
};
22982300

0 commit comments

Comments
 (0)