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: SceneStatsImplementations§
Source§impl Scene
impl Scene
pub fn new() -> Self
pub fn spawn_glyph(&mut self, glyph: Glyph) -> GlyphId
pub fn despawn_glyph(&mut self, id: GlyphId)
pub fn get_glyph(&self, id: GlyphId) -> Option<&Glyph>
pub fn get_glyph_mut(&mut self, id: GlyphId) -> Option<&mut Glyph>
pub fn spawn_entity(&mut self, entity: AmorphousEntity) -> EntityId
pub fn despawn_entity(&mut self, id: EntityId)
pub fn get_entity(&self, id: EntityId) -> Option<&AmorphousEntity>
pub fn get_entity_mut(&mut self, id: EntityId) -> Option<&mut AmorphousEntity>
pub fn add_field(&mut self, field: ForceField) -> FieldId
pub fn remove_field(&mut self, id: FieldId)
pub fn get_field(&self, id: FieldId) -> Option<&ForceField>
pub fn get_field_mut(&mut self, id: FieldId) -> Option<&mut ForceField>
pub fn create_node(&mut self, name: impl Into<String>) -> NodeId
pub fn destroy_node(&mut self, id: NodeId)
pub fn attach_node(&mut self, child: NodeId, parent: NodeId)
pub fn detach_node(&mut self, id: NodeId)
pub fn get_node(&self, id: NodeId) -> Option<&SceneNode>
pub fn get_node_mut(&mut self, id: NodeId) -> Option<&mut SceneNode>
pub fn find_node_by_name(&self, name: &str) -> Option<NodeId>
pub fn find_nodes_by_tag(&self, tag: u32) -> Vec<NodeId>
Sourcepub fn attach_glyph_to_node(&mut self, glyph_id: GlyphId, node_id: NodeId)
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.
pub fn set_layer_visible(&mut self, layer: LayerId, visible: bool)
pub fn is_layer_visible(&self, layer: LayerId) -> bool
pub fn add_zone(&mut self, zone: AmbientZone)
pub fn remove_zone(&mut self, name: &str)
Sourcepub fn zone_at(&self, pos: Vec3) -> Option<(&AmbientZone, f32)>
pub fn zone_at(&self, pos: Vec3) -> Option<(&AmbientZone, f32)>
Find the ambient zone at a world position (first match, blended weight).
pub fn add_portal( &mut self, origin: Vec3, target: Vec3, normal: Vec3, extent: Vec2, ) -> PortalId
pub fn link_portals(&mut self, a: PortalId, b: PortalId)
Sourcepub fn tick(&mut self, dt: f32)
pub fn tick(&mut self, dt: f32)
Advance the scene by dt seconds: step physics, age glyphs/particles, apply fields.
Sourcepub fn rebuild_bvh(&mut self)
pub fn rebuild_bvh(&mut self)
Rebuild the BVH if dirty. Call before performing spatial queries.
Sourcepub fn glyphs_in_sphere(&self, center: Vec3, radius: f32) -> Vec<GlyphId>
pub fn glyphs_in_sphere(&self, center: Vec3, radius: f32) -> Vec<GlyphId>
Find all glyphs within radius of center.
Sourcepub fn raycast_glyphs(
&self,
origin: Vec3,
direction: Vec3,
max_dist: f32,
) -> Option<RaycastHit>
pub fn raycast_glyphs( &self, origin: Vec3, direction: Vec3, max_dist: f32, ) -> Option<RaycastHit>
Raycast against all glyphs, return nearest hit.
Sourcepub fn entities_in_sphere(&self, center: Vec3, radius: f32) -> Vec<EntityId>
pub fn entities_in_sphere(&self, center: Vec3, radius: f32) -> Vec<EntityId>
Return all entities within radius.
Sourcepub fn nearest_entity(&self, point: Vec3) -> Option<EntityId>
pub fn nearest_entity(&self, point: Vec3) -> Option<EntityId>
Return the nearest entity to point, if any.
Sourcepub fn entities_with_tag(&self, tag: &str) -> Vec<EntityId>
pub fn entities_with_tag(&self, tag: &str) -> Vec<EntityId>
Return all entities with a given tag.
pub fn snapshot(&self) -> SceneSnapshot
Sourcepub fn gc(&mut self)
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.
Sourcepub fn spawn_glyph_grid(
&mut self,
origin: Vec3,
cols: u32,
rows: u32,
spacing: f32,
glyph_fn: impl Fn(u32, u32) -> Glyph,
) -> Vec<GlyphId>
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.
Sourcepub fn spawn_glyph_ring(
&mut self,
center: Vec3,
radius: f32,
count: u32,
glyph_fn: impl Fn(u32) -> Glyph,
) -> Vec<GlyphId>
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.
Sourcepub fn despawn_glyphs(&mut self, ids: &[GlyphId])
pub fn despawn_glyphs(&mut self, ids: &[GlyphId])
Despawn all glyphs in a list.
pub fn drain_events(&mut self) -> Vec<SceneEvent>
pub fn push_event(&mut self, e: SceneEvent)
pub fn diagnostics(&self) -> String
Trait Implementations§
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> 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
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
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>
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)
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)
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.