mirror of
https://github.com/DrBeef/Raze.git
synced 2025-02-22 19:51:16 +00:00
- gameinput.h: Remove some of the verticality from the PlayerHorizon
and PlayerAngle
structs.
This commit is contained in:
parent
9d310c7d6a
commit
7ee4f49649
1 changed files with 48 additions and 144 deletions
|
@ -15,63 +15,44 @@ struct PlayerHorizon
|
||||||
|
|
||||||
friend FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerHorizon& w, PlayerHorizon* def);
|
friend FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerHorizon& w, PlayerHorizon* def);
|
||||||
|
|
||||||
|
// Prototypes for functions in gameinput.cpp.
|
||||||
|
void applyinput(float const horz, ESyncBits* actions, double const scaleAdjust = 1);
|
||||||
|
void calcviewpitch(vec2_t const pos, binangle const ang, bool const aimmode, bool const canslopetilt, int const cursectnum, double const scaleAdjust = 1, bool const climbing = false);
|
||||||
|
|
||||||
|
// Interpolation helpers.
|
||||||
void backup()
|
void backup()
|
||||||
{
|
{
|
||||||
ohoriz = horiz;
|
ohoriz = horiz;
|
||||||
ohorizoff = horizoff;
|
ohorizoff = horizoff;
|
||||||
}
|
}
|
||||||
|
|
||||||
void restore()
|
void restore()
|
||||||
{
|
{
|
||||||
horiz = ohoriz;
|
horiz = ohoriz;
|
||||||
horizoff = ohorizoff;
|
horizoff = ohorizoff;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addadjustment(double value)
|
// Commonly used getters.
|
||||||
{
|
fixedhoriz osum() { return ohoriz + ohorizoff; }
|
||||||
__addadjustment(buildfhoriz(value));
|
fixedhoriz sum() { return horiz + horizoff; }
|
||||||
}
|
fixedhoriz interpolatedsum(double const smoothratio) { return q16horiz(interpolatedvalue(osum().asq16(), sum().asq16(), smoothratio)); }
|
||||||
|
|
||||||
void addadjustment(fixedhoriz value)
|
// Ticrate playsim adjustment helpers.
|
||||||
{
|
void addadjustment(double value) { __addadjustment(buildfhoriz(value)); }
|
||||||
__addadjustment(value);
|
void addadjustment(fixedhoriz value) { __addadjustment(value); }
|
||||||
}
|
void settarget(double value, bool backup = false) { __settarget(buildfhoriz(value), backup); }
|
||||||
|
void settarget(fixedhoriz value, bool backup = false) { __settarget(value, backup); }
|
||||||
|
void resetadjustment() { adjustment = 0; }
|
||||||
|
bool targetset() { return target.asq16(); }
|
||||||
|
|
||||||
void resetadjustment()
|
// Input locking helpers.
|
||||||
{
|
void lockinput() { inputdisabled = true; }
|
||||||
adjustment = 0;
|
void unlockinput() { inputdisabled = false; }
|
||||||
}
|
bool movementlocked() { return target.asq16() || inputdisabled; }
|
||||||
|
|
||||||
void settarget(double value, bool backup = false)
|
// Draw code helpers.
|
||||||
{
|
double horizsumfrac(double const smoothratio) { return (!SyncInput() ? sum() : interpolatedsum(smoothratio)).asbuildf() * (1. / 16.); }
|
||||||
__settarget(buildfhoriz(value), backup);
|
|
||||||
}
|
|
||||||
|
|
||||||
void settarget(fixedhoriz value, bool backup = false)
|
|
||||||
{
|
|
||||||
__settarget(value, backup);
|
|
||||||
}
|
|
||||||
|
|
||||||
void lockinput()
|
|
||||||
{
|
|
||||||
inputdisabled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void unlockinput()
|
|
||||||
{
|
|
||||||
inputdisabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool targetset()
|
|
||||||
{
|
|
||||||
return target.asq16();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool movementlocked()
|
|
||||||
{
|
|
||||||
return target.asq16() || inputdisabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Ticrate playsim adjustment processor.
|
||||||
void processhelpers(double const scaleAdjust)
|
void processhelpers(double const scaleAdjust)
|
||||||
{
|
{
|
||||||
if (targetset())
|
if (targetset())
|
||||||
|
@ -94,29 +75,6 @@ struct PlayerHorizon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fixedhoriz osum()
|
|
||||||
{
|
|
||||||
return ohoriz + ohorizoff;
|
|
||||||
}
|
|
||||||
|
|
||||||
fixedhoriz sum()
|
|
||||||
{
|
|
||||||
return horiz + horizoff;
|
|
||||||
}
|
|
||||||
|
|
||||||
fixedhoriz interpolatedsum(double const smoothratio)
|
|
||||||
{
|
|
||||||
return q16horiz(interpolatedvalue(osum().asq16(), sum().asq16(), smoothratio));
|
|
||||||
}
|
|
||||||
|
|
||||||
double horizsumfrac(double const smoothratio)
|
|
||||||
{
|
|
||||||
return (!SyncInput() ? sum() : interpolatedsum(smoothratio)).asbuildf() * (1. / 16.); // Used within draw code for Duke.
|
|
||||||
}
|
|
||||||
|
|
||||||
void applyinput(float const horz, ESyncBits* actions, double const scaleAdjust = 1);
|
|
||||||
void calcviewpitch(vec2_t const pos, binangle const ang, bool const aimmode, bool const canslopetilt, int const cursectnum, double const scaleAdjust = 1, bool const climbing = false);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
fixedhoriz target;
|
fixedhoriz target;
|
||||||
double adjustment;
|
double adjustment;
|
||||||
|
@ -158,13 +116,16 @@ struct PlayerAngle
|
||||||
|
|
||||||
friend FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngle& w, PlayerAngle* def);
|
friend FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngle& w, PlayerAngle* def);
|
||||||
|
|
||||||
|
// Prototypes for functions in gameinput.cpp.
|
||||||
|
void applyinput(float const avel, ESyncBits* actions, double const scaleAdjust = 1);
|
||||||
|
|
||||||
|
// Interpolation helpers.
|
||||||
void backup()
|
void backup()
|
||||||
{
|
{
|
||||||
oang = ang;
|
oang = ang;
|
||||||
olook_ang = look_ang;
|
olook_ang = look_ang;
|
||||||
orotscrnang = rotscrnang;
|
orotscrnang = rotscrnang;
|
||||||
}
|
}
|
||||||
|
|
||||||
void restore()
|
void restore()
|
||||||
{
|
{
|
||||||
ang = oang;
|
ang = oang;
|
||||||
|
@ -172,51 +133,31 @@ struct PlayerAngle
|
||||||
rotscrnang = orotscrnang;
|
rotscrnang = orotscrnang;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addadjustment(double value)
|
// Commonly used getters.
|
||||||
{
|
binangle osum() { return oang + olook_ang; }
|
||||||
__addadjustment(buildfang(value));
|
binangle sum() { return ang + look_ang; }
|
||||||
}
|
binangle interpolatedsum(double const smoothratio) { return interpolatedangle(osum(), sum(), smoothratio); }
|
||||||
|
binangle interpolatedlookang(double const smoothratio) { return interpolatedangle(olook_ang, look_ang, smoothratio); }
|
||||||
|
binangle interpolatedrotscrn(double const smoothratio) { return interpolatedangle(orotscrnang, rotscrnang, smoothratio); }
|
||||||
|
|
||||||
void addadjustment(binangle value)
|
// Ticrate playsim adjustment helpers.
|
||||||
{
|
void addadjustment(double value) { __addadjustment(buildfang(value)); }
|
||||||
__addadjustment(value);
|
void addadjustment(binangle value) { __addadjustment(value); }
|
||||||
}
|
void settarget(double value, bool backup = false) { __settarget(buildfang(value), backup); }
|
||||||
|
void settarget(binangle value, bool backup = false) { __settarget(value, backup); }
|
||||||
|
void resetadjustment() { adjustment = 0; }
|
||||||
|
bool targetset() { return target.asbam(); }
|
||||||
|
|
||||||
void resetadjustment()
|
// Input locking helpers.
|
||||||
{
|
void lockinput() { inputdisabled = true; }
|
||||||
adjustment = 0;
|
void unlockinput() { inputdisabled = false; }
|
||||||
}
|
bool movementlocked() { return target.asq16() || inputdisabled; }
|
||||||
|
|
||||||
void settarget(double value, bool backup = false)
|
// Draw code helpers.
|
||||||
{
|
double look_anghalf(double const smoothratio) { return (!SyncInput() ? look_ang : interpolatedlookang(smoothratio)).signedbuildf() * 0.5; }
|
||||||
__settarget(buildfang(value), backup);
|
double looking_arc(double const smoothratio) { return fabs((!SyncInput() ? look_ang : interpolatedlookang(smoothratio)).signedbuildf()) * (1. / 9.); }
|
||||||
}
|
|
||||||
|
|
||||||
void settarget(binangle value, bool backup = false)
|
|
||||||
{
|
|
||||||
__settarget(value, backup);
|
|
||||||
}
|
|
||||||
|
|
||||||
void lockinput()
|
|
||||||
{
|
|
||||||
inputdisabled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void unlockinput()
|
|
||||||
{
|
|
||||||
inputdisabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool targetset()
|
|
||||||
{
|
|
||||||
return target.asbam();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool movementlocked()
|
|
||||||
{
|
|
||||||
return target.asq16() || inputdisabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Ticrate playsim adjustment processor.
|
||||||
void processhelpers(double const scaleAdjust)
|
void processhelpers(double const scaleAdjust)
|
||||||
{
|
{
|
||||||
if (targetset())
|
if (targetset())
|
||||||
|
@ -239,43 +180,6 @@ struct PlayerAngle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
binangle osum()
|
|
||||||
{
|
|
||||||
return oang + olook_ang;
|
|
||||||
}
|
|
||||||
|
|
||||||
binangle sum()
|
|
||||||
{
|
|
||||||
return ang + look_ang;
|
|
||||||
}
|
|
||||||
|
|
||||||
binangle interpolatedsum(double const smoothratio)
|
|
||||||
{
|
|
||||||
return interpolatedangle(osum(), sum(), smoothratio);
|
|
||||||
}
|
|
||||||
|
|
||||||
binangle interpolatedlookang(double const smoothratio)
|
|
||||||
{
|
|
||||||
return interpolatedangle(olook_ang, look_ang, smoothratio);
|
|
||||||
}
|
|
||||||
|
|
||||||
binangle interpolatedrotscrn(double const smoothratio)
|
|
||||||
{
|
|
||||||
return interpolatedangle(orotscrnang, rotscrnang, smoothratio);
|
|
||||||
}
|
|
||||||
|
|
||||||
double look_anghalf(double const smoothratio)
|
|
||||||
{
|
|
||||||
return (!SyncInput() ? look_ang : interpolatedlookang(smoothratio)).signedbuildf() * 0.5; // Used within draw code for weapon and crosshair when looking left/right.
|
|
||||||
}
|
|
||||||
|
|
||||||
double looking_arc(double const smoothratio)
|
|
||||||
{
|
|
||||||
return fabs((!SyncInput() ? look_ang : interpolatedlookang(smoothratio)).signedbuildf()) * (1. / 9.); // Used within draw code for weapon and crosshair when looking left/right.
|
|
||||||
}
|
|
||||||
|
|
||||||
void applyinput(float const avel, ESyncBits* actions, double const scaleAdjust = 1);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
binangle target;
|
binangle target;
|
||||||
double adjustment;
|
double adjustment;
|
||||||
|
|
Loading…
Reference in a new issue