Compare commits

..

63 Commits

Author SHA1 Message Date
14f3b4fb0d runtime map loading! 2023-10-25 15:29:18 -07:00
6377885d6d rename run to window 2023-10-25 14:07:52 -07:00
f81a1c82bf run_event_loop function 2023-10-24 23:27:35 -07:00
2ee70138d1 true gamer 2023-10-24 23:21:32 -07:00
f14b30138b fix spawn 2023-10-24 21:05:07 -07:00
2116621672 no print in event loop!!!!!! 2023-10-24 21:05:02 -07:00
e2fdf9442c fix requested gpu features 2023-10-24 20:50:48 -07:00
75f958348c LIFETIMES 2023-10-24 20:46:07 -07:00
b5a0cf7045 work 2023-10-24 20:22:30 -07:00
657e5dff7f fix compat worker 2023-10-24 20:20:13 -07:00
5d9308eccc fix physics worker output 2023-10-24 19:09:55 -07:00
b7844bb308 use compat_worker 2023-10-24 19:09:47 -07:00
8113ede3e0 beautiful compat worker implementation 2023-10-24 19:09:39 -07:00
4cf10dad78 what I got done before giving up on thread chaining 2023-10-24 18:51:01 -07:00
de063f4d74 work 2023-10-24 17:02:06 -07:00
83cdb0413c work 2023-10-24 16:53:40 -07:00
4655f43f5f work 2023-10-23 20:28:36 -07:00
9c9d8f8f8f rename setup_context to setup 2023-10-23 20:28:36 -07:00
cbc7b56f28 idea context is the thread setup and owns the state instance defined by other file 2023-10-23 20:28:36 -07:00
44831bd14b don't forget config is transient 2023-10-23 19:31:02 -07:00
099915c980 rename 2023-10-23 19:31:02 -07:00
62e8953ba9 rename graphics_context to setup_context 2023-10-23 18:47:30 -07:00
03a4a60db2 red underlines 2023-10-23 18:46:59 -07:00
c4ad4fbdf9 move run stuff into run module 2023-10-23 17:27:18 -07:00
b445277346 delete window.rs, create run.rs 2023-10-23 17:21:00 -07:00
f6f2995ae0 update code for winit 0.29.2 2023-10-23 16:49:05 -07:00
4cad20da09 wip: move stuff out of event_loop 2023-10-23 16:49:05 -07:00
7805c4db6d update winit dep to 0.29.2 2023-10-23 16:34:25 -07:00
3775fd0b14 rename 2023-10-23 14:15:27 -07:00
2356286dc2 move some stuff 2023-10-20 18:08:50 -07:00
8cc86d88fc note about adapter 2023-10-20 17:54:01 -07:00
c1bc67fd3a write some guesses 2023-10-20 17:51:52 -07:00
d2c896031c graphics resize 2023-10-20 17:51:52 -07:00
d27187aa53 fix many red underline 2023-10-20 17:51:52 -07:00
2e13d9b74e idk about this 2023-10-20 16:51:09 -07:00
431611b62a move window stuff to window 2023-10-20 16:01:17 -07:00
b55a35c488 pull apart framework completely 2023-10-20 16:01:17 -07:00
cb6102b9dc move out of main fixings 2023-10-20 15:56:03 -07:00
6eaec7d6a6 Input::Mailbox 2023-10-19 22:56:28 -07:00
407b322664 note about using functions for input and output 2023-10-19 22:56:28 -07:00
d4c4d9e7d6 Input::Query 2023-10-19 22:56:28 -07:00
ff8c61ee32 comment on issue 2023-10-19 22:56:20 -07:00
00eb1ce19c drop dead code 2023-10-19 22:56:20 -07:00
168091408e shrink pollster onto the only future in the code 2023-10-19 22:56:20 -07:00
ad0130db74 drop async_executor dep 2023-10-19 22:56:20 -07:00
ee8f9ba9e4 drop env_logger & log deps 2023-10-19 22:56:20 -07:00
1af8468e5b drop wasm32 code 2023-10-19 22:56:20 -07:00
f8320c9df5 why did they do it like that 2023-10-19 22:56:20 -07:00
eb376c1e68 put window stuff in here 2023-10-19 22:56:20 -07:00
0bf253aa11 remove graphics stuff from main 2023-10-19 22:32:01 -07:00
85b70331fd thread load file 2023-10-19 22:32:01 -07:00
7fd592329e split load file 2023-10-19 22:32:01 -07:00
5260c2b40d try unpub 2023-10-19 22:32:01 -07:00
b5febfad14 introduce render_thread to manage physics and graphics 2023-10-19 22:32:01 -07:00
d1b491b6e7 wip: implement INWorker 2023-10-19 22:32:01 -07:00
8043862c99 delete compat worker 2023-10-19 22:32:01 -07:00
b760a4bc65 idle does not advance body 2023-10-19 22:32:01 -07:00
124139274f real threads + GraphicsInstruction + thread accessible mouse 2023-10-19 22:32:01 -07:00
7130eafc06 implement QNWorker 2023-10-19 22:24:20 -07:00
ab276b517b rename workers 2023-10-19 22:24:20 -07:00
3721995791 WorkerDescription brainstorming (make invalid states unrepresentable) 2023-10-19 22:24:20 -07:00
72258d3549 self.graphics->self 2023-10-18 18:30:44 -07:00
02170bd91a move graphics code 2023-10-18 18:30:40 -07:00
8 changed files with 84 additions and 139 deletions

