# Fix 994: fix panic when hotloading figure manifests

This commit is contained in:
Leonid Toshchev 2022-04-14 15:53:39 +00:00 committed by Marcel
parent a282e84607
commit 860af759a4
2 changed files with 49 additions and 6 deletions

View File

@ -311,6 +311,8 @@ where
}
}
pub fn watcher_reloaded(&mut self) -> bool { self.watcher.reloaded() }
/// NOTE: Intended for render time (useful with systems like wgpu that
/// expect data used by the rendering pipelines to be stable throughout
/// the render pass).
@ -568,16 +570,12 @@ where
}
}
pub fn clear_models(&mut self) { self.models.clear(); }
pub fn clean(&mut self, col_lights: &mut super::FigureColLights, tick: u64)
where
<Skel::Body as BodySpec>::Spec: Clone,
{
// Check for reloaded manifests
// TODO: maybe do this in a different function, maintain?
if self.watcher.reloaded() {
col_lights.atlas.clear();
self.models.clear();
}
// TODO: Don't hard-code this.
if tick % 60 == 0 {
self.models.retain(|_, ((model_entry, _), last_used)| {

View File

@ -439,8 +439,53 @@ impl FigureMgr {
pub fn col_lights(&self) -> &FigureColLights { &self.col_lights }
fn any_watcher_reloaded(&mut self) -> bool {
self.model_cache.watcher_reloaded()
|| self.theropod_model_cache.watcher_reloaded()
|| self.quadruped_small_model_cache.watcher_reloaded()
|| self.quadruped_medium_model_cache.watcher_reloaded()
|| self.quadruped_low_model_cache.watcher_reloaded()
|| self.bird_medium_model_cache.watcher_reloaded()
|| self.bird_large_model_cache.watcher_reloaded()
|| self.dragon_model_cache.watcher_reloaded()
|| self.fish_medium_model_cache.watcher_reloaded()
|| self.fish_small_model_cache.watcher_reloaded()
|| self.biped_large_model_cache.watcher_reloaded()
|| self.biped_small_model_cache.watcher_reloaded()
|| self.object_model_cache.watcher_reloaded()
|| self.item_drop_model_cache.watcher_reloaded()
|| self.ship_model_cache.watcher_reloaded()
|| self.golem_model_cache.watcher_reloaded()
|| self.volume_model_cache.watcher_reloaded()
|| self.arthropod_model_cache.watcher_reloaded()
}
pub fn clean(&mut self, tick: u64) {
span!(_guard, "clean", "FigureManager::clean");
if self.any_watcher_reloaded() {
self.col_lights.atlas.clear();
self.model_cache.clear_models();
self.theropod_model_cache.clear_models();
self.quadruped_small_model_cache.clear_models();
self.quadruped_medium_model_cache.clear_models();
self.quadruped_low_model_cache.clear_models();
self.bird_medium_model_cache.clear_models();
self.bird_large_model_cache.clear_models();
self.dragon_model_cache.clear_models();
self.fish_medium_model_cache.clear_models();
self.fish_small_model_cache.clear_models();
self.biped_large_model_cache.clear_models();
self.biped_small_model_cache.clear_models();
self.object_model_cache.clear_models();
self.item_drop_model_cache.clear_models();
self.ship_model_cache.clear_models();
self.golem_model_cache.clear_models();
self.volume_model_cache.clear_models();
self.arthropod_model_cache.clear_models();
}
self.model_cache.clean(&mut self.col_lights, tick);
self.theropod_model_cache.clean(&mut self.col_lights, tick);
self.quadruped_small_model_cache