render: transform inaccurate float-based indexing into integer indexing
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use crate::geom::Meters;
|
||||
use crate::geom::Index;
|
||||
use crate::real::ToFloat as _;
|
||||
use crate::cross::vec::{Vec2, Vec3};
|
||||
use crate::sim::{AbstractSim, GenericSim, Sample};
|
||||
@@ -198,12 +198,9 @@ impl<'a, S: AbstractSim> RenderSteps<'a, S> {
|
||||
}
|
||||
|
||||
fn get_at_px<'b>(&'b self, x_px: u32, y_px: u32) -> Sample<'b, S::Real, S::Material> {
|
||||
let x_prop = x_px as f32 / self.im.width() as f32;
|
||||
let x_m = x_prop * (self.sim.width() as f32 * self.sim.feature_size() as f32);
|
||||
let y_prop = y_px as f32 / self.im.height() as f32;
|
||||
let y_m = y_prop * (self.sim.height() as f32 * self.sim.feature_size() as f32);
|
||||
let z_m = self.z as f32 * self.sim.feature_size() as f32;
|
||||
self.sim.sample(Meters(Vec3::new(x_m, y_m, z_m)))
|
||||
let x_idx = x_px * self.sim.width() / self.im.width();
|
||||
let y_idx = y_px * self.sim.height() / self.im.height();
|
||||
self.sim.sample(Index::new(x_idx, y_idx, self.z))
|
||||
}
|
||||
|
||||
////////////// Ex/Ey/Bz configuration ////////////
|
||||
|
Reference in New Issue
Block a user