mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 17:01:51 +00:00
- gameinput.h: Add initial structure for PlayerPosition
as companion to PlayerAngle
and PlayerHorizon
structs.
This commit is contained in:
parent
7ee4f49649
commit
15c4d38694
2 changed files with 50 additions and 0 deletions
|
@ -484,3 +484,17 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerHorizon& w,
|
|||
}
|
||||
return arc;
|
||||
}
|
||||
|
||||
FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerPosition& w, PlayerPosition* def)
|
||||
{
|
||||
if (arc.BeginObject(keyname))
|
||||
{
|
||||
arc("pos", w.pos).EndObject();
|
||||
|
||||
if (arc.isReading())
|
||||
{
|
||||
w.opos = w.pos;
|
||||
}
|
||||
}
|
||||
return arc;
|
||||
}
|
||||
|
|
|
@ -212,9 +212,45 @@ private:
|
|||
}
|
||||
};
|
||||
|
||||
struct PlayerPosition
|
||||
{
|
||||
vec3_t pos, opos;
|
||||
|
||||
// Interpolation helpers.
|
||||
void backupx() { opos.x = pos.x; }
|
||||
void backupy() { opos.y = pos.y; }
|
||||
void backupz() { opos.z = pos.z; }
|
||||
void backuppos() { opos = pos; }
|
||||
|
||||
// Interpolated points.
|
||||
int32_t interpolatedx(double const smoothratio, int const scale = 16) { return interpolatedvalue(opos.x, pos.x, smoothratio, scale); }
|
||||
int32_t interpolatedy(double const smoothratio, int const scale = 16) { return interpolatedvalue(opos.y, pos.y, smoothratio, scale); }
|
||||
int32_t interpolatedz(double const smoothratio, int const scale = 16) { return interpolatedvalue(opos.z, pos.z, smoothratio, scale); }
|
||||
|
||||
// Interpolated vectors.
|
||||
vec2_t interpolatedvec2(double const smoothratio, int const scale = 16)
|
||||
{
|
||||
return
|
||||
{
|
||||
interpolatedx(smoothratio, scale),
|
||||
interpolatedy(smoothratio, scale)
|
||||
};
|
||||
}
|
||||
vec3_t interpolatedvec3(double const smoothratio, int const scale = 16)
|
||||
{
|
||||
return
|
||||
{
|
||||
interpolatedx(smoothratio, scale),
|
||||
interpolatedy(smoothratio, scale),
|
||||
interpolatedz(smoothratio, scale)
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
class FSerializer;
|
||||
FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngle& w, PlayerAngle* def);
|
||||
FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerHorizon& w, PlayerHorizon* def);
|
||||
FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerPosition& w, PlayerPosition* def);
|
||||
|
||||
|
||||
void updateTurnHeldAmt(double const scaleAdjust);
|
||||
|
|
Loading…
Reference in a new issue