Mild optimizations

main
Luke D. Jones 2023-07-31 22:16:07 +12:00
parent eecd3136cb
commit 504dfb440e
6 changed files with 21 additions and 32 deletions

View File

@ -68,7 +68,7 @@ panic = "abort"
[profile.dev]
debug = true
opt-level = 1
opt-level = 3
[profile.bench]
debug = false

View File

@ -369,7 +369,7 @@ fn d_display(
_ => {}
}
// // menus go directly to the screen
// menus go directly to the screen
// draw_buf.clear();
menu.draw(draw_buf); // menu is drawn even on top of everything
// net update does i/o and buildcmds...

View File

@ -129,7 +129,6 @@ impl Visplane {
maxx: 0.0,
top: vec![f32::MAX; screen_width + 1],
bottom: vec![0.0; screen_width + 1],
basexscale: 0.0,
baseyscale: 0.0,
view_angle: Angle::default(),
@ -145,13 +144,7 @@ impl Visplane {
self.picnum = 0;
self.minx = 0.0;
self.maxx = 0.0;
for x in self.top.iter_mut() {
*x = f32::MAX;
}
for x in self.bottom.iter_mut() {
*x = f32::MIN;
}
self.top.fill(f32::MAX);
self.bottom.fill(f32::MIN);
}
}

View File

@ -70,11 +70,8 @@ impl VisPlaneRender {
/// At begining of frame.
pub fn clear_planes(&mut self, view_angle: Angle) {
// opening / clipping determination
for i in 0..self.floorclip.len() {
self.floorclip[i] = self.screen_height;
self.ceilingclip[i] = -1.0;
}
self.floorclip.fill(self.screen_height);
self.ceilingclip.fill(-1.0);
for p in self.visplanes.iter_mut() {
p.clear();
}
@ -268,7 +265,7 @@ fn map_plane(
let ds_ystep = distance * plane.baseyscale;
// distance * distscale[i]
let distscale = screen_to_x_view(x1, pixels.width() as f32).cos().abs();
let distscale = screen_to_x_view(x1, pixels.width() as f32).cos();
let length = distance * (1.0 / distscale);
let angle = plane.view_angle + screen_to_x_view(x1, pixels.width() as f32);
let ds_xfrac = viewxy.x + angle.cos() * length;

View File

@ -22,10 +22,8 @@ impl PortalClip {
}
pub(super) fn clear(&mut self) {
for i in 0..self.screen_width {
self.floorclip[i] = self.screen_height as f32;
self.ceilingclip[i] = -1.0;
}
self.floorclip.fill(self.screen_height as f32);
self.ceilingclip.fill(-1.0);
}
}

View File

@ -694,26 +694,27 @@ impl<'a> DrawColumn<'a> {
pixels: &mut impl PixelBuffer,
) {
let pal = textures.palette();
let dc_x = self.dc_x as usize;
let mut frac =
self.dc_texturemid + (self.yl - pixels.height() as f32 / 2.0) * self.fracstep + 0.1;
self.dc_texturemid + (self.yl - (pixels.height() / 2) as f32) * self.fracstep;
for n in self.yl as i32..=self.yh as i32 {
for n in self.yl as usize..=self.yh as usize {
let mut select = if doubled {
(frac as i32 / 2) & 0xff
} else {
(frac as i32) & 0xff
};
if select >= self.texture_column.len() as i32 {
select %= self.texture_column.len() as i32;
}
if self.texture_column[select as usize] == usize::MAX {
frac += self.fracstep;
continue;
} as usize;
if select >= self.texture_column.len() {
select %= self.texture_column.len();
}
// if self.texture_column[select as usize] == usize::MAX {
// frac += self.fracstep;
// continue;
// }
let px = self.colourmap[self.texture_column[select as usize]];
let px = self.colourmap[self.texture_column[select]];
let c = pal[px];
pixels.set_pixel(self.dc_x as usize, n as usize, (c.r, c.g, c.b, 255));
pixels.set_pixel(dc_x, n, (c.r, c.g, c.b, 255));
frac += self.fracstep;
}