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 visibility_revision(&self) -> u64
pub fn visibility_revision(&self) -> u64
Monotonic counter of VISIBILITY changes — the cache key for anything derived from which bodies are shown.
Hiding a body is SESSION state: it writes no history, runs nothing, and
lands no exact solid, so it moves none of the counters a derived
drawing would otherwise key on. A drawing sheet draws “the solids
visible in the scene” (sheets::project::sheet_solid_names), so its
cached projection depends on this and nothing else could tell it.
Only a REAL change counts. EngineState::apply_view_display sets every
solid’s visibility from the active PMI view’s hidden set on every
activation, and almost all of those calls are no-ops; counting them
would re-project the open sheet for nothing.
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>
Sourcepub fn prune_exact_solids(&mut self)
pub fn prune_exact_solids(&mut self)
Drop every kept B-rep whose display is gone or now comes from a different handle. Called after a run’s displays are reconciled, so “the display’s handle” is that run’s.
Sourcepub fn set_exact_solid(
&mut self,
name: &str,
handle: u32,
solid: BrepSolid,
) -> bool
pub fn set_exact_solid( &mut self, name: &str, handle: u32, solid: BrepSolid, ) -> bool
Record the B-rep the runner sent for name, when handle is still the
one its display was tessellated from; false (and nothing kept) when
the display has moved on since the request went out.
Sourcepub fn drop_exact_solid(&mut self, name: &str)
pub fn drop_exact_solid(&mut self, name: &str)
Forget the B-rep of name: its geometry changed under the SAME handle
(an assembly solve re-poses a resident solid in place), so the next
projection must ask again.
Sourcepub fn clear_exact_solids(&mut self)
pub fn clear_exact_solids(&mut self)
Forget every B-rep: the handles they were keyed by belong to a runner that is gone (a cancel restarts its registry, which counts from one again) or to a document that was replaced.
Sourcepub fn exact_revision(&self) -> u64
pub fn exact_revision(&self) -> u64
See Self::exact’s revision counter.
Sourcepub fn exact_solid(&self, name: &str) -> Option<&BrepSolid>
pub fn exact_solid(&self, name: &str) -> Option<&BrepSolid>
The B-rep the displayed solid name was tessellated from, or None
when the scene holds none for its CURRENT handle — a synthesized sketch
sheet, or a solid whose topology did not reach this thread.
Sourcepub fn exact_solid_fingerprinted(&self, name: &str) -> Option<(&BrepSolid, u64)>
pub fn exact_solid_fingerprinted(&self, name: &str) -> Option<(&BrepSolid, u64)>
Self::exact_solid with its content fingerprint.
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.
Sourcepub fn face_is_planar(&self, name: &str) -> bool
pub fn face_is_planar(&self, name: &str) -> bool
Whether the display face named name is PLANAR: every one of its mesh
triangles’ normals is parallel to the face’s summed normal (within
1e-4 in the sine). A cylinder, cone or freeform face fails this; a
face with no triangles is not planar either. Linear scan like
face_plane_world — the 3D sketch editor asks
this once per reference pick, never per frame.
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
Auto Trait Implementations§
impl !Freeze for RenderScene
impl !RefUnwindSafe for RenderScene
impl !Sync for RenderScene
impl Send 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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.