Module cache

Module cache 

Source
Expand description

Model caching system for efficient multi-viewpoint rendering.

Caches loaded mesh and texture assets to avoid redundant disk I/O and asset loading when rendering multiple viewpoints of the same object.

§Performance

Typical speedup when rendering the same object multiple times:

  • First render: 100% (loads from disk)
  • Subsequent renders: 2-3x faster (cache hits)

§Example

use bevy_sensor::{
    cache::ModelCache,
    render_to_buffer_cached,
    RenderConfig, ViewpointConfig, ObjectRotation,
};
use std::path::PathBuf;

let mut cache = ModelCache::new();
let object_dir = PathBuf::from("/tmp/ycb/003_cracker_box");
let config = RenderConfig::tbp_default();
let viewpoints = bevy_sensor::generate_viewpoints(&ViewpointConfig::default());

// First render: loads from disk
let output1 = render_to_buffer_cached(
    &object_dir,
    &viewpoints[0],
    &ObjectRotation::identity(),
    &config,
    &mut cache,
).unwrap();

// Subsequent renders: uses cache (much faster)
for viewpoint in &viewpoints[1..] {
    let output = render_to_buffer_cached(
        &object_dir,
        viewpoint,
        &ObjectRotation::identity(),
        &config,
        &mut cache,
    ).unwrap();
}

Structs§

ModelCache
Cache for loaded mesh and texture assets.
ModelCacheStats
Statistics about cache usage.