28
Cargo.lock generated
View File

@@ -245,9 +245,9 @@ checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1"
[[package]]
name = "bytemuck"
version = "1.14.0"
version = "1.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6"
checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea"
dependencies = [
"bytemuck_derive",
]
@@ -586,9 +586,9 @@ checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0"
[[package]]
name = "glam"
version = "0.24.2"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5418c17512bdf42730f9032c74e1ae39afc408745ebb2acf72fbc4691c17945"
checksum = "42218cb640844e3872cc3c153dc975229e080a6c4733b34709ef445610550226"
[[package]]
name = "glow"
@@ -1318,9 +1318,9 @@ dependencies = [
[[package]]
name = "rbx_dom_weak"
version = "2.6.0"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "843a2e0e1446623625943f7228d9d4b5cf3883017e3964733600682506864b34"
checksum = "161729449bbb0cfa657ce7bcca6a160d0af06d8b8d9efdc9abe14735dccacdb9"
dependencies = [
"rbx_types",
"serde",
@@ -1328,9 +1328,9 @@ dependencies = [
[[package]]
name = "rbx_reflection"
version = "4.4.0"
version = "4.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41e762dfca3217d2d37da631de2fa0d1616edaa61a0a2633263d5d3305baf8c3"
checksum = "08bd48487192046fec8f805f3fa29f3d7d5beb9890b0859b1a92bd8aff580343"
dependencies = [
"rbx_types",
"serde",
@@ -1339,9 +1339,9 @@ dependencies = [
[[package]]
name = "rbx_reflection_database"
version = "0.2.9+roblox-596"
version = "0.2.7+roblox-588"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b18f088a2b4aa66324ec97b5b6ffacb53188aef19f3497d95d6a1d1dbb28e66"
checksum = "1be6cf674182806f11ad4899dd1feafe977591f1ae035ae05a58d4b74e487276"
dependencies = [
"lazy_static",
"rbx_reflection",
@@ -1351,9 +1351,9 @@ dependencies = [
[[package]]
name = "rbx_types"
version = "1.7.0"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a991523e3ad5f43a4d121cb4a1e5bc23f7826bb4a1db5aa51e94f1073150ec"
checksum = "070106e926b8ae54c7bc443e5db4d868d7f0af51c1d7cfd7efe1364c1753d8a3"
dependencies = [
"base64",
"bitflags 1.3.2",
@@ -1366,9 +1366,9 @@ dependencies = [
[[package]]
name = "rbx_xml"
version = "0.13.2"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc87343301303ff0510903fb7eb3dbd1c75bdb6ab780fea6091bdc3f58b5829f"
checksum = "4bc65b70827519fdc4ab47416d1085b912f087fadab9ed415471b6daba635574"
dependencies = [
"base64",
"log",

View File

@@ -802,7 +802,6 @@ impl GraphicsState{
}),
primitive: wgpu::PrimitiveState {
front_face: wgpu::FrontFace::Cw,
cull_mode:Some(wgpu::Face::Front),
..Default::default()
},
depth_stencil: Some(wgpu::DepthStencilState {
@@ -876,8 +875,8 @@ impl GraphicsState{
config:&wgpu::SurfaceConfiguration,
user_settings:&crate::settings::UserSettings,
) {
self.depth_view=Self::create_depth_texture(config,device);
self.camera.screen_size=glam::uvec2(config.width,config.height);
self.depth_view = Self::create_depth_texture(config,device);
self.camera.screen_size=glam::uvec2(config.width, config.height);
self.load_user_settings(user_settings);
}
pub fn render(

View File

@@ -23,6 +23,14 @@ fn recursive_collect_superclass(objects: &mut std::vec::Vec<rbx_dom_weak::types:
}
}
}
fn get_texture_refs(dom:&rbx_dom_weak::WeakDom) -> Vec<rbx_dom_weak::types::Ref>{
let mut objects = std::vec::Vec::new();
recursive_collect_superclass(&mut objects, dom, dom.root(),"Decal");
//get ids
//clear vec
//next class
objects
}
fn planar64_affine3_from_roblox(cf:&rbx_dom_weak::types::CFrame,size:&rbx_dom_weak::types::Vector3)->Planar64Affine3{
Planar64Affine3::new(
Planar64Mat3::from_cols(

View File

@@ -291,7 +291,7 @@ enum JumpImpulse{
struct StyleModifiers{
controls_mask:u32,//controls which are unable to be activated
controls_held:u32,//controls which must be active to be able to strafe
strafe_tick_rate:Option<Ratio64>,
strafe_tick_rate:Ratio64,
jump_impulse:JumpImpulse,
jump_calculation:JumpCalculation,
static_friction:Planar64,
@@ -305,7 +305,6 @@ struct StyleModifiers{
mass:Planar64,
mv:Planar64,
air_accel_limit:Option<Planar64>,
rocket_force:Option<Planar64>,
gravity:Planar64Vec3,
hitbox_halfsize:Planar64Vec3,
}
@@ -332,7 +331,7 @@ impl StyleModifiers{
Self{
controls_mask:!0,//&!(Self::CONTROL_MOVEUP|Self::CONTROL_MOVEDOWN),
controls_held:0,
strafe_tick_rate:Some(Ratio64::new(128,Time::ONE_SECOND.nanos() as u64).unwrap()),
strafe_tick_rate:Ratio64::new(128,Time::ONE_SECOND.nanos() as u64).unwrap(),
jump_impulse:JumpImpulse::FromEnergy(Planar64::int(512)),
jump_calculation:JumpCalculation::Energy,
gravity:Planar64Vec3::int(0,-80,0),
@@ -341,7 +340,6 @@ impl StyleModifiers{
mass:Planar64::int(1),
mv:Planar64::int(2),
air_accel_limit:None,
rocket_force:None,
walk_speed:Planar64::int(16),
walk_accel:Planar64::int(80),
ladder_speed:Planar64::int(16),
@@ -356,7 +354,7 @@ impl StyleModifiers{
Self{
controls_mask:!0,//&!(Self::CONTROL_MOVEUP|Self::CONTROL_MOVEDOWN),
controls_held:0,
strafe_tick_rate:Some(Ratio64::new(100,Time::ONE_SECOND.nanos() as u64).unwrap()),
strafe_tick_rate:Ratio64::new(100,Time::ONE_SECOND.nanos() as u64).unwrap(),
jump_impulse:JumpImpulse::FromTime(Time::from_micros(715_588)),
jump_calculation:JumpCalculation::Capped,
gravity:Planar64Vec3::int(0,-100,0),
@@ -365,7 +363,6 @@ impl StyleModifiers{
mass:Planar64::int(1),
mv:Planar64::int(27)/10,
air_accel_limit:None,
rocket_force:None,
walk_speed:Planar64::int(18),
walk_accel:Planar64::int(90),
ladder_speed:Planar64::int(18),
@@ -379,7 +376,7 @@ impl StyleModifiers{
Self{
controls_mask:!0,//&!(Self::CONTROL_MOVEUP|Self::CONTROL_MOVEDOWN),
controls_held:0,
strafe_tick_rate:Some(Ratio64::new(100,Time::ONE_SECOND.nanos() as u64).unwrap()),
strafe_tick_rate:Ratio64::new(100,Time::ONE_SECOND.nanos() as u64).unwrap(),
jump_impulse:JumpImpulse::FromTime(Time::from_micros(715_588)),
jump_calculation:JumpCalculation::Capped,
gravity:Planar64Vec3::int(0,-50,0),
@@ -388,7 +385,6 @@ impl StyleModifiers{
mass:Planar64::int(1),
mv:Planar64::int(27)/10,
air_accel_limit:None,
rocket_force:None,
walk_speed:Planar64::int(18),
walk_accel:Planar64::int(90),
ladder_speed:Planar64::int(18),
@@ -404,7 +400,7 @@ impl StyleModifiers{
Self{
controls_mask:!0,//&!(Self::CONTROL_MOVEUP|Self::CONTROL_MOVEDOWN),
controls_held:0,
strafe_tick_rate:Some(Ratio64::new(100,Time::ONE_SECOND.nanos() as u64).unwrap()),
strafe_tick_rate:Ratio64::new(100,Time::ONE_SECOND.nanos() as u64).unwrap(),
jump_impulse:JumpImpulse::FromHeight(Planar64::raw(52<<28)),
jump_calculation:JumpCalculation::Linear,
gravity:Planar64Vec3::raw(0,-800<<28,0),
@@ -413,7 +409,6 @@ impl StyleModifiers{
mass:Planar64::int(1),
mv:Planar64::raw(30<<28),
air_accel_limit:Some(Planar64::raw(150<<28)*66),
rocket_force:None,
walk_speed:Planar64::int(18),//?
walk_accel:Planar64::int(90),//?
ladder_speed:Planar64::int(18),//?
@@ -428,7 +423,7 @@ impl StyleModifiers{
Self{
controls_mask:!0,//&!(Self::CONTROL_MOVEUP|Self::CONTROL_MOVEDOWN),
controls_held:0,
strafe_tick_rate:Some(Ratio64::new(66,Time::ONE_SECOND.nanos() as u64).unwrap()),
strafe_tick_rate:Ratio64::new(66,Time::ONE_SECOND.nanos() as u64).unwrap(),
jump_impulse:JumpImpulse::FromHeight(Planar64::raw(52<<28)),
jump_calculation:JumpCalculation::Linear,
gravity:Planar64Vec3::raw(0,-800<<28,0),
@@ -437,7 +432,6 @@ impl StyleModifiers{
mass:Planar64::int(1),
mv:Planar64::raw(30<<28),
air_accel_limit:Some(Planar64::raw(150<<28)*66),
rocket_force:None,
walk_speed:Planar64::int(18),//?
walk_accel:Planar64::int(90),//?
ladder_speed:Planar64::int(18),//?
@@ -447,29 +441,6 @@ impl StyleModifiers{
hitbox_halfsize:Planar64Vec3::raw(33<<28,73<<28,33<<28)/2,
}
}
fn roblox_rocket()->Self{
Self{
controls_mask:!0,//&!(Self::CONTROL_MOVEUP|Self::CONTROL_MOVEDOWN),
controls_held:0,
strafe_tick_rate:None,
jump_impulse:JumpImpulse::FromTime(Time::from_micros(715_588)),
jump_calculation:JumpCalculation::Capped,
gravity:Planar64Vec3::int(0,-100,0),
static_friction:Planar64::int(2),
kinetic_friction:Planar64::int(3),//unrealistic: kinetic friction is typically lower than static
mass:Planar64::int(1),
mv:Planar64::int(27)/10,
air_accel_limit:None,
rocket_force:Some(Planar64::int(200)),
walk_speed:Planar64::int(18),
walk_accel:Planar64::int(90),
ladder_speed:Planar64::int(18),
ladder_accel:Planar64::int(180),
ladder_dot:(Planar64::int(1)/2).sqrt(),
swim_speed:Planar64::int(12),
hitbox_halfsize:Planar64Vec3::int(2,5,2)/2,
}
}
fn get_control(&self,control:u32,controls:u32)->bool{
controls&self.controls_mask&control==control
@@ -537,9 +508,10 @@ impl StyleModifiers{
// return cross(cross(Normal,ControlDir),Normal)/sqrt(1-d*d)
control_dir*self.walk_speed
}
fn get_propulsion_control_dir(&self,camera:&PhysicsCamera,controls:u32,next_mouse:&MouseState,time:Time)->Planar64Vec3{
fn get_propulsion_target_velocity(&self,camera:&PhysicsCamera,controls:u32,next_mouse:&MouseState,time:Time)->Planar64Vec3{
let camera_mat=camera.simulate_move_rotation(camera.mouse.lerp(&next_mouse,time));
camera_mat*self.get_control_dir(controls)
let control_dir=camera_mat*self.get_control_dir(controls);
control_dir*self.walk_speed
}
}
@@ -884,13 +856,11 @@ impl PhysicsState {
}
fn next_strafe_instruction(&self) -> Option<TimedInstruction<PhysicsInstruction>> {
self.style.strafe_tick_rate.as_ref().map(|strafe_tick_rate|{
TimedInstruction{
time:Time::from_nanos(strafe_tick_rate.rhs_div_int(strafe_tick_rate.mul_int(self.time.nanos())+1)),
//only poll the physics if there is a before and after mouse event
instruction:PhysicsInstruction::StrafeTick
}
})
return Some(TimedInstruction{
time:Time::from_nanos(self.style.strafe_tick_rate.rhs_div_int(self.style.strafe_tick_rate.mul_int(self.time.nanos())+1)),
//only poll the physics if there is a before and after mouse event
instruction:PhysicsInstruction::StrafeTick
});
}
//state mutated on collision:
@@ -924,20 +894,16 @@ impl PhysicsState {
// });
// }
fn refresh_walk_target(&mut self)->Option<Planar64Vec3>{
fn refresh_walk_target(&mut self){
match &mut self.move_state{
MoveState::Air|MoveState::Water=>None,
MoveState::Air|MoveState::Water=>(),
MoveState::Walk(WalkState{normal,state})=>{
let n=normal;
let a;
(*state,a)=WalkEnum::with_target_velocity(&self.touching,&self.body,&self.style,&self.models,self.style.get_walk_target_velocity(&self.camera,self.controls,&self.next_mouse,self.time),&n);
Some(a)
(*state,self.body.acceleration)=WalkEnum::with_target_velocity(&self.touching,&self.body,&self.style,&self.models,self.style.get_walk_target_velocity(&self.camera,self.controls,&self.next_mouse,self.time),&n);
},
MoveState::Ladder(WalkState{normal,state})=>{
let n=normal;
let a;
(*state,a)=WalkEnum::with_target_velocity(&self.touching,&self.body,&self.style,&self.models,self.style.get_ladder_target_velocity(&self.camera,self.controls,&self.next_mouse,self.time),&n);
Some(a)
(*state,self.body.acceleration)=WalkEnum::with_target_velocity(&self.touching,&self.body,&self.style,&self.models,self.style.get_ladder_target_velocity(&self.camera,self.controls,&self.next_mouse,self.time),&n);
},
}
}
@@ -975,8 +941,7 @@ impl PhysicsState {
//collect x
match collision_data.face {
TreyMeshFace::Top|TreyMeshFace::Back|TreyMeshFace::Bottom|TreyMeshFace::Front=>{
let (roots,nroots)=zeroes2(mesh0.max.x()-mesh1.min.x(),v.x(),a.x()/2);
for &t in &roots[0..nroots]{
for t in zeroes2(mesh0.max.x()-mesh1.min.x(),v.x(),a.x()/2) {
//negative t = back in time
//must be moving towards surface to collide
//must beat the current soonest collision time
@@ -989,8 +954,7 @@ impl PhysicsState {
break;
}
}
let (roots,nroots)=zeroes2(mesh0.min.x()-mesh1.max.x(),v.x(),a.x()/2);
for &t in &roots[0..nroots]{
for t in zeroes2(mesh0.min.x()-mesh1.max.x(),v.x(),a.x()/2) {
//negative t = back in time
//must be moving towards surface to collide
//must beat the current soonest collision time
@@ -1022,8 +986,7 @@ impl PhysicsState {
//collect y
match collision_data.face {
TreyMeshFace::Left|TreyMeshFace::Back|TreyMeshFace::Right|TreyMeshFace::Front=>{
let (roots,nroots)=zeroes2(mesh0.max.y()-mesh1.min.y(),v.y(),a.y()/2);
for &t in &roots[0..nroots]{
for t in zeroes2(mesh0.max.y()-mesh1.min.y(),v.y(),a.y()/2) {
//negative t = back in time
//must be moving towards surface to collide
//must beat the current soonest collision time
@@ -1036,8 +999,7 @@ impl PhysicsState {
break;
}
}
let (roots,nroots)=zeroes2(mesh0.min.y()-mesh1.max.y(),v.y(),a.y()/2);
for &t in &roots[0..nroots]{
for t in zeroes2(mesh0.min.y()-mesh1.max.y(),v.y(),a.y()/2) {
//negative t = back in time
//must be moving towards surface to collide
//must beat the current soonest collision time
@@ -1069,8 +1031,7 @@ impl PhysicsState {
//collect z
match collision_data.face {
TreyMeshFace::Left|TreyMeshFace::Bottom|TreyMeshFace::Right|TreyMeshFace::Top=>{
let (roots,nroots)=zeroes2(mesh0.max.z()-mesh1.min.z(),v.z(),a.z()/2);
for &t in &roots[0..nroots]{
for t in zeroes2(mesh0.max.z()-mesh1.min.z(),v.z(),a.z()/2) {
//negative t = back in time
//must be moving towards surface to collide
//must beat the current soonest collision time
@@ -1083,8 +1044,7 @@ impl PhysicsState {
break;
}
}
let (roots,nroots)=zeroes2(mesh0.min.z()-mesh1.max.z(),v.z(),a.z()/2);
for &t in &roots[0..nroots]{
for t in zeroes2(mesh0.min.z()-mesh1.max.z(),v.z(),a.z()/2) {
//negative t = back in time
//must be moving towards surface to collide
//must beat the current soonest collision time
@@ -1114,7 +1074,7 @@ impl PhysicsState {
},
}
//generate instruction
if let Some(_face) = exit_face{
if let Some(face) = exit_face{
return Some(TimedInstruction {
time: best_time,
instruction: PhysicsInstruction::CollisionEnd(collision_data.clone())
@@ -1130,8 +1090,7 @@ impl PhysicsState {
let mut best_time=time_limit;
let mut best_face:Option<TreyMeshFace>=None;
//collect x
let (roots,nroots)=zeroes2(mesh0.max.x()-mesh1.min.x(),v.x(),a.x()/2);
for &t in &roots[0..nroots]{
for t in zeroes2(mesh0.max.x()-mesh1.min.x(),v.x(),a.x()/2) {
//must collide now or in the future
//must beat the current soonest collision time
//must be moving towards surface
@@ -1147,8 +1106,7 @@ impl PhysicsState {
}
}
}
let (roots,nroots)=zeroes2(mesh0.min.x()-mesh1.max.x(),v.x(),a.x()/2);
for &t in &roots[0..nroots]{
for t in zeroes2(mesh0.min.x()-mesh1.max.x(),v.x(),a.x()/2) {
//must collide now or in the future
//must beat the current soonest collision time
//must be moving towards surface
@@ -1165,8 +1123,7 @@ impl PhysicsState {
}
}
//collect y
let (roots,nroots)=zeroes2(mesh0.max.y()-mesh1.min.y(),v.y(),a.y()/2);
for &t in &roots[0..nroots]{
for t in zeroes2(mesh0.max.y()-mesh1.min.y(),v.y(),a.y()/2) {
//must collide now or in the future
//must beat the current soonest collision time
//must be moving towards surface
@@ -1182,8 +1139,7 @@ impl PhysicsState {
}
}
}
let (roots,nroots)=zeroes2(mesh0.min.y()-mesh1.max.y(),v.y(),a.y()/2);
for &t in &roots[0..nroots]{
for t in zeroes2(mesh0.min.y()-mesh1.max.y(),v.y(),a.y()/2) {
//must collide now or in the future
//must beat the current soonest collision time
//must be moving towards surface
@@ -1200,8 +1156,7 @@ impl PhysicsState {
}
}
//collect z
let (roots,nroots)=zeroes2(mesh0.max.z()-mesh1.min.z(),v.z(),a.z()/2);
for &t in &roots[0..nroots]{
for t in zeroes2(mesh0.max.z()-mesh1.min.z(),v.z(),a.z()/2) {
//must collide now or in the future
//must beat the current soonest collision time
//must be moving towards surface
@@ -1217,8 +1172,7 @@ impl PhysicsState {
}
}
}
let (roots,nroots)=zeroes2(mesh0.min.z()-mesh1.max.z(),v.z(),a.z()/2);
for &t in &roots[0..nroots]{
for t in zeroes2(mesh0.min.z()-mesh1.max.z(),v.z(),a.z()/2) {
//must collide now or in the future
//must beat the current soonest collision time
//must be moving towards surface
@@ -1377,7 +1331,7 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
match booster{
&crate::model::GameMechanicBooster::Affine(transform)=>v=transform.transform_point3(v),
&crate::model::GameMechanicBooster::Velocity(velocity)=>v+=velocity,
&crate::model::GameMechanicBooster::Energy{direction: _,energy: _}=>todo!(),
&crate::model::GameMechanicBooster::Energy{direction,energy}=>todo!(),
}
self.touching.constrain_velocity(&self.models,&mut v);
},
@@ -1388,10 +1342,10 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
match trajectory{
crate::model::GameMechanicSetTrajectory::AirTime(_) => todo!(),
crate::model::GameMechanicSetTrajectory::Height(_) => todo!(),
crate::model::GameMechanicSetTrajectory::TargetPointTime { target_point: _, time: _ } => todo!(),
crate::model::GameMechanicSetTrajectory::TrajectoryTargetPoint { target_point: _, speed: _, trajectory_choice: _ } => todo!(),
crate::model::GameMechanicSetTrajectory::TargetPointTime { target_point, time } => todo!(),
crate::model::GameMechanicSetTrajectory::TrajectoryTargetPoint { target_point, speed, trajectory_choice } => todo!(),
&crate::model::GameMechanicSetTrajectory::Velocity(velocity)=>v=velocity,
crate::model::GameMechanicSetTrajectory::DotVelocity { direction: _, dot: _ } => todo!(),
crate::model::GameMechanicSetTrajectory::DotVelocity { direction, dot } => todo!(),
}
self.touching.constrain_velocity(&self.models,&mut v);
},
@@ -1401,11 +1355,9 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
if self.style.get_control(StyleModifiers::CONTROL_JUMP,self.controls){
self.jump();
}
if let Some(a)=self.refresh_walk_target(){
self.body.acceleration=a;
}
self.refresh_walk_target();
},
PhysicsCollisionAttributes::Intersect{intersecting: _,general}=>{
PhysicsCollisionAttributes::Intersect{intersecting,general}=>{
//I think that setting the velocity to 0 was preventing surface contacts from entering an infinite loop
self.touching.insert_intersect(c.model,c);
run_teleport_behaviour(&general.teleport_behaviour,&mut self.game,&self.models,&self.modes,&self.style,&mut self.touching,&mut self.body,model);
@@ -1415,12 +1367,9 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
PhysicsInstruction::CollisionEnd(c) => {
let model=c.model(&self.models).unwrap();
match &model.attributes{
PhysicsCollisionAttributes::Contact{contacting: _,general: _}=>{
PhysicsCollisionAttributes::Contact{contacting,general}=>{
self.touching.remove_contact(c.model);//remove contact before calling contact_constrain_acceleration
let mut a=self.style.gravity;
if let Some(rocket_force)=self.style.rocket_force{
a+=self.style.get_propulsion_control_dir(&self.camera,self.controls,&self.next_mouse,self.time)*rocket_force;
}
self.touching.constrain_acceleration(&self.models,&mut a);
self.body.acceleration=a;
//check ground
@@ -1430,12 +1379,10 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
//TODO: make this more advanced checking contacts
self.move_state=MoveState::Air;
},
_=>if let Some(a)=self.refresh_walk_target(){
self.body.acceleration=a;
},
_=>self.refresh_walk_target(),
}
},
PhysicsCollisionAttributes::Intersect{intersecting: _,general: _}=>{
PhysicsCollisionAttributes::Intersect{intersecting,general}=>{
self.touching.remove_intersect(c.model);
},
}
@@ -1509,14 +1456,7 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
PhysicsInputInstruction::Idle => {refresh_walk_target=false;},//literally idle!
}
if refresh_walk_target{
if let Some(a)=self.refresh_walk_target(){
self.body.acceleration=a;
}else if let Some(rocket_force)=self.style.rocket_force{
let mut a=self.style.gravity;
a+=self.style.get_propulsion_control_dir(&self.camera,self.controls,&self.next_mouse,self.time)*rocket_force;
self.touching.constrain_acceleration(&self.models,&mut a);
self.body.acceleration=a;
}
self.refresh_walk_target();
}
},
}

View File

@@ -62,8 +62,7 @@ impl SetupContextPartial2{
fn pick_adapter(self)->SetupContextPartial3{
let adapter;
//TODO: prefer adapter that implements optional features
//let optional_features=optional_features();
let optional_features=optional_features();
let required_features=required_features();
//no helper function smh gotta write it myself

View File

@@ -21,7 +21,7 @@ struct WindowContext<'a>{
impl WindowContext<'_>{
fn get_middle_of_screen(&self)->winit::dpi::PhysicalPosition<f32>{
winit::dpi::PhysicalPosition::new(self.screen_size.x as f32/2.0,self.screen_size.y as f32/2.0)
winit::dpi::PhysicalPosition::new(self.screen_size.x as f32/2.0, self.screen_size.y as f32/2.0)
}
fn window_event(&mut self,time:crate::integer::Time,event: winit::event::WindowEvent) {
match event {
@@ -32,7 +32,7 @@ impl WindowContext<'_>{
self.physics_thread.send(TimedInstruction{time,instruction:crate::physics_worker::Instruction::GenerateModels(indexed_model_instances)}).unwrap();
}
},
winit::event::WindowEvent::Focused(_state)=>{
winit::event::WindowEvent::Focused(state)=>{
//pause unpause
//recalculate pressed keys on focus
},

View File

@@ -1,6 +1,6 @@
use std::thread;
use std::sync::{mpsc,Arc};
use parking_lot::Mutex;
use parking_lot::{Mutex,Condvar};
//WorkerPool
struct Pool(u32);

View File

@@ -2,32 +2,31 @@
use crate::integer::Planar64;
#[inline]
pub fn zeroes2(a0:Planar64,a1:Planar64,a2:Planar64)->([Planar64;2],usize){
pub fn zeroes2(a0:Planar64,a1:Planar64,a2:Planar64) -> Vec<Planar64>{
if a2==Planar64::ZERO{
let ([ret],ret_len)=zeroes1(a0,a1);
return ([ret,Planar64::ZERO],ret_len);
return zeroes1(a0, a1);
}
let radicand=a1.get() as i128*a1.get() as i128-a2.get() as i128*a0.get() as i128*4;
if 0<radicand{
if 0<radicand {
//start with f64 sqrt
let planar_radicand=Planar64::raw(unsafe{(radicand as f64).sqrt().to_int_unchecked()});
//TODO: one or two newtons
if Planar64::ZERO<a2{
([(-a1-planar_radicand)/(a2*2),(-a1+planar_radicand)/(a2*2)],2)
}else{
([(-a1+planar_radicand)/(a2*2),(-a1-planar_radicand)/(a2*2)],2)
if Planar64::ZERO<a2 {
return vec![(-a1-planar_radicand)/(a2*2),(-a1+planar_radicand)/(a2*2)];
} else {
return vec![(-a1+planar_radicand)/(a2*2),(-a1-planar_radicand)/(a2*2)];
}
}else if radicand==0{
([a1/(a2*-2),Planar64::ZERO],1)
}else{
([Planar64::ZERO,Planar64::ZERO],0)
} else if radicand==0 {
return vec![a1/(a2*-2)];
} else {
return vec![];
}
}
#[inline]
pub fn zeroes1(a0:Planar64,a1:Planar64)->([Planar64;1],usize){
pub fn zeroes1(a0:Planar64,a1:Planar64) -> Vec<Planar64> {
if a1==Planar64::ZERO{
return ([Planar64::ZERO],0);
}else{
return ([-a0/a1],1);
return vec![];
} else {
return vec![-a0/a1];
}
}