View Angles (Part 1 - Redux) (#1002)
* Added ViewAngle/Pitch/Roll properties to actors. - These are offsets for camera angles that allow turning the camera without affecting aim or movement direction. - Added A_SetView<Angle/Pitch/Roll>, which will set the view direction. - Added ABSVIEWANGLES flag, used to make the view absolute instead of an offset. * Converted functions to be direct-native.
This commit is contained in:
parent
c57e669044
commit
eaba63e13b
10 changed files with 203 additions and 35 deletions
|
|
@ -362,6 +362,7 @@ void AActor::Serialize(FSerializer &arc)
|
|||
A("renderhidden", RenderHidden)
|
||||
A("renderrequired", RenderRequired)
|
||||
A("friendlyseeblocks", friendlyseeblocks)
|
||||
A("viewangles", ViewAngles)
|
||||
A("spawntime", SpawnTime)
|
||||
A("spawnorder", SpawnOrder)
|
||||
A("friction", Friction)
|
||||
|
|
@ -3352,52 +3353,106 @@ DEFINE_ACTION_FUNCTION(AActor, SetShade)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void AActor::SetPitch(DAngle p, bool interpolate, bool forceclamp)
|
||||
{
|
||||
if (player != NULL || forceclamp)
|
||||
{ // clamp the pitch we set
|
||||
DAngle min, max;
|
||||
// [MC] Helper function for Set(View)Pitch.
|
||||
DAngle AActor::ClampPitch(DAngle p)
|
||||
{
|
||||
// clamp the pitch we set
|
||||
DAngle min, max;
|
||||
|
||||
if (player != NULL)
|
||||
{
|
||||
min = player->MinPitch;
|
||||
max = player->MaxPitch;
|
||||
}
|
||||
else
|
||||
{
|
||||
min = -89.;
|
||||
max = 89.;
|
||||
}
|
||||
p = clamp(p, min, max);
|
||||
if (player != nullptr)
|
||||
{
|
||||
min = player->MinPitch;
|
||||
max = player->MaxPitch;
|
||||
}
|
||||
else
|
||||
{
|
||||
min = -89.;
|
||||
max = 89.;
|
||||
}
|
||||
p = clamp(p, min, max);
|
||||
return p;
|
||||
}
|
||||
|
||||
void AActor::SetPitch(DAngle p, int fflags)
|
||||
{
|
||||
if (player != nullptr || (fflags & SPF_FORCECLAMP))
|
||||
{
|
||||
p = ClampPitch(p);
|
||||
}
|
||||
|
||||
if (p != Angles.Pitch)
|
||||
{
|
||||
Angles.Pitch = p;
|
||||
if (player != NULL && interpolate)
|
||||
if (player != nullptr && (fflags & SPF_INTERPOLATE))
|
||||
{
|
||||
player->cheats |= CF_INTERPVIEW;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void AActor::SetAngle(DAngle ang, bool interpolate)
|
||||
void AActor::SetAngle(DAngle ang, int fflags)
|
||||
{
|
||||
if (ang != Angles.Yaw)
|
||||
{
|
||||
Angles.Yaw = ang;
|
||||
if (player != NULL && interpolate)
|
||||
if (player != nullptr && (fflags & SPF_INTERPOLATE))
|
||||
{
|
||||
player->cheats |= CF_INTERPVIEW;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void AActor::SetRoll(DAngle r, int fflags)
|
||||
{
|
||||
if (r != Angles.Roll)
|
||||
{
|
||||
Angles.Roll = r;
|
||||
if (player != nullptr && (fflags & SPF_INTERPOLATE))
|
||||
{
|
||||
player->cheats |= CF_INTERPVIEW;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AActor::SetRoll(DAngle r, bool interpolate)
|
||||
void AActor::SetViewPitch(DAngle p, int fflags)
|
||||
{
|
||||
if (r != Angles.Roll)
|
||||
if (player != NULL || (fflags & SPF_FORCECLAMP))
|
||||
{
|
||||
Angles.Roll = r;
|
||||
if (player != NULL && interpolate)
|
||||
p = ClampPitch(p);
|
||||
}
|
||||
|
||||
if (p != ViewAngles.Pitch)
|
||||
{
|
||||
ViewAngles.Pitch = p;
|
||||
if (player != nullptr && (fflags & SPF_INTERPOLATE))
|
||||
{
|
||||
player->cheats |= CF_INTERPVIEW;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void AActor::SetViewAngle(DAngle ang, int fflags)
|
||||
{
|
||||
if (ang != ViewAngles.Yaw)
|
||||
{
|
||||
ViewAngles.Yaw = ang;
|
||||
if (player != nullptr && (fflags & SPF_INTERPOLATE))
|
||||
{
|
||||
player->cheats |= CF_INTERPVIEW;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void AActor::SetViewRoll(DAngle r, int fflags)
|
||||
{
|
||||
if (r != ViewAngles.Roll)
|
||||
{
|
||||
ViewAngles.Roll = r;
|
||||
if (player != nullptr && (fflags & SPF_INTERPOLATE))
|
||||
{
|
||||
player->cheats |= CF_INTERPVIEW;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue