Visplanes?

shader120
Luke 2021-02-09 09:38:23 +13:00
parent d130a86287
commit 28f799d51b
59 changed files with 98 additions and 26 deletions

0
.drone.yml Normal file → Executable file
View File

0
.gitignore vendored Normal file → Executable file
View File

0
.gitlab-ci.yml Normal file → Executable file
View File

0
.gitmodules vendored Normal file → Executable file
View File

0
.rustfmt.toml Normal file → Executable file
View File

0
Cargo.toml Normal file → Executable file
View File

0
LICENSE Normal file → Executable file
View File

0
README.md Normal file → Executable file
View File

0
build.rs Normal file → Executable file
View File

0
doom1.wad Normal file → Executable file
View File

0
game/Cargo.toml Normal file → Executable file
View File

0
game/src/main.rs Normal file → Executable file
View File

0
gamelib/Cargo.toml Normal file → Executable file
View File

0
gamelib/benches/parse_map.rs Normal file → Executable file
View File

0
gamelib/src/angle.rs Normal file → Executable file
View File

0
gamelib/src/d_main.rs Normal file → Executable file
View File

0
gamelib/src/d_thinker.rs Normal file → Executable file
View File

27
gamelib/src/doom_def.rs Normal file → Executable file
View File

@ -20,21 +20,29 @@ pub const ML_MAPPED: u32 = 256;
// to handle IWAD dependend animations etc.
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum GameMode {
Shareware, // DOOM 1 shareware, E1, M9
Registered, // DOOM 1 registered, E3, M27
Commercial, // DOOM 2 retail, E1 M34
Shareware,
// DOOM 1 shareware, E1, M9
Registered,
// DOOM 1 registered, E3, M27
Commercial,
// DOOM 2 retail, E1 M34
// DOOM 2 german edition not handled
Retail, // DOOM 1 retail, E4, M36
Retail,
// DOOM 1 retail, E4, M36
Indetermined, // Well, no IWAD found.
}
// Mission packs - might be useful for TC stuff?
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum GameMission {
Doom, // DOOM 1
Doom2, // DOOM 2
PackTnt, // TNT mission pack
PackPlut, // Plutonia pack
Doom,
// DOOM 1
Doom2,
// DOOM 2
PackTnt,
// TNT mission pack
PackPlut,
// Plutonia pack
None,
}
@ -149,7 +157,8 @@ pub enum PowerType {
#[derive(Debug, Copy, Clone)]
pub enum PowerDuration {
INVULNTICS = (30 * TICRATE) as isize,
INVISTICS = (61 * TICRATE) as isize, // TODO: fix back to 60
INVISTICS = (61 * TICRATE) as isize,
// TODO: fix back to 60
INFRATICS = (120 * TICRATE) as isize,
IRONTICS = (60 * TICRATE) as isize,
}

0
gamelib/src/errors.rs Normal file → Executable file
View File

0
gamelib/src/flags.rs Normal file → Executable file
View File

3
gamelib/src/game.rs Normal file → Executable file
View File

@ -508,8 +508,9 @@ impl Game {
let player = &mut self.players[self.consoleplayer];
level.visplanes.clear_planes();
level.bsp_renderer.clear_clip_segs();
level.r_data.portal_clip.clear();
level.r_data.clear_data();
// The state machine will handle which state renders to the surface
//self.states.render(dt, &mut self.canvas);

0
gamelib/src/info/map_object_info.rs Normal file → Executable file
View File

0
gamelib/src/info/mod.rs Normal file → Executable file
View File

0
gamelib/src/info/states.rs Normal file → Executable file
View File

0
gamelib/src/input.rs Normal file → Executable file
View File

3
gamelib/src/level_data/level.rs Normal file → Executable file
View File

@ -2,6 +2,7 @@ use wad::{lumps::WadThing, WadData};
use crate::level_data::map_data::MapData;
use crate::renderer::bsp::BspRenderer;
use crate::renderer::plane::VisPlaneCtrl;
use crate::renderer::RenderData;
use crate::{
d_main::Skill,
@ -26,6 +27,7 @@ pub(crate) struct Level {
pub map_data: MapData,
pub bsp_renderer: BspRenderer,
pub r_data: RenderData,
pub visplanes: VisPlaneCtrl,
pub mobj_ctrl: SubSectorMinMax,
pub thinkers: Vec<Option<Thinker<MapObject>>>,
max_thinker_capacity: usize,
@ -83,6 +85,7 @@ impl Level {
let mut level = Level {
map_data,
r_data: RenderData::default(),
visplanes: VisPlaneCtrl::default(),
bsp_renderer: BspRenderer::default(),
mobj_ctrl: SubSectorMinMax::default(),
thinkers: Vec::with_capacity(thinker_count + 50),

0
gamelib/src/level_data/map_data.rs Normal file → Executable file
View File

0
gamelib/src/level_data/map_defs.rs Normal file → Executable file
View File

0
gamelib/src/level_data/mod.rs Normal file → Executable file
View File

0
gamelib/src/level_data/node.rs Normal file → Executable file
View File

0
gamelib/src/lib.rs Normal file → Executable file
View File

0
gamelib/src/p_enemy.rs Normal file → Executable file
View File

0
gamelib/src/p_lights.rs Normal file → Executable file
View File

0
gamelib/src/p_local.rs Normal file → Executable file
View File

18
gamelib/src/p_map.rs Normal file → Executable file
View File

@ -252,15 +252,15 @@ impl MapObject {
return;
}
if self.flags
& (MapObjectFlag::MF_DROPOFF as u32
| MapObjectFlag::MF_FLOAT as u32)
!= 0
&& portal.bottom_z - portal.lowest_z > 24.0
{
contacts.push(contact);
return;
}
// if self.flags
// & (MapObjectFlag::MF_DROPOFF as u32
// | MapObjectFlag::MF_FLOAT as u32)
// != 0
// && portal.bottom_z - portal.lowest_z > 24.0
// {
// contacts.push(contact);
// return;
// }
}
}
}

0
gamelib/src/p_map_object.rs Normal file → Executable file
View File

0
gamelib/src/p_map_util.rs Normal file → Executable file
View File

0
gamelib/src/p_player_sprite.rs Normal file → Executable file
View File

0
gamelib/src/p_spec.rs Normal file → Executable file
View File

0
gamelib/src/player.rs Normal file → Executable file
View File

1
gamelib/src/renderer/bsp.rs Normal file → Executable file
View File

@ -179,7 +179,6 @@ impl BspRenderer {
});
}
self.new_end = 2;
// self.r_segs = SegRender::default();
}
/// R_ClipSolidWallSegment - r_bsp

