mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-04-17 15:30:59 +00:00
Replaced SPF_VIEW with A_SetView<Angle/Pitch/Roll>.
This commit is contained in:
parent
d99098fb9a
commit
636d822da7
6 changed files with 158 additions and 63 deletions
|
@ -841,9 +841,13 @@ public:
|
|||
}
|
||||
|
||||
// These also set CF_INTERPVIEW for players.
|
||||
DAngle ClampPitch(DAngle p);
|
||||
void SetPitch(DAngle p, int fflags);
|
||||
void SetAngle(DAngle ang, int fflags);
|
||||
void SetRoll(DAngle roll, int fflags);
|
||||
void SetViewPitch(DAngle p, int fflags);
|
||||
void SetViewAngle(DAngle ang, int fflags);
|
||||
void SetViewRoll(DAngle roll, int fflags);
|
||||
|
||||
PClassActor *GetBloodType(int type = 0) const;
|
||||
|
||||
|
|
|
@ -2855,6 +2855,76 @@ DEFINE_ACTION_FUNCTION(AActor, A_SetRoll)
|
|||
return 0;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// A_SetViewAngle
|
||||
//
|
||||
// Set actor's viewangle (in degrees).
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
DEFINE_ACTION_FUNCTION(AActor, A_SetViewAngle)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
PARAM_FLOAT(angle);
|
||||
PARAM_INT(flags);
|
||||
PARAM_INT(ptr);
|
||||
|
||||
AActor *ref = COPY_AAPTR(self, ptr);
|
||||
if (ref != NULL)
|
||||
{
|
||||
ref->SetViewAngle(angle, flags);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// A_SetViewPitch
|
||||
//
|
||||
// Set actor's viewpitch (in degrees).
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
DEFINE_ACTION_FUNCTION(AActor, A_SetViewPitch)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
PARAM_FLOAT(pitch);
|
||||
PARAM_INT(flags);
|
||||
PARAM_INT(ptr);
|
||||
|
||||
AActor *ref = COPY_AAPTR(self, ptr);
|
||||
|
||||
if (ref != NULL)
|
||||
{
|
||||
ref->SetViewPitch(pitch, flags);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// [MC] A_SetViewRoll
|
||||
//
|
||||
// Set actor's viewroll (in degrees).
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
DEFINE_ACTION_FUNCTION(AActor, A_SetViewRoll)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
PARAM_FLOAT(roll);
|
||||
PARAM_INT(flags);
|
||||
PARAM_INT(ptr);
|
||||
AActor *ref = COPY_AAPTR(self, ptr);
|
||||
|
||||
if (ref != NULL)
|
||||
{
|
||||
ref->SetViewRoll(roll, flags);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// A_SetUserVar
|
||||
|
|
|
@ -221,7 +221,6 @@ enum SPF
|
|||
{
|
||||
SPF_FORCECLAMP = 1, // players always clamp
|
||||
SPF_INTERPOLATE = 2,
|
||||
SPF_VIEW = 4,
|
||||
};
|
||||
|
||||
enum PCM
|
||||
|
|
|
@ -3350,89 +3350,109 @@ DEFINE_ACTION_FUNCTION(AActor, SetShade)
|
|||
return 0;
|
||||
}
|
||||
|
||||
// [MC] Helper function for Set(View)Pitch.
|
||||
DAngle AActor::ClampPitch(DAngle p)
|
||||
{
|
||||
// clamp the pitch we set
|
||||
DAngle 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 != NULL || fflags & SPF_FORCECLAMP)
|
||||
{ // 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);
|
||||
}
|
||||
|
||||
bool view = (fflags & SPF_VIEW);
|
||||
bool changed = false;
|
||||
if (view)
|
||||
if (player != nullptr || (fflags & SPF_FORCECLAMP))
|
||||
{
|
||||
if (p != ViewAngles.Pitch)
|
||||
{
|
||||
ViewAngles.Pitch = p;
|
||||
changed = true;
|
||||
}
|
||||
p = ClampPitch(p);
|
||||
}
|
||||
else if (p != Angles.Pitch)
|
||||
|
||||
if (p != Angles.Pitch)
|
||||
{
|
||||
Angles.Pitch = p;
|
||||
changed = true;
|
||||
}
|
||||
if (changed && player != nullptr && (fflags & SPF_INTERPOLATE))
|
||||
{
|
||||
player->cheats |= CF_INTERPVIEW;
|
||||
if (player != nullptr && (fflags & SPF_INTERPOLATE))
|
||||
{
|
||||
player->cheats |= CF_INTERPVIEW;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void AActor::SetAngle(DAngle ang, int fflags)
|
||||
{
|
||||
bool view = (fflags & SPF_VIEW);
|
||||
bool changed = false;
|
||||
if (view)
|
||||
{
|
||||
if (ang != ViewAngles.Yaw)
|
||||
{
|
||||
ViewAngles.Yaw = ang;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
else if (ang != Angles.Yaw)
|
||||
if (ang != Angles.Yaw)
|
||||
{
|
||||
Angles.Yaw = ang;
|
||||
changed = true;
|
||||
}
|
||||
if (changed && player != nullptr && (fflags & SPF_INTERPOLATE))
|
||||
{
|
||||
player->cheats |= CF_INTERPVIEW;
|
||||
if (player != nullptr && (fflags & SPF_INTERPOLATE))
|
||||
{
|
||||
player->cheats |= CF_INTERPVIEW;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void AActor::SetRoll(DAngle r, int fflags)
|
||||
{
|
||||
bool view = (fflags & SPF_VIEW);
|
||||
bool changed = false;
|
||||
if (view)
|
||||
{
|
||||
if (r != ViewAngles.Roll)
|
||||
{
|
||||
ViewAngles.Roll = r;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
else if (r != Angles.Roll)
|
||||
if (r != Angles.Roll)
|
||||
{
|
||||
Angles.Roll = r;
|
||||
changed = true;
|
||||
if (player != nullptr && (fflags & SPF_INTERPOLATE))
|
||||
{
|
||||
player->cheats |= CF_INTERPVIEW;
|
||||
}
|
||||
}
|
||||
if (changed && player != nullptr && (fflags & SPF_INTERPOLATE))
|
||||
}
|
||||
|
||||
void AActor::SetViewPitch(DAngle p, int fflags)
|
||||
{
|
||||
if (player != NULL || (fflags & SPF_FORCECLAMP))
|
||||
{
|
||||
player->cheats |= CF_INTERPVIEW;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1120,6 +1120,9 @@ class Actor : Thinker native
|
|||
native void A_SetAngle(double angle = 0, int flags = 0, int ptr = AAPTR_DEFAULT);
|
||||
native void A_SetPitch(double pitch, int flags = 0, int ptr = AAPTR_DEFAULT);
|
||||
native void A_SetRoll(double roll, int flags = 0, int ptr = AAPTR_DEFAULT);
|
||||
native void A_SetViewAngle(double angle = 0, int flags = 0, int ptr = AAPTR_DEFAULT);
|
||||
native void A_SetViewPitch(double pitch, int flags = 0, int ptr = AAPTR_DEFAULT);
|
||||
native void A_SetViewRoll(double roll, int flags = 0, int ptr = AAPTR_DEFAULT);
|
||||
deprecated("2.3") native void A_SetUserVar(name varname, int value);
|
||||
deprecated("2.3") native void A_SetUserArray(name varname, int index, int value);
|
||||
deprecated("2.3") native void A_SetUserVarFloat(name varname, double value);
|
||||
|
|
|
@ -547,7 +547,6 @@ enum EAngleFlags
|
|||
{
|
||||
SPF_FORCECLAMP = 1,
|
||||
SPF_INTERPOLATE = 2,
|
||||
SPF_VIEW = 4,
|
||||
};
|
||||
|
||||
// flags for A_CheckLOF
|
||||
|
|
Loading…
Reference in a new issue