pub struct RenderScene { /* private fields */ }Expand description
The scene: insertion-ordered solids + an exact name index (R8 — the
getObjectByName heuristic-scoring lookup is replaced by this map).
Implementations§
Source§impl RenderScene
impl RenderScene
pub fn new() -> Self
Sourcepub fn insert_solid(&mut self, solid: SolidDisplay)
pub fn insert_solid(&mut self, solid: SolidDisplay)
Insert or replace a solid by name (replacement keeps insertion order — a boolean result reusing its target’s name stays in place).
Sourcepub fn drain(&mut self) -> Vec<SolidDisplay>
pub fn drain(&mut self) -> Vec<SolidDisplay>
Empty the scene, RETURNING every solid by value (the name index is cleared
and the vec is mem::take-n out). The history-apply seam MOVES existing
displays out this way to reinsert the reused ones without cloning their
meshes — a scene-free crate::pipeline::SceneRunner delta is applied by
draining then reinserting in snapshot order.
Sourcepub fn set_color_override(
&mut self,
name: &str,
color: Option<[f32; 3]>,
) -> bool
pub fn set_color_override( &mut self, name: &str, color: Option<[f32; 3]>, ) -> bool
Set (or clear) a solid’s metadata color override, bumping its revision so the renderer re-derives the base style. Returns false if unknown.
Sourcepub fn apply_metadata_colors(
&mut self,
lookup: impl Fn(&str) -> Option<[f32; 3]>,
) -> bool
pub fn apply_metadata_colors( &mut self, lookup: impl Fn(&str) -> Option<[f32; 3]>, ) -> bool
Re-derive every solid’s and face’s base colour from the name-keyed
metadata store — the ONE seam through which the durable color
attribute reaches the display.
lookup maps an object NAME (a solid’s or a face’s) to its resolved
colour. It returns None both for “no colour recorded” and for “the
display setting is overriding model colours”, so this method needs to
know about neither.
SKETCH sheets are skipped: their color_override is the synthesized
[crate::engine_state::SKETCH_SHEET_COLOR], not a metadata colour, and
re-deriving it from a store that has no record for the sheet would blank
it back to the global face colour.
A changed solid’s revision is bumped so the renderer re-uploads it —
and ONLY when something actually changed. That no-op guarantee is
load-bearing, not a nicety: this runs after EVERY history apply, and the
R10 GPU-buffer reuse fast path keys off a stable revision.
Sourcepub fn set_visible(&mut self, name: &str, visible: bool) -> bool
pub fn set_visible(&mut self, name: &str, visible: bool) -> bool
Set a solid’s visibility (R11). Returns false if unknown.
Sourcepub fn listing_json(&self) -> String
pub fn listing_json(&self) -> String
Scene enumeration for the host scene-tree panel (R11): names, kind, visibility, child face/edge/vertex counts — as JSON.
Sourcepub fn remove_solid(&mut self, name: &str) -> bool
pub fn remove_solid(&mut self, name: &str) -> bool
Remove a solid by exact name.
pub fn solid(&self, name: &str) -> Option<&SolidDisplay>
pub fn solid_mut(&mut self, name: &str) -> Option<&mut SolidDisplay>
Sourcepub fn solids(&self) -> &[SolidDisplay]
pub fn solids(&self) -> &[SolidDisplay]
Insertion-ordered iteration (deterministic — drives draw order).
Sourcepub fn edge_polyline_world(&self, name: &str) -> Option<Vec<[f64; 3]>>
pub fn edge_polyline_world(&self, name: &str) -> Option<Vec<[f64; 3]>>
The world-space polyline of the first display edge named name across all
solids (widened to f64), or None when no edge carries that exact name.
The engine-native sketch pickEdges tool (S6b-2) uses this to fetch a picked
scene edge’s geometry for projection into the sketch plane. There is no name
index for edges (only solids), so this is a linear scan — fine for the
interactive per-click use.
Sourcepub fn edge_solid_name(&self, name: &str) -> Option<&str>
pub fn edge_solid_name(&self, name: &str) -> Option<&str>
The name of the solid owning the first display edge named name, or None
(the companion of edge_polyline_world — the
pickEdges tool stores it as external-ref metadata).
Sourcepub fn face_plane_world(&self, name: &str) -> Option<([f64; 3], [f64; 3])>
pub fn face_plane_world(&self, name: &str) -> Option<([f64; 3], [f64; 3])>
The world plane of the first display face named name across all solids,
as (centroid, unit outward normal): the area-weighted centroid of the
face’s mesh triangles and the normalized sum of their cross products. The
watertight tessellation winds every face’s triangles by same_sense, so
the cross-product sum IS the outward normal (the stored per-vertex normals
are shading normals and can be blended at shared boundary vertices). This
is what lets an extrude/revolve whose profile is a resident solid FACE
(not a sketch) anchor its dimension gizmo — the engine’s dimension refs
fall back to it (EngineState::lookup_profile_plane). Hidden solids count
too: a hidden source solid still anchors the gizmo. None when no face
carries that exact name, it has no triangles, or the triangles are
degenerate (zero area). Linear scan like edge_polyline_world.
pub fn is_empty(&self) -> bool
Source§impl RenderScene
impl RenderScene
Sourcepub fn set_entity_visible(
&mut self,
solid: &str,
kind: EntityKind,
index: usize,
visible: bool,
) -> bool
pub fn set_entity_visible( &mut self, solid: &str, kind: EntityKind, index: usize, visible: bool, ) -> bool
Show/hide ONE face/edge/vertex of a solid. False if the solid is unknown.
Sourcepub fn set_group_visible(
&mut self,
solid: &str,
kind: EntityKind,
visible: bool,
) -> bool
pub fn set_group_visible( &mut self, solid: &str, kind: EntityKind, visible: bool, ) -> bool
Show/hide a whole group (all faces / all edges / all vertices) of a solid. False if the solid is unknown.
Sourcepub fn entity_visible(
&self,
solid: &str,
kind: EntityKind,
index: usize,
) -> Option<bool>
pub fn entity_visible( &self, solid: &str, kind: EntityKind, index: usize, ) -> Option<bool>
Whether entity index of kind on solid is shown (None if unknown).
Sourcepub fn group_visibility(
&self,
solid: &str,
kind: EntityKind,
) -> Option<GroupState>
pub fn group_visibility( &self, solid: &str, kind: EntityKind, ) -> Option<GroupState>
The group tristate for solid’s kind (None if the solid is unknown).
Trait Implementations§
Source§impl Debug for RenderScene
impl Debug for RenderScene
Source§impl Default for RenderScene
impl Default for RenderScene
Source§fn default() -> RenderScene
fn default() -> RenderScene
Auto Trait Implementations§
impl Freeze for RenderScene
impl RefUnwindSafe for RenderScene
impl Send for RenderScene
impl Sync for RenderScene
impl Unpin for RenderScene
impl UnsafeUnpin for RenderScene
impl UnwindSafe for RenderScene
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more