0
gamelib/src/renderer/defs.rs Normal file → Executable file
View File

4
gamelib/src/renderer/mod.rs Normal file → Executable file
View File

@ -29,3 +29,7 @@ pub(crate) struct RenderData {
/// Used in r_segs and r_things
pub ds_p: usize, // Or, depending on place in code this can be skipped and a new
}
impl RenderData {
pub fn clear_data(&mut self) { self.portal_clip.clear(); }
}

55
gamelib/src/renderer/plane.rs Normal file → Executable file
View File

@ -4,19 +4,23 @@ use crate::renderer::defs::{
pub(crate) struct VisPlaneCtrl {
// Here comes the obnoxious "visplane".
pub visplanes: [Visplane; MAXVISPLANES],
pub visplanes: Vec<Visplane>,
pub lastvisplane: usize,
/// Index of current visplane in `self.visplanes` for floor
pub floorplane: usize,
/// Index of current visplane in `self.visplanes` for ceiling
pub ceilingplane: usize,
// ?
pub openings: [i16; MAXOPENINGS],
pub lastopening: usize,
pub floorclip: [i32; SCREENWIDTH],
pub ceilingclip: [i32; SCREENWIDTH],
/// spanstart holds the start of a plane span
/// initialized to 0 at start
pub spanstart: [i32; SCREENHEIGHT],
pub spanstop: [i32; SCREENHEIGHT],
pub spanstart: [i32; SCREENHEIGHT],
pub spanstop: [i32; SCREENHEIGHT],
//lighttable_t **planezlight;
pub planeheight: f32,
@ -32,15 +36,21 @@ pub(crate) struct VisPlaneCtrl {
pub cachedystep: [f32; SCREENHEIGHT],
}
impl Default for VisPlaneCtrl {
fn default() -> Self { VisPlaneCtrl::new() }
}
impl VisPlaneCtrl {
pub(crate) fn new() -> Self {
VisPlaneCtrl {
visplanes: [Visplane::default(); MAXVISPLANES],
visplanes: vec![Visplane::default(); MAXVISPLANES],
lastvisplane: 0,
floorplane: 0,
ceilingplane: 0,
openings: [0; MAXOPENINGS],
lastopening: 0,
floorclip: [0; SCREENWIDTH],
ceilingclip: [0; SCREENWIDTH],
spanstart: [0; SCREENHEIGHT],
spanstop: [0; SCREENHEIGHT],
planeheight: 0.0,
@ -54,4 +64,41 @@ impl VisPlaneCtrl {
cachedystep: [0.0; SCREENHEIGHT],
}
}
/// R_ClearPlanes
/// At begining of frame.
pub fn clear_planes(&mut self) {
// opening / clipping determination
for i in 0..SCREENWIDTH {
self.floorclip[i] = SCREENHEIGHT as i32;
self.ceilingclip[i] = -1;
}
self.lastvisplane = 0;
self.lastopening = 0;
// texture calculation
for i in self.cachedheight.iter_mut() {
*i = 0.0;
}
// left to right mapping
// TODO: angle = (viewangle - ANG90) >> ANGLETOFINESHIFT;
// TODO: Don't hardcode this; centerxfrac
// scale will be unit scale at SCREENWIDTH/2 distance
self.basexscale = (160.0f32).cos();
self.baseyscale = -(160.0f32).sin();
}
pub fn current_floor_plane(&self) -> &Visplane {
&self.visplanes[self.floorplane]
}
pub fn current_ceiling_plane(&self) -> &Visplane {
&self.visplanes[self.ceilingplane]
}
// R_CheckPlane
//pub fn check_set_floor_plane
}

2
gamelib/src/renderer/portals.rs Normal file → Executable file
View File

@ -19,7 +19,7 @@ impl PortalClip {
}
}
pub(crate) fn clear(&mut self) {
pub(super) fn clear(&mut self) {
for i in 0..SCREENWIDTH {
self.floorclip[i] = SCREENHEIGHT as f32;
self.ceilingclip[i] = -1.0;

11
gamelib/src/renderer/segs.rs Normal file → Executable file
View File

@ -380,7 +380,7 @@ impl SegRender {
// above view plane
self.markfloor = false;
}
// TDOD: if frontsector.ceilingheight <= viewz && frontsector.ceilingpic != skyflatnum
// TODO: if frontsector.ceilingheight <= viewz && frontsector.ceilingpic != skyflatnum
if frontsector.ceilingheight <= viewz {
// below view plane
self.markceiling = false;
@ -405,6 +405,15 @@ impl SegRender {
}
}
// render it
if self.markceiling {
// ceilingplane = R_CheckPlane(ceilingplane, self.rw_x, self.rw_stopx - 1);
}
if self.markfloor {
// floorplane = R_CheckPlane(floorplane, self.rw_x, self.rw_stopx - 1);
}
self.render_seg_loop(object, seg, rdata, canvas);
}

0
gamelib/src/shaders/basic.rs Normal file → Executable file
View File

0
gamelib/src/shaders/cgwg_crt.rs Normal file → Executable file
View File

0
gamelib/src/shaders/lottes_crt.rs Normal file → Executable file
View File

0
gamelib/src/shaders/mod.rs Normal file → Executable file
View File

0
gamelib/src/sounds.rs Normal file → Executable file
View File

0
gamelib/src/tic_cmd.rs Normal file → Executable file
View File

0
gamelib/src/timestep.rs Normal file → Executable file
View File

0
wad/Cargo.toml Normal file → Executable file
View File

0
wad/benches/wad_loading.rs Normal file → Executable file
View File

0
wad/src/iterators.rs Normal file → Executable file
View File

0
wad/src/lib.rs Normal file → Executable file
View File

0
wad/src/lumps.rs Normal file → Executable file
View File

0
wad/src/wad.rs Normal file → Executable file
View File