common: don't use TimeInner as Instruction generics
This commit is contained in:
parent
57552c1a6a
commit
5409548348
engine
lib
strafe-client/src
@ -556,7 +556,7 @@ impl MoveState{
|
|||||||
=>None,
|
=>None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn next_move_instruction(&self,strafe:&Option<gameplay_style::StrafeSettings>,time:Time)->Option<TimedInstruction<InternalInstruction,TimeInner>>{
|
fn next_move_instruction(&self,strafe:&Option<gameplay_style::StrafeSettings>,time:Time)->Option<TimedInstruction<InternalInstruction,Time>>{
|
||||||
//check if you have a valid walk state and create an instruction
|
//check if you have a valid walk state and create an instruction
|
||||||
match self{
|
match self{
|
||||||
MoveState::Walk(walk_state)|MoveState::Ladder(walk_state)=>match &walk_state.target{
|
MoveState::Walk(walk_state)|MoveState::Ladder(walk_state)=>match &walk_state.target{
|
||||||
@ -784,7 +784,7 @@ impl TouchingState{
|
|||||||
}).collect();
|
}).collect();
|
||||||
crate::push_solve::push_solve(&contacts,acceleration)
|
crate::push_solve::push_solve(&contacts,acceleration)
|
||||||
}
|
}
|
||||||
fn predict_collision_end(&self,collector:&mut instruction::InstructionCollector<InternalInstruction,TimeInner>,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,body:&Body,start_time:Time){
|
fn predict_collision_end(&self,collector:&mut instruction::InstructionCollector<InternalInstruction,Time>,models:&PhysicsModels,hitbox_mesh:&HitboxMesh,body:&Body,start_time:Time){
|
||||||
// let relative_body=body.relative_to(&Body::ZERO);
|
// let relative_body=body.relative_to(&Body::ZERO);
|
||||||
let relative_body=body;
|
let relative_body=body;
|
||||||
for contact in &self.contacts{
|
for contact in &self.contacts{
|
||||||
@ -878,7 +878,7 @@ impl PhysicsState{
|
|||||||
fn reset_to_default(&mut self){
|
fn reset_to_default(&mut self){
|
||||||
*self=Self::default();
|
*self=Self::default();
|
||||||
}
|
}
|
||||||
fn next_move_instruction(&self)->Option<TimedInstruction<InternalInstruction,TimeInner>>{
|
fn next_move_instruction(&self)->Option<TimedInstruction<InternalInstruction,Time>>{
|
||||||
self.move_state.next_move_instruction(&self.style.strafe,self.time)
|
self.move_state.next_move_instruction(&self.style.strafe,self.time)
|
||||||
}
|
}
|
||||||
fn cull_velocity(&mut self,data:&PhysicsData,velocity:Planar64Vec3){
|
fn cull_velocity(&mut self,data:&PhysicsData,velocity:Planar64Vec3){
|
||||||
@ -950,21 +950,21 @@ pub struct PhysicsContext<'a>{
|
|||||||
// the physics consumes both Instruction and PhysicsInternalInstruction,
|
// the physics consumes both Instruction and PhysicsInternalInstruction,
|
||||||
// but can only emit PhysicsInternalInstruction
|
// but can only emit PhysicsInternalInstruction
|
||||||
impl InstructionConsumer<InternalInstruction> for PhysicsContext<'_>{
|
impl InstructionConsumer<InternalInstruction> for PhysicsContext<'_>{
|
||||||
type TimeInner=TimeInner;
|
type Time=Time;
|
||||||
fn process_instruction(&mut self,ins:TimedInstruction<InternalInstruction,TimeInner>){
|
fn process_instruction(&mut self,ins:TimedInstruction<InternalInstruction,Time>){
|
||||||
atomic_internal_instruction(&mut self.state,&self.data,ins)
|
atomic_internal_instruction(&mut self.state,&self.data,ins)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl InstructionConsumer<Instruction> for PhysicsContext<'_>{
|
impl InstructionConsumer<Instruction> for PhysicsContext<'_>{
|
||||||
type TimeInner=TimeInner;
|
type Time=Time;
|
||||||
fn process_instruction(&mut self,ins:TimedInstruction<Instruction,TimeInner>){
|
fn process_instruction(&mut self,ins:TimedInstruction<Instruction,Time>){
|
||||||
atomic_input_instruction(&mut self.state,&self.data,ins)
|
atomic_input_instruction(&mut self.state,&self.data,ins)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl InstructionEmitter<InternalInstruction> for PhysicsContext<'_>{
|
impl InstructionEmitter<InternalInstruction> for PhysicsContext<'_>{
|
||||||
type TimeInner=TimeInner;
|
type Time=Time;
|
||||||
//this little next instruction function could cache its return value and invalidate the cached value by watching the State.
|
//this little next instruction function could cache its return value and invalidate the cached value by watching the State.
|
||||||
fn next_instruction(&self,time_limit:Time)->Option<TimedInstruction<InternalInstruction,TimeInner>>{
|
fn next_instruction(&self,time_limit:Time)->Option<TimedInstruction<InternalInstruction,Time>>{
|
||||||
next_instruction_internal(&self.state,&self.data,time_limit)
|
next_instruction_internal(&self.state,&self.data,time_limit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -972,7 +972,7 @@ impl PhysicsContext<'_>{
|
|||||||
pub fn run_input_instruction(
|
pub fn run_input_instruction(
|
||||||
state:&mut PhysicsState,
|
state:&mut PhysicsState,
|
||||||
data:&PhysicsData,
|
data:&PhysicsData,
|
||||||
instruction:TimedInstruction<Instruction,TimeInner>
|
instruction:TimedInstruction<Instruction,Time>
|
||||||
){
|
){
|
||||||
let mut context=PhysicsContext{state,data};
|
let mut context=PhysicsContext{state,data};
|
||||||
context.process_exhaustive(instruction.time);
|
context.process_exhaustive(instruction.time);
|
||||||
@ -1121,7 +1121,7 @@ impl PhysicsData{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//this is the one who asks
|
//this is the one who asks
|
||||||
fn next_instruction_internal(state:&PhysicsState,data:&PhysicsData,time_limit:Time)->Option<TimedInstruction<InternalInstruction,TimeInner>>{
|
fn next_instruction_internal(state:&PhysicsState,data:&PhysicsData,time_limit:Time)->Option<TimedInstruction<InternalInstruction,Time>>{
|
||||||
//JUST POLLING!!! NO MUTATION
|
//JUST POLLING!!! NO MUTATION
|
||||||
let mut collector=instruction::InstructionCollector::new(time_limit);
|
let mut collector=instruction::InstructionCollector::new(time_limit);
|
||||||
|
|
||||||
@ -1651,7 +1651,7 @@ fn collision_end_intersect(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn atomic_internal_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:TimedInstruction<InternalInstruction,TimeInner>){
|
fn atomic_internal_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:TimedInstruction<InternalInstruction,Time>){
|
||||||
state.time=ins.time;
|
state.time=ins.time;
|
||||||
let (should_advance_body,goober_time)=match ins.instruction{
|
let (should_advance_body,goober_time)=match ins.instruction{
|
||||||
InternalInstruction::CollisionStart(_,dt)
|
InternalInstruction::CollisionStart(_,dt)
|
||||||
@ -1747,7 +1747,7 @@ fn atomic_internal_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:Tim
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn atomic_input_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:TimedInstruction<Instruction,TimeInner>){
|
fn atomic_input_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:TimedInstruction<Instruction,Time>){
|
||||||
state.time=ins.time;
|
state.time=ins.time;
|
||||||
let should_advance_body=match ins.instruction{
|
let should_advance_body=match ins.instruction{
|
||||||
//the body may as well be a quantum wave function
|
//the body may as well be a quantum wave function
|
||||||
|
@ -5,13 +5,13 @@ use strafesnet_common::physics::{
|
|||||||
TimeInner as PhysicsTimeInner,
|
TimeInner as PhysicsTimeInner,
|
||||||
Time as PhysicsTime,
|
Time as PhysicsTime,
|
||||||
};
|
};
|
||||||
use strafesnet_common::session::{Time as SessionTime,TimeInner as SessionTimeInner};
|
use strafesnet_common::session::Time as SessionTime;
|
||||||
use strafesnet_common::instruction::{InstructionConsumer,InstructionEmitter,TimedInstruction};
|
use strafesnet_common::instruction::{InstructionConsumer,InstructionEmitter,TimedInstruction};
|
||||||
|
|
||||||
type TimedSelfInstruction=TimedInstruction<Instruction,PhysicsTimeInner>;
|
type TimedSelfInstruction=TimedInstruction<Instruction,PhysicsTime>;
|
||||||
type DoubleTimedSelfInstruction=TimedInstruction<TimedSelfInstruction,SessionTimeInner>;
|
type DoubleTimedSelfInstruction=TimedInstruction<TimedSelfInstruction,SessionTime>;
|
||||||
|
|
||||||
type TimedPhysicsInstruction=TimedInstruction<PhysicsInstruction,PhysicsTimeInner>;
|
type TimedPhysicsInstruction=TimedInstruction<PhysicsInstruction,PhysicsTime>;
|
||||||
|
|
||||||
const MOUSE_TIMEOUT:SessionTime=SessionTime::from_millis(10);
|
const MOUSE_TIMEOUT:SessionTime=SessionTime::from_millis(10);
|
||||||
|
|
||||||
@ -89,14 +89,14 @@ pub struct MouseInterpolator{
|
|||||||
// Maybe MouseInterpolator manipulation is better expressed using impls
|
// Maybe MouseInterpolator manipulation is better expressed using impls
|
||||||
// and called from Instruction trait impls in session
|
// and called from Instruction trait impls in session
|
||||||
impl InstructionConsumer<TimedSelfInstruction> for MouseInterpolator{
|
impl InstructionConsumer<TimedSelfInstruction> for MouseInterpolator{
|
||||||
type TimeInner=SessionTimeInner;
|
type Time=SessionTime;
|
||||||
fn process_instruction(&mut self,ins:DoubleTimedSelfInstruction){
|
fn process_instruction(&mut self,ins:DoubleTimedSelfInstruction){
|
||||||
self.push_unbuffered_input(ins.time,ins.instruction.time,ins.instruction.instruction.into())
|
self.push_unbuffered_input(ins.time,ins.instruction.time,ins.instruction.instruction.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl InstructionEmitter<StepInstruction> for MouseInterpolator{
|
impl InstructionEmitter<StepInstruction> for MouseInterpolator{
|
||||||
type TimeInner=SessionTimeInner;
|
type Time=SessionTime;
|
||||||
fn next_instruction(&self,time_limit:SessionTime)->Option<TimedInstruction<StepInstruction,Self::TimeInner>>{
|
fn next_instruction(&self,time_limit:SessionTime)->Option<TimedInstruction<StepInstruction,Self::Time>>{
|
||||||
self.buffered_instruction_with_timeout(time_limit)
|
self.buffered_instruction_with_timeout(time_limit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -108,7 +108,7 @@ impl MouseInterpolator{
|
|||||||
output:std::collections::VecDeque::new(),
|
output:std::collections::VecDeque::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn push_mouse_and_flush_buffer(&mut self,ins:TimedInstruction<MouseInstruction,PhysicsTimeInner>){
|
fn push_mouse_and_flush_buffer(&mut self,ins:TimedInstruction<MouseInstruction,PhysicsTime>){
|
||||||
self.buffer.push_front(TimedInstruction{
|
self.buffer.push_front(TimedInstruction{
|
||||||
time:ins.time,
|
time:ins.time,
|
||||||
instruction:BufferedInstruction::Mouse(ins.instruction).into(),
|
instruction:BufferedInstruction::Mouse(ins.instruction).into(),
|
||||||
@ -219,7 +219,7 @@ impl MouseInterpolator{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn buffered_instruction_with_timeout(&self,time_limit:SessionTime)->Option<TimedInstruction<StepInstruction,SessionTimeInner>>{
|
fn buffered_instruction_with_timeout(&self,time_limit:SessionTime)->Option<TimedInstruction<StepInstruction,SessionTime>>{
|
||||||
match self.get_mouse_timedout_at(time_limit){
|
match self.get_mouse_timedout_at(time_limit){
|
||||||
Some(timeout)=>Some(TimedInstruction{
|
Some(timeout)=>Some(TimedInstruction{
|
||||||
time:timeout,
|
time:timeout,
|
||||||
@ -232,7 +232,7 @@ impl MouseInterpolator{
|
|||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn pop_buffered_instruction(&mut self,ins:TimedInstruction<StepInstruction,PhysicsTimeInner>)->Option<TimedPhysicsInstruction>{
|
pub fn pop_buffered_instruction(&mut self,ins:TimedInstruction<StepInstruction,PhysicsTime>)->Option<TimedPhysicsInstruction>{
|
||||||
match ins.instruction{
|
match ins.instruction{
|
||||||
StepInstruction::Pop=>(),
|
StepInstruction::Pop=>(),
|
||||||
StepInstruction::Timeout=>self.timeout_mouse(ins.time),
|
StepInstruction::Timeout=>self.timeout_mouse(ins.time),
|
||||||
@ -244,6 +244,7 @@ impl MouseInterpolator{
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test{
|
mod test{
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use strafesnet_common::session::TimeInner as SessionTimeInner;
|
||||||
#[test]
|
#[test]
|
||||||
fn test(){
|
fn test(){
|
||||||
let mut interpolator=MouseInterpolator::new();
|
let mut interpolator=MouseInterpolator::new();
|
||||||
|
@ -88,11 +88,11 @@ impl Simulation{
|
|||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Recording{
|
pub struct Recording{
|
||||||
instructions:Vec<TimedInstruction<PhysicsInputInstruction,PhysicsTimeInner>>,
|
instructions:Vec<TimedInstruction<PhysicsInputInstruction,PhysicsTime>>,
|
||||||
}
|
}
|
||||||
impl Recording{
|
impl Recording{
|
||||||
pub fn new(
|
pub fn new(
|
||||||
instructions:Vec<TimedInstruction<PhysicsInputInstruction,PhysicsTimeInner>>,
|
instructions:Vec<TimedInstruction<PhysicsInputInstruction,PhysicsTime>>,
|
||||||
)->Self{
|
)->Self{
|
||||||
Self{instructions}
|
Self{instructions}
|
||||||
}
|
}
|
||||||
@ -207,8 +207,8 @@ impl Session{
|
|||||||
// Session emits DoStep
|
// Session emits DoStep
|
||||||
|
|
||||||
impl InstructionConsumer<Instruction<'_>> for Session{
|
impl InstructionConsumer<Instruction<'_>> for Session{
|
||||||
type TimeInner=SessionTimeInner;
|
type Time=SessionTime;
|
||||||
fn process_instruction(&mut self,ins:TimedInstruction<Instruction,Self::TimeInner>){
|
fn process_instruction(&mut self,ins:TimedInstruction<Instruction,Self::Time>){
|
||||||
// repetitive procedure macro
|
// repetitive procedure macro
|
||||||
macro_rules! run_mouse_interpolator_instruction{
|
macro_rules! run_mouse_interpolator_instruction{
|
||||||
($instruction:expr)=>{
|
($instruction:expr)=>{
|
||||||
@ -425,8 +425,8 @@ impl InstructionConsumer<Instruction<'_>> for Session{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl InstructionConsumer<StepInstruction> for Session{
|
impl InstructionConsumer<StepInstruction> for Session{
|
||||||
type TimeInner=SessionTimeInner;
|
type Time=SessionTime;
|
||||||
fn process_instruction(&mut self,ins:TimedInstruction<StepInstruction,Self::TimeInner>){
|
fn process_instruction(&mut self,ins:TimedInstruction<StepInstruction,Self::Time>){
|
||||||
let time=self.simulation.timer.time(ins.time);
|
let time=self.simulation.timer.time(ins.time);
|
||||||
if let Some(instruction)=self.mouse_interpolator.pop_buffered_instruction(ins.set_time(time)){
|
if let Some(instruction)=self.mouse_interpolator.pop_buffered_instruction(ins.set_time(time)){
|
||||||
//record
|
//record
|
||||||
@ -436,8 +436,8 @@ impl InstructionConsumer<StepInstruction> for Session{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl InstructionEmitter<StepInstruction> for Session{
|
impl InstructionEmitter<StepInstruction> for Session{
|
||||||
type TimeInner=SessionTimeInner;
|
type Time=SessionTime;
|
||||||
fn next_instruction(&self,time_limit:SessionTime)->Option<TimedInstruction<StepInstruction,Self::TimeInner>>{
|
fn next_instruction(&self,time_limit:SessionTime)->Option<TimedInstruction<StepInstruction,Self::Time>>{
|
||||||
self.mouse_interpolator.next_instruction(time_limit)
|
self.mouse_interpolator.next_instruction(time_limit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
use crate::integer::Time;
|
|
||||||
|
|
||||||
#[derive(Clone,Debug)]
|
#[derive(Clone,Debug)]
|
||||||
pub struct TimedInstruction<I,T>{
|
pub struct TimedInstruction<I,T>{
|
||||||
pub time:Time<T>,
|
pub time:T,
|
||||||
pub instruction:I,
|
pub instruction:I,
|
||||||
}
|
}
|
||||||
impl<I,T> TimedInstruction<I,T>{
|
impl<I,T> TimedInstruction<I,T>{
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_time<TimeInner>(self,new_time:Time<TimeInner>)->TimedInstruction<I,TimeInner>{
|
pub fn set_time<T2>(self,new_time:T2)->TimedInstruction<I,T2>{
|
||||||
TimedInstruction{
|
TimedInstruction{
|
||||||
time:new_time,
|
time:new_time,
|
||||||
instruction:self.instruction,
|
instruction:self.instruction,
|
||||||
@ -17,21 +15,21 @@ impl<I,T> TimedInstruction<I,T>{
|
|||||||
|
|
||||||
/// Ensure all emitted instructions are processed before consuming external instructions
|
/// Ensure all emitted instructions are processed before consuming external instructions
|
||||||
pub trait InstructionEmitter<I>{
|
pub trait InstructionEmitter<I>{
|
||||||
type TimeInner;
|
type Time;
|
||||||
fn next_instruction(&self,time_limit:Time<Self::TimeInner>)->Option<TimedInstruction<I,Self::TimeInner>>;
|
fn next_instruction(&self,time_limit:Self::Time)->Option<TimedInstruction<I,Self::Time>>;
|
||||||
}
|
}
|
||||||
/// Apply an atomic state update
|
/// Apply an atomic state update
|
||||||
pub trait InstructionConsumer<I>{
|
pub trait InstructionConsumer<I>{
|
||||||
type TimeInner;
|
type Time;
|
||||||
fn process_instruction(&mut self,instruction:TimedInstruction<I,Self::TimeInner>);
|
fn process_instruction(&mut self,instruction:TimedInstruction<I,Self::Time>);
|
||||||
}
|
}
|
||||||
/// If the object produces its own instructions, allow exhaustively feeding them back in
|
/// If the object produces its own instructions, allow exhaustively feeding them back in
|
||||||
pub trait InstructionFeedback<I,T>:InstructionEmitter<I,TimeInner=T>+InstructionConsumer<I,TimeInner=T>
|
pub trait InstructionFeedback<I,T>:InstructionEmitter<I,Time=T>+InstructionConsumer<I,Time=T>
|
||||||
where
|
where
|
||||||
Time<T>:Copy,
|
T:Copy,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn process_exhaustive(&mut self,time_limit:Time<T>){
|
fn process_exhaustive(&mut self,time_limit:T){
|
||||||
while let Some(instruction)=self.next_instruction(time_limit){
|
while let Some(instruction)=self.next_instruction(time_limit){
|
||||||
self.process_instruction(instruction);
|
self.process_instruction(instruction);
|
||||||
}
|
}
|
||||||
@ -39,27 +37,27 @@ pub trait InstructionFeedback<I,T>:InstructionEmitter<I,TimeInner=T>+Instruction
|
|||||||
}
|
}
|
||||||
impl<I,T,X> InstructionFeedback<I,T> for X
|
impl<I,T,X> InstructionFeedback<I,T> for X
|
||||||
where
|
where
|
||||||
Time<T>:Copy,
|
T:Copy,
|
||||||
X:InstructionEmitter<I,TimeInner=T>+InstructionConsumer<I,TimeInner=T>,
|
X:InstructionEmitter<I,Time=T>+InstructionConsumer<I,Time=T>,
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//PROPER PRIVATE FIELDS!!!
|
//PROPER PRIVATE FIELDS!!!
|
||||||
pub struct InstructionCollector<I,T>{
|
pub struct InstructionCollector<I,T>{
|
||||||
time:Time<T>,
|
time:T,
|
||||||
instruction:Option<I>,
|
instruction:Option<I>,
|
||||||
}
|
}
|
||||||
impl<I,T> InstructionCollector<I,T>
|
impl<I,T> InstructionCollector<I,T>
|
||||||
where Time<T>:Copy+PartialOrd,
|
where T:Copy+PartialOrd,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn new(time:Time<T>)->Self{
|
pub const fn new(time:T)->Self{
|
||||||
Self{
|
Self{
|
||||||
time,
|
time,
|
||||||
instruction:None
|
instruction:None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn time(&self)->Time<T>{
|
pub const fn time(&self)->T{
|
||||||
self.time
|
self.time
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -6,7 +6,7 @@ use strafesnet_common::physics::Time;
|
|||||||
|
|
||||||
const VERSION:u32=0;
|
const VERSION:u32=0;
|
||||||
|
|
||||||
type TimedPhysicsInstruction=strafesnet_common::instruction::TimedInstruction<strafesnet_common::physics::Instruction,strafesnet_common::physics::TimeInner>;
|
type TimedPhysicsInstruction=strafesnet_common::instruction::TimedInstruction<strafesnet_common::physics::Instruction,strafesnet_common::physics::Time>;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error{
|
pub enum Error{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use super::integer::Time;
|
use super::integer::Time;
|
||||||
use super::common::{bool_from_u8,bool_into_u8};
|
use super::common::{bool_from_u8,bool_into_u8};
|
||||||
|
|
||||||
type TimedPhysicsInstruction=strafesnet_common::instruction::TimedInstruction<strafesnet_common::physics::Instruction,strafesnet_common::physics::TimeInner>;
|
type TimedPhysicsInstruction=strafesnet_common::instruction::TimedInstruction<strafesnet_common::physics::Instruction,strafesnet_common::physics::Time>;
|
||||||
|
|
||||||
#[binrw::binrw]
|
#[binrw::binrw]
|
||||||
#[brw(little)]
|
#[brw(little)]
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
use crate::window::Instruction;
|
use crate::window::Instruction;
|
||||||
use strafesnet_common::integer;
|
use strafesnet_common::integer;
|
||||||
use strafesnet_common::instruction::TimedInstruction;
|
use strafesnet_common::instruction::TimedInstruction;
|
||||||
use strafesnet_common::session::TimeInner as SessionTimeInner;
|
use strafesnet_common::session::Time as SessionTime;
|
||||||
|
|
||||||
pub struct App<'a>{
|
pub struct App<'a>{
|
||||||
root_time:std::time::Instant,
|
root_time:std::time::Instant,
|
||||||
window_thread:crate::compat_worker::QNWorker<'a,TimedInstruction<Instruction,SessionTimeInner>>,
|
window_thread:crate::compat_worker::QNWorker<'a,TimedInstruction<Instruction,SessionTime>>,
|
||||||
}
|
}
|
||||||
impl<'a> App<'a>{
|
impl<'a> App<'a>{
|
||||||
pub fn new(
|
pub fn new(
|
||||||
root_time:std::time::Instant,
|
root_time:std::time::Instant,
|
||||||
window_thread:crate::compat_worker::QNWorker<'a,TimedInstruction<Instruction,SessionTimeInner>>,
|
window_thread:crate::compat_worker::QNWorker<'a,TimedInstruction<Instruction,SessionTime>>,
|
||||||
)->App<'a>{
|
)->App<'a>{
|
||||||
Self{
|
Self{
|
||||||
root_time,
|
root_time,
|
||||||
|
@ -6,7 +6,7 @@ use strafesnet_session::session::{
|
|||||||
};
|
};
|
||||||
use strafesnet_common::instruction::{TimedInstruction,InstructionConsumer};
|
use strafesnet_common::instruction::{TimedInstruction,InstructionConsumer};
|
||||||
use strafesnet_common::physics::Time as PhysicsTime;
|
use strafesnet_common::physics::Time as PhysicsTime;
|
||||||
use strafesnet_common::session::{Time as SessionTime,TimeInner as SessionTimeInner};
|
use strafesnet_common::session::Time as SessionTime;
|
||||||
use strafesnet_common::timer::Timer;
|
use strafesnet_common::timer::Timer;
|
||||||
|
|
||||||
pub enum Instruction{
|
pub enum Instruction{
|
||||||
@ -23,7 +23,7 @@ pub fn new<'a>(
|
|||||||
mut graphics_worker:crate::compat_worker::INWorker<'a,crate::graphics_worker::Instruction>,
|
mut graphics_worker:crate::compat_worker::INWorker<'a,crate::graphics_worker::Instruction>,
|
||||||
directories:Directories,
|
directories:Directories,
|
||||||
user_settings:settings::UserSettings,
|
user_settings:settings::UserSettings,
|
||||||
)->crate::compat_worker::QNWorker<'a,TimedInstruction<Instruction,SessionTimeInner>>{
|
)->crate::compat_worker::QNWorker<'a,TimedInstruction<Instruction,SessionTime>>{
|
||||||
let physics=strafesnet_physics::physics::PhysicsState::default();
|
let physics=strafesnet_physics::physics::PhysicsState::default();
|
||||||
let timer=Timer::unpaused(SessionTime::ZERO,PhysicsTime::ZERO);
|
let timer=Timer::unpaused(SessionTime::ZERO,PhysicsTime::ZERO);
|
||||||
let simulation=Simulation::new(timer,physics);
|
let simulation=Simulation::new(timer,physics);
|
||||||
@ -32,7 +32,7 @@ pub fn new<'a>(
|
|||||||
directories,
|
directories,
|
||||||
simulation,
|
simulation,
|
||||||
);
|
);
|
||||||
crate::compat_worker::QNWorker::new(move |ins:TimedInstruction<Instruction,SessionTimeInner>|{
|
crate::compat_worker::QNWorker::new(move |ins:TimedInstruction<Instruction,SessionTime>|{
|
||||||
// excruciating pain
|
// excruciating pain
|
||||||
macro_rules! run_session_instruction{
|
macro_rules! run_session_instruction{
|
||||||
($time:expr,$instruction:expr)=>{
|
($time:expr,$instruction:expr)=>{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use strafesnet_common::instruction::TimedInstruction;
|
use strafesnet_common::instruction::TimedInstruction;
|
||||||
use strafesnet_common::session::{Time as SessionTime,TimeInner as SessionTimeInner};
|
use strafesnet_common::session::Time as SessionTime;
|
||||||
use strafesnet_common::physics::{MiscInstruction,SetControlInstruction};
|
use strafesnet_common::physics::{MiscInstruction,SetControlInstruction};
|
||||||
use crate::file::LoadFormat;
|
use crate::file::LoadFormat;
|
||||||
use crate::physics_worker::Instruction as PhysicsWorkerInstruction;
|
use crate::physics_worker::Instruction as PhysicsWorkerInstruction;
|
||||||
@ -17,7 +17,7 @@ struct WindowContext<'a>{
|
|||||||
mouse_pos:glam::DVec2,
|
mouse_pos:glam::DVec2,
|
||||||
screen_size:glam::UVec2,
|
screen_size:glam::UVec2,
|
||||||
window:&'a winit::window::Window,
|
window:&'a winit::window::Window,
|
||||||
physics_thread:crate::compat_worker::QNWorker<'a,TimedInstruction<PhysicsWorkerInstruction,SessionTimeInner>>,
|
physics_thread:crate::compat_worker::QNWorker<'a,TimedInstruction<PhysicsWorkerInstruction,SessionTime>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowContext<'_>{
|
impl WindowContext<'_>{
|
||||||
@ -223,7 +223,7 @@ impl WindowContext<'_>{
|
|||||||
pub fn worker<'a>(
|
pub fn worker<'a>(
|
||||||
window:&'a winit::window::Window,
|
window:&'a winit::window::Window,
|
||||||
setup_context:crate::setup::SetupContext<'a>,
|
setup_context:crate::setup::SetupContext<'a>,
|
||||||
)->crate::compat_worker::QNWorker<'a,TimedInstruction<Instruction,SessionTimeInner>>{
|
)->crate::compat_worker::QNWorker<'a,TimedInstruction<Instruction,SessionTime>>{
|
||||||
// WindowContextSetup::new
|
// WindowContextSetup::new
|
||||||
#[cfg(feature="user-install")]
|
#[cfg(feature="user-install")]
|
||||||
let directories=Directories::user().unwrap();
|
let directories=Directories::user().unwrap();
|
||||||
@ -252,7 +252,7 @@ pub fn worker<'a>(
|
|||||||
};
|
};
|
||||||
|
|
||||||
//WindowContextSetup::into_worker
|
//WindowContextSetup::into_worker
|
||||||
crate::compat_worker::QNWorker::new(move |ins:TimedInstruction<Instruction,SessionTimeInner>|{
|
crate::compat_worker::QNWorker::new(move |ins:TimedInstruction<Instruction,SessionTime>|{
|
||||||
match ins.instruction{
|
match ins.instruction{
|
||||||
Instruction::WindowEvent(window_event)=>{
|
Instruction::WindowEvent(window_event)=>{
|
||||||
window_context.window_event(ins.time,window_event);
|
window_context.window_event(ins.time,window_event);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user