mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-10 23:01:59 +00:00
- fixed FraggleScript's moving camera.
The logic here was a bit more complicated than I assumed but it was all buried in a heap of code that tried to deal with angular wraparounds in the BAM format.
This commit is contained in:
parent
c33f358894
commit
57ed4df85e
1 changed files with 38 additions and 20 deletions
|
@ -2885,44 +2885,62 @@ void FParser::SF_MoveCamera(void)
|
|||
}
|
||||
|
||||
double targetheight = floatvalue(t_argv[2]);
|
||||
double movespeed = floatvalue(t_argv[3]);
|
||||
DVector3 campos = cam->Pos();
|
||||
DVector3 targpos = DVector3(target->Pos(), targetheight);
|
||||
DVector3 movement = targpos - campos;
|
||||
double movelen = movement.Length();
|
||||
|
||||
bool finishedmove = false;
|
||||
bool finishedangle = false;
|
||||
|
||||
cam->radius = 1 / 8192.;
|
||||
cam->Height = 1 / 8192.;
|
||||
|
||||
if (campos != targpos)
|
||||
{
|
||||
DVector3 movement = targpos - campos;
|
||||
double movelen = movement.Length();
|
||||
double movespeed = floatvalue(t_argv[3]);
|
||||
DVector3 movepos;
|
||||
bool finished = (movespeed >= movelen);
|
||||
if (finished) movepos = targpos;
|
||||
finishedmove = (movespeed >= movelen);
|
||||
if (finishedmove) movepos = targpos;
|
||||
else movepos = campos + movement.Resized(movespeed);
|
||||
cam->SetOrigin(movepos, true);
|
||||
}
|
||||
|
||||
DAngle targetangle = floatvalue(t_argv[4]);
|
||||
DAngle targetangle = DAngle(floatvalue(t_argv[4])).Normalized360();
|
||||
if (cam->Angles.Yaw != targetangle)
|
||||
{
|
||||
DAngle anglespeed = floatvalue(t_argv[5]);
|
||||
DAngle anglenow = targetangle;
|
||||
const DAngle diffangle = deltaangle(cam->Angles.Yaw, targetangle);
|
||||
|
||||
if (movespeed > 0 && anglespeed == 0.)
|
||||
{
|
||||
if (!finished)
|
||||
if (!finishedmove)
|
||||
{
|
||||
const DAngle diffangle = targetangle - cam->Angles.Yaw;
|
||||
targetangle = cam->Angles.Yaw + diffangle * movespeed / movelen;
|
||||
anglenow = cam->Angles.Yaw + diffangle * movespeed / movelen;
|
||||
}
|
||||
else finishedangle = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
targetangle = cam->Angles.Yaw + anglespeed;
|
||||
if (diffangle > 0)
|
||||
{
|
||||
anglenow = (cam->Angles.Yaw + anglespeed).Normalized360();
|
||||
}
|
||||
else
|
||||
{
|
||||
anglenow = (cam->Angles.Yaw - anglespeed).Normalized360();
|
||||
}
|
||||
const DAngle diffangle2 = deltaangle(anglenow, targetangle);
|
||||
if (diffangle.Degrees * diffangle2.Degrees <= 0)
|
||||
{
|
||||
anglenow = targetangle;
|
||||
finishedangle = true;
|
||||
}
|
||||
}
|
||||
|
||||
cam->radius = 1 / 8192.;
|
||||
cam->Height = 1 / 8192.;
|
||||
cam->SetOrigin(movepos, true);
|
||||
cam->SetAngle(targetangle, false);
|
||||
t_return.value.i = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
t_return.value.i = 0;
|
||||
cam->SetAngle(anglenow, false);
|
||||
}
|
||||
t_return.value.i = !(finishedmove & finishedangle);
|
||||
t_return.type = svt_int;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue