3D and Materials: Expand as Wireframes reshapes edges by the effects after the 3D effect drawn

With two 3D effects on an object, the geometry effects after the first one
reshaped the edges, even when the second one (Revolve, which is drawn first)
built the faces. A geometry effect between the two then moved the profile and
the edges both. The edges now take only the effects after the 3D effect that
built them.
This commit is contained in:
dotCooCoo
2026-11-12 07:44:35 -08:00
parent 55a80ca480
commit 5a8cb30259
2 changed files with 19 additions and 4 deletions
+7 -4
View File
@@ -52,7 +52,7 @@ pub fn three_d_wireframe_in(doc: Option<&Document>, n: &Node) -> Result<Vec<Path
}
let n = &*resolve(doc, n, label)?;
let faces = if revolve { crate::revolve::revolve_face_paths(doc, n)? } else { solid_face_paths(doc, n)? };
let faces = after_geometry(doc, n, faces);
let faces = after_geometry(doc, n, faces, revolve);
let wire = edges(&faces)?;
if wire.is_empty() {
return Err(format!("{label} draws no faces for this object"));
@@ -60,10 +60,13 @@ pub fn three_d_wireframe_in(doc: Option<&Document>, n: &Node) -> Result<Vec<Path
Ok(wire)
}
/// `faces` reshaped by the visible geometry effects after `n`'s own 3D effect ([`reshaped`]).
fn after_geometry(doc: Option<&Document>, n: &Node, faces: Vec<PathData>) -> Vec<PathData> {
/// `faces` reshaped by the visible geometry effects after the 3D effect of `n`'s own that drew them
/// ([`reshaped`]): its first visible Revolve when `revolve` is set, else its first visible Extrude &
/// Bevel, Inflate or Rotate.
fn after_geometry(doc: Option<&Document>, n: &Node, faces: Vec<PathData>, revolve: bool) -> Vec<PathData> {
let fx = &n.appearance.effects;
let Some(index) = fx.iter().position(|e| e.visible && is_three_d(&e.id)) else { return faces };
let drawn = if revolve { fx.iter().position(|e| e.visible && crate::revolve::is_revolve(&e.id)) } else { solid(fx).map(|(i, _)| i) };
let Some(index) = drawn else { return faces };
reshaped(faces, fx.get(index + 1..).unwrap_or_default(), &GeomContext { doc, ..GeomContext::of(n) })
}
@@ -192,6 +192,18 @@ fn a_geometry_effect_after_a_fill_s_3d_effect_reshapes_its_edges() {
}
}
/// With two 3D effects, a geometry effect between them reshapes the faces of the one drawn only
/// once: Revolve is drawn, so a Transform before it moves its profile and not its faces again.
#[test]
fn a_geometry_effect_before_the_drawn_3d_effect_is_not_applied_again() {
let mut n = solid_square(crate::REVOLVE, json!({}));
n.appearance.effects.insert(0, crate::new_effect("distort.transform", &json!({"moveH": 50.0})).unwrap());
let alone = bounds(&three_d_wireframe_in(None, &n).unwrap());
n.appearance.effects.insert(0, crate::new_effect(super::super::EXTRUDE, &json!({})).unwrap());
let both = bounds(&three_d_wireframe_in(None, &n).unwrap());
assert!((both.x0 - alone.x0).abs() < 1e-6 && (both.x1 - alone.x1).abs() < 1e-6, "{alone:?} {both:?}");
}
#[test]
fn an_object_without_a_visible_3d_effect_is_an_error() {
let mut n = solid_square(super::super::EXTRUDE, json!({}));