forked from StrafesNET/strafe-client
graphics: bundle FrameState into struct
This commit is contained in:
parent
50726199b9
commit
fd5a813357
@ -98,6 +98,12 @@ impl std::default::Default for GraphicsCamera{
|
||||
}
|
||||
}
|
||||
|
||||
pub struct FrameState{
|
||||
pub physics_output:crate::physics::PhysicsOutputState,
|
||||
pub predicted_time:integer::Time,
|
||||
pub mouse_pos:glam::IVec2,
|
||||
}
|
||||
|
||||
pub struct GraphicsState{
|
||||
pipelines:GraphicsPipelines,
|
||||
bind_groups:GraphicsBindGroups,
|
||||
@ -876,16 +882,14 @@ impl GraphicsState{
|
||||
view:&wgpu::TextureView,
|
||||
device:&wgpu::Device,
|
||||
queue:&wgpu::Queue,
|
||||
physics_output:crate::physics::PhysicsOutputState,
|
||||
predicted_time:integer::Time,
|
||||
mouse_pos:glam::IVec2,
|
||||
frame_state:FrameState,
|
||||
){
|
||||
//TODO:use scheduled frame times to create beautiful smoothing simulation physics extrapolation assuming no input
|
||||
|
||||
let mut encoder=device.create_command_encoder(&wgpu::CommandEncoderDescriptor{label:None});
|
||||
|
||||
// update rotation
|
||||
let camera_uniforms=self.camera.to_uniform_data(physics_output.extrapolate(strafesnet_common::mouse::MouseState{pos:mouse_pos,time:predicted_time}));
|
||||
let camera_uniforms=self.camera.to_uniform_data(frame_state.physics_output.extrapolate(strafesnet_common::mouse::MouseState{pos:frame_state.mouse_pos,time:frame_state.predicted_time}));
|
||||
self.staging_belt
|
||||
.write_buffer(
|
||||
&mut encoder,
|
||||
|
@ -1,7 +1,5 @@
|
||||
use strafesnet_common::integer;
|
||||
|
||||
pub enum Instruction{
|
||||
Render(crate::physics::PhysicsOutputState,integer::Time,glam::IVec2),
|
||||
Render(crate::graphics::FrameState),
|
||||
//UpdateModel(crate::graphics::GraphicsModelUpdate),
|
||||
Resize(winit::dpi::PhysicalSize<u32>,crate::settings::UserSettings),
|
||||
ChangeMap(strafesnet_common::map::CompleteMap),
|
||||
@ -33,7 +31,7 @@ pub fn new<'a>(
|
||||
Instruction::Resize(size,user_settings)=>{
|
||||
resize=Some((size,user_settings));
|
||||
}
|
||||
Instruction::Render(physics_output,predicted_time,mouse_pos)=>{
|
||||
Instruction::Render(frame_state)=>{
|
||||
if let Some((size,user_settings))=resize.take(){
|
||||
println!("Resizing to {:?}",size);
|
||||
let t0=std::time::Instant::now();
|
||||
@ -58,7 +56,7 @@ pub fn new<'a>(
|
||||
..wgpu::TextureViewDescriptor::default()
|
||||
});
|
||||
|
||||
graphics.render(&view,&device,&queue,physics_output,predicted_time,mouse_pos);
|
||||
graphics.render(&view,&device,&queue,frame_state);
|
||||
|
||||
frame.present();
|
||||
}
|
||||
|
@ -180,8 +180,12 @@ impl MouseInterpolator{
|
||||
self.empty_queue();
|
||||
}
|
||||
}
|
||||
pub fn get_render_stuff(&self,time:Time)->(crate::physics::PhysicsOutputState,Time,glam::IVec2){
|
||||
(self.physics.output(),self.timer.time(time),self.physics.get_next_mouse().pos)
|
||||
pub fn get_frame_state(&self,time:Time)->crate::graphics::FrameState{
|
||||
crate::graphics::FrameState{
|
||||
physics_output:self.physics.output(),
|
||||
mouse_pos:self.physics.get_next_mouse().pos,
|
||||
predicted_time:self.timer.time(time),
|
||||
}
|
||||
}
|
||||
pub fn change_map(&mut self,time:Time,map:&strafesnet_common::map::CompleteMap){
|
||||
//dump any pending interpolation state
|
||||
@ -221,8 +225,8 @@ pub fn new<'a>(
|
||||
interpolator.handle_instruction(&ins);
|
||||
match ins.instruction{
|
||||
Instruction::Render=>{
|
||||
let (physics_output,time,mouse_pos)=interpolator.get_render_stuff(ins.time);
|
||||
graphics_worker.send(crate::graphics_worker::Instruction::Render(physics_output,time,mouse_pos)).unwrap();
|
||||
let frame_state=interpolator.get_frame_state(ins.time);
|
||||
graphics_worker.send(crate::graphics_worker::Instruction::Render(frame_state)).unwrap();
|
||||
},
|
||||
Instruction::Resize(size)=>{
|
||||
graphics_worker.send(crate::graphics_worker::Instruction::Resize(size,interpolator.user_settings().clone())).unwrap();
|
||||
|
Loading…
Reference in New Issue
Block a user