Skip to content

Commit a459ced

Browse files
committed
Final code review
1 parent b14fccb commit a459ced

File tree

3 files changed

+27
-28
lines changed

3 files changed

+27
-28
lines changed

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

@@ -1940,22 +1940,22 @@ async fn jitter_points(
19401940

19411941
/// Interpolates the geometry, appearance, and transform between multiple vector layers, producing a single morphed vector shape.
19421942
///
1943-
/// 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.
1943+
/// *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.
19441944
#[node_macro::node(category("Vector: Modifier"), path(core_types::vector))]
19451945
async fn morph<I: IntoGraphicTable + 'n + Send + Clone>(
19461946
_: impl Ctx,
19471947
/// The vector objects to interpolate between. Mixed graphic content is deeply flattened to keep only vector elements.
19481948
#[implementations(Table<Graphic>, Table<Vector>)]
19491949
content: I,
1950-
/// 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.
1950+
/// 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.
19511951
progression: Progression,
19521952
/// Swap the direction of the progression between objects or along the control path.
19531953
reverse: bool,
19541954
/// 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.
19551955
///
19561956
/// "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.
19571957
distribution: InterpolationDistribution,
1958-
/// 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.
1958+
/// 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.
19591959
path: Table<Vector>,
19601960
) -> Table<Vector> {
19611961
/// Promotes a segment's handle pair to cubic-equivalent Bézier control points.
@@ -1982,11 +1982,11 @@ async fn morph<I: IntoGraphicTable + 'n + Send + Clone>(
19821982
return;
19831983
}
19841984

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

1987-
let prev_anchor = manips[prev_idx].anchor;
1988-
let next_anchor = manips[next_idx].anchor;
1989-
let (h1, h2) = promote_handles_to_cubic(prev_anchor, manips[prev_idx].out_handle, manips[next_idx].in_handle, next_anchor);
1987+
let prev_anchor = manips[prev_index].anchor;
1988+
let next_anchor = manips[next_index].anchor;
1989+
let (h1, h2) = promote_handles_to_cubic(prev_anchor, manips[prev_index].out_handle, manips[next_index].in_handle, next_anchor);
19901990

19911991
// De Casteljau subdivision at t=0.5
19921992
let m01 = prev_anchor.lerp(h1, 0.5);
@@ -1996,8 +1996,8 @@ async fn morph<I: IntoGraphicTable + 'n + Send + Clone>(
19961996
let m123 = m12.lerp(m23, 0.5);
19971997
let mid = m012.lerp(m123, 0.5);
19981998

1999-
manips[prev_idx].out_handle = Some(m01);
2000-
manips[next_idx].in_handle = Some(m23);
1999+
manips[prev_index].out_handle = Some(m01);
2000+
manips[next_index].in_handle = Some(m23);
20012001

20022002
let mid_manip = ManipulatorGroup {
20032003
anchor: mid,
@@ -2009,7 +2009,7 @@ async fn morph<I: IntoGraphicTable + 'n + Send + Clone>(
20092009
if closed {
20102010
manips.push(mid_manip);
20112011
} else {
2012-
manips.insert(next_idx, mid_manip);
2012+
manips.insert(next_index, mid_manip);
20132013
}
20142014
}
20152015

@@ -2143,16 +2143,18 @@ async fn morph<I: IntoGraphicTable + 'n + Send + Clone>(
21432143
InterpolationDistribution::Distances => segment_lengths.clone(),
21442144
InterpolationDistribution::Angles | InterpolationDistribution::Sizes | InterpolationDistribution::Slants => (0..segment_count)
21452145
.map(|i| {
2146-
let src_idx = (content_offset + i).min(max_content_index);
2147-
let tgt_idx = if is_closed && i >= subpath_anchors - 1 {
2146+
let source_index = (content_offset + i).min(max_content_index);
2147+
let target_index = if is_closed && i >= subpath_anchors - 1 {
21482148
content_offset
21492149
} else {
21502150
(content_offset + i + 1).min(max_content_index)
21512151
};
21522152

2153-
let (Some(src), Some(tgt)) = (content.get(src_idx), content.get(tgt_idx)) else { return 0. };
2154-
let (s_angle, s_scale, s_skew) = src.transform.decompose_rotation_scale_skew();
2155-
let (t_angle, t_scale, t_skew) = tgt.transform.decompose_rotation_scale_skew();
2153+
let (Some(source), Some(target)) = (content.get(source_index), content.get(target_index)) else {
2154+
return 0.;
2155+
};
2156+
let (s_angle, s_scale, s_skew) = source.transform.decompose_rotation_scale_skew();
2157+
let (t_angle, t_scale, t_skew) = target.transform.decompose_rotation_scale_skew();
21562158

21572159
match distribution {
21582160
InterpolationDistribution::Angles => {
@@ -2199,8 +2201,8 @@ async fn morph<I: IntoGraphicTable + 'n + Send + Clone>(
21992201
// Convert the blend time to a parametric t for evaluating spatial position on the control path
22002202
let path_segment_index = local_source_index;
22012203
let parametric_t = {
2202-
let seg_idx = path_segment_index.min(segment_count - 1);
2203-
let segment = control_bezpath.get_seg(seg_idx + 1).unwrap();
2204+
let segment_index = path_segment_index.min(segment_count - 1);
2205+
let segment = control_bezpath.get_seg(segment_index + 1).unwrap();
22042206
eval_pathseg_euclidean(segment, time, DEFAULT_ACCURACY)
22052207
};
22062208

0 commit comments

Comments
 (0)