From 05ec7ea5d81ec557464101f3a99e7adccf000bee Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 7 Aug 2024 17:08:31 -0700 Subject: [PATCH] physics: rework jumping and boosters --- Cargo.lock | 25 +++++++++++++------------ Cargo.toml | 4 ++-- src/physics.rs | 27 ++++++++++----------------- 3 files changed, 25 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b658757..77ac76e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -326,9 +326,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.7" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc" +checksum = "504bdec147f2cc13c8b57ed9401fd8a147cc66b67ad5cb241394244f2c947549" dependencies = [ "jobserver", "libc", @@ -1900,9 +1900,9 @@ dependencies = [ [[package]] name = "strafesnet_bsp_loader" -version = "0.1.3" +version = "0.1.4" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" -checksum = "6d4af68c422b5f57febbaa218f44ba02d413fd25e84afff9e45e557a8caee2ce" +checksum = "b6b3e1324034abfd648e339580989f8f2c30ac2009296229349d88b8fcb4eedd" dependencies = [ "glam", "strafesnet_common", @@ -1912,10 +1912,11 @@ dependencies = [ [[package]] name = "strafesnet_common" -version = "0.2.3" +version = "0.3.0" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" -checksum = "e6155b62ce5d118d1aab0d90d6d6981bca1e046c4ca86829bc93215e8b3bb929" +checksum = "1077d45a0b064964906a57de765a5a2bfe47b41f2f807d13b18c70765e76d3dd" dependencies = [ + "arrayvec", "bitflags 2.6.0", "glam", "id", @@ -1923,9 +1924,9 @@ dependencies = [ [[package]] name = "strafesnet_deferred_loader" -version = "0.3.1" +version = "0.3.2" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" -checksum = "c3891dcbdbc20b03cf561786b810e839ae7c11dd8810fd005f2474805ee9cccc" +checksum = "9d5ad437524fb201fd5be68f76c53dd831e81ccad4655e19e3d1ca201863b566" dependencies = [ "lazy-regex", "strafesnet_common", @@ -1934,9 +1935,9 @@ dependencies = [ [[package]] name = "strafesnet_rbx_loader" -version = "0.3.2" +version = "0.3.3" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" -checksum = "21ea93b0170063dd2a063a138c41e6f7a6c14a82c6553fa4ba32df65a26efc6e" +checksum = "3a910867e1f5ab2d9cc9c178973aee7fa029547e27465e47fea2eb99b860bb81" dependencies = [ "bytemuck", "glam", @@ -1951,9 +1952,9 @@ dependencies = [ [[package]] name = "strafesnet_snf" -version = "0.1.1" +version = "0.1.2" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" -checksum = "78479f73437a3f10230efd2304be0f3ef30dff98c54d93613ed1621bfd6a7da6" +checksum = "d12fc351b2af5fd7a8183175d55ac43e21eb8fd1f76cc70cd4713c0d1a556c96" dependencies = [ "binrw 0.14.0", "id", diff --git a/Cargo.toml b/Cargo.toml index 070640b..d0cea52 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,10 +23,10 @@ id = { version = "0.1.0", registry = "strafesnet" } parking_lot = "0.12.1" pollster = "0.3.0" 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_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.2", registry = "strafesnet", optional = true } wgpu = "22.0.0" winit = "0.30.4" diff --git a/src/physics.rs b/src/physics.rs index 17c0d8b..daacd0b 100644 --- a/src/physics.rs +++ b/src/physics.rs @@ -1325,25 +1325,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()){ 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 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 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); } } @@ -1369,6 +1354,10 @@ fn atomic_internal_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:Tim (PhysicsCollisionAttributes::Intersect{intersecting:_,general},Collision::Intersect(_intersect))=>{ //I think that setting the velocity to 0 was preventing surface contacts from entering an infinite loop 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()){ let zone=mode.get_zone(convex_mesh_id.model_id.into()); match zone{ @@ -1526,7 +1515,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(jump_settings)=&state.style.jump{ 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); } }