Skip to main content

Scene

Struct Scene 

Source
pub struct Scene {
Show 13 fields pub glyphs: GlyphPool, pub particles: ParticlePool, pub entities: Vec<(EntityId, AmorphousEntity)>, pub fields: Vec<(FieldId, ForceField)>, pub time: f32, pub nodes: HashMap<NodeId, SceneNode>, pub root_nodes: Vec<NodeId>, pub layers: [SceneLayer; 8], pub zones: Vec<AmbientZone>, pub portals: Vec<Portal>, pub bvh: Option<Bvh>, pub events: SceneEventQueue, pub stats: SceneStats, /* private fields */
}
Expand description

The complete scene: all renderable objects and active forces.

Fields§

§glyphs: GlyphPool§particles: ParticlePool§entities: Vec<(EntityId, AmorphousEntity)>§fields: Vec<(FieldId, ForceField)>§time: f32§nodes: HashMap<NodeId, SceneNode>§root_nodes: Vec<NodeId>§layers: [SceneLayer; 8]§zones: Vec<AmbientZone>§portals: Vec<Portal>§bvh: Option<Bvh>§events: SceneEventQueue§stats: SceneStats

Implementations§

Source§

impl Scene

Source

pub fn new() -> Self

Source

pub fn spawn_glyph(&mut self, glyph: Glyph) -> GlyphId

Source

pub fn despawn_glyph(&mut self, id: GlyphId)

Source

pub fn get_glyph(&self, id: GlyphId) -> Option<&Glyph>

Source

pub fn get_glyph_mut(&mut self, id: GlyphId) -> Option<&mut Glyph>

Source

pub fn spawn_entity(&mut self, entity: AmorphousEntity) -> EntityId

Source

pub fn despawn_entity(&mut self, id: EntityId)

Source

pub fn get_entity(&self, id: EntityId) -> Option<&AmorphousEntity>

Source

pub fn get_entity_mut(&mut self, id: EntityId) -> Option<&mut AmorphousEntity>

Source

pub fn add_field(&mut self, field: ForceField) -> FieldId

Source

pub fn remove_field(&mut self, id: FieldId)

Source

pub fn get_field(&self, id: FieldId) -> Option<&ForceField>

Source

pub fn get_field_mut(&mut self, id: FieldId) -> Option<&mut ForceField>

Source

pub fn create_node(&mut self, name: impl Into<String>) -> NodeId

Source

pub fn destroy_node(&mut self, id: NodeId)

Source

pub fn attach_node(&mut self, child: NodeId, parent: NodeId)

Source

pub fn detach_node(&mut self, id: NodeId)

Source

pub fn get_node(&self, id: NodeId) -> Option<&SceneNode>

Source

pub fn get_node_mut(&mut self, id: NodeId) -> Option<&mut SceneNode>

Source

pub fn find_node_by_name(&self, name: &str) -> Option<NodeId>

Source

pub fn find_nodes_by_tag(&self, tag: u32) -> Vec<NodeId>

Source

pub fn attach_glyph_to_node(&mut self, glyph_id: GlyphId, node_id: NodeId)

Attach a glyph to a node so it moves with it.

Source

pub fn set_layer_visible(&mut self, layer: LayerId, visible: bool)

Source

pub fn is_layer_visible(&self, layer: LayerId) -> bool

Source

pub fn add_zone(&mut self, zone: AmbientZone)

Source

pub fn remove_zone(&mut self, name: &str)

Source

pub fn zone_at(&self, pos: Vec3) -> Option<(&AmbientZone, f32)>

Find the ambient zone at a world position (first match, blended weight).

Source

pub fn add_portal( &mut self, origin: Vec3, target: Vec3, normal: Vec3, extent: Vec2, ) -> PortalId

Source

pub fn tick(&mut self, dt: f32)

Advance the scene by dt seconds: step physics, age glyphs/particles, apply fields.

Source

pub fn rebuild_bvh(&mut self)

Rebuild the BVH if dirty. Call before performing spatial queries.

Source

pub fn glyphs_in_sphere(&self, center: Vec3, radius: f32) -> Vec<GlyphId>

Find all glyphs within radius of center.

Source

pub fn raycast_glyphs( &self, origin: Vec3, direction: Vec3, max_dist: f32, ) -> Option<RaycastHit>

Raycast against all glyphs, return nearest hit.

Source

pub fn entities_in_sphere(&self, center: Vec3, radius: f32) -> Vec<EntityId>

Return all entities within radius.

Source

pub fn nearest_entity(&self, point: Vec3) -> Option<EntityId>

Return the nearest entity to point, if any.

Source

pub fn entities_with_tag(&self, tag: &str) -> Vec<EntityId>

Return all entities with a given tag.

Source

pub fn snapshot(&self) -> SceneSnapshot

Source

pub fn gc(&mut self)

Remove all expired glyphs/particles and despawned entities. Already handled by tick, but can be called manually to force GC.

Source

pub fn clear(&mut self)

Clear the entire scene.

Source

pub fn spawn_glyph_grid( &mut self, origin: Vec3, cols: u32, rows: u32, spacing: f32, glyph_fn: impl Fn(u32, u32) -> Glyph, ) -> Vec<GlyphId>

Spawn a burst of glyphs in a grid pattern.

Source

pub fn spawn_glyph_ring( &mut self, center: Vec3, radius: f32, count: u32, glyph_fn: impl Fn(u32) -> Glyph, ) -> Vec<GlyphId>

Spawn a ring of glyphs.

Source

pub fn despawn_glyphs(&mut self, ids: &[GlyphId])

Despawn all glyphs in a list.

Source

pub fn drain_events(&mut self) -> Vec<SceneEvent>

Source

pub fn push_event(&mut self, e: SceneEvent)

Source

pub fn diagnostics(&self) -> String

Trait Implementations§

Source§

impl Default for Scene

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl Freeze for Scene

§

impl RefUnwindSafe for Scene

§

impl Send for Scene

§

impl Sync for Scene

§

impl Unpin for Scene

§

impl UnsafeUnpin for Scene

§

impl UnwindSafe for Scene

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<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,