cleanup
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -82,3 +82,4 @@ fabric.properties
|
||||
build/deploy/
|
||||
build/capture/
|
||||
*.blend1
|
||||
.idea/
|
||||
@@ -14,8 +14,8 @@ name = "reload_shaders"
|
||||
vk_code = "VK_F5"
|
||||
|
||||
[[button]]
|
||||
name = "print_framerate"
|
||||
scan_code = 33
|
||||
name = "toggle_framerate"
|
||||
vk_code = "VK_F2"
|
||||
|
||||
[[button]]
|
||||
name = "button_forward"
|
||||
|
||||
@@ -14,12 +14,17 @@ impl FpsCounter {
|
||||
}
|
||||
|
||||
impl Updatable for FpsCounter {
|
||||
fn update(&mut self, _delta_time: f32, _input: &InputState, game_state: &mut GameState, game_objects: &mut Vec<GameObject>, renderer: &mut VulkanRenderer) {
|
||||
fn update(&mut self, _delta_time: f32, input: &InputState, game_state: &mut GameState, game_objects: &mut Vec<GameObject>, renderer: &mut VulkanRenderer) {
|
||||
if input.button_just_pressed("toggle_framerate") {
|
||||
let go = &mut game_objects[self.game_object];
|
||||
go.visible = !go.visible;
|
||||
}
|
||||
|
||||
let update_duration = renderer.game_data.update_perf_counters.iter().sum::<u128>() / PERF_COUNTER_SIZE as u128;
|
||||
let render_duration = renderer.game_data.render_perf_counters.iter().sum::<u128>() / PERF_COUNTER_SIZE as u128;
|
||||
let other_duration = renderer.game_data.other_perf_counters.iter().sum::<u128>() / PERF_COUNTER_SIZE as u128;
|
||||
let other_variance = renderer.game_data.other_perf_counters.iter().fold(0, |acc, b| acc + (*b as i128 - other_duration as i128) * (*b as i128 - other_duration as i128)) / PERF_COUNTER_SIZE as i128;
|
||||
let text = format!("Update: {:.0}ms\nRender: {:.0}ms\nTotal: {:.0}ms (±{:.1})\nDelta: {:.0}ms", update_duration as f64 / 1000., render_duration as f64 / 1000., other_duration as f64 / 1000., f64::sqrt(other_variance as f64) / 1000., _delta_time * 1000.);
|
||||
update_text(self.game_object, &text, 30., renderer, &mut game_state.brush, game_objects)
|
||||
update_text(self.game_object, &text, 30., renderer, &mut game_state.brush, game_objects);
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ use crate::{config::LogConfig, vulkan};
|
||||
use crate::input::InputState;
|
||||
use crate::vulkan::{Game, MeshHandle, TextVertex, Vertex, VulkanRenderer};
|
||||
use crate::vulkan::gameobject::{GameObject, GameObjectHandle, Updatable};
|
||||
use crate::vulkan::mesh::{self};
|
||||
use crate::vulkan::mesh;
|
||||
use crate::vulkan::pipelines::vs::ty::ObjectUniformData;
|
||||
|
||||
pub mod player;
|
||||
@@ -95,10 +95,6 @@ impl Game for TestGame {
|
||||
load_level("levels/test.lvl", self, renderer).unwrap();
|
||||
}
|
||||
|
||||
if self.input.button_down("print_framerate") {
|
||||
println!("{:?}", renderer.game_data.other_perf_counters);
|
||||
}
|
||||
|
||||
if self.input.button_just_pressed("test") {
|
||||
self.game_state.paused = !self.game_state.paused;
|
||||
}
|
||||
@@ -216,7 +212,7 @@ impl TestGame {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_quat_as_euler(quat: Quaternion<f32>) {
|
||||
pub fn _print_quat_as_euler(quat: Quaternion<f32>) {
|
||||
let euler = Euler::from(quat);
|
||||
print!("({:?},{:?},{:?})", Deg::from(euler.x), Deg::from(euler.y), Deg::from(euler.z));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#[cfg(test)]
|
||||
#[allow(deprecated)]
|
||||
mod tests {
|
||||
use cgmath::{vec3};
|
||||
use winit::{dpi::PhysicalPosition, event::{DeviceId, ElementState, Event, Force, KeyboardInput, ModifiersState, Touch, TouchPhase, WindowEvent}, window::WindowId};
|
||||
|
||||
@@ -20,6 +20,7 @@ pub struct GameObject {
|
||||
pub descriptor_sets: Vec<Arc<RendererDescriptorSets>>,
|
||||
pub is_selected: bool,
|
||||
pub pipeline_index: usize,
|
||||
pub visible: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -37,7 +38,7 @@ impl GameObject {
|
||||
|
||||
GameObject { mesh_index: mesh.index, textures, position: Vector3::new(0.0, 0.0, 0.0),
|
||||
rotation: Quaternion::new(1.0, 0.0, 0.0, 0.0), scale: Vector3::new(1.0, 1.0, 1.0), children: vec![],
|
||||
descriptor_sets: vec![], is_selected: false, pipeline_index: mesh.pipeline_index }
|
||||
descriptor_sets: vec![], is_selected: false, pipeline_index: mesh.pipeline_index, visible: true }
|
||||
}
|
||||
|
||||
pub fn init_descriptor_sets(&mut self, renderer: &mut VulkanRenderer) {
|
||||
|
||||
@@ -335,7 +335,8 @@ impl VulkanRenderer {
|
||||
// Draw meshes etc.
|
||||
let mut index = 0;
|
||||
for pipeline in &self.pipelines {
|
||||
pipeline.draw(&mut builder, fb_index, game_objects.iter().filter(|go| go.pipeline_index == index).collect(), &self.game_data, &self.dynamic_state);
|
||||
let objects = game_objects.iter().filter(|go| go.visible && go.pipeline_index == index).collect();
|
||||
pipeline.draw(&mut builder, fb_index, objects, &self.game_data, &self.dynamic_state);
|
||||
index += 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user