This commit is contained in:
Quaternions 2023-09-19 20:36:50 -07:00
parent 91bfa70f05
commit 6ed71073f6
2 changed files with 161 additions and 104 deletions

View File

@ -6,7 +6,6 @@ pub enum PhysicsInstruction {
CollisionEnd(RelativeCollision), CollisionEnd(RelativeCollision),
StrafeTick, StrafeTick,
Jump, Jump,
RefreshWalkTarget,//this could be a helper function instead of an instruction
ReachWalkTargetVelocity, ReachWalkTargetVelocity,
// Water, // Water,
// Spawn( // Spawn(
@ -15,8 +14,20 @@ pub enum PhysicsInstruction {
// bool,//true = Force // bool,//true = Force
// ) // )
//Both of these conditionally activate RefreshWalkTarget (by doing what SetWalkTargetVelocity used to do and then flagging it) //Both of these conditionally activate RefreshWalkTarget (by doing what SetWalkTargetVelocity used to do and then flagging it)
Input(InputInstruction),
}
#[derive(Debug)]
pub enum InputInstruction {
MoveMouse(glam::IVec2), MoveMouse(glam::IVec2),
SetControls(u32,u32),//can activate Jump MoveForward(bool),
MoveLeft(bool),
MoveBack(bool),
MoveRight(bool),
MoveUp(bool),
MoveDown(bool),
Jump(bool),
Zoom(bool),
Reset,
} }
pub struct Body { pub struct Body {
@ -90,6 +101,15 @@ pub struct MouseInterpolationState {
} }
impl MouseInterpolationState { impl MouseInterpolationState {
pub fn new() -> Self {
Self {
interpolation:MouseInterpolation::Lerp,
time0:0,
time1:1,//ONE NANOSECOND!!!! avoid divide by zero
mouse0:glam::IVec2::ZERO,
mouse1:glam::IVec2::ZERO,
}
}
pub fn move_mouse(&mut self,time:TIME,pos:glam::IVec2){ pub fn move_mouse(&mut self,time:TIME,pos:glam::IVec2){
self.time0=self.time1; self.time0=self.time1;
self.mouse0=self.mouse1; self.mouse0=self.mouse1;
@ -115,7 +135,6 @@ impl MouseInterpolationState {
pub enum WalkEnum{ pub enum WalkEnum{
Reached, Reached,
Transient, Transient,
Invalid,
} }
pub struct WalkState { pub struct WalkState {
pub target_velocity: glam::Vec3, pub target_velocity: glam::Vec3,
@ -127,7 +146,7 @@ impl WalkState {
Self{ Self{
target_velocity:glam::Vec3::ZERO, target_velocity:glam::Vec3::ZERO,
target_time:0, target_time:0,
state:WalkEnum::Invalid, state:WalkEnum::Reached,
} }
} }
} }
@ -135,22 +154,63 @@ impl WalkState {
// Note: we use the Y=up coordinate space in this example. // Note: we use the Y=up coordinate space in this example.
pub struct Camera { pub struct Camera {
offset: glam::Vec3, offset: glam::Vec3,
angles: glam::Vec3, angles: glam::DVec2,//YAW AND THEN PITCH
//punch: glam::Vec3, //punch: glam::Vec3,
//punch_velocity: glam::Vec3, //punch_velocity: glam::Vec3,
fov: glam::Vec2,//slope fov: glam::Vec2,//slope
sensitivity: glam::Vec2, sensitivity: glam::DVec2,
time: TIME,
} }
#[inline]
fn mat3_from_rotation_y_f64(angle: f64) -> glam::Mat3 {
let (sina, cosa) = angle.sin_cos();
glam::Mat3::from_cols(
glam::Vec3::new(cosa as f32, 0.0, -sina as f32),
glam::Vec3::Y,
glam::Vec3::new(sina as f32, 0.0, cosa as f32),
)
}
#[inline]
fn perspective_rh(fov_x_slope: f32, fov_y_slope: f32, z_near: f32, z_far: f32) -> glam::Mat4 {
//glam_assert!(z_near > 0.0 && z_far > 0.0);
let r = z_far / (z_near - z_far);
glam::Mat4::from_cols(
glam::Vec4::new(1.0/fov_x_slope, 0.0, 0.0, 0.0),
glam::Vec4::new(0.0, 1.0/fov_y_slope, 0.0, 0.0),
glam::Vec4::new(0.0, 0.0, r, -1.0),
glam::Vec4::new(0.0, 0.0, r * z_near, 0.0),
)
}
impl Camera { impl Camera {
fn from_offset(offset:glam::Vec3,aspect:f32) -> Self { pub fn from_offset(offset:glam::Vec3,aspect:f32) -> Self {
Self{ Self{
offset, offset,
angles: glam::Vec3::ZERO, angles: glam::DVec2::ZERO,
fov: glam::vec2(aspect,1.0), fov: glam::vec2(aspect,1.0),
sensitivity: glam::vec2(1.0/2048.0,1.0/2048.0), sensitivity: glam::dvec2(1.0/2048.0,1.0/2048.0),
time: 0,
} }
} }
fn simulate_move_angles(&self, delta: glam::IVec2) -> glam::DVec2 {
let mut a=self.angles-self.sensitivity*delta.as_dvec2();
a.y=a.y.clamp(-std::f64::consts::PI, std::f64::consts::PI);
return a
}
fn simulate_move_rotation_y(&self, delta_x: i32) -> glam::Mat3 {
mat3_from_rotation_y_f64(self.angles.x-self.sensitivity.x*(delta_x as f64))
}
pub fn proj(&self)->glam::Mat4{
perspective_rh(self.fov.x, self.fov.y, 0.5, 1000.0)
}
pub fn view(&self,pos:glam::Vec3)->glam::Mat4{
//f32 good enough for view matrix
glam::Mat4::from_translation(pos+self.offset) * glam::Mat4::from_euler(glam::EulerRot::YXZ, self.angles.y as f32, self.angles.x as f32, 0f32)
}
pub fn set_fov_aspect(&mut self,fov:f32,aspect:f32){
self.fov.x=fov*aspect;
self.fov.y=fov;
}
} }
const CONTROL_MOVEFORWARD:u32 = 0b00000001; const CONTROL_MOVEFORWARD:u32 = 0b00000001;
@ -441,7 +501,6 @@ impl PhysicsState {
} }
} }
} }
fn next_strafe_instruction(&self) -> Option<TimedInstruction<PhysicsInstruction>> { fn next_strafe_instruction(&self) -> Option<TimedInstruction<PhysicsInstruction>> {
return Some(TimedInstruction{ return Some(TimedInstruction{
time:(self.time*self.strafe_tick_num/self.strafe_tick_den+1)*self.strafe_tick_den/self.strafe_tick_num, time:(self.time*self.strafe_tick_num/self.strafe_tick_den+1)*self.strafe_tick_den/self.strafe_tick_num,
@ -481,6 +540,31 @@ impl PhysicsState {
// }); // });
// } // }
fn refresh_walk_target(&mut self){
//calculate acceleration yada yada
if self.grounded{
let mut v=self.walk.target_velocity;
self.contact_constrain_velocity(&mut v);
let mut target_diff=v-self.body.velocity;
target_diff.y=0f32;
if target_diff==glam::Vec3::ZERO{
let mut a=glam::Vec3::ZERO;
self.contact_constrain_acceleration(&mut a);
self.body.acceleration=a;
self.walk.state=WalkEnum::Reached;
}else{
let accel=self.walk_accel.min(self.gravity.length()*self.friction);
let time_delta=target_diff.length()/accel;
let mut a=target_diff/time_delta;
self.contact_constrain_acceleration(&mut a);
self.body.acceleration=a;
self.walk.target_time=self.body.time+((time_delta as f64)*1_000_000_000f64) as TIME;
self.walk.state=WalkEnum::Transient;
}
}else{
self.walk.state=WalkEnum::Reached;//there is no walk target while not grounded
}
}
fn next_walk_instruction(&self) -> Option<TimedInstruction<PhysicsInstruction>> { fn next_walk_instruction(&self) -> Option<TimedInstruction<PhysicsInstruction>> {
//check if you have a valid walk state and create an instruction //check if you have a valid walk state and create an instruction
if self.grounded{ if self.grounded{
@ -489,10 +573,6 @@ impl PhysicsState {
time:self.walk.target_time, time:self.walk.target_time,
instruction:PhysicsInstruction::ReachWalkTargetVelocity instruction:PhysicsInstruction::ReachWalkTargetVelocity
}), }),
WalkEnum::Invalid=>Some(TimedInstruction{
time:self.time,
instruction:PhysicsInstruction::RefreshWalkTarget,
}),
WalkEnum::Reached=>None, WalkEnum::Reached=>None,
} }
}else{ }else{
@ -808,13 +888,12 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
fn process_instruction(&mut self, ins:TimedInstruction<PhysicsInstruction>) { fn process_instruction(&mut self, ins:TimedInstruction<PhysicsInstruction>) {
match &ins.instruction { match &ins.instruction {
PhysicsInstruction::StrafeTick => (), PhysicsInstruction::StrafeTick => (),
PhysicsInstruction::Input(InputInstruction::MoveMouse(_)) => (),
_=>println!("{:?}",ins), _=>println!("{:?}",ins),
} }
//selectively update body //selectively update body
match &ins.instruction { match &ins.instruction {
PhysicsInstruction::SetWalkTargetVelocity(_) PhysicsInstruction::Input(_)
|PhysicsInstruction::SetControlDir(_) => self.time=ins.time,//TODO: queue instructions
PhysicsInstruction::RefreshWalkTarget
|PhysicsInstruction::ReachWalkTargetVelocity |PhysicsInstruction::ReachWalkTargetVelocity
|PhysicsInstruction::CollisionStart(_) |PhysicsInstruction::CollisionStart(_)
|PhysicsInstruction::CollisionEnd(_) |PhysicsInstruction::CollisionEnd(_)
@ -836,14 +915,13 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
let mut v=self.body.velocity; let mut v=self.body.velocity;
self.contact_constrain_velocity(&mut v); self.contact_constrain_velocity(&mut v);
self.body.velocity=v; self.body.velocity=v;
self.walk.state=WalkEnum::Invalid; self.refresh_walk_target();
}, },
PhysicsInstruction::CollisionEnd(c) => { PhysicsInstruction::CollisionEnd(c) => {
self.contacts.remove(&c);//remove contact before calling contact_constrain_acceleration self.contacts.remove(&c);//remove contact before calling contact_constrain_acceleration
let mut a=self.gravity; let mut a=self.gravity;
self.contact_constrain_acceleration(&mut a); self.contact_constrain_acceleration(&mut a);
self.body.acceleration=a; self.body.acceleration=a;
self.walk.state=WalkEnum::Invalid;
//check ground //check ground
match &c.face { match &c.face {
AabbFace::Top => { AabbFace::Top => {
@ -851,16 +929,14 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
}, },
_ => (), _ => (),
} }
}, self.refresh_walk_target();
PhysicsInstruction::SetControlDir(control_dir)=>{
self.temp_control_dir=control_dir;
self.walk.state=WalkEnum::Invalid;
}, },
PhysicsInstruction::StrafeTick => { PhysicsInstruction::StrafeTick => {
//let control_dir=self.get_control_dir();//this should respect your mouse interpolation settings let camera_mat=self.camera.simulate_move_rotation_y(self.mouse_interpolation.interpolated_position(self.time).x-self.mouse_interpolation.mouse0.x);
let d=self.body.velocity.dot(self.temp_control_dir); let control_dir=camera_mat*get_control_dir(self.controls);
let d=self.body.velocity.dot(control_dir);
if d<self.mv { if d<self.mv {
let mut v=self.body.velocity+(self.mv-d)*self.temp_control_dir; let mut v=self.body.velocity+(self.mv-d)*control_dir;
self.contact_constrain_velocity(&mut v); self.contact_constrain_velocity(&mut v);
self.body.velocity=v; self.body.velocity=v;
} }
@ -870,7 +946,7 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
let mut v=self.body.velocity+glam::Vec3::new(0.0,0.715588/2.0*100.0,0.0); let mut v=self.body.velocity+glam::Vec3::new(0.0,0.715588/2.0*100.0,0.0);
self.contact_constrain_velocity(&mut v); self.contact_constrain_velocity(&mut v);
self.body.velocity=v; self.body.velocity=v;
self.walk.state=WalkEnum::Invalid; self.refresh_walk_target();
}, },
PhysicsInstruction::ReachWalkTargetVelocity => { PhysicsInstruction::ReachWalkTargetVelocity => {
//precisely set velocity //precisely set velocity
@ -882,32 +958,25 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
self.body.velocity=v; self.body.velocity=v;
self.walk.state=WalkEnum::Reached; self.walk.state=WalkEnum::Reached;
}, },
PhysicsInstruction::RefreshWalkTarget => { PhysicsInstruction::Input(input_instruction) => {
//calculate acceleration yada yada match input_instruction{
if self.grounded{ InputInstruction::MoveMouse(m) => self.mouse_interpolation.move_mouse(self.time,m),
let mut v=self.walk.target_velocity; InputInstruction::MoveForward(s) => self.controls=if s{self.controls|CONTROL_MOVEFORWARD}else{self.controls&!CONTROL_MOVEFORWARD},
self.contact_constrain_velocity(&mut v); InputInstruction::MoveLeft(s) => self.controls=if s{self.controls|CONTROL_MOVELEFT}else{self.controls&!CONTROL_MOVELEFT},
let mut target_diff=v-self.body.velocity; InputInstruction::MoveBack(s) => self.controls=if s{self.controls|CONTROL_MOVEBACK}else{self.controls&!CONTROL_MOVEBACK},
target_diff.y=0f32; InputInstruction::MoveRight(s) => self.controls=if s{self.controls|CONTROL_MOVERIGHT}else{self.controls&!CONTROL_MOVERIGHT},
if target_diff==glam::Vec3::ZERO{ InputInstruction::MoveUp(s) => self.controls=if s{self.controls|CONTROL_MOVEUP}else{self.controls&!CONTROL_MOVEUP},
let mut a=glam::Vec3::ZERO; InputInstruction::MoveDown(s) => self.controls=if s{self.controls|CONTROL_MOVEDOWN}else{self.controls&!CONTROL_MOVEDOWN},
self.contact_constrain_acceleration(&mut a); InputInstruction::Jump(s) => self.controls=if s{self.controls|CONTROL_JUMP}else{self.controls&!CONTROL_JUMP},
self.body.acceleration=a; InputInstruction::Zoom(s) => self.controls=if s{self.controls|CONTROL_ZOOM}else{self.controls&!CONTROL_ZOOM},
self.walk.state=WalkEnum::Reached; InputInstruction::Reset => println!("reset"),
}else{
let accel=self.walk_accel.min(self.gravity.length()*self.friction);
let time_delta=target_diff.length()/accel;
let mut a=target_diff/time_delta;
self.contact_constrain_acceleration(&mut a);
self.body.acceleration=a;
self.walk.target_time=self.body.time+((time_delta as f64)*1_000_000_000f64) as TIME;
self.walk.state=WalkEnum::Transient;
}
} }
}, //calculate control dir
PhysicsInstruction::SetWalkTargetVelocity(v) => { let camera_mat=self.camera.simulate_move_rotation_y(self.mouse_interpolation.interpolated_position(self.time).x-self.mouse_interpolation.mouse0.x);
self.walk.target_velocity=v; let control_dir=camera_mat*get_control_dir(self.controls);
self.walk.state=WalkEnum::Invalid; //calculate walk target velocity
self.walk.target_velocity=self.walkspeed*control_dir;
self.refresh_walk_target();
}, },
} }
} }

View File

@ -1,5 +1,5 @@
use bytemuck::{Pod, Zeroable}; use bytemuck::{Pod, Zeroable};
use strafe_client::{instruction::{TimedInstruction, self}, body::MouseInterpolationState}; use strafe_client::{instruction::{TimedInstruction, InstructionConsumer},body::{InputInstruction, PhysicsInstruction}};
use std::{borrow::Cow, time::Instant}; use std::{borrow::Cow, time::Instant};
use wgpu::{util::DeviceExt, AstcBlock, AstcChannel}; use wgpu::{util::DeviceExt, AstcBlock, AstcChannel};
@ -261,22 +261,11 @@ fn generate_modeldatas(data:obj::ObjData,color:[f32;4]) -> Vec<ModelData>{
modeldatas modeldatas
} }
#[inline]
fn perspective_rh(fov_x_slope: f32, fov_y_slope: f32 z_near: f32, z_far: f32) -> glam::Mat4 {
//glam_assert!(z_near > 0.0 && z_far > 0.0);
let r = z_far / (z_near - z_far);
glam::Mat4::from_cols(
glam::Vec4::new(1.0/fov_x_slope, 0.0, 0.0, 0.0),
glam::Vec4::new(0.0, 1.0/fov_y_slope, 0.0, 0.0),
glam::Vec4::new(0.0, 0.0, r, -1.0),
glam::Vec4::new(0.0, 0.0, r * z_near, 0.0),
)
}
fn to_uniform_data(camera: &Camera, pos: glam::Vec3) -> [f32; 16 * 3 + 4] { fn to_uniform_data(camera: &strafe_client::body::Camera, pos: glam::Vec3) -> [f32; 16 * 3 + 4] {
let proj = perspective_rh(self.fov_x, self.fov_y, 0.5, 1000.0); let proj=camera.proj();
let proj_inv = proj.inverse(); let proj_inv = proj.inverse();
let view = glam::Mat4::from_translation(pos+self.offset) * glam::Mat4::from_euler(glam::EulerRot::YXZ, self.angles.y, self.angles.x, self.angles.z); let view=camera.view(pos);
let view_inv = view.inverse(); let view_inv = view.inverse();
let mut raw = [0f32; 16 * 3 + 4]; let mut raw = [0f32; 16 * 3 + 4];
@ -526,12 +515,12 @@ impl strafe_client::framework::Example for GraphicsData {
jump_trying: false, jump_trying: false,
walkspeed: 18.0, walkspeed: 18.0,
contacts: std::collections::HashSet::new(), contacts: std::collections::HashSet::new(),
models: Vec::new(), models: Vec::new(),
walk: strafe_client::body::WalkState::new(), walk: strafe_client::body::WalkState::new(),
hitbox_halfsize: glam::vec3(1.0,2.5,1.0), hitbox_halfsize: glam::vec3(1.0,2.5,1.0),
camera: Camera::from_offset(glam::vec3(0.0,4.5-2.5,0.0),(config.width as f32)/(config.height as f32)), camera: strafe_client::body::Camera::from_offset(glam::vec3(0.0,4.5-2.5,0.0),(config.width as f32)/(config.height as f32)),
mouse_interpolation: strafe_client::body::MouseInterpolationState::new(), mouse_interpolation: strafe_client::body::MouseInterpolationState::new(),
controls: 0, controls: 0,
}; };
//load textures //load textures
@ -720,7 +709,7 @@ impl strafe_client::framework::Example for GraphicsData {
multiview: None, multiview: None,
}); });
let camera_uniforms = camera.to_uniform_data(physics.body.extrapolated_position(0)); let camera_uniforms = to_uniform_data(&physics.camera,physics.body.extrapolated_position(0));
let camera_buf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { let camera_buf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("Camera"), label: Some("Camera"),
contents: bytemuck::cast_slice(&camera_uniforms), contents: bytemuck::cast_slice(&camera_uniforms),
@ -756,7 +745,7 @@ impl strafe_client::framework::Example for GraphicsData {
let mut graphics=GraphicsData { let mut graphics=GraphicsData {
handy_unit_cube:unit_cube, handy_unit_cube:unit_cube,
start_time: Instant::now(), start_time: Instant::now(),
screen_size, screen_size: (config.width,config.height),
physics, physics,
pipelines:GraphicsPipelines{ pipelines:GraphicsPipelines{
skybox:sky_pipeline, skybox:sky_pipeline,
@ -806,58 +795,57 @@ impl strafe_client::framework::Example for GraphicsData {
fn device_event(&mut self, event: winit::event::DeviceEvent) { fn device_event(&mut self, event: winit::event::DeviceEvent) {
//there's no way this is the best way get a timestamp. //there's no way this is the best way get a timestamp.
let time=self.start_time.elapsed().as_nanos() as i64; let time=self.start_time.elapsed().as_nanos() as i64;
self.physics.run(time);//call it a day
match event { match event {
winit::event::DeviceEvent::KeyboardInput { winit::event::DeviceEvent::Key(winit::event::KeyboardInput {
input: state,
winit::event::KeyboardInput { scancode: keycode,
state, ..
scancode: keycode, }) => {
..
},
} => {
let s=match state { let s=match state {
winit::event::ElementState::Pressed => true, winit::event::ElementState::Pressed => true,
winit::event::ElementState::Released => false, winit::event::ElementState::Released => false,
}; };
if let Some(instruction)=match keycode { if let Some(input_instruction)=match keycode {
119 => Some(InputInstruction::MoveForward(s)),//W 17 => Some(InputInstruction::MoveForward(s)),//W
97 => Some(InputInstruction::MoveLeft(s)),//A 30 => Some(InputInstruction::MoveLeft(s)),//A
115 => Some(InputInstruction::MoveBack(s)),//S 31 => Some(InputInstruction::MoveBack(s)),//S
100 => Some(InputInstruction::MoveRight(s)),//D 32 => Some(InputInstruction::MoveRight(s)),//D
101 => Some(InputInstruction::MoveUp(s)),//E 18 => Some(InputInstruction::MoveUp(s)),//E
113 => Some(InputInstruction::MoveDown(s)),//Q 16 => Some(InputInstruction::MoveDown(s)),//Q
32 => Some(InputInstruction::Jump(s)),//Space 57 => Some(InputInstruction::Jump(s)),//Space
122 => Some(InputInstruction::Zoom(s)),//Z 44 => Some(InputInstruction::Zoom(s)),//Z
114 => if s{Some(InputInstruction::Reset)}else{None},//R 19 => if s{Some(InputInstruction::Reset)}else{None},//R
_ => None, _ => None,
} }
{ {
self.physics.queue_input_instruction(TimedInstruction{ self.physics.process_instruction(TimedInstruction{
time, time,
instruction, instruction:PhysicsInstruction::Input(input_instruction),
}) })
} }
}, },
winit::event::DeviceEvent::MouseMotion { winit::event::DeviceEvent::MouseMotion {
delta,//these (f64,f64) are integers on my machine delta,//these (f64,f64) are integers on my machine
} => { } => {
self.physics.queue_input_instruction(TimedInstruction{ self.physics.process_instruction(TimedInstruction{
time, time,
instruction:InputInstruction::MoveMouse(glam::ivec2(delta.0 as i32,delta.1 as i32)) instruction:PhysicsInstruction::Input(InputInstruction::MoveMouse(glam::ivec2(delta.0 as i32,delta.1 as i32))),
}) })
}, },
winit::event::DeviceEvent::MouseWheel { winit::event::DeviceEvent::MouseWheel {
delta,//these (f64,f64) are integers on my machine delta,
} => { } => {
if self.physics.use_scroll{ println!("mousewheel{:?}",delta);
self.physics.queue_input_instruction(TimedInstruction{ if true{//self.physics.use_scroll
self.physics.process_instruction(TimedInstruction{
time, time,
instruction:InputInstruction::Jump(true)//activates the immediate jump path, but the style modifier prevents controls&CONTROL_JUMP bit from being set to auto jump instruction:PhysicsInstruction::Input(InputInstruction::Jump(true)),//activates the immediate jump path, but the style modifier prevents controls&CONTROL_JUMP bit from being set to auto jump
}) })
} }
} }
_=>(),
} }
self.physics.queue_input_instruction()
} }
fn resize( fn resize(
@ -868,7 +856,7 @@ impl strafe_client::framework::Example for GraphicsData {
) { ) {
self.depth_view = Self::create_depth_texture(config, device); self.depth_view = Self::create_depth_texture(config, device);
self.screen_size = (config.width, config.height); self.screen_size = (config.width, config.height);
self.physics.camera.fov_x=self.physics.camera.fov_y*(config.width as f32)/(config.height as f32); self.physics.camera.set_fov_aspect(1.0,(config.width as f32)/(config.height as f32));
} }
fn render( fn render(
@ -886,7 +874,7 @@ impl strafe_client::framework::Example for GraphicsData {
device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None }); device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None });
// update rotation // update rotation
let camera_uniforms = to_uniform_data(self.camera,self.physics.body.extrapolated_position(time)); let camera_uniforms = to_uniform_data(&self.physics.camera,self.physics.body.extrapolated_position(time));
self.staging_belt self.staging_belt
.write_buffer( .write_buffer(
&mut encoder, &mut encoder,