Compare commits
5 Commits
master
...
Only-Veloc
Author | SHA1 | Date | |
---|---|---|---|
|
5994b05e1f | ||
|
5e6ebdf125 | ||
|
cda4d82236 | ||
f07d9f968e | |||
2cef79da1d |
@ -45,6 +45,7 @@ pub struct Body{
|
|||||||
pub acceleration:Planar64Vec3,//I64 where 2^32 = 1 u/s/s
|
pub acceleration:Planar64Vec3,//I64 where 2^32 = 1 u/s/s
|
||||||
pub time:Time,//nanoseconds x xxxxD!
|
pub time:Time,//nanoseconds x xxxxD!
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::ops::Neg for Body{
|
impl std::ops::Neg for Body{
|
||||||
type Output=Self;
|
type Output=Self;
|
||||||
fn neg(self)->Self::Output{
|
fn neg(self)->Self::Output{
|
||||||
@ -727,7 +728,7 @@ enum MoveState{
|
|||||||
|
|
||||||
pub struct PhysicsState{
|
pub struct PhysicsState{
|
||||||
time:Time,
|
time:Time,
|
||||||
body:Body,
|
pub body:Body,
|
||||||
world:WorldState,//currently there is only one state the world can be in
|
world:WorldState,//currently there is only one state the world can be in
|
||||||
game:GameMechanicsState,
|
game:GameMechanicsState,
|
||||||
style:StyleModifiers,
|
style:StyleModifiers,
|
||||||
@ -744,6 +745,8 @@ pub struct PhysicsState{
|
|||||||
//the spawn point is where you spawn when you load into the map.
|
//the spawn point is where you spawn when you load into the map.
|
||||||
//This is not the same as Reset which teleports you to Spawn0
|
//This is not the same as Reset which teleports you to Spawn0
|
||||||
spawn_point:Planar64Vec3,
|
spawn_point:Planar64Vec3,
|
||||||
|
//lmao lets go
|
||||||
|
start_time:Option<Time>,
|
||||||
}
|
}
|
||||||
#[derive(Clone,Default)]
|
#[derive(Clone,Default)]
|
||||||
pub struct PhysicsOutputState{
|
pub struct PhysicsOutputState{
|
||||||
@ -1086,6 +1089,7 @@ impl Default for PhysicsState{
|
|||||||
world:WorldState{},
|
world:WorldState{},
|
||||||
game:GameMechanicsState::default(),
|
game:GameMechanicsState::default(),
|
||||||
modes:Modes::default(),
|
modes:Modes::default(),
|
||||||
|
start_time:None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1174,7 +1178,7 @@ impl PhysicsState {
|
|||||||
ordered_checkpoint_from_checkpoint_id:eshmep2,
|
ordered_checkpoint_from_checkpoint_id:eshmep2,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
println!("Physics Objects: {}",self.models.models.len());
|
// println!("Physics Objects: {}",self.models.models.len());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_user_settings(&mut self,user_settings:&crate::settings::UserSettings){
|
pub fn load_user_settings(&mut self,user_settings:&crate::settings::UserSettings){
|
||||||
@ -1357,7 +1361,7 @@ fn set_velocity_cull(body:&mut Body,touching:&mut TouchingState,models:&PhysicsM
|
|||||||
let r=n.dot(v)<=Planar64::ZERO;
|
let r=n.dot(v)<=Planar64::ZERO;
|
||||||
if !r{
|
if !r{
|
||||||
culled=true;
|
culled=true;
|
||||||
println!("set_velocity_cull contact={:?}",contact);
|
// println!("set_velocity_cull contact={:?}",contact);
|
||||||
}
|
}
|
||||||
r
|
r
|
||||||
});
|
});
|
||||||
@ -1377,7 +1381,7 @@ fn set_acceleration_cull(body:&mut Body,touching:&mut TouchingState,models:&Phys
|
|||||||
let r=n.dot(a)<=Planar64::ZERO;
|
let r=n.dot(a)<=Planar64::ZERO;
|
||||||
if !r{
|
if !r{
|
||||||
culled=true;
|
culled=true;
|
||||||
println!("set_acceleration_cull contact={:?}",contact);
|
// println!("set_acceleration_cull contact={:?}",contact);
|
||||||
}
|
}
|
||||||
r
|
r
|
||||||
});
|
});
|
||||||
@ -1473,7 +1477,7 @@ impl instruction::InstructionConsumer<PhysicsInstruction> for PhysicsState {
|
|||||||
|PhysicsInstruction::Input(PhysicsInputInstruction::SetNextMouse(_))
|
|PhysicsInstruction::Input(PhysicsInputInstruction::SetNextMouse(_))
|
||||||
|PhysicsInstruction::Input(PhysicsInputInstruction::ReplaceMouse(_,_))
|
|PhysicsInstruction::Input(PhysicsInputInstruction::ReplaceMouse(_,_))
|
||||||
|PhysicsInstruction::StrafeTick=>(),
|
|PhysicsInstruction::StrafeTick=>(),
|
||||||
_=>println!("{}|{:?}",ins.time,ins.instruction),
|
_=> print!(""), //println!("{}|{:?}",ins.time,ins.instruction),
|
||||||
}
|
}
|
||||||
//selectively update body
|
//selectively update body
|
||||||
match &ins.instruction{
|
match &ins.instruction{
|
||||||
@ -1569,6 +1573,21 @@ impl instruction::InstructionConsumer<PhysicsInstruction> for PhysicsState {
|
|||||||
set_acceleration(&mut self.body,&self.touching,&self.models,&self.style.mesh(),a);
|
set_acceleration(&mut self.body,&self.touching,&self.models,&self.style.mesh(),a);
|
||||||
},
|
},
|
||||||
(PhysicsCollisionAttributes::Intersect{intersecting: _,general},Collision::Intersect(intersect))=>{
|
(PhysicsCollisionAttributes::Intersect{intersecting: _,general},Collision::Intersect(intersect))=>{
|
||||||
|
//check for mapstart and set start time
|
||||||
|
let model_id=c.model_id();
|
||||||
|
let start_model_id=self.modes.get_mode(0).unwrap().start;
|
||||||
|
if model_id==start_model_id{
|
||||||
|
//object touched is a mapstart
|
||||||
|
println!("Start!");
|
||||||
|
self.start_time=Some(self.time);
|
||||||
|
}
|
||||||
|
|
||||||
|
//check for map finish and print end time
|
||||||
|
if general.zone.as_ref().is_some_and(|zone|zone.behaviour==crate::model::ZoneBehaviour::Finish){
|
||||||
|
if let Some(start_time)=self.start_time.take(){
|
||||||
|
println!("Finish! Time={}",self.time-start_time);
|
||||||
|
}
|
||||||
|
}
|
||||||
//I think that setting the velocity to 0 was preventing surface contacts from entering an infinite loop
|
//I think that setting the velocity to 0 was preventing surface contacts from entering an infinite loop
|
||||||
self.touching.insert(c);
|
self.touching.insert(c);
|
||||||
run_teleport_behaviour(&general.teleport_behaviour,&mut self.game,&self.models,&self.modes,&self.style,&mut self.touching,&mut self.body,model_id);
|
run_teleport_behaviour(&general.teleport_behaviour,&mut self.game,&self.models,&self.modes,&self.style,&mut self.touching,&mut self.body,model_id);
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
use crate::physics::{MouseState,PhysicsInputInstruction};
|
use crate::physics::{MouseState,PhysicsInputInstruction, PhysicsState};
|
||||||
use strafesnet_common::integer::Time;
|
use strafesnet_common::integer::Time;
|
||||||
use strafesnet_common::instruction::{TimedInstruction,InstructionConsumer};
|
use strafesnet_common::instruction::{TimedInstruction,InstructionConsumer};
|
||||||
|
use strafesnet_common::integer::{self,Planar64,Planar64Vec3,Planar64Mat3,Angle32,Ratio64,Ratio64Vec2};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum InputInstruction {
|
pub enum InputInstruction {
|
||||||
MoveMouse(glam::IVec2),
|
MoveMouse(glam::IVec2),
|
||||||
@ -22,11 +24,28 @@ pub enum Instruction{
|
|||||||
ClearModels,
|
ClearModels,
|
||||||
//Graphics(crate::graphics_worker::Instruction),
|
//Graphics(crate::graphics_worker::Instruction),
|
||||||
}
|
}
|
||||||
|
pub struct Speed{
|
||||||
|
pub player_vel:Planar64Vec3,
|
||||||
|
pub time:Time,
|
||||||
|
pub start_time:Option<Time>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Speed{
|
||||||
|
pub fn new(self,player_vel:Planar64Vec3,time:Time)->Self{
|
||||||
|
Self{
|
||||||
|
player_vel,
|
||||||
|
time,
|
||||||
|
start_time:None,
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn new(mut physics:crate::physics::PhysicsState,mut graphics_worker:crate::compat_worker::INWorker<crate::graphics_worker::Instruction>)->crate::compat_worker::QNWorker<TimedInstruction<Instruction>>{
|
pub fn new(mut physics:crate::physics::PhysicsState,mut graphics_worker:crate::compat_worker::INWorker<crate::graphics_worker::Instruction>)->crate::compat_worker::QNWorker<TimedInstruction<Instruction>>{
|
||||||
let mut mouse_blocking=true;
|
let mut mouse_blocking=true;
|
||||||
let mut last_mouse_time=physics.next_mouse.time;
|
let mut last_mouse_time=physics.next_mouse.time;
|
||||||
let mut timeline=std::collections::VecDeque::new();
|
let mut timeline=std::collections::VecDeque::new();
|
||||||
|
let mut next_velocity_print=std::time::Instant::now();
|
||||||
crate::compat_worker::QNWorker::new(move |ins:TimedInstruction<Instruction>|{
|
crate::compat_worker::QNWorker::new(move |ins:TimedInstruction<Instruction>|{
|
||||||
if if let Some(phys_input)=match &ins.instruction{
|
if if let Some(phys_input)=match &ins.instruction{
|
||||||
Instruction::Input(input_instruction)=>match input_instruction{
|
Instruction::Input(input_instruction)=>match input_instruction{
|
||||||
@ -110,6 +129,12 @@ pub enum Instruction{
|
|||||||
instruction:crate::physics::PhysicsInstruction::Input(instruction.instruction),
|
instruction:crate::physics::PhysicsInstruction::Input(instruction.instruction),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
//some random print stuff
|
||||||
|
if 3.0/5.0<next_velocity_print.elapsed().as_secs_f64(){
|
||||||
|
next_velocity_print=next_velocity_print+std::time::Duration::from_secs_f64(1.0/10.0);
|
||||||
|
println!("xz Velocity: {} u/s", (Planar64Vec3::new(physics.body.velocity.x(), Planar64::int(0), physics.body.velocity.z())).length());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
match ins.instruction{
|
match ins.instruction{
|
||||||
Instruction::Render=>{
|
Instruction::Render=>{
|
||||||
|
Loading…
Reference in New Issue
Block a user