Skip to main content

RenderScene

Struct RenderScene 

Source
pub struct RenderScene {
    pub highlight: Vec<(String, String, bool)>,
    pub tint: Option<[f32; 4]>,
    /* private fields */
}
Expand description

The scene: insertion-ordered solids + an exact name index (R8 — the getObjectByName heuristic-scoring lookup is replaced by this map).

Fields§

§highlight: Vec<(String, String, bool)>

A Work part’s CONTEXT scene only: the context faces drawn emphasised, (solid, face, selected) (else hovered). Set by EngineState::sync_context_highlight; the context render pass reads it.

§tint: Option<[f32; 4]>

A Work part’s CONTEXT scene only: its colour and opacity (None: the default crate::render::WORK_PART_CONTEXT_RGBA). Set by EngineState::set_context_display; the context render pass reads it.

Implementations§

Source§

impl RenderScene

Source

pub fn new() -> Self

Source

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).

Source

pub fn clear(&mut self)

Drop every solid (the scene rebuild path clears then repopulates).

Source

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.

Source

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.

Source

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.

Source

pub fn set_visible(&mut self, name: &str, visible: bool) -> bool

Set a solid’s visibility (R11). Returns false if unknown.

Source

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.

Source

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.

Source

pub fn remove_solid(&mut self, name: &str) -> bool

Remove a solid by exact name.

Source

pub fn solid(&self, name: &str) -> Option<&SolidDisplay>

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn exact_revision(&self) -> u64

See Self::exact’s revision counter.

Source

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.

Source

pub fn exact_solid_fingerprinted(&self, name: &str) -> Option<(&BrepSolid, u64)>

Self::exact_solid with its content fingerprint.

Source

pub fn solid_mut(&mut self, name: &str) -> Option<&mut SolidDisplay>

Source

pub fn solids(&self) -> &[SolidDisplay]

Insertion-ordered iteration (deterministic — drives draw order).

Source

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.

Source

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).

Source

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.

Source

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.

Source

pub fn is_empty(&self) -> bool

Source

pub fn bbox(&self) -> Aabb

World bbox over every VISIBLE solid.

Source§

impl RenderScene

Source

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.

Source

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.

Source

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).

Source

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RenderScene

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pipe for T
where T: ?Sized,

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows 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
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows 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
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .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
where Self: BorrowMut<B>, B: ?Sized,

Calls .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
where Self: AsRef<R>, R: ?Sized,

Calls .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
where Self: AsMut<R>, R: ?Sized,

Calls .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
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,