mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-29 13:00:43 +00:00
- Duke: Fix security cameras skewing over time.
* Fixes regression from e1ee9bc83c
. +='ing the angle by 16 gave a noticeable hiccup, but was keeping the poor math before in-check so the angle didn't drift.
* Using more temp data fields in hittype, properly define a min/max using the initial camera angle and the hitag which is conveniently the camera's viewing arc.
This commit is contained in:
parent
5784ff6ef7
commit
ce7af5fe0e
1 changed files with 34 additions and 9 deletions
|
@ -1981,7 +1981,6 @@ void camera(int i)
|
|||
auto t = &hittype[i].temp_data[0];
|
||||
if (t[0] == 0)
|
||||
{
|
||||
t[1] += 8;
|
||||
if (camerashitable)
|
||||
{
|
||||
int j = fi.ifhitbyweapon(i);
|
||||
|
@ -1995,21 +1994,47 @@ void camera(int i)
|
|||
}
|
||||
}
|
||||
|
||||
// backup current angle for interpolating camera angle.
|
||||
hittype[i].tempang = s->ang;
|
||||
|
||||
if (s->hitag > 0)
|
||||
{
|
||||
if (t[1] < s->hitag)
|
||||
s->ang += 8;
|
||||
else if (t[1] < (s->hitag * 3))
|
||||
s->ang -= 8;
|
||||
else if (t[1] < (s->hitag << 2))
|
||||
s->ang += 8;
|
||||
else
|
||||
// set up camera if already not.
|
||||
if (t[4] != 1)
|
||||
{
|
||||
// set amount to adjust camera angle every tic.
|
||||
t[1] = 8;
|
||||
s->ang += 8;
|
||||
|
||||
// set min/max camera angles respectively. hitag is used as a viewing arc -/+ the initial camera angle.
|
||||
t[2] = s->ang - s->hitag - t[1];
|
||||
t[3] = s->ang + s->hitag - t[1];
|
||||
|
||||
// flag that we've set up the camera.
|
||||
t[4] = 1;
|
||||
}
|
||||
|
||||
// if already at min/max, invert the adjustment, add it and return.
|
||||
if (s->ang == t[2] || s->ang == t[3])
|
||||
{
|
||||
t[1] = -t[1];
|
||||
s->ang += t[1];
|
||||
return;
|
||||
}
|
||||
|
||||
// if we're below the min or above the max, just return either.
|
||||
if (s->ang + t[1] < t[2])
|
||||
{
|
||||
s->ang = t[2];
|
||||
return;
|
||||
}
|
||||
if (s->ang + t[1] > t[3])
|
||||
{
|
||||
s->ang = t[3];
|
||||
return;
|
||||
}
|
||||
|
||||
// if we're within range, increment ang with adjustment.
|
||||
s->ang += t[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue