mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-16 09:31:14 +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
285791622d
commit
ae49f6138e
1 changed files with 38 additions and 20 deletions
|
@ -2896,44 +2896,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);
|
||||
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;
|
||||
else movepos = campos + movement.Resized(movespeed);
|
||||
|
||||
DAngle targetangle = floatvalue(t_argv[4]);
|
||||
DAngle anglespeed = floatvalue(t_argv[5]);
|
||||
|
||||
if (movespeed > 0 && anglespeed == 0.)
|
||||
{
|
||||
if (!finished)
|
||||
{
|
||||
const DAngle diffangle = targetangle - cam->Angles.Yaw;
|
||||
targetangle = cam->Angles.Yaw + diffangle * movespeed / movelen;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
targetangle = cam->Angles.Yaw + anglespeed;
|
||||
}
|
||||
bool finishedmove = false;
|
||||
bool finishedangle = false;
|
||||
|
||||
cam->radius = 1 / 8192.;
|
||||
cam->Height = 1 / 8192.;
|
||||
|
||||
if (campos != targpos)
|
||||
{
|
||||
DVector3 movepos;
|
||||
finishedmove = (movespeed >= movelen);
|
||||
if (finishedmove) movepos = targpos;
|
||||
else movepos = campos + movement.Resized(movespeed);
|
||||
cam->SetOrigin(movepos, true);
|
||||
cam->SetAngle(targetangle, false);
|
||||
t_return.value.i = 1;
|
||||
}
|
||||
|
||||
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 (!finishedmove)
|
||||
{
|
||||
anglenow = cam->Angles.Yaw + diffangle * movespeed / movelen;
|
||||
}
|
||||
else finishedangle = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
t_return.value.i = 0;
|
||||
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->SetAngle(anglenow, false);
|
||||
}
|
||||
t_return.value.i = !(finishedmove & finishedangle);
|
||||
t_return.type = svt_int;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue