Compare commits
14 Commits
pause
...
bot-resimu
| Author | SHA1 | Date | |
|---|---|---|---|
| d4b6dfc71c | |||
| 16575eb777 | |||
| cc33eeb2ad | |||
| a4077ed0e3 | |||
| b9e34f53c3 | |||
| 394f1f1dc2 | |||
| 05ec7ea5d8 | |||
| 7996df532e | |||
| b4b85b7da4 | |||
| 3a98eaff7c | |||
| 4b5b7dc2fb | |||
| 8a13640c55 | |||
| 85ba12ff92 | |||
| 4f492d73b0 |
90
Cargo.lock
generated
90
Cargo.lock
generated
@@ -28,7 +28,7 @@ dependencies = [
|
|||||||
"getrandom",
|
"getrandom",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"version_check",
|
"version_check",
|
||||||
"zerocopy 0.7.35",
|
"zerocopy",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -294,9 +294,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytes"
|
name = "bytes"
|
||||||
version = "1.7.0"
|
version = "1.7.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fca2be1d5c43812bae364ee3f30b3afcb7877cf59f4aeb94c66f313a41d2fac9"
|
checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "calloop"
|
name = "calloop"
|
||||||
@@ -326,9 +326,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.1.7"
|
version = "1.1.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc"
|
checksum = "504bdec147f2cc13c8b57ed9401fd8a147cc66b67ad5cb241394244f2c947549"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"jobserver",
|
"jobserver",
|
||||||
"libc",
|
"libc",
|
||||||
@@ -1460,11 +1460,11 @@ checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ppv-lite86"
|
name = "ppv-lite86"
|
||||||
version = "0.2.18"
|
version = "0.2.20"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dee4364d9f3b902ef14fab8a1ddffb783a1cb6b4bba3bfc1fa3922732c7de97f"
|
checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"zerocopy 0.6.6",
|
"zerocopy",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1677,9 +1677,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex"
|
name = "regex"
|
||||||
version = "1.10.5"
|
version = "1.10.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f"
|
checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"memchr",
|
"memchr",
|
||||||
@@ -1880,7 +1880,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "strafe-client"
|
name = "strafe-client"
|
||||||
version = "0.10.2"
|
version = "0.10.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"configparser",
|
"configparser",
|
||||||
@@ -1900,9 +1900,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "strafesnet_bsp_loader"
|
name = "strafesnet_bsp_loader"
|
||||||
version = "0.1.3"
|
version = "0.1.4"
|
||||||
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
|
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
|
||||||
checksum = "6d4af68c422b5f57febbaa218f44ba02d413fd25e84afff9e45e557a8caee2ce"
|
checksum = "b6b3e1324034abfd648e339580989f8f2c30ac2009296229349d88b8fcb4eedd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"glam",
|
"glam",
|
||||||
"strafesnet_common",
|
"strafesnet_common",
|
||||||
@@ -1912,10 +1912,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "strafesnet_common"
|
name = "strafesnet_common"
|
||||||
version = "0.2.1"
|
version = "0.3.0"
|
||||||
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
|
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
|
||||||
checksum = "0ac1343bd9731706a962b66fac1efd1bd5ff56fd0a40f41c48e006fad91cf80c"
|
checksum = "1077d45a0b064964906a57de765a5a2bfe47b41f2f807d13b18c70765e76d3dd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"arrayvec",
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.6.0",
|
||||||
"glam",
|
"glam",
|
||||||
"id",
|
"id",
|
||||||
@@ -1923,9 +1924,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "strafesnet_deferred_loader"
|
name = "strafesnet_deferred_loader"
|
||||||
version = "0.3.1"
|
version = "0.3.2"
|
||||||
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
|
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
|
||||||
checksum = "c3891dcbdbc20b03cf561786b810e839ae7c11dd8810fd005f2474805ee9cccc"
|
checksum = "9d5ad437524fb201fd5be68f76c53dd831e81ccad4655e19e3d1ca201863b566"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lazy-regex",
|
"lazy-regex",
|
||||||
"strafesnet_common",
|
"strafesnet_common",
|
||||||
@@ -1934,9 +1935,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "strafesnet_rbx_loader"
|
name = "strafesnet_rbx_loader"
|
||||||
version = "0.3.2"
|
version = "0.3.3"
|
||||||
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
|
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
|
||||||
checksum = "21ea93b0170063dd2a063a138c41e6f7a6c14a82c6553fa4ba32df65a26efc6e"
|
checksum = "3a910867e1f5ab2d9cc9c178973aee7fa029547e27465e47fea2eb99b860bb81"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"glam",
|
"glam",
|
||||||
@@ -1951,9 +1952,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "strafesnet_snf"
|
name = "strafesnet_snf"
|
||||||
version = "0.1.1"
|
version = "0.1.3-bot"
|
||||||
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
|
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
|
||||||
checksum = "78479f73437a3f10230efd2304be0f3ef30dff98c54d93613ed1621bfd6a7da6"
|
checksum = "69448a3ed6ab5e9886cf83a3b2358c1f05d652cde4839963cd867978b924b52b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"binrw 0.14.0",
|
"binrw 0.14.0",
|
||||||
"id",
|
"id",
|
||||||
@@ -2103,9 +2104,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ttf-parser"
|
name = "ttf-parser"
|
||||||
version = "0.24.0"
|
version = "0.24.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8686b91785aff82828ed725225925b33b4fde44c4bb15876e5f7c832724c420a"
|
checksum = "5be21190ff5d38e8b4a2d3b6a3ae57f612cc39c96e83cedeaf7abc338a8bac4a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
@@ -2527,11 +2528,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi-util"
|
name = "winapi-util"
|
||||||
version = "0.1.8"
|
version = "0.1.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b"
|
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2577,6 +2578,15 @@ dependencies = [
|
|||||||
"windows-targets 0.52.6",
|
"windows-targets 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-sys"
|
||||||
|
version = "0.59.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
||||||
|
dependencies = [
|
||||||
|
"windows-targets 0.52.6",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-targets"
|
name = "windows-targets"
|
||||||
version = "0.42.2"
|
version = "0.42.2"
|
||||||
@@ -2875,19 +2885,9 @@ checksum = "b9cc00251562a284751c9973bace760d86c0276c471b4be569fe6b068ee97a56"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "xml-rs"
|
name = "xml-rs"
|
||||||
version = "0.8.20"
|
version = "0.8.21"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "791978798f0597cfc70478424c2b4fdc2b7a8024aaff78497ef00f24ef674193"
|
checksum = "539a77ee7c0de333dcc6da69b177380a0b81e0dacfa4f7344c465a36871ee601"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "zerocopy"
|
|
||||||
version = "0.6.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "854e949ac82d619ee9a14c66a1b674ac730422372ccb759ce0c39cabcf2bf8e6"
|
|
||||||
dependencies = [
|
|
||||||
"byteorder 1.5.0",
|
|
||||||
"zerocopy-derive 0.6.6",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zerocopy"
|
name = "zerocopy"
|
||||||
@@ -2895,18 +2895,8 @@ version = "0.7.35"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0"
|
checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"zerocopy-derive 0.7.35",
|
"byteorder 1.5.0",
|
||||||
]
|
"zerocopy-derive",
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "zerocopy-derive"
|
|
||||||
version = "0.6.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "125139de3f6b9d625c39e2efdd73d41bdac468ccd556556440e322be0e1bbd91"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 2.0.72",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "strafe-client"
|
name = "strafe-client"
|
||||||
version = "0.10.2"
|
version = "0.10.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
repository = "https://git.itzana.me/StrafesNET/strafe-client"
|
repository = "https://git.itzana.me/StrafesNET/strafe-client"
|
||||||
license = "Custom"
|
license = "Custom"
|
||||||
@@ -23,10 +23,10 @@ id = { version = "0.1.0", registry = "strafesnet" }
|
|||||||
parking_lot = "0.12.1"
|
parking_lot = "0.12.1"
|
||||||
pollster = "0.3.0"
|
pollster = "0.3.0"
|
||||||
strafesnet_bsp_loader = { version = "0.1.3", registry = "strafesnet", optional = true }
|
strafesnet_bsp_loader = { version = "0.1.3", registry = "strafesnet", optional = true }
|
||||||
strafesnet_common = { version = "0.2.1", registry = "strafesnet" }
|
strafesnet_common = { version = "0.3.0", registry = "strafesnet" }
|
||||||
strafesnet_deferred_loader = { version = "0.3.1", features = ["legacy"], registry = "strafesnet", optional = true }
|
strafesnet_deferred_loader = { version = "0.3.1", features = ["legacy"], registry = "strafesnet", optional = true }
|
||||||
strafesnet_rbx_loader = { version = "0.3.2", registry = "strafesnet", optional = true }
|
strafesnet_rbx_loader = { version = "0.3.2", registry = "strafesnet", optional = true }
|
||||||
strafesnet_snf = { version = "0.1.0", registry = "strafesnet", optional = true }
|
strafesnet_snf = { version = "0.1.3-bot", registry = "strafesnet", optional = true }
|
||||||
wgpu = "22.0.0"
|
wgpu = "22.0.0"
|
||||||
winit = "0.30.4"
|
winit = "0.30.4"
|
||||||
|
|
||||||
|
|||||||
@@ -816,7 +816,7 @@ impl GraphicsState{
|
|||||||
});
|
});
|
||||||
|
|
||||||
let camera=GraphicsCamera::default();
|
let camera=GraphicsCamera::default();
|
||||||
let camera_uniforms=camera.to_uniform_data(crate::physics::PhysicsOutputState::default().extrapolate(crate::physics::MouseState::default()));
|
let camera_uniforms=camera.to_uniform_data(crate::physics::PhysicsOutputState::default().extrapolate(strafesnet_common::mouse::MouseState::default()));
|
||||||
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),
|
||||||
@@ -893,7 +893,7 @@ impl GraphicsState{
|
|||||||
let mut encoder=device.create_command_encoder(&wgpu::CommandEncoderDescriptor{label:None});
|
let mut encoder=device.create_command_encoder(&wgpu::CommandEncoderDescriptor{label:None});
|
||||||
|
|
||||||
// update rotation
|
// update rotation
|
||||||
let camera_uniforms=self.camera.to_uniform_data(physics_output.extrapolate(crate::physics::MouseState{pos:mouse_pos,time:predicted_time}));
|
let camera_uniforms=self.camera.to_uniform_data(physics_output.extrapolate(strafesnet_common::mouse::MouseState{pos:mouse_pos,time:predicted_time}));
|
||||||
self.staging_belt
|
self.staging_belt
|
||||||
.write_buffer(
|
.write_buffer(
|
||||||
&mut encoder,
|
&mut encoder,
|
||||||
|
|||||||
@@ -4,8 +4,7 @@ pub enum Instruction{
|
|||||||
Render(crate::physics::PhysicsOutputState,integer::Time,glam::IVec2),
|
Render(crate::physics::PhysicsOutputState,integer::Time,glam::IVec2),
|
||||||
//UpdateModel(crate::graphics::GraphicsModelUpdate),
|
//UpdateModel(crate::graphics::GraphicsModelUpdate),
|
||||||
Resize(winit::dpi::PhysicalSize<u32>,crate::settings::UserSettings),
|
Resize(winit::dpi::PhysicalSize<u32>,crate::settings::UserSettings),
|
||||||
GenerateModels(strafesnet_common::map::CompleteMap),
|
ChangeMap(strafesnet_common::map::CompleteMap),
|
||||||
ClearModels,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Ideally the graphics thread worker description is:
|
//Ideally the graphics thread worker description is:
|
||||||
@@ -27,11 +26,9 @@ pub fn new<'a>(
|
|||||||
let mut resize=None;
|
let mut resize=None;
|
||||||
crate::compat_worker::INWorker::new(move |ins:Instruction|{
|
crate::compat_worker::INWorker::new(move |ins:Instruction|{
|
||||||
match ins{
|
match ins{
|
||||||
Instruction::GenerateModels(map)=>{
|
Instruction::ChangeMap(map)=>{
|
||||||
graphics.generate_models(&device,&queue,&map);
|
|
||||||
},
|
|
||||||
Instruction::ClearModels=>{
|
|
||||||
graphics.clear();
|
graphics.clear();
|
||||||
|
graphics.generate_models(&device,&queue,&map);
|
||||||
},
|
},
|
||||||
Instruction::Resize(size,user_settings)=>{
|
Instruction::Resize(size,user_settings)=>{
|
||||||
resize=Some((size,user_settings));
|
resize=Some((size,user_settings));
|
||||||
@@ -69,4 +66,4 @@ pub fn new<'a>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
177
src/physics.rs
177
src/physics.rs
@@ -5,6 +5,7 @@ use strafesnet_common::map;
|
|||||||
use strafesnet_common::run;
|
use strafesnet_common::run;
|
||||||
use strafesnet_common::aabb;
|
use strafesnet_common::aabb;
|
||||||
use strafesnet_common::model::{MeshId,ModelId};
|
use strafesnet_common::model::{MeshId,ModelId};
|
||||||
|
use strafesnet_common::mouse::MouseState;
|
||||||
use strafesnet_common::gameplay_attributes::{self,CollisionAttributesId};
|
use strafesnet_common::gameplay_attributes::{self,CollisionAttributesId};
|
||||||
use strafesnet_common::gameplay_modes::{self,StageId};
|
use strafesnet_common::gameplay_modes::{self,StageId};
|
||||||
use strafesnet_common::gameplay_style::{self,StyleModifiers};
|
use strafesnet_common::gameplay_style::{self,StyleModifiers};
|
||||||
@@ -13,6 +14,10 @@ use strafesnet_common::instruction::{self,InstructionEmitter,InstructionConsumer
|
|||||||
use strafesnet_common::integer::{self,Time,Planar64,Planar64Vec3,Planar64Mat3,Angle32,Ratio64Vec2};
|
use strafesnet_common::integer::{self,Time,Planar64,Planar64Vec3,Planar64Mat3,Angle32,Ratio64Vec2};
|
||||||
use gameplay::ModeState;
|
use gameplay::ModeState;
|
||||||
|
|
||||||
|
//external influence
|
||||||
|
//this is how you influence the physics from outside
|
||||||
|
use strafesnet_common::physics::Instruction as PhysicsInputInstruction;
|
||||||
|
|
||||||
//internal influence
|
//internal influence
|
||||||
//when the physics asks itself what happens next, this is how it's represented
|
//when the physics asks itself what happens next, this is how it's represented
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -22,34 +27,6 @@ enum PhysicsInternalInstruction{
|
|||||||
StrafeTick,
|
StrafeTick,
|
||||||
ReachWalkTargetVelocity,
|
ReachWalkTargetVelocity,
|
||||||
// Water,
|
// Water,
|
||||||
// Spawn(
|
|
||||||
// Option<SpawnId>,
|
|
||||||
// bool,//true = Trigger; false = teleport
|
|
||||||
// bool,//true = Force
|
|
||||||
// )
|
|
||||||
}
|
|
||||||
//external influence
|
|
||||||
//this is how you influence the physics from outside
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub enum PhysicsInputInstruction{
|
|
||||||
ReplaceMouse(MouseState,MouseState),
|
|
||||||
SetNextMouse(MouseState),
|
|
||||||
SetMoveRight(bool),
|
|
||||||
SetMoveUp(bool),
|
|
||||||
SetMoveBack(bool),
|
|
||||||
SetMoveLeft(bool),
|
|
||||||
SetMoveDown(bool),
|
|
||||||
SetMoveForward(bool),
|
|
||||||
SetJump(bool),
|
|
||||||
SetZoom(bool),
|
|
||||||
Restart,
|
|
||||||
Spawn(gameplay_modes::ModeId,StageId),
|
|
||||||
Idle,
|
|
||||||
//Idle: there were no input events, but the simulation is safe to advance to this timestep
|
|
||||||
//for interpolation / networking / playback reasons, most playback heads will always want
|
|
||||||
//to be 1 instruction ahead to generate the next state for interpolation.
|
|
||||||
PracticeFly,
|
|
||||||
SetSensitivity(Ratio64Vec2),
|
|
||||||
}
|
}
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum PhysicsInstruction{
|
enum PhysicsInstruction{
|
||||||
@@ -78,32 +55,6 @@ impl std::ops::Neg for Body{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//hey dumbass just use a delta
|
|
||||||
#[derive(Clone,Debug)]
|
|
||||||
pub struct MouseState {
|
|
||||||
pub pos: glam::IVec2,
|
|
||||||
pub time:Time,
|
|
||||||
}
|
|
||||||
impl Default for MouseState{
|
|
||||||
fn default() -> Self {
|
|
||||||
Self {
|
|
||||||
time:Time::ZERO,
|
|
||||||
pos:glam::IVec2::ZERO,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl MouseState {
|
|
||||||
pub fn lerp(&self,target:&MouseState,time:Time)->glam::IVec2 {
|
|
||||||
let m0=self.pos.as_i64vec2();
|
|
||||||
let m1=target.pos.as_i64vec2();
|
|
||||||
//these are deltas
|
|
||||||
let t1t=(target.time-time).nanos();
|
|
||||||
let tt0=(time-self.time).nanos();
|
|
||||||
let dt=(target.time-self.time).nanos();
|
|
||||||
((m0*t1t+m1*tt0)/dt).as_ivec2()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone,Debug,Default)]
|
#[derive(Clone,Debug,Default)]
|
||||||
pub struct InputState{
|
pub struct InputState{
|
||||||
mouse:MouseState,
|
mouse:MouseState,
|
||||||
@@ -1055,28 +1006,6 @@ impl instruction::InstructionEmitter<PhysicsInternalInstruction> for PhysicsCont
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl PhysicsContext{
|
impl PhysicsContext{
|
||||||
pub fn clear(&mut self){
|
|
||||||
self.state.clear();
|
|
||||||
}
|
|
||||||
//TODO: remove non-standard interfaces to process_instruction
|
|
||||||
pub fn load_user_settings(&mut self,user_settings:&crate::settings::UserSettings){
|
|
||||||
self.run_input_instruction(TimedInstruction{
|
|
||||||
time:self.state.time,
|
|
||||||
instruction:PhysicsInputInstruction::SetSensitivity(user_settings.calculate_sensitivity()),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
pub fn restart(&mut self){
|
|
||||||
self.run_input_instruction(TimedInstruction{
|
|
||||||
time:self.state.time,
|
|
||||||
instruction:PhysicsInputInstruction::Restart,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
pub fn spawn(&mut self){
|
|
||||||
self.run_input_instruction(TimedInstruction{
|
|
||||||
time:self.state.time,
|
|
||||||
instruction:PhysicsInputInstruction::Spawn(gameplay_modes::ModeId::MAIN,StageId::FIRST),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
pub const fn output(&self)->PhysicsOutputState{
|
pub const fn output(&self)->PhysicsOutputState{
|
||||||
PhysicsOutputState{
|
PhysicsOutputState{
|
||||||
body:self.state.body,
|
body:self.state.body,
|
||||||
@@ -1088,7 +1017,9 @@ impl PhysicsContext{
|
|||||||
pub const fn get_next_mouse(&self)->&MouseState{
|
pub const fn get_next_mouse(&self)->&MouseState{
|
||||||
self.state.input_state.get_next_mouse()
|
self.state.input_state.get_next_mouse()
|
||||||
}
|
}
|
||||||
|
/// use with caution, this is the only non-instruction way to mess with physics
|
||||||
pub fn generate_models(&mut self,map:&map::CompleteMap){
|
pub fn generate_models(&mut self,map:&map::CompleteMap){
|
||||||
|
self.state.clear();
|
||||||
self.data.modes=map.modes.clone();
|
self.data.modes=map.modes.clone();
|
||||||
for mode in &mut self.data.modes.modes{
|
for mode in &mut self.data.modes.modes{
|
||||||
mode.denormalize_data();
|
mode.denormalize_data();
|
||||||
@@ -1193,15 +1124,16 @@ impl PhysicsContext{
|
|||||||
let mut aabb=aabb::Aabb::default();
|
let mut aabb=aabb::Aabb::default();
|
||||||
state.body.grow_aabb(&mut aabb,state.time,collector.time());
|
state.body.grow_aabb(&mut aabb,state.time,collector.time());
|
||||||
aabb.inflate(data.hitbox_mesh.halfsize);
|
aabb.inflate(data.hitbox_mesh.halfsize);
|
||||||
//common body
|
//relative to moving platforms
|
||||||
let relative_body=VirtualBody::relative(&Body::default(),&state.body).body(state.time);
|
//let relative_body=&VirtualBody::relative(&Body::default(),&state.body).body(state.time);
|
||||||
|
let relative_body=&state.body;
|
||||||
data.bvh.the_tester(&aabb,&mut |&convex_mesh_id|{
|
data.bvh.the_tester(&aabb,&mut |&convex_mesh_id|{
|
||||||
//no checks are needed because of the time limits.
|
//no checks are needed because of the time limits.
|
||||||
let model_mesh=data.models.mesh(convex_mesh_id);
|
let model_mesh=data.models.mesh(convex_mesh_id);
|
||||||
let minkowski=model_physics::MinkowskiMesh::minkowski_sum(model_mesh,data.hitbox_mesh.transformed_mesh());
|
let minkowski=model_physics::MinkowskiMesh::minkowski_sum(model_mesh,data.hitbox_mesh.transformed_mesh());
|
||||||
collector.collect(minkowski.predict_collision_in(&relative_body,collector.time())
|
collector.collect(minkowski.predict_collision_in(relative_body,collector.time())
|
||||||
//temp (?) code to avoid collision loops
|
//temp (?) code to avoid collision loops
|
||||||
.map_or(None,|(face,time)|if time==state.time{None}else{Some((face,time))})
|
.map_or(None,|(face,time)|if time<=state.time{None}else{Some((face,time))})
|
||||||
.map(|(face,time)|{
|
.map(|(face,time)|{
|
||||||
TimedInstruction{time,instruction:PhysicsInternalInstruction::CollisionStart(match data.models.attr(convex_mesh_id.model_id){
|
TimedInstruction{time,instruction:PhysicsInternalInstruction::CollisionStart(match data.models.attr(convex_mesh_id.model_id){
|
||||||
PhysicsCollisionAttributes::Contact{contacting:_,general:_}=>Collision::Contact(ContactCollision{convex_mesh_id,face_id:face}),
|
PhysicsCollisionAttributes::Contact{contacting:_,general:_}=>Collision::Contact(ContactCollision{convex_mesh_id,face_id:face}),
|
||||||
@@ -1340,6 +1272,7 @@ fn run_teleport_behaviour(wormhole:&Option<gameplay_attributes::Wormhole>,models
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn atomic_internal_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:TimedInstruction<PhysicsInternalInstruction>){
|
fn atomic_internal_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:TimedInstruction<PhysicsInternalInstruction>){
|
||||||
|
state.time=ins.time;
|
||||||
let should_advance_body=match ins.instruction{
|
let should_advance_body=match ins.instruction{
|
||||||
PhysicsInternalInstruction::CollisionStart(_)
|
PhysicsInternalInstruction::CollisionStart(_)
|
||||||
|PhysicsInternalInstruction::CollisionEnd(_)
|
|PhysicsInternalInstruction::CollisionEnd(_)
|
||||||
@@ -1393,25 +1326,10 @@ fn atomic_internal_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:Tim
|
|||||||
if let Some(mode)=data.modes.get_mode(state.mode_state.get_mode_id()){
|
if let Some(mode)=data.modes.get_mode(state.mode_state.get_mode_id()){
|
||||||
run_teleport_behaviour(&general.wormhole,&data.models,mode,&state.style,&data.hitbox_mesh,&mut state.mode_state,&mut state.touching,&mut state.body,convex_mesh_id);
|
run_teleport_behaviour(&general.wormhole,&data.models,mode,&state.style,&data.hitbox_mesh,&mut state.mode_state,&mut state.touching,&mut state.body,convex_mesh_id);
|
||||||
}
|
}
|
||||||
match &general.booster{
|
|
||||||
Some(booster)=>{
|
|
||||||
//DELETE THIS when boosters get converted to height machines
|
|
||||||
match booster{
|
|
||||||
//&gameplay_attributes::Booster::Affine(transform)=>v=transform.transform_point3(v),
|
|
||||||
&gameplay_attributes::Booster::Velocity(velocity)=>{
|
|
||||||
let boosted_velocity=state.body.velocity+velocity;
|
|
||||||
//fall through boosters
|
|
||||||
state.cull_velocity(data,boosted_velocity);
|
|
||||||
},
|
|
||||||
&gameplay_attributes::Booster::Energy{direction: _,energy: _}=>todo!(),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
None=>(),
|
|
||||||
}
|
|
||||||
if state.style.get_control(Controls::Jump,state.input_state.controls){
|
if state.style.get_control(Controls::Jump,state.input_state.controls){
|
||||||
if let (Some(jump_settings),Some(walk_state))=(&state.style.jump,state.move_state.get_walk_state()){
|
if let (Some(jump_settings),Some(walk_state))=(&state.style.jump,state.move_state.get_walk_state()){
|
||||||
let jump_dir=walk_state.jump_direction.direction(&data.models,&data.hitbox_mesh,&walk_state.contact);
|
let jump_dir=walk_state.jump_direction.direction(&data.models,&data.hitbox_mesh,&walk_state.contact);
|
||||||
let jumped_velocity=jump_settings.jumped_velocity(&state.style,jump_dir,state.body.velocity);
|
let jumped_velocity=jump_settings.jumped_velocity(&state.style,jump_dir,state.body.velocity,general.booster.as_ref());
|
||||||
state.cull_velocity(data,jumped_velocity);
|
state.cull_velocity(data,jumped_velocity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1437,6 +1355,10 @@ fn atomic_internal_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:Tim
|
|||||||
(PhysicsCollisionAttributes::Intersect{intersecting:_,general},Collision::Intersect(_intersect))=>{
|
(PhysicsCollisionAttributes::Intersect{intersecting:_,general},Collision::Intersect(_intersect))=>{
|
||||||
//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
|
||||||
state.touching.insert(collision);
|
state.touching.insert(collision);
|
||||||
|
//insta booster!
|
||||||
|
if let Some(booster)=&general.booster{
|
||||||
|
state.cull_velocity(data,booster.boost(state.body.velocity));
|
||||||
|
}
|
||||||
if let Some(mode)=data.modes.get_mode(state.mode_state.get_mode_id()){
|
if let Some(mode)=data.modes.get_mode(state.mode_state.get_mode_id()){
|
||||||
let zone=mode.get_zone(convex_mesh_id.model_id.into());
|
let zone=mode.get_zone(convex_mesh_id.model_id.into());
|
||||||
match zone{
|
match zone{
|
||||||
@@ -1538,10 +1460,12 @@ fn atomic_internal_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:Tim
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn atomic_input_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:TimedInstruction<PhysicsInputInstruction>){
|
fn atomic_input_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:TimedInstruction<PhysicsInputInstruction>){
|
||||||
|
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
|
||||||
//as far as these instruction are concerned (they don't care where it is)
|
//as far as these instruction are concerned (they don't care where it is)
|
||||||
PhysicsInputInstruction::SetSensitivity(..)
|
PhysicsInputInstruction::SetSensitivity(..)
|
||||||
|
|PhysicsInputInstruction::Reset
|
||||||
|PhysicsInputInstruction::Restart
|
|PhysicsInputInstruction::Restart
|
||||||
|PhysicsInputInstruction::Spawn(..)
|
|PhysicsInputInstruction::Spawn(..)
|
||||||
|PhysicsInputInstruction::SetZoom(..)
|
|PhysicsInputInstruction::SetZoom(..)
|
||||||
@@ -1593,7 +1517,11 @@ fn atomic_input_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:TimedI
|
|||||||
if let Some(walk_state)=state.move_state.get_walk_state(){
|
if let Some(walk_state)=state.move_state.get_walk_state(){
|
||||||
if let Some(jump_settings)=&state.style.jump{
|
if let Some(jump_settings)=&state.style.jump{
|
||||||
let jump_dir=walk_state.jump_direction.direction(&data.models,&data.hitbox_mesh,&walk_state.contact);
|
let jump_dir=walk_state.jump_direction.direction(&data.models,&data.hitbox_mesh,&walk_state.contact);
|
||||||
let jumped_velocity=jump_settings.jumped_velocity(&state.style,jump_dir,state.body.velocity);
|
let booster_option=match data.models.attr(walk_state.contact.convex_mesh_id.model_id){
|
||||||
|
PhysicsCollisionAttributes::Contact{contacting:_,general}=>general.booster.as_ref(),
|
||||||
|
PhysicsCollisionAttributes::Intersect{..}=>None,
|
||||||
|
};
|
||||||
|
let jumped_velocity=jump_settings.jumped_velocity(&state.style,jump_dir,state.body.velocity,booster_option);
|
||||||
state.cull_velocity(&data,jumped_velocity);
|
state.cull_velocity(&data,jumped_velocity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1603,10 +1531,13 @@ fn atomic_input_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:TimedI
|
|||||||
state.input_state.set_control(Controls::Zoom,s);
|
state.input_state.set_control(Controls::Zoom,s);
|
||||||
b_refresh_walk_target=false;
|
b_refresh_walk_target=false;
|
||||||
},
|
},
|
||||||
PhysicsInputInstruction::Restart=>{
|
PhysicsInputInstruction::Reset=>{
|
||||||
//totally reset physics state
|
//totally reset physics state
|
||||||
state.reset_to_default();
|
state.reset_to_default();
|
||||||
//spawn at start zone
|
b_refresh_walk_target=false;
|
||||||
|
},
|
||||||
|
PhysicsInputInstruction::Restart=>{
|
||||||
|
//teleport to start zone
|
||||||
let spawn_point=data.modes.get_mode(state.mode_state.get_mode_id()).map(|mode|
|
let spawn_point=data.modes.get_mode(state.mode_state.get_mode_id()).map(|mode|
|
||||||
//TODO: spawn at the bottom of the start zone plus the hitbox size
|
//TODO: spawn at the bottom of the start zone plus the hitbox size
|
||||||
//TODO: set camera andles to face the same way as the start zone
|
//TODO: set camera andles to face the same way as the start zone
|
||||||
@@ -1655,8 +1586,12 @@ fn atomic_input_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:TimedI
|
|||||||
|PhysicsInstruction::Internal(PhysicsInternalInstruction::ReachWalkTargetVelocity)=>(),
|
|PhysicsInstruction::Internal(PhysicsInternalInstruction::ReachWalkTargetVelocity)=>(),
|
||||||
_=>println!("{}|{:?}",ins.time,ins.instruction),
|
_=>println!("{}|{:?}",ins.time,ins.instruction),
|
||||||
}
|
}
|
||||||
state.time=ins.time;
|
if ins.time<state.time{
|
||||||
|
println!("@@@@ Time travel warning! {:?}",ins);
|
||||||
|
}
|
||||||
|
//idle is special, it is specifically a no-op to get Internal events to catch up to real time
|
||||||
match ins.instruction{
|
match ins.instruction{
|
||||||
|
PhysicsInstruction::Input(PhysicsInputInstruction::Idle)=>(),
|
||||||
PhysicsInstruction::Internal(instruction)=>atomic_internal_instruction(state,data,TimedInstruction{time:ins.time,instruction}),
|
PhysicsInstruction::Internal(instruction)=>atomic_internal_instruction(state,data,TimedInstruction{time:ins.time,instruction}),
|
||||||
PhysicsInstruction::Input(instruction)=>atomic_input_instruction(state,data,TimedInstruction{time:ins.time,instruction}),
|
PhysicsInstruction::Input(instruction)=>atomic_input_instruction(state,data,TimedInstruction{time:ins.time,instruction}),
|
||||||
}
|
}
|
||||||
@@ -1876,4 +1811,46 @@ mod test{
|
|||||||
Time::ZERO
|
Time::ZERO
|
||||||
),None);
|
),None);
|
||||||
}
|
}
|
||||||
|
fn simulate(map:&str,bot:&str){
|
||||||
|
//create physics
|
||||||
|
let mut physics=PhysicsContext::default();
|
||||||
|
|
||||||
|
//load map
|
||||||
|
let map_file=std::fs::File::open(format!("/run/media/quat/Files/Documents/map-files/verify-scripts/maps/{map}.snfm")).unwrap();
|
||||||
|
let map=strafesnet_snf::read_map(map_file).unwrap().into_complete_map().unwrap();
|
||||||
|
physics.generate_models(&map);
|
||||||
|
|
||||||
|
//load bot
|
||||||
|
let bot_file=std::fs::File::open(format!("/run/media/quat/Files/Documents/Strafe Client/debug_bots_v1/{bot}")).unwrap();
|
||||||
|
let instructions=strafesnet_snf::bot::read_bot_debug(bot_file).unwrap();
|
||||||
|
|
||||||
|
//run bot on physics
|
||||||
|
for ins in instructions{
|
||||||
|
physics.run_input_instruction(ins);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
|
fn simulate_bot_1(){
|
||||||
|
//arcane
|
||||||
|
simulate("bhop_snfm/5692113331","ff4940efb50f724e48eb54ce3593d88f")
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
|
fn simulate_bot_2(){
|
||||||
|
simulate("bhop_snfm/5692113331","17cf70412eba16d172a67385cab5727e")
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
|
fn simulate_bot_4(){
|
||||||
|
//brick
|
||||||
|
simulate("bhop_snfm/5692176057","c0631c6f524eebddbf75237cac48e78e")
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
|
fn simulate_bot_5(){
|
||||||
|
//toc
|
||||||
|
simulate("bhop_snfm/5692152916","1722976199076914659")
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
|
fn simulate_bot_6(){
|
||||||
|
//utopia
|
||||||
|
simulate("surf_snfm/5692145408","1722980796007573431")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
use crate::physics::{MouseState,PhysicsInputInstruction};
|
use strafesnet_common::mouse::MouseState;
|
||||||
|
use strafesnet_common::physics::Instruction as PhysicsInputInstruction;
|
||||||
use strafesnet_common::integer::Time;
|
use strafesnet_common::integer::Time;
|
||||||
use strafesnet_common::instruction::{TimedInstruction,InstructionConsumer};
|
use strafesnet_common::instruction::TimedInstruction;
|
||||||
|
use strafesnet_common::timer::{Scaled,Timer,TimerState};
|
||||||
|
use mouse_interpolator::MouseInterpolator;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum InputInstruction{
|
pub enum InputInstruction{
|
||||||
MoveMouse(glam::IVec2),
|
MoveMouse(glam::IVec2),
|
||||||
@@ -12,30 +16,54 @@ pub enum InputInstruction{
|
|||||||
MoveForward(bool),
|
MoveForward(bool),
|
||||||
Jump(bool),
|
Jump(bool),
|
||||||
Zoom(bool),
|
Zoom(bool),
|
||||||
Restart,
|
ResetAndRestart,
|
||||||
Spawn(strafesnet_common::gameplay_modes::ModeId,strafesnet_common::gameplay_modes::StageId),
|
ResetAndSpawn(strafesnet_common::gameplay_modes::ModeId,strafesnet_common::gameplay_modes::StageId),
|
||||||
PracticeFly,
|
PracticeFly,
|
||||||
}
|
}
|
||||||
pub enum Instruction{
|
pub enum Instruction{
|
||||||
Input(InputInstruction),
|
Input(InputInstruction),
|
||||||
Render,
|
Render,
|
||||||
Resize(winit::dpi::PhysicalSize<u32>,crate::settings::UserSettings),
|
Resize(winit::dpi::PhysicalSize<u32>),
|
||||||
GenerateModels(strafesnet_common::map::CompleteMap),
|
ChangeMap(strafesnet_common::map::CompleteMap),
|
||||||
ClearModels,
|
//SetPaused is not an InputInstruction: the physics doesn't know that it's paused.
|
||||||
|
SetPaused(bool),
|
||||||
//Graphics(crate::graphics_worker::Instruction),
|
//Graphics(crate::graphics_worker::Instruction),
|
||||||
}
|
}
|
||||||
|
mod mouse_interpolator{
|
||||||
|
use super::*;
|
||||||
|
//TODO: move this or tab
|
||||||
pub struct MouseInterpolator{
|
pub struct MouseInterpolator{
|
||||||
|
//"PlayerController"
|
||||||
|
user_settings:crate::settings::UserSettings,
|
||||||
|
//"MouseInterpolator"
|
||||||
timeline:std::collections::VecDeque<TimedInstruction<PhysicsInputInstruction>>,
|
timeline:std::collections::VecDeque<TimedInstruction<PhysicsInputInstruction>>,
|
||||||
last_mouse_time:Time,
|
last_mouse_time:Time,//this value is pre-transformed to simulation time
|
||||||
mouse_blocking:bool,
|
mouse_blocking:bool,
|
||||||
|
//"Simulation"
|
||||||
|
timer:Timer<Scaled>,
|
||||||
|
physics:crate::physics::PhysicsContext,
|
||||||
|
|
||||||
}
|
}
|
||||||
impl MouseInterpolator{
|
impl MouseInterpolator{
|
||||||
fn push_mouse_instruction(&mut self,physics:&crate::physics::PhysicsContext,ins:&TimedInstruction<Instruction>,m:glam::IVec2){
|
pub fn new(
|
||||||
|
physics:crate::physics::PhysicsContext,
|
||||||
|
user_settings:crate::settings::UserSettings,
|
||||||
|
)->MouseInterpolator{
|
||||||
|
MouseInterpolator{
|
||||||
|
mouse_blocking:true,
|
||||||
|
last_mouse_time:physics.get_next_mouse().time,
|
||||||
|
timeline:std::collections::VecDeque::new(),
|
||||||
|
timer:Timer::from_state(Scaled::identity(),false),
|
||||||
|
physics,
|
||||||
|
user_settings,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn push_mouse_instruction(&mut self,ins:&TimedInstruction<Instruction>,m:glam::IVec2){
|
||||||
if self.mouse_blocking{
|
if self.mouse_blocking{
|
||||||
//tell the game state which is living in the past about its future
|
//tell the game state which is living in the past about its future
|
||||||
self.timeline.push_front(TimedInstruction{
|
self.timeline.push_front(TimedInstruction{
|
||||||
time:self.last_mouse_time,
|
time:self.last_mouse_time,
|
||||||
instruction:PhysicsInputInstruction::SetNextMouse(MouseState{time:ins.time,pos:m}),
|
instruction:PhysicsInputInstruction::SetNextMouse(MouseState{time:self.timer.time(ins.time),pos:m}),
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
//mouse has just started moving again after being still for longer than 10ms.
|
//mouse has just started moving again after being still for longer than 10ms.
|
||||||
@@ -43,57 +71,93 @@ impl MouseInterpolator{
|
|||||||
self.timeline.push_front(TimedInstruction{
|
self.timeline.push_front(TimedInstruction{
|
||||||
time:self.last_mouse_time,
|
time:self.last_mouse_time,
|
||||||
instruction:PhysicsInputInstruction::ReplaceMouse(
|
instruction:PhysicsInputInstruction::ReplaceMouse(
|
||||||
MouseState{time:self.last_mouse_time,pos:physics.get_next_mouse().pos},
|
MouseState{time:self.last_mouse_time,pos:self.physics.get_next_mouse().pos},
|
||||||
MouseState{time:ins.time,pos:m}
|
MouseState{time:self.timer.time(ins.time),pos:m}
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
//delay physics execution until we have an interpolation target
|
//delay physics execution until we have an interpolation target
|
||||||
self.mouse_blocking=true;
|
self.mouse_blocking=true;
|
||||||
}
|
}
|
||||||
self.last_mouse_time=ins.time;
|
self.last_mouse_time=self.timer.time(ins.time);
|
||||||
}
|
}
|
||||||
/// returns the mapped physics input instruction
|
fn push(&mut self,time:Time,phys_input:PhysicsInputInstruction){
|
||||||
|
//This is always a non-mouse event
|
||||||
|
self.timeline.push_back(TimedInstruction{
|
||||||
|
time:self.timer.time(time),
|
||||||
|
instruction:phys_input,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/// returns should_empty_queue
|
||||||
/// may or may not mutate internal state XD!
|
/// may or may not mutate internal state XD!
|
||||||
fn map_instruction(&mut self,physics:&crate::physics::PhysicsContext,ins:&TimedInstruction<Instruction>)->Option<PhysicsInputInstruction>{
|
fn map_instruction(&mut self,ins:&TimedInstruction<Instruction>)->bool{
|
||||||
|
let mut update_mouse_blocking=true;
|
||||||
match &ins.instruction{
|
match &ins.instruction{
|
||||||
Instruction::Input(input_instruction)=>match input_instruction{
|
Instruction::Input(input_instruction)=>match input_instruction{
|
||||||
&InputInstruction::MoveMouse(m)=>{
|
&InputInstruction::MoveMouse(m)=>{
|
||||||
self.push_mouse_instruction(physics,ins,m);
|
if !self.timer.is_paused(){
|
||||||
None
|
self.push_mouse_instruction(ins,m);
|
||||||
|
}
|
||||||
|
update_mouse_blocking=false;
|
||||||
},
|
},
|
||||||
&InputInstruction::MoveForward(s)=>Some(PhysicsInputInstruction::SetMoveForward(s)),
|
&InputInstruction::MoveForward(s)=>self.push(ins.time,PhysicsInputInstruction::SetMoveForward(s)),
|
||||||
&InputInstruction::MoveLeft(s)=>Some(PhysicsInputInstruction::SetMoveLeft(s)),
|
&InputInstruction::MoveLeft(s)=>self.push(ins.time,PhysicsInputInstruction::SetMoveLeft(s)),
|
||||||
&InputInstruction::MoveBack(s)=>Some(PhysicsInputInstruction::SetMoveBack(s)),
|
&InputInstruction::MoveBack(s)=>self.push(ins.time,PhysicsInputInstruction::SetMoveBack(s)),
|
||||||
&InputInstruction::MoveRight(s)=>Some(PhysicsInputInstruction::SetMoveRight(s)),
|
&InputInstruction::MoveRight(s)=>self.push(ins.time,PhysicsInputInstruction::SetMoveRight(s)),
|
||||||
&InputInstruction::MoveUp(s)=>Some(PhysicsInputInstruction::SetMoveUp(s)),
|
&InputInstruction::MoveUp(s)=>self.push(ins.time,PhysicsInputInstruction::SetMoveUp(s)),
|
||||||
&InputInstruction::MoveDown(s)=>Some(PhysicsInputInstruction::SetMoveDown(s)),
|
&InputInstruction::MoveDown(s)=>self.push(ins.time,PhysicsInputInstruction::SetMoveDown(s)),
|
||||||
&InputInstruction::Jump(s)=>Some(PhysicsInputInstruction::SetJump(s)),
|
&InputInstruction::Jump(s)=>self.push(ins.time,PhysicsInputInstruction::SetJump(s)),
|
||||||
&InputInstruction::Zoom(s)=>Some(PhysicsInputInstruction::SetZoom(s)),
|
&InputInstruction::Zoom(s)=>self.push(ins.time,PhysicsInputInstruction::SetZoom(s)),
|
||||||
&InputInstruction::Spawn(mode_id,stage_id)=>Some(PhysicsInputInstruction::Spawn(mode_id,stage_id)),
|
&InputInstruction::ResetAndSpawn(mode_id,stage_id)=>{
|
||||||
InputInstruction::Restart=>Some(PhysicsInputInstruction::Restart),
|
self.push(ins.time,PhysicsInputInstruction::Reset);
|
||||||
InputInstruction::PracticeFly=>Some(PhysicsInputInstruction::PracticeFly),
|
self.push(ins.time,PhysicsInputInstruction::SetSensitivity(self.user_settings.calculate_sensitivity()));
|
||||||
|
self.push(ins.time,PhysicsInputInstruction::Spawn(mode_id,stage_id));
|
||||||
|
},
|
||||||
|
InputInstruction::ResetAndRestart=>{
|
||||||
|
self.push(ins.time,PhysicsInputInstruction::Reset);
|
||||||
|
self.push(ins.time,PhysicsInputInstruction::SetSensitivity(self.user_settings.calculate_sensitivity()));
|
||||||
|
self.push(ins.time,PhysicsInputInstruction::Restart);
|
||||||
|
},
|
||||||
|
InputInstruction::PracticeFly=>self.push(ins.time,PhysicsInputInstruction::PracticeFly),
|
||||||
},
|
},
|
||||||
Instruction::GenerateModels(_)=>Some(PhysicsInputInstruction::Idle),
|
//do these really need to idle the physics?
|
||||||
Instruction::ClearModels=>Some(PhysicsInputInstruction::Idle),
|
//sending None dumps the instruction queue
|
||||||
Instruction::Resize(_,_)=>Some(PhysicsInputInstruction::Idle),
|
Instruction::ChangeMap(_)=>self.push(ins.time,PhysicsInputInstruction::Idle),
|
||||||
Instruction::Render=>Some(PhysicsInputInstruction::Idle),
|
Instruction::Resize(_)=>self.push(ins.time,PhysicsInputInstruction::Idle),
|
||||||
|
Instruction::Render=>self.push(ins.time,PhysicsInputInstruction::Idle),
|
||||||
|
&Instruction::SetPaused(paused)=>{
|
||||||
|
if let Err(e)=self.timer.set_paused(ins.time,paused){
|
||||||
|
println!("Cannot pause: {e}");
|
||||||
|
}
|
||||||
|
self.push(ins.time,PhysicsInputInstruction::Idle);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
if update_mouse_blocking{
|
||||||
|
//this returns the bool for us
|
||||||
|
self.update_mouse_blocking(ins.time)
|
||||||
|
}else{
|
||||||
|
//do flush that queue
|
||||||
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn update_mouse_blocking(&mut self,physics:&crate::physics::PhysicsContext,ins:&TimedInstruction<Instruction>)->bool{
|
/// must check if self.mouse_blocking==true before calling!
|
||||||
|
fn unblock_mouse(&mut self,time:Time){
|
||||||
|
//push an event to extrapolate no movement from
|
||||||
|
self.timeline.push_front(TimedInstruction{
|
||||||
|
time:self.last_mouse_time,
|
||||||
|
instruction:PhysicsInputInstruction::SetNextMouse(MouseState{time:self.timer.time(time),pos:self.physics.get_next_mouse().pos}),
|
||||||
|
});
|
||||||
|
self.last_mouse_time=self.timer.time(time);
|
||||||
|
//stop blocking. the mouse is not moving so the physics does not need to live in the past and wait for interpolation targets.
|
||||||
|
self.mouse_blocking=false;
|
||||||
|
}
|
||||||
|
fn update_mouse_blocking(&mut self,time:Time)->bool{
|
||||||
if self.mouse_blocking{
|
if self.mouse_blocking{
|
||||||
//assume the mouse has stopped moving after 10ms.
|
//assume the mouse has stopped moving after 10ms.
|
||||||
//shitty mice are 125Hz which is 8ms so this should cover that.
|
//shitty mice are 125Hz which is 8ms so this should cover that.
|
||||||
//setting this to 100us still doesn't print even though it's 10x lower than the polling rate,
|
//setting this to 100us still doesn't print even though it's 10x lower than the polling rate,
|
||||||
//so mouse events are probably not handled separately from drawing and fire right before it :(
|
//so mouse events are probably not handled separately from drawing and fire right before it :(
|
||||||
if Time::from_millis(10)<ins.time-physics.get_next_mouse().time{
|
if Time::from_millis(10)<self.timer.time(time)-self.physics.get_next_mouse().time{
|
||||||
//push an event to extrapolate no movement from
|
self.unblock_mouse(time);
|
||||||
self.timeline.push_front(TimedInstruction{
|
|
||||||
time:self.last_mouse_time,
|
|
||||||
instruction:PhysicsInputInstruction::SetNextMouse(MouseState{time:ins.time,pos:physics.get_next_mouse().pos}),
|
|
||||||
});
|
|
||||||
self.last_mouse_time=ins.time;
|
|
||||||
//stop blocking. the mouse is not moving so the physics does not need to live in the past and wait for interpolation targets.
|
|
||||||
self.mouse_blocking=false;
|
|
||||||
true
|
true
|
||||||
}else{
|
}else{
|
||||||
false
|
false
|
||||||
@@ -101,71 +165,74 @@ impl MouseInterpolator{
|
|||||||
}else{
|
}else{
|
||||||
//keep this up to date so that it can be used as a known-timestamp
|
//keep this up to date so that it can be used as a known-timestamp
|
||||||
//that the mouse was not moving when the mouse starts moving again
|
//that the mouse was not moving when the mouse starts moving again
|
||||||
self.last_mouse_time=ins.time;
|
self.last_mouse_time=self.timer.time(time);
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// returns whether or not to empty the instruction queue
|
fn empty_queue(&mut self){
|
||||||
fn handle_physics_input(&mut self,physics:&crate::physics::PhysicsContext,ins:&TimedInstruction<Instruction>,phys_input_option:Option<PhysicsInputInstruction>)->bool{
|
|
||||||
if let Some(phys_input)=phys_input_option{
|
|
||||||
//non-mouse event
|
|
||||||
self.timeline.push_back(TimedInstruction{
|
|
||||||
time:ins.time,
|
|
||||||
instruction:phys_input,
|
|
||||||
});
|
|
||||||
|
|
||||||
//this returns the bool for us
|
|
||||||
self.update_mouse_blocking(physics,ins)
|
|
||||||
}else{
|
|
||||||
//mouse event
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn empty_queue(&mut self,physics:&mut crate::physics::PhysicsContext){
|
|
||||||
while let Some(instruction)=self.timeline.pop_front(){
|
while let Some(instruction)=self.timeline.pop_front(){
|
||||||
physics.run_input_instruction(instruction);
|
self.physics.run_input_instruction(instruction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn handle_instruction(&mut self,physics:&mut crate::physics::PhysicsContext,ins:&TimedInstruction<Instruction>){
|
pub fn handle_instruction(&mut self,ins:&TimedInstruction<Instruction>){
|
||||||
let physics_input_option=self.map_instruction(physics,ins);
|
let should_empty_queue=self.map_instruction(ins);
|
||||||
let should_empty_queue=self.handle_physics_input(physics,ins,physics_input_option);
|
|
||||||
if should_empty_queue{
|
if should_empty_queue{
|
||||||
self.empty_queue(physics);
|
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 change_map(&mut self,time:Time,map:&strafesnet_common::map::CompleteMap){
|
||||||
|
//dump any pending interpolation state
|
||||||
|
if self.mouse_blocking{
|
||||||
|
self.unblock_mouse(time);
|
||||||
|
}
|
||||||
|
self.empty_queue();
|
||||||
|
|
||||||
|
//doing it like this to avoid doing PhysicsInstruction::ChangeMap(Rc<CompleteMap>)
|
||||||
|
self.physics.generate_models(&map);
|
||||||
|
|
||||||
|
//use the standard input interface so the instructions are written out to bots
|
||||||
|
self.handle_instruction(&TimedInstruction{
|
||||||
|
time:self.timer.time(time),
|
||||||
|
instruction:Instruction::Input(InputInstruction::ResetAndSpawn(
|
||||||
|
strafesnet_common::gameplay_modes::ModeId::MAIN,
|
||||||
|
strafesnet_common::gameplay_modes::StageId::FIRST,
|
||||||
|
)),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
pub const fn user_settings(&self)->&crate::settings::UserSettings{
|
||||||
|
&self.user_settings
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(mut physics:crate::physics::PhysicsContext,mut graphics_worker:crate::compat_worker::INWorker<crate::graphics_worker::Instruction>)->crate::compat_worker::QNWorker<TimedInstruction<Instruction>>{
|
pub fn new<'a>(
|
||||||
let mut interpolator=MouseInterpolator{
|
mut graphics_worker:crate::compat_worker::INWorker<'a,crate::graphics_worker::Instruction>,
|
||||||
mouse_blocking:true,
|
user_settings:crate::settings::UserSettings,
|
||||||
last_mouse_time:physics.get_next_mouse().time,
|
)->crate::compat_worker::QNWorker<'a,TimedInstruction<Instruction>>{
|
||||||
timeline:std::collections::VecDeque::new(),
|
let physics=crate::physics::PhysicsContext::default();
|
||||||
};
|
let mut interpolator=MouseInterpolator::new(
|
||||||
|
physics,
|
||||||
|
user_settings
|
||||||
|
);
|
||||||
crate::compat_worker::QNWorker::new(move |ins:TimedInstruction<Instruction>|{
|
crate::compat_worker::QNWorker::new(move |ins:TimedInstruction<Instruction>|{
|
||||||
interpolator.handle_instruction(&mut physics,&ins);
|
interpolator.handle_instruction(&ins);
|
||||||
match ins.instruction{
|
match ins.instruction{
|
||||||
Instruction::Render=>{
|
Instruction::Render=>{
|
||||||
graphics_worker.send(crate::graphics_worker::Instruction::Render(physics.output(),ins.time,physics.get_next_mouse().pos)).unwrap();
|
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();
|
||||||
},
|
},
|
||||||
Instruction::Resize(size,user_settings)=>{
|
Instruction::Resize(size)=>{
|
||||||
graphics_worker.send(crate::graphics_worker::Instruction::Resize(size,user_settings)).unwrap();
|
graphics_worker.send(crate::graphics_worker::Instruction::Resize(size,interpolator.user_settings().clone())).unwrap();
|
||||||
},
|
},
|
||||||
Instruction::GenerateModels(map)=>{
|
Instruction::ChangeMap(map)=>{
|
||||||
physics.generate_models(&map);
|
interpolator.change_map(ins.time,&map);
|
||||||
//important!
|
graphics_worker.send(crate::graphics_worker::Instruction::ChangeMap(map)).unwrap();
|
||||||
//bots will not work properly without this exact restart + spawn setup
|
|
||||||
//reset the physics state to start a new run on the new map
|
|
||||||
physics.restart();
|
|
||||||
//generate a spawn event so bots work properly on the first run
|
|
||||||
//no run started so does not invalidate the run
|
|
||||||
physics.spawn();
|
|
||||||
graphics_worker.send(crate::graphics_worker::Instruction::GenerateModels(map)).unwrap();
|
|
||||||
},
|
},
|
||||||
Instruction::ClearModels=>{
|
Instruction::Input(_)=>(),
|
||||||
physics.clear();
|
Instruction::SetPaused(_)=>(),
|
||||||
graphics_worker.send(crate::graphics_worker::Instruction::ClearModels).unwrap();
|
|
||||||
},
|
|
||||||
_=>(),
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -213,9 +213,11 @@ pub fn setup_and_start(title:String){
|
|||||||
|
|
||||||
//dedicated thread to ping request redraw back and resize the window doesn't seem logical
|
//dedicated thread to ping request redraw back and resize the window doesn't seem logical
|
||||||
|
|
||||||
let window=crate::window::WindowContextSetup::new(&setup_context,&window);
|
|
||||||
//the thread that spawns the physics thread
|
//the thread that spawns the physics thread
|
||||||
let mut window_thread=window.into_worker(setup_context);
|
let mut window_thread=crate::window::worker(
|
||||||
|
&window,
|
||||||
|
setup_context,
|
||||||
|
);
|
||||||
|
|
||||||
if let Some(arg)=std::env::args().nth(1){
|
if let Some(arg)=std::env::args().nth(1){
|
||||||
let path=std::path::PathBuf::from(arg);
|
let path=std::path::PathBuf::from(arg);
|
||||||
|
|||||||
@@ -13,9 +13,8 @@ pub enum WindowInstruction{
|
|||||||
//holds thread handles to dispatch to
|
//holds thread handles to dispatch to
|
||||||
struct WindowContext<'a>{
|
struct WindowContext<'a>{
|
||||||
manual_mouse_lock:bool,
|
manual_mouse_lock:bool,
|
||||||
mouse:crate::physics::MouseState,//std::sync::Arc<std::sync::Mutex<>>
|
mouse:strafesnet_common::mouse::MouseState,//std::sync::Arc<std::sync::Mutex<>>
|
||||||
screen_size:glam::UVec2,
|
screen_size:glam::UVec2,
|
||||||
user_settings:crate::settings::UserSettings,
|
|
||||||
window:&'a winit::window::Window,
|
window:&'a winit::window::Window,
|
||||||
physics_thread:crate::compat_worker::QNWorker<'a, TimedInstruction<crate::physics_worker::Instruction>>,
|
physics_thread:crate::compat_worker::QNWorker<'a, TimedInstruction<crate::physics_worker::Instruction>>,
|
||||||
}
|
}
|
||||||
@@ -28,15 +27,16 @@ impl WindowContext<'_>{
|
|||||||
match event {
|
match event {
|
||||||
winit::event::WindowEvent::DroppedFile(path)=>{
|
winit::event::WindowEvent::DroppedFile(path)=>{
|
||||||
match crate::file::load(path.as_path()){
|
match crate::file::load(path.as_path()){
|
||||||
Ok(map)=>{
|
Ok(map)=>self.physics_thread.send(TimedInstruction{time,instruction:crate::physics_worker::Instruction::ChangeMap(map)}).unwrap(),
|
||||||
self.physics_thread.send(TimedInstruction{time,instruction:crate::physics_worker::Instruction::ClearModels}).unwrap();
|
|
||||||
self.physics_thread.send(TimedInstruction{time,instruction:crate::physics_worker::Instruction::GenerateModels(map)}).unwrap();
|
|
||||||
},
|
|
||||||
Err(e)=>println!("Failed to load map: {e}"),
|
Err(e)=>println!("Failed to load map: {e}"),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
winit::event::WindowEvent::Focused(_state)=>{
|
winit::event::WindowEvent::Focused(state)=>{
|
||||||
//pause unpause
|
//pause unpause
|
||||||
|
self.physics_thread.send(TimedInstruction{
|
||||||
|
time,
|
||||||
|
instruction:crate::physics_worker::Instruction::SetPaused(!state),
|
||||||
|
}).unwrap();
|
||||||
//recalculate pressed keys on focus
|
//recalculate pressed keys on focus
|
||||||
},
|
},
|
||||||
winit::event::WindowEvent::KeyboardInput{
|
winit::event::WindowEvent::KeyboardInput{
|
||||||
@@ -109,8 +109,8 @@ impl WindowContext<'_>{
|
|||||||
"z"=>Some(InputInstruction::Zoom(s)),
|
"z"=>Some(InputInstruction::Zoom(s)),
|
||||||
"r"=>if s{
|
"r"=>if s{
|
||||||
//mouse needs to be reset since the position is absolute
|
//mouse needs to be reset since the position is absolute
|
||||||
self.mouse=crate::physics::MouseState::default();
|
self.mouse=strafesnet_common::mouse::MouseState::default();
|
||||||
Some(InputInstruction::Restart)
|
Some(InputInstruction::ResetAndRestart)
|
||||||
}else{None},
|
}else{None},
|
||||||
"f"=>if s{Some(InputInstruction::PracticeFly)}else{None},
|
"f"=>if s{Some(InputInstruction::PracticeFly)}else{None},
|
||||||
_=>None,
|
_=>None,
|
||||||
@@ -165,48 +165,32 @@ impl WindowContext<'_>{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pub fn worker<'a>(
|
||||||
pub struct WindowContextSetup<'a>{
|
|
||||||
user_settings:crate::settings::UserSettings,
|
|
||||||
window:&'a winit::window::Window,
|
window:&'a winit::window::Window,
|
||||||
physics:crate::physics::PhysicsContext,
|
setup_context:crate::setup::SetupContext<'a>,
|
||||||
graphics:crate::graphics::GraphicsState,
|
)->crate::compat_worker::QNWorker<'a,TimedInstruction<WindowInstruction>>{
|
||||||
}
|
// WindowContextSetup::new
|
||||||
|
|
||||||
impl<'a> WindowContextSetup<'a>{
|
|
||||||
pub fn new(context:&crate::setup::SetupContext,window:&'a winit::window::Window)->Self{
|
|
||||||
let user_settings=crate::settings::read_user_settings();
|
let user_settings=crate::settings::read_user_settings();
|
||||||
|
|
||||||
let mut physics=crate::physics::PhysicsContext::default();
|
let mut graphics=crate::graphics::GraphicsState::new(&setup_context.device,&setup_context.queue,&setup_context.config);
|
||||||
physics.load_user_settings(&user_settings);
|
|
||||||
|
|
||||||
let mut graphics=crate::graphics::GraphicsState::new(&context.device,&context.queue,&context.config);
|
|
||||||
graphics.load_user_settings(&user_settings);
|
graphics.load_user_settings(&user_settings);
|
||||||
|
|
||||||
Self{
|
//WindowContextSetup::into_context
|
||||||
user_settings,
|
|
||||||
window,
|
|
||||||
graphics,
|
|
||||||
physics,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn into_context(self,setup_context:crate::setup::SetupContext<'a>)->WindowContext<'a>{
|
|
||||||
let screen_size=glam::uvec2(setup_context.config.width,setup_context.config.height);
|
let screen_size=glam::uvec2(setup_context.config.width,setup_context.config.height);
|
||||||
let graphics_thread=crate::graphics_worker::new(self.graphics,setup_context.config,setup_context.surface,setup_context.device,setup_context.queue);
|
let graphics_thread=crate::graphics_worker::new(graphics,setup_context.config,setup_context.surface,setup_context.device,setup_context.queue);
|
||||||
WindowContext{
|
let mut window_context=WindowContext{
|
||||||
manual_mouse_lock:false,
|
manual_mouse_lock:false,
|
||||||
mouse:crate::physics::MouseState::default(),
|
mouse:strafesnet_common::mouse::MouseState::default(),
|
||||||
//make sure to update this!!!!!
|
//make sure to update this!!!!!
|
||||||
screen_size,
|
screen_size,
|
||||||
user_settings:self.user_settings,
|
window,
|
||||||
window:self.window,
|
physics_thread:crate::physics_worker::new(
|
||||||
physics_thread:crate::physics_worker::new(self.physics,graphics_thread),
|
graphics_thread,
|
||||||
}
|
user_settings,
|
||||||
}
|
),
|
||||||
|
};
|
||||||
|
|
||||||
pub fn into_worker(self,setup_context:crate::setup::SetupContext<'a>)->crate::compat_worker::QNWorker<'a,TimedInstruction<WindowInstruction>>{
|
//WindowContextSetup::into_worker
|
||||||
let mut window_context=self.into_context(setup_context);
|
|
||||||
crate::compat_worker::QNWorker::new(move |ins:TimedInstruction<WindowInstruction>|{
|
crate::compat_worker::QNWorker::new(move |ins:TimedInstruction<WindowInstruction>|{
|
||||||
match ins.instruction{
|
match ins.instruction{
|
||||||
WindowInstruction::RequestRedraw=>{
|
WindowInstruction::RequestRedraw=>{
|
||||||
@@ -222,7 +206,7 @@ impl<'a> WindowContextSetup<'a>{
|
|||||||
window_context.physics_thread.send(
|
window_context.physics_thread.send(
|
||||||
TimedInstruction{
|
TimedInstruction{
|
||||||
time:ins.time,
|
time:ins.time,
|
||||||
instruction:crate::physics_worker::Instruction::Resize(size,window_context.user_settings.clone())
|
instruction:crate::physics_worker::Instruction::Resize(size)
|
||||||
}
|
}
|
||||||
).unwrap();
|
).unwrap();
|
||||||
}
|
}
|
||||||
@@ -236,5 +220,4 @@ impl<'a> WindowContextSetup<'a>{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ mod test{
|
|||||||
for _ in 0..5 {
|
for _ in 0..5 {
|
||||||
let task = instruction::TimedInstruction{
|
let task = instruction::TimedInstruction{
|
||||||
time:integer::Time::ZERO,
|
time:integer::Time::ZERO,
|
||||||
instruction:physics::PhysicsInputInstruction::Idle,
|
instruction:strafesnet_common::physics::Instruction::Idle,
|
||||||
};
|
};
|
||||||
worker.send(task).unwrap();
|
worker.send(task).unwrap();
|
||||||
}
|
}
|
||||||
@@ -204,7 +204,7 @@ mod test{
|
|||||||
// Send a new task
|
// Send a new task
|
||||||
let task = instruction::TimedInstruction{
|
let task = instruction::TimedInstruction{
|
||||||
time:integer::Time::ZERO,
|
time:integer::Time::ZERO,
|
||||||
instruction:physics::PhysicsInputInstruction::Idle,
|
instruction:strafesnet_common::physics::Instruction::Idle,
|
||||||
};
|
};
|
||||||
worker.send(task).unwrap();
|
worker.send(task).unwrap();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user