Added A_SetViewPos(Vector3 Offset, int Flags = -1)

- Offset: The offset from the actor's view to move the camera about.
 - Flags: (Default is -1, which means don't change flags)
  - VPSF_ABSOLUTEOFFSET: Don't include actor angles in calculation.
  - VPSF_ABSOLUTEPOS: Position is absolute, and disables all transformations. Modders are responsible for being portal aware!

Notes:
- `ViewPos` in Actor will be `null` until A_SetViewPos is called for the first time.

**Issues:**
- Hiding sprite while in portal incomplete.
This commit is contained in:
Major Cooke 2021-12-05 13:51:47 -06:00 committed by Rachael Alexanderson
commit 4e8d59951b
10 changed files with 283 additions and 29 deletions

View file

@ -1770,7 +1770,6 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, isFrozen, isFrozen)
ACTION_RETURN_BOOL(isFrozen(self));
}
//===========================================================================
//
// PlayerPawn functions
@ -1796,7 +1795,31 @@ DEFINE_ACTION_FUNCTION_NATIVE(APlayerPawn, GetPrintableDisplayName, GetPrintable
ACTION_RETURN_STRING(type->GetDisplayName());
}
static void SetViewPos(AActor *self, double x, double y, double z, int flags)
{
if (!self->ViewPos)
{
self->ViewPos = Create<FViewPosition>();
}
DVector3 pos = { x,y,z };
self->ViewPos->Set(pos, flags);
}
DEFINE_ACTION_FUNCTION_NATIVE(AActor, SetViewPos, SetViewPos)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_FLOAT(x);
PARAM_FLOAT(y);
PARAM_FLOAT(z);
PARAM_INT(flags);
SetViewPos(self, x, y, z, flags);
return 0;
}
IMPLEMENT_CLASS(FViewPosition, false, false);
DEFINE_FIELD_X(ViewPosition, FViewPosition, Offset)
DEFINE_FIELD_X(ViewPosition, FViewPosition, Flags)
DEFINE_FIELD(DThinker, Level)
DEFINE_FIELD(AActor, snext)
@ -1975,6 +1998,7 @@ DEFINE_FIELD(AActor, friendlyseeblocks)
DEFINE_FIELD(AActor, SpawnTime)
DEFINE_FIELD(AActor, InventoryID)
DEFINE_FIELD(AActor, ThruBits)
DEFINE_FIELD(AActor, ViewPos)
DEFINE_FIELD_NAMED(AActor, ViewAngles.Yaw, viewangle)
DEFINE_FIELD_NAMED(AActor, ViewAngles.Pitch, viewpitch)
DEFINE_FIELD_NAMED(AActor, ViewAngles.Roll, viewroll)