♻️ refactor: split up static level param in graphics

main
_ 2022-01-09 14:16:38 +00:00
parent 6ccae593d3
commit e742bcad5c
2 changed files with 9 additions and 15 deletions

View File

@ -172,7 +172,8 @@ impl Graphics {
pub fn draw (
&self,
state: &GameState,
static_level: &crate::StaticLevel,
logic: &crate::LogicState,
gl_state: &mut GlState,
level: &crate::LoadedLevel,
camera: &crate::Camera,
@ -216,7 +217,7 @@ impl Graphics {
) = camera.transform.clone ().decomposed ();
let cam_trans = Vec3::from (cam_trans);
let cam_trans = Vec3::new (cam_trans.x.max (state.logic.player.pos.x + 4.0), cam_trans.y, cam_trans.z);
let cam_trans = Vec3::new (cam_trans.x.max (logic.player.pos.x + 4.0), cam_trans.y, cam_trans.z);
let view_mat =
Mat4::from_quat (Quat::from_array (cam_rot).inverse ()) *
@ -244,7 +245,7 @@ impl Graphics {
self.texture_earth.bind ();
let mvp = view_mat *
Mat4::from_translation (state.logic.player.pos) *
Mat4::from_translation (logic.player.pos) *
Mat4::from_scale ((0.5, 0.5, 0.5).into ());
glezz::uniform_matrix_4fv (unis [&u::MVP], &mvp);
glezz::uniform_3fv (unis [&u::ALBEDO], &white);
@ -340,9 +341,9 @@ impl Graphics {
if true {
// Raycast for player shadow
let coll = opengl_rust::physics::get_candidate (
&state.static_level.tris, &[],
state.logic.player.pos,
state.logic.player.pos + Vec3::new (0.0, 0.0, -100.0),
&static_level.tris, &[],
logic.player.pos,
logic.player.pos + Vec3::new (0.0, 0.0, -100.0),
0.0
);

View File

@ -29,13 +29,6 @@ pub struct GameState {
static_level: StaticLevel,
}
impl GameState {
fn step (&mut self, phys_params: &opengl_rust::physics::Params, p_gp: VirtualGamepad) -> LogicStepOutput
{
self.logic.step (&self.static_level, phys_params, p_gp)
}
}
struct StaticLevel {
tris: Vec <opengl_rust::physics::Triangle>,
}
@ -362,7 +355,7 @@ async fn main () -> Result <()> {
let p_gp = player_gamepad;
let logic_step_output = game_state.step (&phys_params, p_gp);
let logic_step_output = game_state.logic.step (&game_state.static_level, &phys_params, p_gp);
if logic_step_output.reset_level {
game_state.logic.reset_level (&level);
}
@ -371,7 +364,7 @@ async fn main () -> Result <()> {
window.gl_make_current (&gl_ctx).unwrap ();
graphics.draw (&game_state, &mut gl_state, &level, &camera);
graphics.draw (&game_state.static_level, &game_state.logic, &mut gl_state, &level, &camera);
graphics.frames += 1;
if graphics.frames == next_upf_print {