pub struct MeshPreparationSystem { /* private fields */ }Expand description
Manages the GPU upload and caching of mesh assets.
This system observes the World for entities that have a HandleComponent<Mesh>
(a CPU asset) but do not yet have a HandleComponent<GpuMesh> (a GPU asset).
For each such entity, it ensures the corresponding mesh data is uploaded to the
GPU, caches the resulting GpuMesh asset, and then adds the
HandleComponent<GpuMesh> to the entity.
Implementations§
Source§impl MeshPreparationSystem
impl MeshPreparationSystem
Sourcepub fn new(gpu_meshes_cache: Arc<RwLock<Assets<GpuMesh>>>) -> Self
pub fn new(gpu_meshes_cache: Arc<RwLock<Assets<GpuMesh>>>) -> Self
Creates a new MeshPreparationSystem.
§Arguments
gpu_meshes_cache: A shared pointer to theAssetsstorage whereGpuMeshassets will be cached.
Sourcepub fn run(
&self,
world: &mut World,
cpu_meshes: &Assets<Mesh>,
graphics_device: &dyn GraphicsDevice,
)
pub fn run( &self, world: &mut World, cpu_meshes: &Assets<Mesh>, graphics_device: &dyn GraphicsDevice, )
Runs the preparation logic for one frame.
This should be called once per frame, typically during the “Control Plane” phase, before the render extraction process begins. The process is split into two phases to comply with Rust’s borrow checker: a read-only query phase and a subsequent mutation phase.
§Arguments
world: A mutable reference to the main ECSWorld.cpu_meshes: An immutable reference to the storage for loaded CPUMeshassets.graphics_device: A trait object for the active graphics device, used for buffer creation.
Auto Trait Implementations§
impl Freeze for MeshPreparationSystem
impl RefUnwindSafe for MeshPreparationSystem
impl Send for MeshPreparationSystem
impl Sync for MeshPreparationSystem
impl Unpin for MeshPreparationSystem
impl UnwindSafe for MeshPreparationSystem
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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