Expand description
The balls: dropping them, giving each one a render instance and a physics body, and publishing where they are.
This is the sceneβs busiest object. Every drop spawns a Ball entity of its
own and then asks the two other worlds for the halves that make it visible:
the render world creates an instance, the physics world a body, and both
answer with the ball entity they were asked for, so an answer that no longer
finds its ball is cleaned up instead of leaking. A ball the camera loses
sight of is put away whole: the render world despawns the instance and
reports it, and the body and the ball entity go with it.
Every answer names the ball, never a place in a parallel list, so two answers arriving in either order land on the same ball. A ball counts as shown once the render world confirms the instance wears its assets, not when the job is queued: a job a full queue turned away is simply sent again on the next tick.
Re-exportsΒ§
use std::sync::Arc;πuse glam::Vec3;πuse unlit_ecs::Bundle;πuse unlit_ecs::DynamicBundle;πuse unlit_ecs::Entity;πuse unlit_ecs::Scope;πuse unlit_ecs::World;πuse unlit_ecs::bundle;πuse unlit3d::components::Transform;πuse super::Scene;πuse super::shapes::BALL_COLORS;πuse super::shapes::SHAPE_KINDS;πuse super::shapes::shape_body;πuse super::shared::SceneState;πuse super::shared::create_instance;πuse super::shared::look;πuse super::tick::advancing_in;πuse super::GamePhysics;πuse super::ScenePoses;πuse super::pose_job;πuse super::world_ended;πuse crate::render::BallInstance;πuse crate::render::RenderEntity;πuse crate::render::despawn_instances_job;πuse crate::render::show;πuse crate::render::sweep;πuse unlit3dx::prelude::*;π
StructsΒ§
- Ball
- One ball, on an entity of its own in the gameplay world.
- Ball
Drops π - The balls and the tick that drops, poses and sweeps them, spawned together.
- Balls
- The balls, living on their own entity in the gameplay world.
- Show
Candidate π - A ball whose two halves have both landed, waiting to be shown.
EnumsΒ§
- Ball
Phase - How far a ball has come through its flow.
- Waiting π
- What a tick does with a ball that has not been shown yet.
ConstantsΒ§
- PENDING_
TIMEOUT π - How long a ball may wait for its two halves before its instance and body are reclaimed, in seconds.
- SPAWN_
HEIGHT π - Where balls spawn, in metres above the ground.
- SPAWN_
PERIOD π - How long between automatic ball drops, in seconds.
- SPAWN_
SPREAD π - How far from the centre a ball may spawn, in metres.
- STATUS_
PERIOD π - How often the ball flow reports its own status, in seconds.
- SWEEP_
PERIOD π - How often live instances are tested against the cameraβs view, in seconds.
FunctionsΒ§
- live_
poses π - The poses a tick publishes: one per shown ball, at the pose the physics snapshot names for its body. A ball the snapshot has not named yet is left out, keeping the transform the show job gave it.
- waiting π
- What a tick does with a ball.