pub struct GameObjectScene {
pub name: String,
pub objects: Vec<GameObject>,
/* private fields */
}Expand description
A bounded scene of game objects with hierarchy support.
Serializable as JSON for .wm scene files, editor snapshots, and replication.
Fields§
§name: String§objects: Vec<GameObject>Implementations§
Source§impl GameObjectScene
impl GameObjectScene
pub fn new(name: String) -> Self
Sourcepub fn spawn(&mut self, name: String) -> Result<u64, String>
pub fn spawn(&mut self, name: String) -> Result<u64, String>
Spawn an empty game object. Returns its ID.
Sourcepub fn spawn_primitive(
&mut self,
name: String,
kind: PrimitiveKind,
) -> Result<u64, String>
pub fn spawn_primitive( &mut self, name: String, kind: PrimitiveKind, ) -> Result<u64, String>
Spawn a game object with a primitive mesh. Returns its ID.
pub fn find(&self, id: u64) -> Option<&GameObject>
pub fn find_mut(&mut self, id: u64) -> Option<&mut GameObject>
Sourcepub fn despawn(&mut self, id: u64) -> bool
pub fn despawn(&mut self, id: u64) -> bool
Despawn an object by ID. Clears dangling parent references.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn roots(&self) -> impl Iterator<Item = &GameObject>
pub fn roots(&self) -> impl Iterator<Item = &GameObject>
Root objects (no parent).
Sourcepub fn children_of(&self, parent_id: u64) -> impl Iterator<Item = &GameObject>
pub fn children_of(&self, parent_id: u64) -> impl Iterator<Item = &GameObject>
Children of a given parent.
Sourcepub fn propagate_transforms(&self) -> Vec<[f32; 16]>
pub fn propagate_transforms(&self) -> Vec<[f32; 16]>
Propagate transforms through the parent-child hierarchy.
Each child’s world matrix = parent_world * child_local.
Stores results indexed by object position in self.objects.
Uses topological BFS from roots — O(N) single pass, each object computed exactly once. Parents are always processed before children.
Sourcepub fn visible_mesh_count(&self) -> usize
pub fn visible_mesh_count(&self) -> usize
Count of visible objects with a mesh binding.
Trait Implementations§
Source§impl Clone for GameObjectScene
impl Clone for GameObjectScene
Source§fn clone(&self) -> GameObjectScene
fn clone(&self) -> GameObjectScene
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for GameObjectScene
impl Debug for GameObjectScene
Source§impl Default for GameObjectScene
impl Default for GameObjectScene
Source§fn default() -> GameObjectScene
fn default() -> GameObjectScene
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for GameObjectScene
impl<'de> Deserialize<'de> for GameObjectScene
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for GameObjectScene
impl RefUnwindSafe for GameObjectScene
impl Send for GameObjectScene
impl Sync for GameObjectScene
impl Unpin for GameObjectScene
impl UnsafeUnpin for GameObjectScene
impl UnwindSafe for GameObjectScene
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