Commit graph

141 commits

Author SHA1 Message Date
Mitchell Richters
c3adf5ea58 - Slight clean up of input constants. 2022-10-25 07:07:14 +02:00
Mitchell Richters
5d8cc1b4fc - Store all input speed constants as DAngle to avoid calling DAngle::fromDeg() all the time. 2022-10-25 07:07:02 +02:00
Mitchell Richters
2baf35ed2d - Slightly tidy up PlayerHorizon::applyinput(). 2022-10-25 07:06:55 +02:00
Mitchell Richters
8d3f3c6025 - Cut over to DAngle from fixedhoriz and remove the latter. 2022-10-25 07:06:55 +02:00
Mitchell Richters
0d8b2ba59d - Tidy up all constants in gameinput.cpp and convert to native degrees/pitch where appropriate. 2022-10-25 07:06:55 +02:00
Mitchell Richters
eedcfb46c6 - Convert calcviewpitch() to work with a temporary DAngle so we can eliminate the temporary tanhoriz() friend. 2022-10-25 07:06:54 +02:00
Mitchell Richters
ca8f8d6d36 - Remove all remaining q16horiz() calls, also correcting a long-standing Duke bug. 2022-10-25 07:06:54 +02:00
Mitchell Richters
8697e5f054 - Replace all q16horiz(0) calls. 2022-10-25 07:06:54 +02:00
Mitchell Richters
5bf23f0642 - Develop new scaled horizon return to centre with initial return from full articulation scaled by the pitch's sine.
* When coming back from a full view pitch using the original algorithm, the initial snap-back from 90 degrees is very aggressive.
* Return to centre speed retuned to be 1:1 to the ms with the tangent at Duke/SW's clamped pitch.
2022-10-25 07:06:54 +02:00
Mitchell Richters
d923ef9a8c - Perform horizon's return to centre using pitch instead of tangent.
* Return to centre speed tuned to be 1:1 to the ms with the tangent at Duke/SW's clamped pitch.
2022-10-25 07:06:53 +02:00
Mitchell Richters
5851c0f2c6 - Clean up some q16horiz usage and how the view pitch is clamped. 2022-10-25 07:06:53 +02:00
Mitchell Richters
4ef9ec93ea - Remove fixedhoriz::asbuildf() and associated buildf friend.
* The new friend `tanhoriz()` is just for the input code for now.
2022-10-25 07:06:53 +02:00
Mitchell Richters
fcdb360b92 - Add fixedhoriz::Sgn(). 2022-10-25 07:06:53 +02:00
Mitchell Richters
e4ae726015 - Rename fixedhoriz::aspitch() to Degrees() to match DAngle objects. 2022-10-25 07:06:53 +02:00
Mitchell Richters
95cd74bdc0 - renamed slope functions so that the int versions get a special name. 2022-10-22 12:17:02 +02:00
Mitchell Richters
85f716e49b - floatify calcviewpitch 2022-10-22 12:17:00 +02:00
Mitchell Richters
8bfcb8c939 - Floatify InputPacket::fvel and InputPacket::svel.
* Since all velocities are floated, we can now take each game's keymove scaling into its ticker and use a consistent keymove size, making non-mouselook and controller input truly identical across the games without having to try and fudge any values.
2022-10-20 00:48:09 +02:00
Mitchell Richters
def2b9d483 - Flip svel around in the input code so we can use proper anti-clockwise vector math. 2022-10-20 00:48:09 +02:00
Mitchell Richters
bc018dd946 - Use getCorrectedScale() in conjunction with looking keys like scaletozero() functions. 2022-10-18 19:52:02 +02:00
Mitchell Richters
bdc6a5cf69 - Remove fudging from I_GetInputFrac() and correct getPushBuild(). 2022-10-18 19:52:02 +02:00
Mitchell Richters
478e7a6801 - Eliminate some TAngle floating point Build method usage. 2022-10-05 00:36:31 +02:00
Mitchell Richters
5c84f93c08 - Use the static constexpr nullAngle everywhere possible. 2022-10-05 00:36:30 +02:00
Mitchell Richters
b23e77d9c7 - Replace player's ang with DAngle object.
* This commit does not build. Committed items are everything that's been done by find and replace.
* Next commit has hand-performed changes that are better separated out for clarity.
2022-10-05 00:36:27 +02:00
Mitchell Richters
7a6f5c0864 - Replace binangle usage in PlayerHorizon::calcviewpitch() with DAngle object. 2022-10-05 00:36:27 +02:00
Mitchell Richters
13ea55b4cb - Replace player's rotscrnang and look_ang angles with DAngle objects.
* Went the el cheapo route and added some floating point Build angle methods. As these and the integer build methods are really just refactoring aids, we'll come back to this in due course.
2022-10-05 00:36:26 +02:00
Christoph Oelckers
b31e6c0bdf - replaced getclosestpointonwall_internal with a floating point version based on NearestPointLine. 2022-08-05 17:04:46 +02:00
Mitchell Richters
79022e8afa - Clean up and simplify getincangle()/getincanglebam() functions and inline them. 2022-07-23 12:57:45 +10:00
Mitchell Richters
4324f923bc - Call updateTurnHeldAmt() after doing the turn, not before it. This gives one tic more preamble. 2022-07-23 10:37:32 +10:00
Mitchell Richters
e016f65321 - Don't adjust joystick pitch/yaw speeds based on whether autorun is enabled or not.
* Only SW did this out of the box.
* Duke never did, NBlood has no working joystick setup to compare with, and GZDoom doesn't either.
* Fixes #693.
2022-07-23 10:37:32 +10:00
Mitchell Richters
a423b93ad8 - Use turnscale in controller pitch calculations, which is only used in SW when on a sector object, and is original behaviour. 2022-07-23 10:37:32 +10:00
Mitchell Richters
78fcf2b4f0 - Move invertmouse and invertmousex CVARs from gameinput.cpp to inputstate.cpp.
* Old setup was inverting the entire player's horz/avel, even for joystick input while not inverting `mousemovex` or `mousemovey` at all.
2022-07-23 10:37:32 +10:00
Mitchell Richters
c68e112867 - Remove some unnecessary branching and abs() calls in processMovement().
* Since fvel/svel is clamped at the end of the function, these tests just aren't necessary.
* Reversed the logic in some if statements so the most likely outcome doesn't fall to the else branch.
2022-07-23 10:37:32 +10:00
Mitchell Richters
ea17352aea - Do some small tidying up in gameinput.cpp and change how some constants are stored. 2022-07-23 10:37:32 +10:00
Mitchell Richters
1906491129 - Move some PlayerHorizon/PlayerAngle class methods out into inlines in gameinput.cpp.
* These class methods did nothing with the objects inside the class, they worked generically so they're better as inlines.
* Also tidied up some of the internals so they're easier to read.
2022-07-23 10:37:32 +10:00
Mitchell Richters
612dd049f9 - Remove unused PlayerPosition structure.
* There were some plans around this being in use for all the various player structs in each game, but it hasn't come to be.
* Code remains in the commit history, it can come back if it's of use in the future.
2022-05-30 21:33:14 +10:00
Mitchell Richters
70d2a8dc78 - Remove a seldom-used getTicrateScale() overload. 2022-05-30 21:06:32 +10:00
Mitchell Richters
118ceb18ca - Capitalise vec2_t y variable. 2021-12-30 09:57:02 +01:00
Mitchell Richters
3c9cd926ba - Capitalise vec2_t x variable. 2021-12-30 09:57:02 +01:00
Christoph Oelckers
41506f35db - calcviewpitch 2021-12-26 23:08:40 +01:00
Mitch Richters
8fefead4e5 - Remove cancellation of quick turn if mouse/keyboard/controller angle input is detected that was introduced in 2129d3b4e7.
* Requested in https://forum.zdoom.org/viewtopic.php?f=342&t=73231
* Neither EDuke32 nor GZDoom do this, so the rationale is we shouldn't either.
2021-11-29 00:56:32 +01:00
Christoph Oelckers
fcbb7320a8 - Duke/RR: added all checks needed for not letting Duke crash with noclip when not accepting -1 as a valid sector pointer.
All places that were causing a crash are now guared by calling 'insector()'.
2021-11-29 00:56:31 +01:00
Mitch Richters
e491d15ff9 - Move InputScale() out of inputstate.cpp and into i_time.cpp as I_GetInputFrac() to make it available to GZDoom for potential future requirements.
* As part of this, feed the output of `I_GetInputFrac()` to `gi->GetInput()` instead of having each game's virtual override calling it locally.
2021-11-29 00:55:01 +01:00
Mitch Richters
bb20827027 - processMovement(): Fix prescaling for Exhumed when using mouse or controller.
* Controller input before was too fast compared to other games, now it's 1:1.
* Mouse input when used without mouse look was too slow, now it's also 1:1 with the other games.
* `hid` in the context of `hidprescale` refers to 'Human Interface Device'.
2021-11-07 18:32:02 +11:00
Mitch Richters
b27f5e3be0 - gameinput.cpp/h: Internalise if statements used before calling PlayerHorizon and PlayerAngle class method scaletozero() into method itself. 2021-11-07 18:25:37 +11:00
Mitch Richters
72531e61db - gameinput.cpp/h: Consolidate all the return to zero code for angles and horizons into class members, using technique from horizoff as basis. 2021-11-07 11:37:12 +11:00
Christoph Oelckers
83fe41e71e - made updatesector receive a 32 bit int pointer and deprecated the 16 bit variant. 2021-11-06 15:53:16 +01:00
Mitch Richters
5050947dca - PlayerAngle::applyinput(): Consolidate some mostly duplicated code into a lambda. 2021-11-06 17:57:00 +11:00
Mitch Richters
ed67d5d395 - PlayerHorizon::applyinput(): Only run through all the horizon to pitch and back code if we have input to process. 2021-11-06 15:34:10 +11:00
Mitch Richters
5f8c8fe0a4 - PlayerHorizon::applyinput(): Consolidate some mostly duplicated code into a lambda. 2021-11-06 15:07:28 +11:00
Mitch Richters
5ec5321034 - gameinput.h/cpp: Abstract the angle/horizon adjustment math into a few inlines to avoid repetition and having to cast enums as doubles for C++20 compliance. 2021-11-06 14:07:53 +11:00
Mitch Richters
4c02663842 - PlayerAngle::applyinput(): Re-add addition of +/- 1. when returning rotscrnang to 0 lost long, long ago. 2021-11-06 14:07:36 +11:00
Mitch Richters
ab99b6b29d - PlayerHorizon::calcviewpitch(): Make returning horizoff to 0 speed uniform across all games. 2021-11-06 13:31:29 +11:00
Mitch Richters
0eb4ff4ad2 - PlayerHorizon::calcviewpitch(): Provide commentary on how numeric literals used in function came to be and place into an enum for clarity. 2021-11-06 10:27:00 +11:00
Mitch Richters
1df2ba80ed - PlayerAngle::applyinput(): Provide commentary on how numeric literals used in rotscrnang/look_ang/spin math came to be and place into an enum for clarity. 2021-11-06 10:26:54 +11:00
Mitch Richters
8e8dfa9f9a - PlayerHorizon::applyinput(): Provide commentary on how numeric literals used in aim/look up/down and return to centre math came to be and place into an enum for clarity. 2021-11-06 09:30:03 +11:00
Mitch Richters
c424f7c8dd - processMovement(). Remove cl_exhumedoldturn CVAR and tidy up numeric literals in use.
* In our older codebase before the input code was refactored, Exhumed's turning was broken and was only applying the base factor of 12, significantly slower than the other games.
* Upon doing some testing in PCExhumed, I noticed their turning was faster as when the counter meets its target, the turn value is shifted left by 2, effectively making it 48: b90417ed8e/source/exhumed/src/player.cpp (L336-L337)
* Removed this CVAR because of this.
* Reworked turning code so that pressing left+right together cancel each other out and that pressing both doesn't call `updateTurnHeldAmt(scaleAdjust)` twice.
* Redid turn averages factoring in Exhumed's speeds, rounded off values and stored in an enum for clarity.
2021-11-06 09:28:47 +11:00
Mitch Richters
eb8b075727 - binaryangle.h: Change binangle bitshift operators to operate on signed value to properly handle angles > 1024. 2021-11-01 22:13:39 +11:00
Mitch Richters
15c4d38694 - gameinput.h: Add initial structure for PlayerPosition as companion to PlayerAngle and PlayerHorizon structs. 2021-10-30 17:30:01 +02:00
Christoph Oelckers
29769dd673 - fixed engine code warnings pointed out by XCode 13. 2021-10-08 19:06:41 +02:00
Mitchell Richters
ca65c4c9da - Allow ticker to lock input to player's angle and horizon without having to force use of synchronised input. 2021-07-18 19:25:41 +10:00
Christoph Oelckers
1168341d5a - fixed more warnings in 'core'. 2021-05-12 21:47:32 +02:00
Mitchell Richters
c0e5599478 Merge branch 'master' into newrenderer 2021-04-22 08:58:26 +10:00
Mitchell Richters
ab4c18a73a - processMovement(): Remove attenuation of hidInput->dyaw that was missed when scaling was removed from backend in 44e4c5ff78. 2021-04-22 08:58:17 +10:00
Mitchell Richters
93edeac791 - Clean-up of input functions.
* Remove unused `getincanglef()`.
* Remove unused `getincangleq16()`.
* In `PlayerHorizon` struct, clamp value when setting target in `__settarget()`, not each public `settarget()` overload.
* Rename `PlayerAngle` method `applylook()` to `applyinput()`.
* Rename `PlayerHorizon` method `sethorizon()` to `applyinput()`.
* In `PlayerHorizon::applylook()`, slightly clean return to centre code so it doesn't do math if already at 0.
* In `PlayerAngle::applylook()`, slightly clean rotscrnang/look_ang code so it doesn't do math if already at 0 and reposition where mouse input is applied so that if input is applied, the player never enters a spin.
* In `Duke3d::player_struct::apply_seasick()`, use `buildfang()` method instead of scaling float to BAM within function.
2021-04-21 20:41:04 +10:00
Mitchell Richters
de06030ea0 - gameinput.cpp: Make sethorizon(), applylook() and calcviewpitch() class functions of PlayerHorizon and PlayerAngle where appropriate. 2021-04-19 20:50:10 +10:00
Mitchell Richters
92d1d7fbde - Fix potential overflow issue in binangle::tosigned() and getincanglebam(). 2021-04-15 08:25:08 +10:00
Mitchell Richters
f254eeb465 - binaryangle.h: Remove lookangle class and replace use with binangle.
* Added in fca846272e to deal with signed adjustments but its just not needed.
* Made better use of `binangle`/`fixedhoriz` class getters and setters than before as well.
2021-04-11 15:45:53 +10:00
Christoph Oelckers
55ad51ee1f Merge branch 'master' into newrenderer2 2021-04-04 13:23:51 +02:00
Mitchell Richters
e3c2757f1c - sethorizon(): Ensure SB_CENTERVIEW bit is always cleared if horizon target is set. 2021-04-02 23:23:24 +11:00
Mitchell Richters
9c01bde44e - gameinput.cpp: Block player input within sethorizon() and applylook() if target for each has been set by the ticker.
* Stops players having the ability to provide input and fight the system trying to set an input.
2021-04-02 22:47:19 +11:00
Mitchell Richters
88695ef554 Merge branch 'master' into newrenderer2 2021-04-01 16:49:07 +11:00
Mitchell Richters
029f8807df - Make 360. / 2048. a constant expression and replace all uses throughout code. 2021-04-01 10:42:22 +11:00
Christoph Oelckers
0c7f05a416 - let the clipper work exclusively on Build coordinates. 2021-03-22 23:40:25 +01:00
Mitchell Richters
25eaeff0db - Wrap all g_gameType & GAMEFLAG_BLOOD checks into isBlood() inline. 2021-01-02 14:46:58 +11:00
Mitchell Richters
532d128afd - Blood: Migrate game's slopetilting code to calcviewpitch(). 2021-01-02 14:40:35 +11:00
Mitchell Richters
4397646cc4 - Duke: Move cancellation of spin from FinalizeInput() into applylook() in gameinput.cpp. 2021-01-02 10:26:22 +11:00
Mitchell Richters
36c25ee2a0 - gameinput.cpp: Break out processMovement()'s turnheldamt calculations into functions. 2021-01-02 09:53:03 +11:00
Mitchell Richters
dac08a2cb9 - calcviewpitch(): Fix issue with returning horizoff to 0 from negative slope. 2021-01-02 01:15:58 +11:00
Mitchell Richters
8003753989 - Duke/SW: Move each game's check of cl_slopetilting into calcviewpitch() backend function. 2021-01-02 00:34:44 +11:00
Mitchell Richters
6d12159006 - Duke/SW: Consolidate each game's slopetilting function into backend solution.
* Based on SW's implementation purely for its commentary, but includes a fix from Duke's.
* Allow disabling Duke's slopetilting via `cl_slopetilting` like SW.
2021-01-02 00:30:11 +11:00
Mitchell Richters
5c87b7b894 - Return to center using tangent of pitch, as per original games (Duke/SW).
* Preserves the original return to center feel more accurately as original algorithm can't directly translate to pitch. If we ever get rid of Build's horizon throughout the games, this can go on the chopping block then as a necessity.
2020-12-30 18:04:00 +11:00
Mitchell Richters
80ff918b17 - gameinput.h: For PlayerAngle struct methods settarget(), properly set target as angle + delta between angle & target within method and not game-side. 2020-11-26 17:26:29 +11:00
Mitchell Richters
42689e02c4 - gameinput.cpp: Define getincanglebam() and slightly clean up other getincangle*() functions. 2020-11-22 21:18:11 +01:00
Mitchell Richters
ade1a80515 - gameinput.cpp: Remove crouch bool from applylook() since we can now just rely in the actions bitfield that's already incoming as required and default scaleAdjust in the prototype to 1. 2020-11-07 18:25:06 +11:00
Mitchell Richters
6e3d414b3c - inputstate.cpp: Move checkCrouchToggle() from gameinput.ccp into ApplyGlobalInput() and use static bool for crouch toggling vs. game-side bool. 2020-11-07 18:16:16 +11:00
Mitchell Richters
4ef0d20e0e - gameinput.cpp: Consolidate checkCrouchToggle() from Duke with discrete implementations from Blood in 7c8efde38c and Exhumed in 032db82f82 to unify the functionality. 2020-11-07 13:44:25 +11:00
Mitchell Richters
c9708a5464 - CONTROL_GetInput(): Reverse polarity of dx/dz and update processMovement() appropriately. 2020-11-07 09:56:57 +11:00
Mitchell Richters
c98f7ac491 - gameinput.cpp: Don't set a target when serialising PlayerHorizon struct.
* Fixes #131.
2020-10-22 09:41:21 +11:00
Mitchell Richters
fb91fc49a3 - processMovement(): Add commentary around avel constants used within function and how they came to be. Also clean up some left-over code. 2020-10-15 20:12:34 +11:00
Christoph Oelckers
cb8d2eb94c - added serializers for PlayerAngle and PlayerHorizon. 2020-10-11 16:55:12 +02:00
Christoph Oelckers
1757ef2aa6 - split the game input code off gamecontrol.cpp into its own file. 2020-10-11 16:33:43 +02:00