SerializeRenderer: render to GenericSim, not StaticSim

This commit is contained in:
2022-07-29 13:27:05 -07:00
parent 95213e61be
commit 604f368f0d
4 changed files with 23 additions and 28 deletions

View File

@@ -1,7 +1,7 @@
//! Post-processing tools
use coremem::meas;
use coremem::render::{ColorTermRenderer, Renderer as _, RenderConfig, SerializedFrame};
use coremem::sim::{AbstractSim, StaticSim};
use coremem::sim::{AbstractSim, GenericSim};
use itertools::Itertools as _;
use lru::LruCache;
@@ -9,7 +9,6 @@ use rayon::{ThreadPool, ThreadPoolBuilder};
use std::collections::HashSet;
use std::fs::{DirEntry, File, read_dir};
use std::io::BufReader;
use std::ops::Deref;
use std::path::{Path, PathBuf};
use std::sync::Arc;
use std::sync::mpsc::{self, Receiver, Sender};
@@ -33,25 +32,21 @@ pub type Result<T> = std::result::Result<T, Error>;
pub struct Frame {
path: PathBuf,
data: SerializedFrame<StaticSim>,
data: SerializedFrame<GenericSim<f32>>,
}
impl Frame {
pub fn measurements(&self) -> &[meas::Evaluated] {
&*self.data.measurements
}
pub fn sim(&self) -> &GenericSim<f32> {
&self.data.state
}
pub fn path(&self) -> &Path {
&*self.path
}
}
impl Deref for Frame {
type Target = StaticSim;
fn deref(&self) -> &Self::Target {
&self.data.state
}
}
#[derive(Default)]
pub struct Loader {
dir: PathBuf,
@@ -252,7 +247,7 @@ impl Viewer {
let mut cache = LoaderCache::new(loader, 6, 6);
let viewing = cache.load_first();
Self {
z: viewing.depth() / 2,
z: viewing.sim().depth() / 2,
viewing,
cache,
renderer: Default::default(),
@@ -262,7 +257,7 @@ impl Viewer {
}
pub fn navigate(&mut self, time_steps: isize, z_steps: i32) {
let new_z = (self.z as i32).saturating_add(z_steps);
let new_z = new_z.max(0).min(self.viewing.depth() as i32 - 1) as u32;
let new_z = new_z.max(0).min(self.viewing.sim().depth() as i32 - 1) as u32;
if time_steps == 0 && new_z == self.z && self.render_config == self.last_config {
return;
}
@@ -274,7 +269,7 @@ impl Viewer {
}
pub fn render(&self) {
self.renderer.render_z_slice(
&**self.viewing,
self.viewing.sim(),
self.z,
&*meas::as_dyn_measurements(self.viewing.measurements()),
self.render_config,