From 9e88bfe698c6baed576fcc280e15dd3f6521e7ff Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 15 Nov 2026 07:09:57 -0800 Subject: [PATCH] Revolve: a partial sweep with Cap closes its cut sides With an Angle below 360 and Cap on, Revolve and Revolve (Classic) now close the two angular cut sides instead of leaving them open. Each side is flat and evenly shaded and is drawn in depth order with the rest of the surface: the region between each open subpath and the axis, and the area of each closed subpath, one face per region. A subpath that walls a hole under the object's fill rule leaves the hole open, and a self-intersecting subpath fills what the nonzero rule fills. The cut sides appear in preview, SVG/PDF export, Expand Appearance, Expand as Wireframes, shadows and exported 3D meshes. Cap off keeps the surface hollow. Painter visibility now looks for covers over every piece of a face, so a face drawn as several contours is trimmed where any of them is covered. Docs: docs/revolve.md, docs/three-d.md, docs/mcp.md, the effects-parity row, the Cap tooltip and its catalog rows. --- crates/effects/src/catalog.rs | 4 +- crates/effects/src/revolve.rs | 53 +++-- crates/three-d/src/lib.rs | 260 ++++++++++++++++++++++++- crates/three-d/src/mesh.rs | 9 +- crates/three-d/src/mesh/tests.rs | 8 +- crates/three-d/src/shadow.rs | 4 +- crates/three-d/src/tests.rs | 1 + crates/three-d/src/tests/cut_sides.rs | 235 ++++++++++++++++++++++ crates/three-d/src/visibility.rs | 7 +- crates/three-d/src/visibility_parts.rs | 19 ++ crates/ui-egui/src/dialogs/revolve.rs | 2 +- crates/ui-egui/src/i18n/bg.tsv | 2 +- crates/ui-egui/src/i18n/bs.tsv | 2 +- crates/ui-egui/src/i18n/ca.tsv | 2 +- crates/ui-egui/src/i18n/cs.tsv | 2 +- crates/ui-egui/src/i18n/da.tsv | 2 +- crates/ui-egui/src/i18n/de.tsv | 2 +- crates/ui-egui/src/i18n/el.tsv | 2 +- crates/ui-egui/src/i18n/es.tsv | 2 +- crates/ui-egui/src/i18n/fi.tsv | 2 +- crates/ui-egui/src/i18n/fr.tsv | 2 +- crates/ui-egui/src/i18n/gu.tsv | 2 +- crates/ui-egui/src/i18n/hi.tsv | 2 +- crates/ui-egui/src/i18n/hu.tsv | 2 +- crates/ui-egui/src/i18n/id.tsv | 2 +- crates/ui-egui/src/i18n/it.tsv | 2 +- crates/ui-egui/src/i18n/ja.tsv | 2 +- crates/ui-egui/src/i18n/ka.tsv | 2 +- crates/ui-egui/src/i18n/ko.tsv | 2 +- crates/ui-egui/src/i18n/nl.tsv | 2 +- crates/ui-egui/src/i18n/pl.tsv | 2 +- crates/ui-egui/src/i18n/pt-br.tsv | 2 +- crates/ui-egui/src/i18n/ru.tsv | 2 +- crates/ui-egui/src/i18n/sv.tsv | 2 +- crates/ui-egui/src/i18n/tr.tsv | 2 +- crates/ui-egui/src/i18n/uk.tsv | 2 +- crates/ui-egui/src/i18n/vi.tsv | 2 +- crates/ui-egui/src/i18n/zh-hans.tsv | 2 +- crates/ui-egui/src/i18n/zh-hant.tsv | 2 +- docs/effects-parity.md | 2 +- docs/mcp.md | 11 +- docs/revolve.md | 19 +- docs/three-d.md | 3 +- 43 files changed, 614 insertions(+), 79 deletions(-) create mode 100644 crates/three-d/src/tests/cut_sides.rs diff --git a/crates/effects/src/catalog.rs b/crates/effects/src/catalog.rs index 1c1ca96d9f..a2bebe2fd1 100644 --- a/crates/effects/src/catalog.rs +++ b/crates/effects/src/catalog.rs @@ -182,7 +182,7 @@ pub fn effect_catalog() -> Vec { REVOLVE, "Revolve…", &["Effect", "3D and Materials"], - "{angle: degrees (0..360, 360), offset: pt (0..100000, 0), edge: left|right, rotationX: degrees (0), rotationY: degrees (0), rotationZ: degrees (0), perspectiveAngle: degrees (0..160, 0; 0 is none, wider brings the eye nearer), perspective: % (0..100; the earlier form, read as the perspectiveAngle that shows the same view), segments: integer (8..128, 64), shade: bool (true), lightColor: #rrggbb (white, #ffffff; legacy directional light color), lights: null or array of 1..10 objects (color: #rrggbb, intensity: % 0..100, rotation: degrees -180..180, height: degrees 0..90, softness: % 0..100, behind: bool; overrides the single-light fields; ambient is shared), lightRotation: degrees (-180..180, 125.26; round the object on the page, 0 on its right, counterclockwise), lightHeight: degrees (0..90, 30; 0 beside the object, 90 straight in front), lightBehind: bool (false; true lights it from behind), lightIntensity: % (0..100, 80), lightSoftness: % (0..100, 0; how far round the object the light reaches), ambient: % (0..200, 25; Ambient Light), lightAzimuth: degrees (the earlier form: with lightElevation, read as the lightRotation, lightHeight and lightBehind of the same light), lightElevation: degrees (the earlier form, with lightAzimuth), shadow: bool (false; the first light casts a hard-edged shadow, black at 50% times the art's opacity), shadowPosition: behind|below (behind; behind: on a plane square to the view, below: on the floor under the object, turned with it), shadowDistance: % (0..100, 0; how far the plane is from the object, as a share of its largest size), shadowBounds: % (10..400, 100; how far the plane reaches: at 100 it is four times the object's largest size across), cap: bool (true, close circular ends of open profiles; partial-sweep cut sides stay open), expandVisibleOnly: bool (true, trim covered opaque solid surfaces only on Expand Appearance; surfaces with graphics keep every face), graphics: array of 0..64 objects ([]; the 3D and Materials panel's Graphics on the swept side, see threeD.mapGraphic: symbol: name of a document symbol, face: front (the side), x: pt (0; the offset of the graphic's center from the middle of the side, around the axis: the angle times the profile's distance from the axis at that point), y: pt (0; along the profile, toward its lower end), scale: % (1..10000, 100), rotation: degrees (-360..360, 0; counterclockwise); wrapped around the side at its own size, so it reaches farther around where the profile comes nearer the axis, shaded with it and drawn only where the side's outside faces the viewer; a full turn cuts it at the back; nothing on the caps)}. Shaded surfaces use smooth vector gradients automatically; intersecting profiles use approximate painter visibility.", + "{angle: degrees (0..360, 360), offset: pt (0..100000, 0), edge: left|right, rotationX: degrees (0), rotationY: degrees (0), rotationZ: degrees (0), perspectiveAngle: degrees (0..160, 0; 0 is none, wider brings the eye nearer), perspective: % (0..100; the earlier form, read as the perspectiveAngle that shows the same view), segments: integer (8..128, 64), shade: bool (true), lightColor: #rrggbb (white, #ffffff; legacy directional light color), lights: null or array of 1..10 objects (color: #rrggbb, intensity: % 0..100, rotation: degrees -180..180, height: degrees 0..90, softness: % 0..100, behind: bool; overrides the single-light fields; ambient is shared), lightRotation: degrees (-180..180, 125.26; round the object on the page, 0 on its right, counterclockwise), lightHeight: degrees (0..90, 30; 0 beside the object, 90 straight in front), lightBehind: bool (false; true lights it from behind), lightIntensity: % (0..100, 80), lightSoftness: % (0..100, 0; how far round the object the light reaches), ambient: % (0..200, 25; Ambient Light), lightAzimuth: degrees (the earlier form: with lightElevation, read as the lightRotation, lightHeight and lightBehind of the same light), lightElevation: degrees (the earlier form, with lightAzimuth), shadow: bool (false; the first light casts a hard-edged shadow, black at 50% times the art's opacity), shadowPosition: behind|below (behind; behind: on a plane square to the view, below: on the floor under the object, turned with it), shadowDistance: % (0..100, 0; how far the plane is from the object, as a share of its largest size), shadowBounds: % (10..400, 100; how far the plane reaches: at 100 it is four times the object's largest size across), cap: bool (true: solid, closing circular ends of open profiles and a partial sweep's cut sides; false: hollow), expandVisibleOnly: bool (true, trim covered opaque solid surfaces only on Expand Appearance; surfaces with graphics keep every face), graphics: array of 0..64 objects ([]; the 3D and Materials panel's Graphics on the swept side, see threeD.mapGraphic: symbol: name of a document symbol, face: front (the side), x: pt (0; the offset of the graphic's center from the middle of the side, around the axis: the angle times the profile's distance from the axis at that point), y: pt (0; along the profile, toward its lower end), scale: % (1..10000, 100), rotation: degrees (-360..360, 0; counterclockwise); wrapped around the side at its own size, so it reaches farther around where the profile comes nearer the axis, shaded with it and drawn only where the side's outside faces the viewer; a full turn cuts it at the back; nothing on the caps)}. Shaded surfaces use smooth vector gradients automatically; intersecting profiles use approximate painter visibility.", json!({"angle":360.0,"offset":0.0,"edge":"left","rotationX":0.0,"rotationY":0.0,"rotationZ":0.0,"perspectiveAngle":0.0,"segments":64,"shade":true,"lightColor":"#ffffff","lights":null,"lightRotation":125.26438968275465,"lightHeight":30.0,"lightBehind":false,"lightIntensity":80.0,"lightSoftness":0.0,"ambient":25.0,"shadow":false,"shadowPosition":"behind","shadowDistance":0.0,"shadowBounds":100.0,"cap":true,"expandVisibleOnly":true,"graphics":[]}), ), g( @@ -217,7 +217,7 @@ pub fn effect_catalog() -> Vec { CLASSIC_REVOLVE, "Revolve (Classic)…", &["Effect", "3D and Materials", "3D (Classic)"], - "{angle: degrees (0..360, 360; how far the profile sweeps round the axis), cap: bool (true: solid, the open ends closed; false: hollow), offset: pt (0..1000, 0; the axis's distance from the profile, a ring past 0), edge: left|right (left; the axis is at the left or the right edge of the profile's bounds), rotationX: degrees (-180..180, -21.88), rotationY: degrees (-180..180, -23.4), rotationZ: degrees (-180..180, 9.06; the defaults are the Off-Axis Front position), perspectiveAngle: degrees (0..160, 0; 0 is none, wider brings the eye nearer), surface: wireframe|none|diffuse|plastic (plastic; wireframe draws the edges of every face and fills none; none keeps the paint unlit; diffuse lights the faces softly; plastic adds a glossy highlight), lights: null or array of 1..10 objects (intensity: % 0..100, rotation: degrees -180..180, height: degrees 0..90, behind: bool; overrides the single-light fields; the lights add up; color and softness are not used), lightRotation: degrees (-180..180, 125.26; round the object on the page, 0 on its right, counterclockwise), lightHeight: degrees (0..90, 30; 0 beside the object, 90 straight in front), lightBehind: bool (false; true lights it from behind), lightIntensity: % (0..100, 100), ambient: % (0..100, 50; Ambient Light, every face whichever way it faces), highlightIntensity: % (0..100, 60; plastic only), highlightSize: % (0..100, 90; 100 broad, 0 a small spot; plastic only), blendSteps: integer (1..256, 25; how many levels the shading and the highlight are rounded to), shadingColor: black|custom|none (black; the color the faces darken toward; none keeps the paint and adds only the highlight), shadingCustom: #rrggbb (#000000; the color shadingColor custom darkens toward)}. The profile sweeps round a vertical axis, as Revolve's does, painted with the top fill (else the top stroke); every face is drawn, back to front. The defaults are VectorCraft's own.", + "{angle: degrees (0..360, 360; how far the profile sweeps round the axis), cap: bool (true: solid, the open ends and a partial sweep's cut sides closed; false: hollow), offset: pt (0..1000, 0; the axis's distance from the profile, a ring past 0), edge: left|right (left; the axis is at the left or the right edge of the profile's bounds), rotationX: degrees (-180..180, -21.88), rotationY: degrees (-180..180, -23.4), rotationZ: degrees (-180..180, 9.06; the defaults are the Off-Axis Front position), perspectiveAngle: degrees (0..160, 0; 0 is none, wider brings the eye nearer), surface: wireframe|none|diffuse|plastic (plastic; wireframe draws the edges of every face and fills none; none keeps the paint unlit; diffuse lights the faces softly; plastic adds a glossy highlight), lights: null or array of 1..10 objects (intensity: % 0..100, rotation: degrees -180..180, height: degrees 0..90, behind: bool; overrides the single-light fields; the lights add up; color and softness are not used), lightRotation: degrees (-180..180, 125.26; round the object on the page, 0 on its right, counterclockwise), lightHeight: degrees (0..90, 30; 0 beside the object, 90 straight in front), lightBehind: bool (false; true lights it from behind), lightIntensity: % (0..100, 100), ambient: % (0..100, 50; Ambient Light, every face whichever way it faces), highlightIntensity: % (0..100, 60; plastic only), highlightSize: % (0..100, 90; 100 broad, 0 a small spot; plastic only), blendSteps: integer (1..256, 25; how many levels the shading and the highlight are rounded to), shadingColor: black|custom|none (black; the color the faces darken toward; none keeps the paint and adds only the highlight), shadingCustom: #rrggbb (#000000; the color shadingColor custom darkens toward)}. The profile sweeps round a vertical axis, as Revolve's does, painted with the top fill (else the top stroke); every face is drawn, back to front. The defaults are VectorCraft's own.", json!({"angle":360.0,"cap":true,"offset":0.0,"edge":"left","rotationX":-21.88,"rotationY":-23.4,"rotationZ":9.06,"perspectiveAngle":0.0,"surface":"plastic","lights":null,"lightRotation":125.26438968275465,"lightHeight":30.0,"lightBehind":false,"lightIntensity":100.0,"ambient":50.0,"highlightIntensity":60.0,"highlightSize":90.0,"blendSteps":25,"shadingColor":"black","shadingCustom":"#000000"}), ), g( diff --git a/crates/effects/src/revolve.rs b/crates/effects/src/revolve.rs index a9c9482d1d..51d51628c6 100644 --- a/crates/effects/src/revolve.rs +++ b/crates/effects/src/revolve.rs @@ -5,7 +5,7 @@ use std::sync::Arc; use serde_json::Value; use vectorcraft_doc::color::{Color, Paint}; use vectorcraft_doc::{Appearance, AppearanceItem, Document, Effect, FillLayer, Node, NodeId, NodeKind}; -use vectorcraft_geom::{PathData, PathEl, Point, Rect, Vec2}; +use vectorcraft_geom::{FillRule, PathData, PathEl, Point, Rect, Vec2}; use vectorcraft_three_d::{Edge, Revolve, SolidFaces}; use crate::solids::wireframe::WireFace; @@ -105,6 +105,7 @@ pub fn revolve_options(p: &Value) -> Revolve { shade: flag(p, "shade", true), smooth_shading: true, cap_ends: flag(p, "cap", true), + fill_rule: FillRule::NonZero, curve_samples: None, map_surface: false, } @@ -222,7 +223,7 @@ fn check_shadow<'a>(p: &Value, paths: impl IntoIterator, b: return Ok(()); } let mut caster = vectorcraft_three_d::ShadowCaster::new(); - paths.into_iter().try_for_each(|path| caster.revolve(path, vectorcraft_geom::FillRule::NonZero, b, options).map(|_| ())) + paths.into_iter().try_for_each(|path| caster.revolve(path, options.fill_rule, b, options).map(|_| ())) } /// [`validate_revolve`] for a Revolve with parameters `p` at index `index` of the effects of @@ -380,7 +381,7 @@ fn cast_surface( None => { #[cfg(test)] crate::solids::SOLIDS_BUILT.with(|n| n.set(n.get() + 1)); - caster.revolve(path, vectorcraft_geom::FillRule::NonZero, b, options) + caster.revolve(path, options.fill_rule, b, options) } } } @@ -411,7 +412,7 @@ fn group_shadow( if ink.opacity <= 0.0 { continue; } - let faces = cast_surface(&mut caster, &s.path, b, options, kept)?; + let faces = cast_surface(&mut caster, &s.path, b, Revolve { fill_rule: s.rule, ..options }, kept)?; cast.push((s.scopes.as_slice(), ink, faces)); } Ok(crate::solids::shadow::scoped_art(id, &caster, settings, cast, crate::solids::has_masks(shapes))) @@ -607,13 +608,16 @@ fn in_order(items: Vec, order: &[usize]) -> Vec { order.iter().filter_map(|&k| slots.get_mut(k).and_then(Option::take)).collect() } -/// A surface of one object about the bounds of `path`, built with options derived from `fx`, and -/// when `fx` casts a shadow from it, the faces it is cast from ([`surface`]). `copies` is the count -/// [`surface`] adds to; its graphics take the symbols of `doc`. +/// A surface of one object about the bounds of `path`, filled with `rule`, built with options +/// derived from `fx` ([`rule_options`]), and when `fx` casts a shadow from it, the faces it is cast +/// from ([`surface`]). `copies` is the count [`surface`] adds to; its graphics take the symbols of +/// `doc`. +#[allow(clippy::too_many_arguments)] fn object_surface( doc: Option<&Document>, n: &Node, path: &PathData, + rule: FillRule, fx: &Effect, item: &AppearanceItem, expand: bool, @@ -622,7 +626,13 @@ fn object_surface( let b = path.bounds()?; let (paint, opacity, blend) = paint_of(item); let cast = casts(fx, opacity); - surface(doc, n, path, b, fx_options(fx), fx, paint, opacity, blend, expand, copies, cast).map(|(_, art, kept)| (art, kept)) + surface(doc, n, path, b, rule_options(fx, rule), fx, paint, opacity, blend, expand, copies, cast).map(|(_, art, kept)| (art, kept)) +} + +/// The options effect `fx` sweeps the surface of a profile filled with `rule` with: its cut sides +/// leave open the holes `rule` leaves in the profile. +fn rule_options(fx: &Effect, rule: FillRule) -> Revolve { + Revolve { fill_rule: rule, ..fx_options(fx) } } /// The paint of a graphic's solid color `c` on `face`, shaded as the face shades a solid fill of @@ -750,11 +760,11 @@ pub(crate) fn revolve_face_paths(doc: Option<&Document>, n: &Node) -> Result, n: &Node) -> Result, n: &Node) -> Result, n: &Node, expand: bool) -> Option { let paints = solid_paints(n); let item = surface_item(&paints)?; let expand = expand && !n.appearance.effects.iter().skip(index + 1).any(|e| e.visible && is_geometry(&e.id)); - let (surface, kept) = object_surface(doc, n, &path, fx, item, expand, &mut copies)?; + let (surface, kept) = object_surface(doc, n, &path, rule, fx, item, expand, &mut copies)?; if let Some(b) = path.bounds() - && let Some(shadow) = shadow_of(n.id, fx, &path, item, b, fx_options(fx), kept).ok()? + && let Some(shadow) = shadow_of(n.id, fx, &path, item, b, rule_options(fx, rule), kept).ok()? { children.push(Arc::new(shadow)); } @@ -850,10 +860,10 @@ fn art(doc: Option<&Document>, n: &Node, expand: bool) -> Option { let fx = item.effects().get(index)?; let p = geometry(&path, item.effects().get(..index)?, &ctx.item(original)); let expand = expand && !item.effects().iter().skip(index + 1).any(|e| e.visible && is_geometry(&e.id)); - let (mut art, kept) = object_surface(doc, n, &p, fx, item, expand, &mut copies)?; + let (mut art, kept) = object_surface(doc, n, &p, rule, fx, item, expand, &mut copies)?; art.appearance.effects = item.effects().iter().skip(index + 1).filter(|e| !is_revolve(&e.id)).cloned().collect(); if let Some(b) = p.bounds() - && let Some(mut shadow) = shadow_of(n.id, fx, &p, item, b, fx_options(fx), kept).ok()? + && let Some(mut shadow) = shadow_of(n.id, fx, &p, item, b, rule_options(fx, rule), kept).ok()? { shadow.appearance.effects = art.appearance.effects.clone(); shadows.push(Arc::new(shadow)); @@ -1021,6 +1031,7 @@ fn group_art(doc: Option<&Document>, n: &Node, expand: bool) -> Option { let expand = expand && s.scopes.is_empty(); let doc = doc.filter(|_| longest == Some(k)); let cast = casts(fx, opacity * s.opacity); + let options = Revolve { fill_rule: s.rule, ..options }; let (depths, art, faces) = surface(doc, n, &s.path, b, options, fx, paint, opacity, blend, expand, &mut copies, cast)?; surfaces.push((depths, art, s.scopes.as_slice())); kept.push(faces); @@ -1771,7 +1782,7 @@ mod tests { let mut fx = crate::new_effect(id, &json!({})).unwrap(); fx.params = params.clone(); let n = profile_node(); - let (path, _) = profile(&n).unwrap(); + let (path, rule) = profile(&n).unwrap(); let b = path.bounds().unwrap(); let mut half = n.clone(); if let AppearanceItem::Fill(f) = &mut half.appearance.items[0] { @@ -1779,9 +1790,9 @@ mod tests { } for n in [n, half] { let item = surface_item(&n.appearance.items).unwrap(); - let (_, kept) = object_surface(None, &n, &path, &fx, item, false, &mut Copies::default()).unwrap(); - let drawn = shadow_of(n.id, &fx, &path, item, b, fx_options(&fx), kept).unwrap(); - let alone = shadow_of(n.id, &fx, &path, item, b, fx_options(&fx), None).unwrap(); + let (_, kept) = object_surface(None, &n, &path, rule, &fx, item, false, &mut Copies::default()).unwrap(); + let drawn = shadow_of(n.id, &fx, &path, item, b, rule_options(&fx, rule), kept).unwrap(); + let alone = shadow_of(n.id, &fx, &path, item, b, rule_options(&fx, rule), None).unwrap(); assert!(alone.is_some() || id == CLASSIC_REVOLVE, "{id} {params}"); assert_eq!(format!("{drawn:?}"), format!("{alone:?}"), "{id} {params}"); } diff --git a/crates/three-d/src/lib.rs b/crates/three-d/src/lib.rs index 4290bc1c75..2790458cc8 100644 --- a/crates/three-d/src/lib.rs +++ b/crates/three-d/src/lib.rs @@ -1,7 +1,7 @@ //! Portable 3D effect geometry: Revolve, Extrude & Bevel, Inflate and Rotate. No windowing, GPU or //! document dependencies. //! -//! Open profiles optionally close their circular ends with caps. Faces are projected and sorted back to front, +//! Open profiles optionally close their circular ends with caps, and a partial sweep its cut sides. Faces are projected and sorted back to front, //! then flat or smoothly shaded with vector gradients. This preview uses a painter's algorithm, not a depth buffer: //! intersecting profiles can have ambiguous visibility and are not solid modelling inputs. #![forbid(unsafe_code)] @@ -102,9 +102,14 @@ pub struct Revolve { pub shade: bool, /// Interpolate profile normals using vector gradients. Enabled by default. pub smooth_shading: bool, - /// Close circular endpoint rings of open profiles. Partial sweeps get sectors; - /// the angular cut sides are left open. Enabled by default. + /// Close circular endpoint rings of open profiles (sectors on a partial sweep), and the two + /// angular cut sides of a partial sweep: each is one flat face of the region between an open + /// profile and the axis, and of a closed profile's own area with its holes left open. Off, the + /// surface is hollow. Enabled by default. pub cap_ends: bool, + /// The profile's fill rule, which decides the holes the cut sides leave open in [`revolve`] and + /// [`revolve_shadowed`]. Nonzero by default. + pub fill_rule: FillRule, /// Samples for each curved profile segment, from [`revolve_curve_samples`] for the surfaces of /// one object. `None` plans them from the profile alone. pub curve_samples: Option, @@ -140,6 +145,7 @@ impl Default for Revolve { shade: true, smooth_shading: true, cap_ends: true, + fill_rule: FillRule::NonZero, curve_samples: None, map_surface: false, } @@ -729,7 +735,7 @@ fn project_face(vertices: &[V3], normals: Option<&[V3]>, o: Revolve, origin: Poi /// Evaluate a profile in document space. All subpaths share one axis from `bounds`. /// Invalid or excessively complex inputs return an error, never a partial surface. pub fn revolve(path: &PathData, bounds: Rect, options: Revolve) -> Result, String> { - revolve_faces(path, FillRule::NonZero, bounds, options, None) + revolve_faces(path, options.fill_rule, bounds, options, None) } /// [`revolve`]'s faces as facets, back to front, for the classic surfaces: each keeps its @@ -772,7 +778,10 @@ pub fn revolve_curve_samples<'a>(paths: impl IntoIterator, if lines.saturating_add(curves.saturating_mul(MIN_CURVE_SAMPLES)) > points { return Err(TOO_COMPLEX_PROFILE.into()); } - let edges = (MAX_REVOLVE_FACES.saturating_sub(caps.saturating_mul(steps)) / per_edge).min(points); + // A partial sweep with caps closes each of its two cut sides with a face for each outline, + // planned here as one for each contour. + let cut_sides = if o.cap_ends && o.angle > 0.0 && o.angle < 360.0 { contours.saturating_mul(2) } else { 0 }; + let edges = (MAX_REVOLVE_FACES.saturating_sub(caps.saturating_mul(steps)).saturating_sub(cut_sides) / per_edge).min(points); if curves == 0 { return if lines > edges { Err(TOO_COMPLEX_SURFACE.into()) } else { Ok(CURVE_SAMPLES) }; } @@ -1055,6 +1064,242 @@ fn keep_profile(at: &Sweeping, s: &Swept, turn: f64, caps: &[usize], mut keep: i Ok(()) } +/// Twice the signed area of the polygon `ring`. +fn ring_area(ring: &[Point]) -> f64 { + ring.iter().zip(ring.iter().cycle().skip(1)).take(ring.len()).map(|(p, q)| p.x * q.y - q.x * p.y).sum() +} + +/// The region a cut side of a partial sweep closes for one contour's profile `points`, in the +/// profile's plane and in the order the profile runs: a closed contour's own area, or an open one +/// closed along the axis at `axis` from its last end back to its first. An open contour whose ends +/// meet is taken as closed. The region is given as the loops the nonzero rule fills, so one that +/// crosses itself, such as a bow tie, gives a loop for each part it encloses. None when the contour +/// encloses no area. +fn cut_region(points: &[Point], closed: bool, axis: f64) -> Vec> { + let (Some(&first), Some(&last)) = (points.first(), points.last()) else { return vec![] }; + let mut ring = points.to_vec(); + if !closed && first.distance(last) > 1e-10 { + ring.extend([Point::new(axis, last.y), Point::new(axis, first.y)]); + } + ring.dedup_by(|a, b| a.distance(*b) <= 1e-10); + while ring.len() > 1 && ring.first().zip(ring.last()).is_some_and(|(a, b)| a.distance(*b) <= 1e-10) { + ring.pop(); + } + if ring.len() < 3 { + return vec![]; + } + let crossed = PathData::new(vec![vectorcraft_geom::SubPath::polyline(&ring, true)]); + match vectorcraft_pathops::try_unite_all_with(&[(&crossed, FillRule::NonZero)], 1e-6) { + Ok(loops) => loops + .subpaths + .iter() + .map(|s| s.anchors.iter().map(|a| a.p).collect::>()) + .filter(|l| l.len() >= 3 && ring_area(l).abs() > 1e-10) + .collect(), + // Past the boolean's limits, the region is kept as the profile draws it. + Err(_) if ring_area(&ring).abs() > 1e-10 => vec![ring], + Err(_) => vec![], + } +} + +/// The steps at whose ends the two cut sides of a partial sweep lie, each with its outward normal +/// before the view's rotation: the start faces back against the sweep, the end on along it. +fn cut_sides(at: &Sweeping) -> [(usize, V3); 2] { + // The profile lies on one side of the axis: the sweep turns it forward on the left and back on + // the right. + let side = if at.o.edge == Edge::Left { 1.0 } else { -1.0 }; + let (s, c) = at.sweep.sin_cos(); + [(0, V3(0.0, 0.0, -side)), (at.steps, V3(-s * side, 0.0, c * side))] +} + +/// Whether `p` lies inside the polygon `ring`. +fn ring_contains(ring: &[Point], p: Point) -> bool { + let mut inside = false; + for (a, b) in ring.iter().zip(ring.iter().cycle().skip(1)).take(ring.len()) { + if (a.y > p.y) != (b.y > p.y) && p.x < a.x + (p.y - a.y) / (b.y - a.y) * (b.x - a.x) { + inside = !inside; + } + } + inside +} + +/// The regions `regions` (turned as [`oriented`] gives them) grouped into the faces of one cut +/// side: each outline, counterclockwise, first, with the holes, clockwise, that the smallest outline +/// around them holds. +fn cut_groups(regions: &[Vec]) -> Vec>> { + let bounds = |r: &[Point]| r.iter().fold(Rect::new(f64::INFINITY, f64::INFINITY, f64::NEG_INFINITY, f64::NEG_INFINITY), |b, p| b.union_pt(*p)); + // Each outline with its bounds and area, and the holes it holds. + let mut groups: Vec<(Rect, f64, Vec<&Vec>)> = + regions.iter().filter(|r| ring_area(r) > 0.0).map(|r| (bounds(r), ring_area(r), vec![r])).collect(); + for hole in regions.iter().filter(|r| ring_area(r) < 0.0) { + let Some(&p) = hole.first() else { continue }; + let owner = + groups.iter_mut().filter(|(b, _, g)| b.contains(p) && g.first().is_some_and(|o| ring_contains(o, p))).min_by(|a, b| a.1.total_cmp(&b.1)); + if let Some((_, _, g)) = owner { + g.push(hole); + } + } + groups.into_iter().map(|(_, _, g)| g).collect() +} + +/// One face of the cut side of a partial sweep at the end of step `step`: an outline among the +/// regions ([`cut_groups`]) and its holes, turned there and drawn as one flat, evenly shaded face, +/// filled with the nonzero rule, so its holes stay open. The outline gives the face's shading, +/// depth and polygon. `None` when it is seen edge on. +fn cut_face(at: &Sweeping, regions: &[&Vec], step: usize, eye: Option, light: V3) -> Result, String> { + let origin = Point::new(at.axis, at.center_y); + let turned: Vec> = regions.iter().map(|r| r.iter().map(|p| at.vertex(*p, step)).collect()).collect(); + let Some(vertices) = turned.first() else { return Ok(None) }; + let Some(mut face) = project_face(vertices, None, at.o, origin, eye, light)? else { return Ok(None) }; + let project = |v: &V3| { + let factor = perspective_scale(eye, v.2); + Point::new(origin.x + v.0 * factor, origin.y + v.1 * factor) + }; + let drawn: Vec> = turned.iter().map(|c| c.iter().map(project).collect()).collect(); + if drawn.iter().flatten().any(|p| !p.x.is_finite() || !p.y.is_finite()) { + return Err("Revolve projection is not finite".into()); + } + face.outline = Some(PathData::new(drawn.iter().map(|c| vectorcraft_geom::SubPath::polyline(c, true)).collect())); + Ok(Some(face)) +} + +/// Both cut sides of a partial sweep drawn, a face for each outline among `regions` with its holes +/// ([`cut_face`]), those seen edge on left out; none for no regions. +fn cut_faces(at: &Sweeping, regions: &[Vec], eye: Option, light: V3) -> Result, String> { + let groups = cut_groups(regions); + let mut out = vec![]; + for (step, _) in cut_sides(at) { + for group in &groups { + out.extend(cut_face(at, group, step, eye, light)?); + } + } + Ok(out) +} + +/// The regions the cut sides of a partial sweep close ([`cut_region`]), contour by contour: those +/// of the profile drawn, each with its contour's index, and those of the profile kept for a mesh, +/// each with whether it walls a hole. +struct CutRegions { + /// A partial sweep with caps: there are cut sides to close. + on: bool, + drawn: Vec<(Vec>, usize)>, + kept: Vec<(Vec>, bool)>, +} + +/// The loops of each contour's region in `regions` turned so a region runs counterclockwise in the +/// profile's plane, or clockwise when it is marked as a hole: filled with the nonzero rule, the +/// holes stay open and every outline fills. A region's largest loop decides, and loops inside it +/// that run the other way stay holes of it. +fn oriented(regions: impl IntoIterator>, bool)>) -> Vec> { + let mut out = vec![]; + for (mut loops, hole) in regions { + let largest = loops.iter().map(|l| ring_area(l)).max_by(|a, b| a.abs().total_cmp(&b.abs())).unwrap_or_default(); + if (largest < 0.0) != hole { + loops.iter_mut().for_each(|l| l.reverse()); + } + out.extend(loops); + } + out +} + +/// Whether each of the closed contours `contours` of `path` walls a hole under `rule`: the fill is +/// outside it and not inside at most of its segments' middles. An open contour, or every contour +/// when there is only one or the search passes its limits, walls none. +fn holes_of(path: &PathData, rule: FillRule, contours: &[usize]) -> Vec { + let none = vec![false; contours.len()]; + if contours.len() < 2 { + return none; + } + let Ok(mut search) = HoleSearch::new(path, rule) else { return none }; + let mut out = Vec::with_capacity(contours.len()); + for &k in contours { + let Some(sp) = path.subpaths.get(k).filter(|sp| sp.closed) else { + out.push(false); + continue; + }; + let mut walls = 0; + for segment in 0..sp.anchors.len() { + match search.is_hole(k, sp.segment(segment).eval(0.5)) { + Ok(hole) => walls += usize::from(hole), + Err(_) => return none, + } + } + out.push(walls * 2 > sp.anchors.len()); + } + out +} + +impl CutRegions { + /// The regions of a sweep with sanitized options `o`, none yet. + fn new(o: Revolve) -> Self { + Self { on: o.cap_ends && o.angle > 0.0 && o.angle < 360.0, drawn: vec![], kept: vec![] } + } + + /// Add the regions of contour `contour`'s profiles: `drawn`, when faces are drawn, and `kept`, + /// when a mesh keeps them. + fn add(&mut self, contour: usize, drawn: Option<&Swept>, kept: Option<&Swept>, closed: bool, axis: f64) { + if !self.on { + return; + } + if let Some(region) = drawn.map(|s| cut_region(&s.points, closed, axis)).filter(|r| !r.is_empty()) { + self.drawn.push((region, contour)); + } + if let Some(s) = kept { + let region = cut_region(&s.points, closed, axis); + // A contour walls a hole when most of its parts do. + let walls = s.holes.iter().filter(|h| **h).count(); + if !region.is_empty() { + self.kept.push((region, walls * 2 > s.holes.len())); + } + } + } + + /// Close the cut sides of sweep `at` of `path`: keep them for the mesh, if any, of `kept` + /// (whether faces are drawn, the mesh, and the error that stopped it, as [`lose_mesh`] takes + /// them) within `face_limit` faces, and give them drawn ([`cut_faces`]), the holes `rule` + /// leaves in `path` left open. + fn close( + &self, + at: &Sweeping, + (path, rule): (&PathData, FillRule), + kept: (bool, &mut Option<&mut Vec>, &mut Option), + face_limit: usize, + eye: Option, + light: V3, + ) -> Result, String> { + let (draw, mesh, lost) = kept; + let result = match mesh.as_deref_mut() { + Some(m) => keep_cuts(at, &self.kept, |contours, normal| { + m.push((contours, normal)); + if m.len() > face_limit { Err(TOO_COMPLEX_SURFACE.to_string()) } else { Ok(()) } + }), + None => Ok(()), + }; + if let Err(e) = result { + lose_mesh(draw, mesh, lost, e)?; + } + let contours: Vec = self.drawn.iter().map(|(_, k)| *k).collect(); + let holes = holes_of(path, rule, &contours); + cut_faces(at, &oriented(self.drawn.iter().map(|(r, _)| r.clone()).zip(holes)), eye, light) + } +} + +/// Keep for a mesh the two cut sides of a partial sweep: the regions `regions` of every contour +/// ([`cut_region`]), each marked when it walls a hole, turned to each side. Outlines run one way +/// round and holes the other, so the mesh leaves the holes open. `keep` keeps one face with its +/// outward normal. +fn keep_cuts(at: &Sweeping, regions: &[(Vec>, bool)], mut keep: impl FnMut(Vec>, V3) -> Result<(), String>) -> Result<(), String> { + if regions.is_empty() { + return Ok(()); + } + let oriented = oriented(regions.iter().cloned()); + for (step, normal) in cut_sides(at) { + let contours = oriented.iter().map(|r| r.iter().map(|p| at.vertex(*p, step)).collect()).collect(); + keep(contours, at.o.rotate(normal))?; + } + Ok(()) +} + /// Keep no more faces for a mesh after error `e`, which is the result when no face is drawn. fn lose_mesh(draw: bool, mesh: &mut Option<&mut Vec>, lost: &mut Option, e: String) -> Result<(), String> { if !draw { @@ -1152,6 +1397,9 @@ fn revolve_sweep( // its edges are cut into. let (mut count, mut kept_count) = (0, 0); let mut curve_budget = 0; + // With caps, a partial sweep closes its two cut sides: the regions of every contour drawn, and + // those kept for the mesh with whether each walls a hole. + let mut cuts = CutRegions::new(o); for (contour, sp) in path.subpaths.iter().enumerate() { let (mut drawn, mut kept) = (Swept::default(), Swept::default()); if let Some(first) = sp.anchors.first() { @@ -1244,6 +1492,7 @@ fn revolve_sweep( } } } + cuts.add(contour, draw.then_some(&drawn), mesh.is_some().then_some(&kept), sp.closed, axis); // Which way a profile runs round the region it sweeps (closed against the axis at its ends // when it is open), so the faces' normals point out of the solid. A closed contour that does // not touch the axis has its side cut opposite the middle of its outer side; an anchor goes @@ -1344,6 +1593,7 @@ fn revolve_sweep( } } } + cuts.close(&at, (path, rule), (draw, &mut mesh, &mut lost), face_limit, eye, light)?.into_iter().try_for_each(|face| emit(Some(face), 1))?; faces.sort_by(|a, b| a.depth.total_cmp(&b.depth)); Ok((faces, lost)) } diff --git a/crates/three-d/src/mesh.rs b/crates/three-d/src/mesh.rs index cd9623191c..14284cb1bf 100644 --- a/crates/three-d/src/mesh.rs +++ b/crates/three-d/src/mesh.rs @@ -118,8 +118,9 @@ pub fn inflate_meshed( } /// Revolve's surface ([`crate::revolve`]) as a mesh. As the effect draws it, a sweep of less than -/// 360° caps its ends with sectors and leaves its two cut sides open ([`Revolve::cap_ends`]). The -/// walls of holes under `rule`, such as the counter of an O, face into the hole. +/// 360° caps its ends with sectors and closes its two cut sides with flat faces ([`Revolve::cap_ends`]). +/// The walls of holes under `rule`, such as the counter of an O, face into the hole, and the cut +/// sides leave those holes open. pub fn revolve_mesh(path: &PathData, rule: FillRule, bounds: Rect, options: Revolve) -> Result { let mut faces = vec![]; crate::revolve_faces(path, rule, bounds, options, Some(&mut faces))?; @@ -127,7 +128,7 @@ pub fn revolve_mesh(path: &PathData, rule: FillRule, bounds: Rect, options: Revo } /// The area-weighted normal of `contours` (Newell's method). -fn newell(contours: &[Vec]) -> V3 { +pub(crate) fn newell(contours: &[Vec]) -> V3 { let mut n = V3::default(); for c in contours { for (a, b) in c.iter().zip(c.iter().cycle().skip(1)).take(c.len()) { @@ -210,7 +211,7 @@ fn spend(work: &mut usize, steps: usize) -> Result<(), String> { /// The triangles covering one face: `contours` (outlines one way round, holes the other) on the /// plane across `normal` (its Newell normal). -fn triangulate(contours: &[Vec], normal: V3, work: &mut usize) -> Result, String> { +pub(crate) fn triangulate(contours: &[Vec], normal: V3, work: &mut usize) -> Result, String> { // Cut the face on the coordinate plane it is least slanted to, turned so outlines run // counterclockwise. let (ax, ay, az) = (normal.0.abs(), normal.1.abs(), normal.2.abs()); diff --git a/crates/three-d/src/mesh/tests.rs b/crates/three-d/src/mesh/tests.rs index 76f9b04ecc..8b2ec0ae75 100644 --- a/crates/three-d/src/mesh/tests.rs +++ b/crates/three-d/src/mesh/tests.rs @@ -239,7 +239,7 @@ fn a_revolved_profile_is_a_closed_cylinder() { } #[test] -fn a_partial_revolve_caps_its_ends_with_sectors() { +fn a_partial_revolve_caps_its_ends_with_sectors_and_closes_its_cut_sides() { let mut b = BezPath::new(); b.move_to((20.0, 0.0)); b.line_to((20.0, 100.0)); @@ -247,8 +247,12 @@ fn a_partial_revolve_caps_its_ends_with_sectors() { let r = p.bounds().unwrap(); let o = Revolve { angle: 90.0, offset: 10.0, segments: 64, ..Revolve::default() }; let m = revolve_mesh(&p, FillRule::NonZero, r, o).unwrap(); - let exact = 0.25 * (2.0 * std::f64::consts::PI * 10.0 * 100.0 + 2.0 * std::f64::consts::PI * 100.0); + // The side and the two end sectors, and the two cut sides, each 10 pt from the axis by 100 pt. + let exact = 0.25 * (2.0 * std::f64::consts::PI * 10.0 * 100.0 + 2.0 * std::f64::consts::PI * 100.0) + 2.0 * 10.0 * 100.0; assert!((area(&m) - exact).abs() / exact < 0.01, "{} vs {exact}", area(&m)); + assert!(closed(&m), "the quarter of a cylinder is a closed solid"); + let hollow = revolve_mesh(&p, FillRule::NonZero, r, Revolve { cap_ends: false, ..o }).unwrap(); + assert!(!closed(&hollow)); } #[test] diff --git a/crates/three-d/src/shadow.rs b/crates/three-d/src/shadow.rs index b580ddcd5f..83c9b1dc8b 100644 --- a/crates/three-d/src/shadow.rs +++ b/crates/three-d/src/shadow.rs @@ -335,11 +335,11 @@ pub fn inflate_shadowed( } /// Revolve's surface ([`crate::revolve`]) and, from the same sweep, the faces -/// [`ShadowCaster::revolve`] adds for it with the nonzero fill rule. An error where +/// [`ShadowCaster::revolve`] adds for it with the fill rule of `options`. An error where /// [`crate::revolve`] gives one. pub fn revolve_shadowed(path: &PathData, bounds: Rect, options: Revolve) -> Result<(Vec, SolidFaces), String> { let mut kept = vec![]; - let (faces, lost) = crate::revolve_sweep(path, FillRule::NonZero, bounds, options, true, Some(&mut kept))?; + let (faces, lost) = crate::revolve_sweep(path, options.fill_rule, bounds, options, true, Some(&mut kept))?; let projection = Some(crate::revolve_projection(bounds, options.sanitized())); Ok((faces, SolidFaces { faces: lost.map_or(Ok(kept), Err), projection })) } diff --git a/crates/three-d/src/tests.rs b/crates/three-d/src/tests.rs index 5dba29c480..ace8566816 100644 --- a/crates/three-d/src/tests.rs +++ b/crates/three-d/src/tests.rs @@ -2,6 +2,7 @@ use super::*; mod caps; mod classic; +mod cut_sides; mod lighting; mod multiple_lights; mod profile_limits; diff --git a/crates/three-d/src/tests/cut_sides.rs b/crates/three-d/src/tests/cut_sides.rs new file mode 100644 index 0000000000..9d78da3e9d --- /dev/null +++ b/crates/three-d/src/tests/cut_sides.rs @@ -0,0 +1,235 @@ +use crate::*; +use vectorcraft_geom::Shape; + +/// Swept with Cap on, unshaded and seen from the front. +fn options() -> Revolve { + Revolve { cap_ends: true, shade: false, ..Default::default() } +} + +fn profile(data: &str) -> PathData { + PathData::from_bezpath(&BezPath::from_svg(data).unwrap()) +} + +fn area(face: &Face) -> f64 { + face.path().to_bezpath().area().abs() +} + +/// The faces of the cut sides among `faces`: the flat faces in a plane through the axis, which these +/// tests keep upright. The strips of the swept side lie off the axis, and the endpoint caps across it. +fn cut_sides(faces: &[Face]) -> Vec<&Face> { + faces.iter().filter(|f| !f.cap && f.plane.is_some_and(|p| p.offset.abs() < 1e-6 && p.normal[1].abs() < 1e-9)).collect() +} + +#[test] +fn a_half_turn_closes_both_cut_sides_with_the_region_between_the_profile_and_the_axis() { + let path = profile("M40 10 L40 90"); + let bounds = Rect::new(0.0, 10.0, 40.0, 90.0); + // Seen from the front, a half turn's two cut sides both face the viewer: the profile's plane + // to the right of the axis and to its left. + let faces = revolve(&path, bounds, Revolve { angle: 180.0, ..options() }).unwrap(); + let cuts = cut_sides(&faces); + assert_eq!(cuts.len(), 2); + for cut in &cuts { + assert!((area(cut) - 40.0 * 80.0).abs() < 1e-6, "{}", area(cut)); + assert!(cut.points.iter().all(|p| (10.0 - 1e-9..=90.0 + 1e-9).contains(&p.y))); + } + assert!(cuts.iter().any(|f| f.points.iter().all(|p| p.x >= -1e-9))); + assert!(cuts.iter().any(|f| f.points.iter().all(|p| p.x <= 1e-9))); + assert!(faces.windows(2).all(|pair| pair[0].depth <= pair[1].depth)); +} + +#[test] +fn cap_off_full_turns_and_no_turn_leave_the_cut_sides_open() { + let path = profile("M40 10 L40 90"); + let bounds = Rect::new(0.0, 10.0, 40.0, 90.0); + for (o, what) in [ + (Revolve { angle: 180.0, cap_ends: false, ..options() }, "hollow"), + (Revolve { angle: 360.0, rotation_x: 90.0, ..options() }, "a full turn"), + (Revolve { angle: 0.0, ..options() }, "no turn"), + ] { + let faces = revolve(&path, bounds, o).unwrap(); + assert!(cut_sides(&faces).is_empty(), "{what}"); + } +} + +#[test] +fn a_closed_profile_closes_its_cut_sides_with_its_area_and_leaves_its_hole_open() { + // A square ring away from the axis, its hole wound the other way. + let path = profile("M20 10 L60 10 L60 50 L20 50 Z M30 20 L30 40 L50 40 L50 20 Z"); + let bounds = path.bounds().unwrap(); + let o = Revolve { angle: 180.0, offset: 10.0, rotation_y: 20.0, ..options() }; + let faces = revolve(&path, bounds, o).unwrap(); + let cuts = cut_sides(&faces); + assert_eq!(cuts.len(), 2); + for cut in &cuts { + let outline = cut.outline.as_ref().unwrap(); + assert_eq!(outline.subpaths.len(), 2, "the outline and its hole"); + // Turned 20° about the vertical axis, each side is foreshortened by cos 20°. + let expected = (40.0 * 40.0 - 20.0 * 20.0) * 20f64.to_radians().cos(); + assert!((area(cut) - expected).abs() < 1e-6, "{} != {expected}", area(cut)); + } + // Visibility measures the face with its hole open. + assert!(!visible_faces(&faces).unwrap().is_empty()); +} + +#[test] +fn an_even_odd_hole_wound_with_its_outline_stays_open_in_the_drawn_cut_sides() { + // The hole runs the same way round as the outline, so only the even-odd rule leaves it open. + let path = profile("M20 10 L60 10 L60 50 L20 50 Z M30 20 L50 20 L50 40 L30 40 Z"); + let bounds = path.bounds().unwrap(); + let o = Revolve { angle: 180.0, offset: 10.0, ..options() }; + let faces = revolve(&path, bounds, Revolve { fill_rule: FillRule::EvenOdd, ..o }).unwrap(); + let cuts = cut_sides(&faces); + assert_eq!(cuts.len(), 2); + for cut in cuts { + // The drawn path is filled with the nonzero rule; the hole is in the middle of the side. + let filled = cut.path().to_bezpath(); + assert!(!filled.contains(filled.bounding_box().center())); + assert!((area(cut) - (40.0 * 40.0 - 20.0 * 20.0)).abs() < 1e-6, "{}", area(cut)); + } + // Under the nonzero rule the inner contour fills too: each side is the outer square and the + // inner one drawn over it. + let faces = revolve(&path, bounds, Revolve { fill_rule: FillRule::NonZero, ..o }).unwrap(); + let mut areas: Vec = cut_sides(&faces).iter().map(|f| area(f)).collect(); + areas.sort_by(f64::total_cmp); + assert_eq!(areas.len(), 4); + assert!(areas.iter().zip([400.0, 400.0, 1600.0, 1600.0]).all(|(a, b)| (a - b).abs() < 1e-6), "{areas:?}"); +} + +#[test] +fn a_bow_tie_whose_loops_cancel_out_closes_its_cut_sides_with_both_loops() { + // Two triangles of 400 pt² that meet at (40, 30), wound opposite ways. + let path = profile("M20 10 L60 50 L60 10 L20 50 Z"); + let bounds = path.bounds().unwrap(); + let o = Revolve { angle: 180.0, offset: 10.0, rotation_y: 20.0, ..options() }; + let faces = revolve(&path, bounds, o).unwrap(); + let cuts = cut_sides(&faces); + // Each side draws each loop as a face. + assert_eq!(cuts.len(), 4); + let expected = 400.0 * 20f64.to_radians().cos(); + for cut in cuts { + assert!((area(cut) - expected).abs() < 1e-6, "{} != {expected}", area(cut)); + } + let mesh = revolve_mesh(&path, FillRule::NonZero, bounds, Revolve { angle: 90.0, rotation_y: 0.0, ..o }).unwrap(); + let start = area_facing(&mesh, [0.0, 0.0, -1.0]); + assert!((start - 800.0).abs() < 1e-6, "{start}"); +} + +#[test] +fn the_mesh_closes_a_cut_side_that_crosses_itself_with_both_of_its_loops() { + // Loops of 900 pt² and 100 pt² that meet at (50, 40): the mesh covers both, and nothing + // between them. + let path = profile("M20 10 L60 50 L60 30 L20 70 Z"); + let bounds = path.bounds().unwrap(); + let mesh = revolve_mesh(&path, FillRule::NonZero, bounds, Revolve { angle: 90.0, offset: 10.0, ..options() }).unwrap(); + let start = area_facing(&mesh, [0.0, 0.0, -1.0]); + assert!((start - 1000.0).abs() < 1e-6, "{start}"); +} + +#[test] +fn visibility_keeps_both_of_two_separate_regions_wound_opposite_ways() { + let path = profile("M20 10 L30 10 L30 50 L20 50 Z M40 10 L40 50 L50 50 L50 10 Z"); + let bounds = path.bounds().unwrap(); + // Seen from behind, the half turn's walls are behind both cut sides, which nothing covers. Seen + // from the front, the walls the outer square sweeps cover both sides completely. + for (rotation_y, all) in [(180.0, 4.0 * 10.0 * 40.0), (0.0, 0.0)] { + let faces = revolve(&path, bounds, Revolve { angle: 180.0, offset: 10.0, rotation_y, ..options() }).unwrap(); + let cuts = cut_sides(&faces); + assert_eq!(cuts.len(), 4, "a face for each region on each side"); + let mut depths: Vec = cuts.iter().map(|f| f.depth).collect(); + depths.dedup(); + let visible = visible_faces(&faces).unwrap(); + let shown: f64 = visible + .iter() + .filter(|v| depths.contains(&v.depth)) + .flat_map(|v| v.path.subpaths.iter().map(|s| PathData::new(vec![s.clone()]).to_bezpath().area().abs())) + .sum(); + assert!((shown - all).abs() < 1e-6, "turned {rotation_y}°, the cut sides show {shown}, not {all}"); + } +} + +#[test] +fn every_open_contour_of_a_compound_profile_closes_its_own_region_on_each_side() { + let path = profile("M40 10 L40 40 M20 60 L50 90"); + let bounds = Rect::new(0.0, 10.0, 50.0, 90.0); + let faces = revolve(&path, bounds, Revolve { angle: 180.0, ..options() }).unwrap(); + let mut areas: Vec = cut_sides(&faces).iter().map(|f| area(f)).collect(); + areas.sort_by(f64::total_cmp); + // The trapezoid between the slanted line and the axis, (20 + 50) / 2 × 30, and 40 × 30. + let expected = [35.0 * 30.0, 35.0 * 30.0, 40.0 * 30.0, 40.0 * 30.0]; + assert_eq!(areas.len(), 4); + assert!(areas.iter().zip(expected).all(|(a, b)| (a - b).abs() < 1e-6), "{areas:?}"); +} + +#[test] +fn a_cut_side_seen_edge_on_is_not_drawn() { + let path = profile("M40 10 L40 90"); + let bounds = Rect::new(0.0, 10.0, 40.0, 90.0); + // A quarter turn ends in the plane through the axis toward the viewer. + let faces = revolve(&path, bounds, Revolve { angle: 90.0, ..options() }).unwrap(); + let cuts = cut_sides(&faces); + assert_eq!(cuts.len(), 1); + assert!((area(cuts[0]) - 40.0 * 80.0).abs() < 1e-6); +} + +#[test] +fn cut_sides_are_shaded_evenly_by_their_plane() { + let path = profile("M40 10 L40 90"); + let bounds = Rect::new(0.0, 10.0, 40.0, 90.0); + let o = Revolve { angle: 180.0, shade: true, rotation_y: 30.0, ..options() }; + let faces = revolve(&path, bounds, o).unwrap(); + let cuts = cut_sides(&faces); + assert_eq!(cuts.len(), 2); + for cut in cuts { + assert!(cut.gradient.is_none(), "a flat face is shaded evenly"); + assert!(cut.plane.is_some()); + assert!((0.0..=1.0).contains(&cut.brightness)); + // Both sides lie in the plane through the axis turned 30°, whose normal faces the viewer. + let n = cut.normal; + assert!((n[0].abs() - 30f64.to_radians().sin()).abs() < 1e-9 && n[2] > 0.0, "{n:?}"); + } +} + +/// The area of the triangles of `mesh` whose normal is `normal`. +fn area_facing(mesh: &Mesh, normal: [f64; 3]) -> f64 { + mesh.triangles + .iter() + .filter(|t| t.iter().all(|&i| mesh.normals[i as usize].iter().zip(normal).all(|(a, b)| (a - b).abs() < 1e-9))) + .map(|t| { + let [a, b, c] = t.map(|i| mesh.positions[i as usize]); + let (u, v) = ([b[0] - a[0], b[1] - a[1], b[2] - a[2]], [c[0] - a[0], c[1] - a[1], c[2] - a[2]]); + let x = [u[1] * v[2] - u[2] * v[1], u[2] * v[0] - u[0] * v[2], u[0] * v[1] - u[1] * v[0]]; + (x[0] * x[0] + x[1] * x[1] + x[2] * x[2]).sqrt() / 2.0 + }) + .sum() +} + +#[test] +fn the_mesh_closes_both_cut_sides_and_leaves_holes_open_under_either_fill_rule() { + let ring = "M20 10 L60 10 L60 50 L20 50 Z"; + let o = Revolve { angle: 90.0, offset: 10.0, ..options() }; + let expected = 40.0 * 40.0 - 20.0 * 20.0; + // The hole wound against the outline, and wound with it under even-odd. + for (hole, rule) in [("M30 20 L30 40 L50 40 L50 20 Z", FillRule::NonZero), ("M30 20 L50 20 L50 40 L30 40 Z", FillRule::EvenOdd)] { + let path = profile(&format!("{ring} {hole}")); + let mesh = revolve_mesh(&path, rule, path.bounds().unwrap(), o).unwrap(); + // The start faces back, against the sweep; a quarter turn ends facing left, along it. + let start = area_facing(&mesh, [0.0, 0.0, -1.0]); + let end = area_facing(&mesh, [-1.0, 0.0, 0.0]); + assert!((start - expected).abs() < 1e-6, "{rule:?}: {start}"); + assert!((end - expected).abs() < 1e-6, "{rule:?}: {end}"); + } + let path = profile(ring); + let hollow = revolve_mesh(&path, FillRule::NonZero, path.bounds().unwrap(), Revolve { cap_ends: false, ..o }).unwrap(); + assert_eq!(area_facing(&hollow, [0.0, 0.0, -1.0]), 0.0); +} + +#[test] +fn the_mesh_cut_sides_face_out_of_a_sweep_on_the_left_of_its_axis() { + // The axis is 40 pt to the right of the line, which sweeps from the left of the axis to its back. + let path = profile("M40 10 L40 90"); + let o = Revolve { angle: 90.0, edge: Edge::Right, offset: 40.0, ..options() }; + let mesh = revolve_mesh(&path, FillRule::NonZero, Rect::new(40.0, 10.0, 40.0, 90.0), o).unwrap(); + assert!((area_facing(&mesh, [0.0, 0.0, 1.0]) - 40.0 * 80.0).abs() < 1e-6); + assert!((area_facing(&mesh, [1.0, 0.0, 0.0]) - 40.0 * 80.0).abs() < 1e-6); +} diff --git a/crates/three-d/src/visibility.rs b/crates/three-d/src/visibility.rs index 3ed491ae10..71c5af62c3 100644 --- a/crates/three-d/src/visibility.rs +++ b/crates/three-d/src/visibility.rs @@ -199,7 +199,8 @@ pub fn visible_faces(faces: &[Face]) -> Result, String> { }) { return Err("Revolve visibility requires finite projected faces".into()); } - let all = faces.iter().flat_map(|f| &f.points).copied().collect::>(); + let outlines = faces.iter().filter_map(|f| f.outline.as_ref()).flat_map(|o| o.subpaths.iter().flat_map(|s| s.anchors.iter().map(|a| a.p))); + let all = faces.iter().flat_map(|f| f.points.iter().copied()).chain(outlines).collect::>(); let total = bounds(&all); if total.width() <= 0.0 || total.height() <= 0.0 { return Ok(vec![]); @@ -222,7 +223,9 @@ pub fn visible_faces(faces: &[Face]) -> Result, String> { if pieces.is_empty() { continue; } - let source_bounds = bounds(&face.points); + // A face drawn as several contours, such as a cut side of a partial sweep, reaches past its + // own polygon: look for covers over all of its pieces. + let source_bounds = pieces.iter().map(|p| p.bounds).reduce(|a, b| a.union(b)).unwrap_or_else(|| bounds(&face.points)); let mut fragments: Vec<_> = pieces.iter().map(|p| p.points.clone()).collect(); let mut clipped = false; 'covers: for tile in index.tiles(source_bounds) { diff --git a/crates/three-d/src/visibility_parts.rs b/crates/three-d/src/visibility_parts.rs index 2a14435025..ebf1d47b4b 100644 --- a/crates/three-d/src/visibility_parts.rs +++ b/crates/three-d/src/visibility_parts.rs @@ -91,6 +91,22 @@ fn triangulate(mut points: Vec, epsilon: f64, work: &mut usize, depth: us Ok(out) } +/// Triangles covering a flat face drawn as several straight-edged contours, such as a cut side of a +/// partial Revolve whose profile has holes: outlines one way round and holes the other, the holes +/// left uncovered. The work is checked before the face is cut, at four times its corners squared. +fn with_holes(outline: &vectorcraft_geom::PathData, epsilon: f64, work: &mut usize) -> Result>, String> { + const LIMIT: &str = "Revolve visibility exceeds its geometry work limit"; + let rings: Vec> = outline.subpaths.iter().map(|s| s.anchors.iter().map(|a| crate::V3(a.p.x, a.p.y, 0.0)).collect()).collect(); + let corners: usize = rings.iter().map(Vec::len).sum(); + *work = work.saturating_add(corners.saturating_mul(corners).saturating_mul(4)); + if *work > MAX_WORK { + return Err(LIMIT.into()); + } + let mut spent = 0; + let triangles = crate::mesh::triangulate(&rings, crate::mesh::newell(&rings), &mut spent)?; + Ok(triangles.into_iter().map(|t| clean(t.iter().map(|v| Point::new(v.0, v.1)).collect(), epsilon)).filter(|t| !t.is_empty()).collect()) +} + pub(super) fn pieces(face: &Face, epsilon: f64, work: &mut usize) -> Result>, String> { if let Some(strips) = &face.visibility_pieces { let mut out = vec![]; @@ -99,6 +115,9 @@ pub(super) fn pieces(face: &Face, epsilon: f64, work: &mut usize) -> Result 1) { + return with_holes(outline, epsilon, work); + } if !face.cap { return triangulate(clean(face.points.clone(), epsilon), epsilon, work, 0); } diff --git a/crates/ui-egui/src/dialogs/revolve.rs b/crates/ui-egui/src/dialogs/revolve.rs index a547c8fbb7..e213291c5a 100644 --- a/crates/ui-egui/src/dialogs/revolve.rs +++ b/crates/ui-egui/src/dialogs/revolve.rs @@ -118,7 +118,7 @@ pub(crate) fn controls(app: &VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) number(ui, d, "offset", tl!("Offset"), (0.0, 100000.0), "", 1, Some(unit)); ui.horizontal(|ui| { let cap = flag(d, "cap", true); - let tip = tl!("Close the circular ends of open profiles. Partial sweeps keep their cut sides open."); + let tip = tl!("Close the circular ends of open profiles. Partial sweeps also close their cut sides."); if widgets::check3_tip(ui, c3("Cap"), cap, true, tip) { d.fields.insert("cap".into(), json!(cap != Some(true))); } diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv index 8534505172..21603afe18 100644 --- a/crates/ui-egui/src/i18n/bg.tsv +++ b/crates/ui-egui/src/i18n/bg.tsv @@ -5817,7 +5817,7 @@ theme Appearance Външен вид @msg Unknown dimension orientation Непозната ориентация на размера @msg Unknown dimension style Непознат стил на размера @msg Unknown unit Непозната единица - Close the circular ends of open profiles. Partial sweeps keep their cut sides open. Затваря кръговите краища на отворени профили. При частично завъртане срязаните страни остават отворени. + Close the circular ends of open profiles. Partial sweeps also close their cut sides. Затваря кръговите краища на отворени профили. При частично завъртане срязаните страни също се затварят. # Strings added with Drop Shadow Darkness, Isolate Selected Object, Pencil Keep selected, Sample Color from Screen, Tritanopia proofing, Panels Except Tools and Control Darkness Затъмняване diff --git a/crates/ui-egui/src/i18n/bs.tsv b/crates/ui-egui/src/i18n/bs.tsv index 1a1b1bdbff..93a65d0ddf 100644 --- a/crates/ui-egui/src/i18n/bs.tsv +++ b/crates/ui-egui/src/i18n/bs.tsv @@ -5867,7 +5867,7 @@ mark-style Japanese Japanski @msg Unknown dimension orientation Nepoznata orijentacija kote @msg Unknown dimension style Nepoznat stil kote @msg Unknown unit Nepoznata jedinica - Close the circular ends of open profiles. Partial sweeps keep their cut sides open. Zatvori kružne krajeve otvorenih profila. Djelimična izvlačenja zadržavaju otvorene rezane strane. + Close the circular ends of open profiles. Partial sweeps also close their cut sides. Zatvori kružne krajeve otvorenih profila. Djelimična izvlačenja zatvaraju i svoje rezane strane. @msg span must be "object" or "selection", got {v} span mora biti "object" ili "selection", dobiveno {v} @msg span: "selection" places a `gradient`, not a swatch span: "selection" postavlja `gradient`, a ne uzorak boje @msg span: "selection" places a gradient: give `gradient` span: "selection" postavlja gradijent: navedite `gradient` diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index a7fcccfe2f..7f13dfde9a 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -753,7 +753,7 @@ antiAlias Sharp Nítid Close Panel Tanca el panell Close Path Tanca el traçat Close paths when ends are within: Tanca els traçats quan els extrems siguin a menys de: - Close the circular ends of open profiles. Partial sweeps keep their cut sides open. Tanca els extrems circulars dels perfils oberts. Els escombrats parcials mantenen oberts els costats tallats. + Close the circular ends of open profiles. Partial sweeps also close their cut sides. Tanca els extrems circulars dels perfils oberts. Els escombrats parcials també tanquen els costats tallats. Closed Tancat Closing bracket with no opening one Delimitador de tancament sense un d’obertura Clumped Agrupat diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index acab417f65..47bf5b79f7 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -6176,7 +6176,7 @@ mark-style Japanese Japonské @msg Unknown dimension style Neznámý styl kóty @msg Unknown unit Neznámá jednotka # Revolve cap description - Close the circular ends of open profiles. Partial sweeps keep their cut sides open. Uzavře kruhové konce otevřených profilů. Boční řezy částečného otočení zůstávají otevřené. + Close the circular ends of open profiles. Partial sweeps also close their cut sides. Uzavře kruhové konce otevřených profilů. Boční řezy částečného otočení se také uzavřou. @msg span must be "object" or "selection", got {v} span musí být "object" nebo "selection", ne {v} @msg span: "selection" places a `gradient`, not a swatch span: "selection" umísťuje `gradient`, ne vzorník @msg span: "selection" places a gradient: give `gradient` span: "selection" umísťuje přechod: zadejte `gradient` diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index 9e74a00a64..5ea9342e1e 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -6194,7 +6194,7 @@ mark-style Japanese Japansk @msg Unknown dimension orientation Ukendt målretning @msg Unknown dimension style Ukendt målstil @msg Unknown unit Ukendt enhed - Close the circular ends of open profiles. Partial sweeps keep their cut sides open. Luk de runde ender af åbne profiler. Delvise omdrejninger beholder deres skårne sider åbne. + Close the circular ends of open profiles. Partial sweeps also close their cut sides. Luk de runde ender af åbne profiler. Delvise omdrejninger lukker også deres skårne sider. Darkness Mørke Isolate Selected Object Isolér markeret objekt Keep selected Behold markeret diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 527b1c89e8..e8e19bff9d 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -5758,7 +5758,7 @@ effect Soft Weich @msg Unknown dimension style Unbekannter Bemaßungsstil @msg Unknown unit Unbekannte Einheit # Revolve cap description - Close the circular ends of open profiles. Partial sweeps keep their cut sides open. Schließt die kreisförmigen Enden offener Profile. Bei einer Teildrehung bleiben die Schnittseiten offen. + Close the circular ends of open profiles. Partial sweeps also close their cut sides. Schließt die kreisförmigen Enden offener Profile. Bei einer Teildrehung werden auch die Schnittseiten geschlossen. Distance Abstand @msg span must be "object" or "selection", got {v} span muss "object" oder "selection" sein, nicht {v} @msg span: "selection" places a `gradient`, not a swatch span: "selection" platziert einen `gradient`, kein Farbfeld diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index a7dd7ed926..4f6337aed7 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -6030,7 +6030,7 @@ effect Points Σημεία By Object Ανά αντικείμενο Check an artboard to save. Επιλέξτε έναν πίνακα σχεδίασης για αποθήκευση. Clear All Εκκαθάριση όλων - Close the circular ends of open profiles. Partial sweeps keep their cut sides open. Κλείσιμο των κυκλικών άκρων των ανοιχτών προφίλ. Οι μερικές περιστροφές κρατούν ανοιχτές τις πλευρές τομής τους. + Close the circular ends of open profiles. Partial sweeps also close their cut sides. Κλείσιμο των κυκλικών άκρων των ανοιχτών προφίλ. Οι μερικές περιστροφές κλείνουν επίσης τις πλευρές τομής τους. Color Panel Options Επιλογές πίνακα χρώματος Color blindness – Tritanopia-type Αχρωματοψία – τύπου τριτανοπίας Create Dimension Δημιουργία διάστασης diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index cf3d0bbf96..220e2d11f9 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -6120,7 +6120,7 @@ mark-style Japanese Japonesas @msg Unknown dimension style Estilo de cota desconocido @msg Unknown unit Unidad desconocida # Revolve cap description - Close the circular ends of open profiles. Partial sweeps keep their cut sides open. Cierra los extremos circulares de los perfiles abiertos. Los giros parciales mantienen abiertos sus lados de corte. + Close the circular ends of open profiles. Partial sweeps also close their cut sides. Cierra los extremos circulares de los perfiles abiertos. Los giros parciales también cierran sus lados de corte. Distance Distancia @msg span must be "object" or "selection", got {v} span debe ser "object" o "selection", no {v} @msg span: "selection" places a `gradient`, not a swatch span: "selection" coloca un `gradient`, no una muestra diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index 24b7858169..8a8413199c 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -6041,7 +6041,7 @@ mark-style Japanese Japanilainen By Object Objektin mukaan Check an artboard to save. Valitse tallennettava piirtoalusta. Clear All Tyhjennä kaikki - Close the circular ends of open profiles. Partial sweeps keep their cut sides open. Sulje avointen profiilien pyöreät päät. Osittaiset pyöräytykset jättävät leikkauspintansa auki. + Close the circular ends of open profiles. Partial sweeps also close their cut sides. Sulje avointen profiilien pyöreät päät. Osittaiset pyöräytykset sulkevat myös leikkauspintansa. Color Panel Options Väri-paneelin asetukset Color blindness – Tritanopia-type Värisokeus – tritanopia Create Dimension Luo mitta diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 8303bbae94..75f10a3dfd 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -6171,7 +6171,7 @@ theme Appearance Apparence @msg Unknown dimension style Style de cote inconnu @msg Unknown unit Unité inconnue # Revolve cap description - Close the circular ends of open profiles. Partial sweeps keep their cut sides open. Ferme les extrémités circulaires des profils ouverts. Les rotations partielles conservent leurs faces de coupe ouvertes. + Close the circular ends of open profiles. Partial sweeps also close their cut sides. Ferme les extrémités circulaires des profils ouverts. Les rotations partielles ferment aussi leurs faces de coupe. @msg span must be "object" or "selection", got {v} span doit être "object" ou "selection", pas {v} @msg span: "selection" places a `gradient`, not a swatch span: "selection" place un `gradient`, pas une nuance @msg span: "selection" places a gradient: give `gradient` span: "selection" place un dégradé : indiquez `gradient` diff --git a/crates/ui-egui/src/i18n/gu.tsv b/crates/ui-egui/src/i18n/gu.tsv index 551c39d1f8..341c8aeead 100644 --- a/crates/ui-egui/src/i18n/gu.tsv +++ b/crates/ui-egui/src/i18n/gu.tsv @@ -601,7 +601,7 @@ Close Path… પાથ બંધ કરો… Close or Join બંધ કરો અથવા જોડો Close paths when ends are within: છેડા આ અંતરમાં હોય ત્યારે પાથ બંધ કરો: - Close the circular ends of open profiles. Partial sweeps keep their cut sides open. ખુલ્લી પ્રોફાઇલના ગોળ છેડા બંધ કરો. આંશિક સ્વીપ તેમની કાપેલી બાજુઓ ખુલ્લી રાખે છે. + Close the circular ends of open profiles. Partial sweeps also close their cut sides. ખુલ્લી પ્રોફાઇલના ગોળ છેડા બંધ કરો. આંશિક સ્વીપ તેમની કાપેલી બાજુઓ પણ બંધ કરે છે. Closing bracket with no opening one ખુલતા કૌંસ વગરનો બંધ થતો કૌંસ Coincidence: સંયોગ: Collapse Panel Group પેનલ ગ્રૂપ સંકોચો diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index 6a135dccaa..102ad3f05a 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -879,7 +879,7 @@ antiAlias Sharp शार्प Close Path: बंद पाथ: Close Path… बंद पाथ… Close paths when ends are within: जब समाप्त होता है तो बंद पाथ भीतर होते हैं: - Close the circular ends of open profiles. Partial sweeps keep their cut sides open. खुली प्रोफ़ाइल के गोल सिरे बंद करें। आंशिक स्वीप की कटी हुई साइड खुली रहती हैं। + Close the circular ends of open profiles. Partial sweeps also close their cut sides. खुली प्रोफ़ाइल के गोल सिरे बंद करें। आंशिक स्वीप की कटी हुई साइड भी बंद होती हैं। Closed बंद Closing bracket with no opening one बंद करने वाला ब्रैकेट, जिसका कोई खोलने वाला ब्रैकेट नहीं है Clumped गुच्छेदार diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 09a9797d3e..1aceaa1300 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -6158,7 +6158,7 @@ imageTrace Outline Körvonal @msg Unknown dimension style Ismeretlen méretezési stílus @msg Unknown unit Ismeretlen mértékegység # Revolve cap description - Close the circular ends of open profiles. Partial sweeps keep their cut sides open. Nyitott profilok kör alakú végeinek lezárása. Részleges körforgatás esetén a vágott oldalak nyitva maradnak. + Close the circular ends of open profiles. Partial sweeps also close their cut sides. Nyitott profilok kör alakú végeinek lezárása. Részleges körforgatás esetén a vágott oldalak is lezáródnak. Distance Távolság @msg span must be "object" or "selection", got {v} a span értéke "object" vagy "selection" lehet, nem {v} @msg span: "selection" places a `gradient`, not a swatch span: "selection" egy `gradient` értéket helyez el, nem színmintát diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index 32283beade..7421f0f607 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -5584,7 +5584,7 @@ mark-style Japanese Jepang @msg Unknown dimension orientation Orientasi dimensi tidak dikenal @msg Unknown dimension style Gaya dimensi tidak dikenal @msg Unknown unit Satuan tidak dikenal - Close the circular ends of open profiles. Partial sweeps keep their cut sides open. Menutup ujung melingkar profil terbuka. Sapuan parsial mempertahankan sisi potongannya tetap terbuka. + Close the circular ends of open profiles. Partial sweeps also close their cut sides. Menutup ujung melingkar profil terbuka. Sapuan parsial juga menutup sisi potongannya. Darkness Kegelapan Isolate Selected Object Isolasikan objek terpilih Keep selected Tetap terseleksi diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 2c8cc708dc..b94aa6cc34 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -5795,7 +5795,7 @@ lighting Light Luce @msg Unknown dimension style Stile di quota sconosciuto @msg Unknown unit Unità sconosciuta # Revolve cap description - Close the circular ends of open profiles. Partial sweeps keep their cut sides open. Chiude le estremità circolari dei profili aperti. Le rotazioni parziali mantengono aperti i lati di taglio. + Close the circular ends of open profiles. Partial sweeps also close their cut sides. Chiude le estremità circolari dei profili aperti. Le rotazioni parziali chiudono anche i lati di taglio. Distance Distanza @msg span must be "object" or "selection", got {v} span deve essere "object" o "selection", non {v} @msg span: "selection" places a `gradient`, not a swatch span: "selection" posiziona un `gradient`, non un campione diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index bd03123f11..8e7db179c3 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -5839,7 +5839,7 @@ lighting Light ライト @msg Unknown dimension style 寸法のスタイルが不明です @msg Unknown unit 単位が不明です # Revolve cap description - Close the circular ends of open profiles. Partial sweeps keep their cut sides open. 開いたプロファイルの円形の端を閉じます。部分的な回転では切断面は開いたままです。 + Close the circular ends of open profiles. Partial sweeps also close their cut sides. 開いたプロファイルの円形の端を閉じます。部分的な回転では切断面も閉じます。 Distance 距離 @msg span must be "object" or "selection", got {v} span は "object" または "selection" で指定してください ({v} は指定できません) @msg span: "selection" places a `gradient`, not a swatch span: "selection" は `gradient` を配置します。スウォッチは配置できません diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 54445dffb9..a3616ad36b 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -5804,7 +5804,7 @@ imageTrace Outline კონტური @msg Unknown dimension orientation ზომის უცნობი ორიენტაცია @msg Unknown dimension style ზომის უცნობი სტილი @msg Unknown unit უცნობი ერთეული - Close the circular ends of open profiles. Partial sweeps keep their cut sides open. ღია პროფილების წრიული ბოლოების დახურვა. ნაწილობრივი ბრუნვისას ჭრის მხარეები ღია რჩება. + Close the circular ends of open profiles. Partial sweeps also close their cut sides. ღია პროფილების წრიული ბოლოების დახურვა. ნაწილობრივი ბრუნვისას ჭრის მხარეებიც იხურება. Distance მანძილი # Upstream sync 2026-10-16 (2): Smart Blur modes, Layers panel filter, Color panel options, templates, PostScript files. Mode რეჟიმი diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 2f91553467..d1a182b4b6 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -5756,7 +5756,7 @@ lighting Light 광원 @msg Unknown dimension style 알 수 없는 치수 스타일 @msg Unknown unit 알 수 없는 단위 # Revolve cap description - Close the circular ends of open profiles. Partial sweeps keep their cut sides open. 열린 프로파일의 원형 끝을 닫습니다. 부분 회전에서는 절단 측면이 열린 상태로 유지됩니다. + Close the circular ends of open profiles. Partial sweeps also close their cut sides. 열린 프로파일의 원형 끝을 닫습니다. 부분 회전에서는 절단 측면도 닫힙니다. Distance 거리 @msg span must be "object" or "selection", got {v} span은 "object" 또는 "selection"이어야 합니다. {v}은(는) 사용할 수 없습니다 @msg span: "selection" places a `gradient`, not a swatch span: "selection"은 `gradient`를 배치합니다. 견본은 배치할 수 없습니다 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index b8eede91bd..2a0121465c 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -7988,7 +7988,7 @@ mark-style Japanese Japans @msg Unknown dimension orientation Onbekende maatlijnrichting @msg Unknown dimension style Onbekende maatlijnstijl @msg Unknown unit Onbekende eenheid - Close the circular ends of open profiles. Partial sweeps keep their cut sides open. Sluit de ronde uiteinden van open profielen. Gedeeltelijke omwentelingen houden hun afgesneden zijden open. + Close the circular ends of open profiles. Partial sweeps also close their cut sides. Sluit de ronde uiteinden van open profielen. Gedeeltelijke omwentelingen sluiten ook hun afgesneden zijden. Darkness Donkerte Isolate Selected Object Geselecteerd object isoleren Keep selected Geselecteerd houden diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index b846ae308c..7414b00635 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -6029,7 +6029,7 @@ mark-style Japanese Japońskie @msg Unknown dimension style Nieznany styl wymiaru @msg Unknown unit Nieznana jednostka # Revolve cap description - Close the circular ends of open profiles. Partial sweeps keep their cut sides open. Zamknij okrągłe końce otwartych profili. Przy częściowym obrocie boki przekroju pozostają otwarte. + Close the circular ends of open profiles. Partial sweeps also close their cut sides. Zamknij okrągłe końce otwartych profili. Przy częściowym obrocie boki przekroju również zostają zamknięte. Distance Odległość @msg span must be "object" or "selection", got {v} span musi mieć wartość "object" lub "selection", a nie {v} @msg span: "selection" places a `gradient`, not a swatch span: "selection" umieszcza `gradient`, a nie próbkę diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 9b74bba16e..fc13f816d0 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -6057,7 +6057,7 @@ mark-style Japanese Japonesas Create Dimension Criar Cota Update Dimensions Atualizar Cotas # Revolve cap description - Close the circular ends of open profiles. Partial sweeps keep their cut sides open. Fecha as extremidades circulares dos perfis abertos. Giros parciais mantêm as faces de corte abertas. + Close the circular ends of open profiles. Partial sweeps also close their cut sides. Fecha as extremidades circulares dos perfis abertos. Giros parciais também fecham as faces de corte. @msg span must be "object" or "selection", got {v} span deve ser "object" ou "selection", não {v} @msg span: "selection" places a `gradient`, not a swatch span: "selection" posiciona um `gradient`, não uma amostra @msg span: "selection" places a gradient: give `gradient` span: "selection" posiciona um degradê: informe `gradient` diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index cd904e1224..cde27b031a 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -5782,7 +5782,7 @@ lighting Light Свет @msg Unknown dimension style Неизвестный стиль размера @msg Unknown unit Неизвестная единица # Revolve cap description - Close the circular ends of open profiles. Partial sweeps keep their cut sides open. Закрывает круглые торцы открытых профилей. При неполном вращении боковые срезы остаются открытыми. + Close the circular ends of open profiles. Partial sweeps also close their cut sides. Закрывает круглые торцы открытых профилей. При неполном вращении боковые срезы тоже закрываются. Distance Расстояние @msg span must be "object" or "selection", got {v} span должен быть "object" или "selection", а не {v} @msg span: "selection" places a `gradient`, not a swatch span: "selection" размещает `gradient`, а не образец diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index 5d20472e7b..f2c808db5c 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -6025,7 +6025,7 @@ theme Appearance Utseende By Object Efter objekt Check an artboard to save. Markera en rityta som ska sparas. Clear All Rensa alla - Close the circular ends of open profiles. Partial sweeps keep their cut sides open. Stäng de cirkulära ändarna på öppna profiler. Partiella svep behåller sina snittsidor öppna. + Close the circular ends of open profiles. Partial sweeps also close their cut sides. Stäng de cirkulära ändarna på öppna profiler. Partiella svep stänger även sina snittsidor. Color Panel Options Alternativ för panelen Färg Color blindness – Tritanopia-type Färgblindhet – tritanopi Create Dimension Skapa mått diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index 9bdf0c5036..7e4b793b95 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -5939,7 +5939,7 @@ theme Appearance Görünüm @msg Unknown dimension orientation Bilinmeyen boyut yönü @msg Unknown dimension style Bilinmeyen boyut stili @msg Unknown unit Bilinmeyen birim - Close the circular ends of open profiles. Partial sweeps keep their cut sides open. Açık profillerin dairesel uçlarını kapatın. Kısmi süpürmeler kesik taraflarını açık tutar. + Close the circular ends of open profiles. Partial sweeps also close their cut sides. Açık profillerin dairesel uçlarını kapatın. Kısmi süpürmeler kesik taraflarını da kapatır. @msg span must be "object" or "selection", got {v} span "object" veya "selection" olmalıdır, {v} değil @msg span: "selection" places a `gradient`, not a swatch span: "selection" bir renk örneği değil, bir `gradient` yerleştirir @msg span: "selection" places a gradient: give `gradient` span: "selection" bir degrade yerleştirir: `gradient` verin diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 7395cdec64..7e5caf0332 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -5775,7 +5775,7 @@ lighting Light Світло @msg Unknown dimension style Невідомий стиль розміру @msg Unknown unit Невідома одиниця # Revolve cap description - Close the circular ends of open profiles. Partial sweeps keep their cut sides open. Закриває круглі торці відкритих профілів. За неповного обертання бічні зрізи залишаються відкритими. + Close the circular ends of open profiles. Partial sweeps also close their cut sides. Закриває круглі торці відкритих профілів. За неповного обертання бічні зрізи теж закриваються. Distance Відстань @msg span must be "object" or "selection", got {v} span має бути "object" або "selection", а не {v} @msg span: "selection" places a `gradient`, not a swatch span: "selection" розміщує `gradient`, а не зразок diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index 8df980ee37..38d3ffa42f 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -5780,7 +5780,7 @@ theme Appearance Giao diện @msg Unknown dimension style Kiểu kích thước không xác định @msg Unknown unit Đơn vị không xác định # Revolve cap description - Close the circular ends of open profiles. Partial sweeps keep their cut sides open. Đóng các đầu tròn của biên dạng mở. Khi xoay một phần, các mặt cắt bên vẫn mở. + Close the circular ends of open profiles. Partial sweeps also close their cut sides. Đóng các đầu tròn của biên dạng mở. Khi xoay một phần, các mặt cắt bên cũng được đóng. Distance Khoảng cách @msg span must be "object" or "selection", got {v} span phải là "object" hoặc "selection", không phải {v} @msg span: "selection" places a `gradient`, not a swatch span: "selection" đặt một `gradient`, không phải mẫu màu diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index ca19647856..2551462f17 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -6022,7 +6022,7 @@ lighting Light 光源 @msg Choose a circle or a perfect arc 请选择圆或标准圆弧 @msg Choose a precision from 0 to 6 请选择 0 到 6 之间的精度 # Revolve cap description - Close the circular ends of open profiles. Partial sweeps keep their cut sides open. 封闭开放轮廓的圆形端部。部分旋转的切割侧面保持开放。 + Close the circular ends of open profiles. Partial sweeps also close their cut sides. 封闭开放轮廓的圆形端部。部分旋转的切割侧面也会封闭。 Distance 距离 Make Image Dynamic 使图像动态化 Import Data Sets… 导入数据集… diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 748ff1848b..241374bc4c 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -5856,7 +5856,7 @@ lighting Light 光源 X: X: Y: Y: # Revolve cap description - Close the circular ends of open profiles. Partial sweeps keep their cut sides open. 封閉開放輪廓的圓形端部。部分旋轉的切割側面保持開放。 + Close the circular ends of open profiles. Partial sweeps also close their cut sides. 封閉開放輪廓的圓形端部。部分旋轉的切割側面也會封閉。 Distance 距離 Make Image Dynamic 使影像動態化 Import Data Sets… 匯入資料集… diff --git a/docs/effects-parity.md b/docs/effects-parity.md index 342a5171b6..0ce8dc778f 100644 --- a/docs/effects-parity.md +++ b/docs/effects-parity.md @@ -178,7 +178,7 @@ VectorCraft choices; an original approximation, never compared with another appl | Item | Ours | |---|---| -| Revolve | initial: live, editable profile, rotation and light gizmos, default-on Cap with continuous curved rims, smooth vector shading and round seam joins, overlapping faces drawn in the order of their depths where they overlap, SVG/PDF output, Expand Appearance ([revolve.md](revolve.md), #846) | +| Revolve | initial: live, editable profile, rotation and light gizmos, default-on Cap with continuous curved rims that also closes a partial sweep's cut sides, smooth vector shading and round seam joins, overlapping faces drawn in the order of their depths where they overlap, SVG/PDF output, Expand Appearance ([revolve.md](revolve.md), #846) | | Extrude & Bevel, Inflate, Rotate | initial: live, round seam joins, depth, twist, taper, solid or hollow caps, five original bevel shapes, Inflate volume, both sides, twist, taper and cap, Rotate of every fill and stroke, groups and layers turned about one shared axis (#4506), contours that cross, touch or overlap merged first ([three-d.md](three-d.md)), Position presets, rotation and light gizmos, SVG/PDF output, Expand Appearance ([three-d.md](three-d.md)) | | Materials panel, lighting, ray-traced render | Window › 3D and Materials panel with the object types (Plane, Extrude, Revolve, Inflate) and the Object, Rotation and Lighting settings of the applied effect, and Quick Actions › Expand as Wireframes ([three-d.md](three-d.md#3d-and-materials-panel)); one to ten directional lights with per-light Color (opaque RGB, white by default), Intensity, Rotation, Height, Softness and neutral Ambient Light, Revolve and colored Inflate use smooth vector shading; Extrude & Bevel and Rotate retain planar shading; original Standard, Diffuse, Top Left and Right lighting rigs; hard-edged shadows behind or below the object from the first light ([three-d.md](three-d.md#shadows)); the Materials tab's Graphics, document symbols mapped onto Extrude & Bevel's caps and onto a plane, moved with an artboard handle, and wrapped around Revolve's side ([three-d.md](three-d.md#graphics)); no base materials, graphics on Inflate or on Extrude & Bevel's walls and bevels, soft shadows or ray tracing | | 3D (Classic): Extrude & Bevel, Revolve, Rotate | Extrude & Bevel (Classic) initial: live, round seam joins, Extrude Depth, Cap, five original bevel shapes with Height and Bevel Extent In or Out, Position presets and rotation gizmo, Perspective, Wireframe, No Shading, Diffuse and Plastic surfaces with one to ten lights, Light Intensity, Ambient Light, Highlight Intensity and Size, Blend Steps, Black, Custom or no Shading Color, Draw Hidden Faces ([create 3D objects](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/create-3d-graphics/create-3d-objects.html)); Revolve (Classic) initial: live, round seam joins, Angle, Cap, Offset from the left or right edge, Position presets and rotation gizmo, Perspective, the same four surfaces, lights, highlight, Blend Steps and Shading Color, groups and layers revolved about one shared axis (same page); Rotate (Classic) initial: live, round seam joins, every fill and stroke turned as one plane, Position presets and rotation gizmo, Perspective, No Shading and Diffuse surfaces with lights, Ambient Light, Blend Steps and Shading Color ([rotate objects in 3D](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/create-3d-graphics/rotate-objects-in-3d.html)); Map Art: none | diff --git a/docs/mcp.md b/docs/mcp.md index 494b4f4ef6..88f113e58c 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -4063,9 +4063,12 @@ Parameters: `angle` (degrees, 0..360, default 360), `offset` (points, 0..100000, default 0), `ambient` (Ambient Light, 0..200%, default 25; an earlier `lightAzimuth` and `lightElevation` are read as the same light), `cap` (boolean, default true), and `expandVisibleOnly` (boolean, default true). A vertical-line profile needs a positive offset to have a radius. `cap` closes each circular endpoint of an open profile with one curved, uniformly shaded -vector path. Body faces share that curved rim. Partial sweeps use sectors and leave their angular -cut sides open. Closed or coincident-end profiles are unchanged. -Missing `cap` enables caps; set it to false for open endpoints. Shaded Revolve surfaces automatically interpolate curved-surface lighting with vector gradients while preserving profile corners and flat caps. There is no separate smoothing parameter. `shade: false` disables all lighting. Visibility of intersecting surfaces is approximate. +vector path. Body faces share that curved rim. Partial sweeps use sectors, and `cap` also closes their two +angular cut sides with flat faces: the region between each open subpath and the axis and the area of each closed +subpath, one face for each region. A closed subpath that walls a hole under the object's fill rule leaves that +hole open. +Exported 3D meshes include the cut sides. +Missing `cap` enables caps; set it to false for open endpoints and open cut sides (hollow). Shaded Revolve surfaces automatically interpolate curved-surface lighting with vector gradients while preserving profile corners and flat caps. There is no separate smoothing parameter. `shade: false` disables all lighting. Visibility of intersecting surfaces is approximate. `lights` is null by default, retaining the earlier single-light controls. Set an array of one to ten objects to replace that light: `{color: "#rrggbb", intensity: 0..100, rotation: -180..180, height: 0..90, softness: 0..100, behind: bool}`. Defaults per light are white, 80%, 125.26 degrees, 30 degrees, 0%, false. Omitted fields use defaults; unknown nested keys and malformed lists are refused before mutation. `ambient` is shared and counted once. Set `lights: null` to restore the earlier controls. The list is saved in the native file and survives preview, undo and expansion. ```json @@ -4258,7 +4261,7 @@ an unknown surface or shading color is refused with an error and the document is `effect.apply {effect: "threeD.classicRevolve", params: {...}, ids?, item?}` is Effect › 3D and Materials › 3D (Classic) › Revolve (Classic)…. It sweeps the profile round a vertical axis as `threeD.revolve` does, at 64 segments for a full turn, and draws every face, back to front, with the classic surfaces. Parameters: `angle` (degrees, -0..360, default 360), `cap` (true closes the profile's open ends, false leaves the surface hollow), `offset` (points, +0..360, default 360), `cap` (true closes the profile's open ends and a partial sweep's cut sides, false leaves the surface hollow), `offset` (points, 0..1000, default 0; the axis's distance from the profile, so a value above 0 makes a ring), `edge` (`left`, the default, or `right`: the edge of the profile's bounds the axis is at), `rotationX/Y/Z` and `perspectiveAngle` as above, and `surface`, the lights, `ambient`, `highlightIntensity`, `highlightSize`, `blendSteps`, `shadingColor` and diff --git a/docs/revolve.md b/docs/revolve.md index 7e80ee3e24..99165377d9 100644 --- a/docs/revolve.md +++ b/docs/revolve.md @@ -75,10 +75,17 @@ orthographic view); a partial turn produces a sector. Body faces share the same so no triangle patches interrupt the cap edge. Caps share the surface's rotation, perspective and paint, and appear in preview, SVG/PDF export and Expand Appearance. The checkbox has a reset dot and is included in Reset all. -An endpoint on the axis needs no cap. Closed profiles and open profiles whose endpoints coincide -keep their existing geometry. Each open subpath of a compound profile is capped independently. -A partial revolve adds only the swept sector at each endpoint; the angular cut sides remain open. -This option does not make intersecting or compound profiles into a watertight solid. +An endpoint on the axis needs no cap. Each open subpath of a compound profile is capped independently. + +With an Angle below 360°, Cap also closes the two angular cut sides, so the object appears solid; with Cap +off it is hollow ([Revolve options](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=185)). +Each cut side is flat and uniformly shaded, and is drawn in depth order with the rest of the surface. It covers the +region between each open subpath and the axis, and the area each closed subpath encloses, with one face for each +region. A closed subpath that walls a hole under the object's fill rule leaves that hole open in the face of the +region around it, and the other regions are filled. A self-intersecting subpath fills what the nonzero rule fills, +with one face for each loop it encloses; this is VectorCraft's own rule. A cut side seen edge on is not drawn. +The cut sides appear in preview, SVG/PDF export, Expand Appearance, Expand as Wireframes, Revolve (Classic) and +exported 3D meshes. Cap does not make intersecting profiles into a watertight solid. In **Advanced**, **Keep visible surfaces only when expanding** is on by default. Expansion removes completely covered faces and trims partially covered ones using the current rotation and perspective. @@ -98,12 +105,12 @@ with the standard command. - Lighting offers Standard, Diffuse, Top Left and Right, using the [shared original rigs](three-d.md#presets). Other effective settings show Custom; changing the view does not change the recognized lighting preset. - Paths, compound paths, type, clipping groups, blends, symbol instances, and groups or layers of them. A clipping group, a blend or a symbol instance sweeps the art it shows about one axis, as described in [three-d.md](three-d.md#clipping-groups-blends-and-symbol-instances). Images must be traced first with Object › Image Trace › Make, and other live objects expanded. -- Open profiles have circular end caps by default; turning Cap off keeps them open. Partial-sweep angular cut sides remain open. Closed profile boundaries are swept as provided. +- Open profiles have circular end caps by default, and a partial sweep closes its angular cut sides; turning Cap off keeps both open. Closed profile boundaries are swept as provided. - One Revolve per source object. Edit its options rather than applying another. - Object-level Revolve uses the top visible fill, falling back to a stroke. Per-item Revolve uses that item's paint. - Smooth diffuse shading, one to ten directional lights, no textures, cast shadows or physical materials. Smooth shading interpolates lighting in projected triangles; it does not smooth the silhouette or add specular highlights. - Faces are drawn back to front by the depths of their centers. When that order draws the nearer of two overlapping faces of a surface first, every pair of overlapping faces goes in the order of their depths at the middle of where they overlap; the sort compares at most 4,000,000 pairs (VectorCraft's own limit), and the pairs past that keep the depths of their centers. Caps facing the camera cover their rim seams; a cap facing away is drawn behind the body except where it is nearer than a body face it overlaps. Intersecting profiles can have incorrect visibility. -- Curves use sixteen samples per segment, and as few as four when a surface would otherwise pass its limits. Surfaces are limited to 16,384 profile points and 163,840 faces, the members of a group together. A straight segment takes one point, a curve takes at least four, and each contour takes one. Smooth shaded side quads become two triangles and share the face limit. A continuous cap retains its original radial mesh cost within this limit. Projected ring curves have a 0.001-point fitting tolerance and a shared 32,768-curve limit. +- Curves use sixteen samples per segment, and as few as four when a surface would otherwise pass its limits. Surfaces are limited to 16,384 profile points and 163,840 faces, the members of a group together. A straight segment takes one point, a curve takes at least four, and each contour takes one. Smooth shaded side quads become two triangles and share the face limit. A continuous cap retains its original radial mesh cost within this limit, and each region of a cut side counts as one face. Projected ring curves have a 0.001-point fitting tolerance and a shared 32,768-curve limit. - Axis, bounds and ordinary selection handles continue to refer to the editable 2D source profile. - Extrude & Bevel, Inflate and Rotate are described in [three-d.md](three-d.md). Materials remain unimplemented. diff --git a/docs/three-d.md b/docs/three-d.md index 871b28772c..4adc5716ee 100644 --- a/docs/three-d.md +++ b/docs/three-d.md @@ -528,7 +528,8 @@ out, perspective). No Adobe software, assets, presets or bevel shapes were used. across the shape) is refused because the 3D surface is too complex; a closed path of 65,536 points round a circle builds. - **3D (Classic)**: Extrude & Bevel (Classic), Revolve (Classic) and Rotate (Classic) are built, with their surface - types and blend steps. Revolve (Classic) sweeps the surface Revolve sweeps, at 64 segments for a full turn, and draws + types and blend steps. Revolve (Classic) sweeps the surface Revolve sweeps, with Cap closing a partial sweep's cut + sides ([revolve.md](revolve.md)), at 64 segments for a full turn, and draws every face back to front, so it has no Draw Hidden Faces setting. Rotate (Classic) turns the plane Rotate turns, seen from either side, with the No Shading and Diffuse surfaces only. The track cube, map art, Turntable and 3D export are separate, unbuilt items.