Commit graph

71 commits

Author SHA1 Message Date
Mitchell Richters
7a6f5c0864 - Replace binangle usage in PlayerHorizon::calcviewpitch() with DAngle object. 2022-10-05 00:36:27 +02:00
Mitchell Richters
dbc46e2a75 - Change out PlayerAngle::settarget()'s input from binangle to DAngle. 2022-10-05 00:36:27 +02:00
Mitchell Richters
a090f31bc4 - Change out PlayerAngle::addadjustment()'s input from binangle to DAngle. 2022-10-05 00:36:26 +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
fb4da6bbd4 - added some utilities.
This also had to use explicit types in a few places to clear ambiguities.
2022-10-02 20:46:58 +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
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
71fb91940d Revert "- Simplify PlayerHorizon::settarget() by adding a dedicated angle setter that resets interpolated value as well."
This reverts commit 0416834d9d.

Revert "- Simplify `PlayerAngle::settarget()` by adding a dedicated angle setter that resets interpolated value as well."

This reverts commit 5a550613f3.

Revert "- Add bool `lock` to `PlayerHorizon::settarget()` when setting target from the ticker without having to call setters and resetters."

This reverts commit 18541d1ab4.

Revert "- Add bool `lock` to `PlayerAngle::settarget()` when setting target from the ticker without having to call setters and resetters."

This reverts commit 1ac58dc41c.

* We need to ensure only the ticker can unlock the player's input if it's telling us to lock the input.
2022-06-06 18:41:45 +10:00
Mitchell Richters
0359d49df2 - Move repeated input code algorithm into an inline function. 2022-06-06 18:40:17 +10:00
Mitchell Richters
dcf1c540e6 - Another amendment to 18541d1ab4 and 1ac58dc41c to ensure input lock is only set when we're running unsynchronised input. 2022-06-05 21:31:02 +10:00
Mitchell Richters
990c8287fc - Amendment to 18541d1ab4 and 1ac58dc41c to reset inputdisabled once target is reached. 2022-05-30 22:13:42 +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
1ac58dc41c - Add bool lock to PlayerAngle::settarget() when setting target from the ticker without having to call setters and resetters. 2022-05-30 21:24:02 +10:00
Mitchell Richters
18541d1ab4 - Add bool lock to PlayerHorizon::settarget() when setting target from the ticker without having to call setters and resetters. 2022-05-30 21:22:24 +10:00
Mitchell Richters
5a550613f3 - Simplify PlayerAngle::settarget() by adding a dedicated angle setter that resets interpolated value as well. 2022-05-30 21:22:10 +10:00
Mitchell Richters
0416834d9d - Simplify PlayerHorizon::settarget() by adding a dedicated angle setter that resets interpolated value as well. 2022-05-30 21:21:52 +10:00
Mitchell Richters
70d2a8dc78 - Remove a seldom-used getTicrateScale() overload. 2022-05-30 21:06:32 +10:00
Mitchell Richters
7282e0d8bf - Remove multiple addadjustment()/settarget() overloads in favour of native binangle/fixedhoriz versions only.
* Simplifies these classes a bit.
* Better shows intent in actual game code.
* Removes unnecessary int to double conversions.
2022-05-30 20:35:41 +10:00
Mitchell Richters
b2ab64bb62 - Capitalise vec3_t z variable. 2021-12-30 09:57:03 +01:00
Mitchell Richters
68e2691be7 - Capitalise vec3_t y variable. 2021-12-30 09:57:03 +01:00
Mitchell Richters
c549cc5276 - Capitalise vec3_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
1906de5d0c - Adjust PlayerHorizon and PlayerAngle struct member scaletozero() to consistently return to zero at the same speed for synchronised and unsynchronised input at any framerate from 60 fps to at least 1000 fps. 2021-11-29 00:55:15 +01: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
Mitch Richters
7499c84d0b - Add interpolatedhorizon() inlines to handle interpolating fixedhoriz objects without having to convert old and new values back to Q16.16 first. 2021-11-06 14:07:58 +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
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
0fe5ac6a56 - gameinput.h: Correctly use targetset() in PlayerHorizon and PlayerAngle structs. 2021-10-30 17:30:01 +02: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
Mitch Richters
7ee4f49649 - gameinput.h: Remove some of the verticality from the PlayerHorizon and PlayerAngle 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
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
d34070b8ae - gameinput.h: Remove precise bool from horizsumfrac(), look_anghalf() and looking_arc() added in a4895cb270.
* It looks terrible to have low precision math versions of look_anghalf and looking_arc since we always interpolate `look_ang` now, so lets just not.
2021-04-20 21:12:17 +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
a4895cb270 - All Games: Allow for HUD interpolation to be disabled.
* Requested by users, really don't know why...
* Interpolation values are guarded by the CVAR.
* For Blood, integer truncation is employed just like original game.
* For all games where more precise sine/cosine math has been utilised, no changes have been made.
2021-04-15 13:35:53 +10:00
Mitchell Richters
f343bd8d5e - Fix death camera issues stemming from f254eeb465.
* Adjustment in `__addadjustment()` needs to be signed.
* Output of `bvectangbam()` needs to be signed before Duke/SW left-shift the value.
2021-04-11 17:52:29 +10:00
Mitchell Richters
534271c62a - PlayerHorizon::interpolatedsum(): Cut over interpolation code to inline functions that was missed when doing e76f63e2c0. 2021-04-11 17:50:32 +10:00
Mitchell Richters
e76f63e2c0 - Consolidate all game interpolation code into inline functions. 2021-04-11 16:45:35 +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
Mitchell Richters
ba90f444dd - PlayerAngle: Repair issues with addadjustment() method following changes in 4ffe004483 that were affecting negative input. 2021-04-05 21:41:11 +10: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
4ffe004483 - Further work within PlayerAngle and PlayerHorizon structs following 39fe9efaff and bf2d8078a4.
* Reduce code repetition.
* Clamp incoming horizon when using `settarget()` methods.
* Eliminate double calculation that was occurring in `processhelpers()`.
2021-04-02 22:47:17 +11:00
Mitchell Richters
bf2d8078a4 - PlayerHorizon: Replicate changes to settarget() and processhelpers() methods from 39fe9efaff. 2021-03-31 19:44:50 +11:00
Mitchell Richters
39fe9efaff - PlayerAngle: Adjust how settarget() methods store angle for unsynchronised angle adjustments and adjust processhelpers() method accordingly.
* Repairs angle issues raised in https://forum.zdoom.org/viewtopic.php?f=340&p=1185365.
2021-03-31 19:43:41 +11:00
Mitchell Richters
7fcf1c94a1 - Exhumed: Minor fixes to panning code.
* Stop panning if underwater.
* Remove overload from PlayerHorizon from d32dcd5f8e that was causing problems for other games.
* Remove static bool `plrFalling` also from d32dcd5f8e and add `bIsFalling` to `Player` struct, hooking up with save code as well.
2021-01-05 17:07:56 +11:00
Mitchell Richters
d32dcd5f8e - Exhumed: Fix player panning when walking up/down steps while horizon is 0. 2021-01-05 11:01:41 +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
3a801cbf5c - calcviewpitch(): Set scaleAdjust to default to 1 in prototype like other functions in gameinput.cpp. 2021-01-02 09:32:19 +11:00