mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-06-03 02:11:21 +00:00
- implement proper GC handling for AActor::ViewPos.
This commit is contained in:
parent
4049a0d8f1
commit
27cba4c990
6 changed files with 13 additions and 12 deletions
src
|
@ -660,9 +660,9 @@ enum EViewPosFlags // [MC] Flags for SetViewPos.
|
||||||
VPSF_ABSOLUTEPOS = 1 << 2, // Use absolute position.
|
VPSF_ABSOLUTEPOS = 1 << 2, // Use absolute position.
|
||||||
};
|
};
|
||||||
|
|
||||||
class FViewPosition : public DObject
|
class DViewPosition : public DObject
|
||||||
{
|
{
|
||||||
DECLARE_CLASS(FViewPosition, DObject);
|
DECLARE_CLASS(DViewPosition, DObject);
|
||||||
public:
|
public:
|
||||||
// Variables
|
// Variables
|
||||||
// Exposed to ZScript
|
// Exposed to ZScript
|
||||||
|
@ -670,7 +670,7 @@ public:
|
||||||
int Flags;
|
int Flags;
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
FViewPosition()
|
DViewPosition()
|
||||||
{
|
{
|
||||||
Offset = { 0,0,0 };
|
Offset = { 0,0,0 };
|
||||||
Flags = 0;
|
Flags = 0;
|
||||||
|
@ -1011,7 +1011,7 @@ public:
|
||||||
DAngle SpriteRotation;
|
DAngle SpriteRotation;
|
||||||
DRotator Angles;
|
DRotator Angles;
|
||||||
DRotator ViewAngles; // Angle offsets for cameras
|
DRotator ViewAngles; // Angle offsets for cameras
|
||||||
FViewPosition *ViewPos; // Position offsets for cameras
|
TObjPtr<DViewPosition*> ViewPos; // Position offsets for cameras
|
||||||
DVector2 Scale; // Scaling values; 1 is normal size
|
DVector2 Scale; // Scaling values; 1 is normal size
|
||||||
double Alpha; // Since P_CheckSight makes an alpha check this can't be a float. It has to be a double.
|
double Alpha; // Since P_CheckSight makes an alpha check this can't be a float. It has to be a double.
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ struct secplane_t;
|
||||||
struct FCheckPosition;
|
struct FCheckPosition;
|
||||||
struct FTranslatedLineTarget;
|
struct FTranslatedLineTarget;
|
||||||
struct FLinePortal;
|
struct FLinePortal;
|
||||||
class FViewPosition;
|
class DViewPosition;
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
@ -394,7 +394,7 @@ void P_PlaySpawnSound(AActor *missile, AActor *spawner);
|
||||||
void P_AimCamera (AActor *t1, DVector3 &, DAngle &, sector_t *&sec, bool &unlinked);
|
void P_AimCamera (AActor *t1, DVector3 &, DAngle &, sector_t *&sec, bool &unlinked);
|
||||||
|
|
||||||
// [MC] Aiming for ViewPos
|
// [MC] Aiming for ViewPos
|
||||||
void P_AdjustViewPos(AActor *t1, DVector3 orig, DVector3 &, sector_t *&sec, bool &unlinked, FViewPosition *VP);
|
void P_AdjustViewPos(AActor *t1, DVector3 orig, DVector3 &, sector_t *&sec, bool &unlinked, DViewPosition *VP);
|
||||||
|
|
||||||
|
|
||||||
// [RH] Means of death
|
// [RH] Means of death
|
||||||
|
|
|
@ -5424,7 +5424,7 @@ void P_AimCamera(AActor *t1, DVector3 &campos, DAngle &camangle, sector_t *&Came
|
||||||
}
|
}
|
||||||
|
|
||||||
// [MC] Used for ViewPos. Uses code borrowed from P_AimCamera.
|
// [MC] Used for ViewPos. Uses code borrowed from P_AimCamera.
|
||||||
void P_AdjustViewPos(AActor *t1, DVector3 orig, DVector3 &campos, sector_t *&CameraSector, bool &unlinked, FViewPosition *VP)
|
void P_AdjustViewPos(AActor *t1, DVector3 orig, DVector3 &campos, sector_t *&CameraSector, bool &unlinked, DViewPosition *VP)
|
||||||
{
|
{
|
||||||
FTraceResults trace;
|
FTraceResults trace;
|
||||||
const DVector3 vvec = campos - orig;
|
const DVector3 vvec = campos - orig;
|
||||||
|
|
|
@ -171,6 +171,7 @@ IMPLEMENT_POINTERS_START(AActor)
|
||||||
IMPLEMENT_POINTER(master)
|
IMPLEMENT_POINTER(master)
|
||||||
IMPLEMENT_POINTER(Poisoner)
|
IMPLEMENT_POINTER(Poisoner)
|
||||||
IMPLEMENT_POINTER(alternative)
|
IMPLEMENT_POINTER(alternative)
|
||||||
|
IMPLEMENT_POINTER(ViewPos)
|
||||||
IMPLEMENT_POINTERS_END
|
IMPLEMENT_POINTERS_END
|
||||||
|
|
||||||
AActor::~AActor ()
|
AActor::~AActor ()
|
||||||
|
|
|
@ -793,7 +793,7 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor
|
||||||
// Handles offsetting the camera with ChaseCam and/or viewpos.
|
// Handles offsetting the camera with ChaseCam and/or viewpos.
|
||||||
{
|
{
|
||||||
AActor *mo = viewpoint.camera;
|
AActor *mo = viewpoint.camera;
|
||||||
FViewPosition *VP = mo->ViewPos;
|
DViewPosition *VP = mo->ViewPos;
|
||||||
const DVector3 orig = { mo->Pos().XY(), mo->player ? mo->player->viewz : mo->Z() + mo->GetCameraHeight() };
|
const DVector3 orig = { mo->Pos().XY(), mo->player ? mo->player->viewz : mo->Z() + mo->GetCameraHeight() };
|
||||||
viewpoint.ActorPos = orig;
|
viewpoint.ActorPos = orig;
|
||||||
|
|
||||||
|
|
|
@ -1821,7 +1821,7 @@ static void SetViewPos(AActor *self, double x, double y, double z, int flags)
|
||||||
{
|
{
|
||||||
if (!self->ViewPos)
|
if (!self->ViewPos)
|
||||||
{
|
{
|
||||||
self->ViewPos = Create<FViewPosition>();
|
self->ViewPos = Create<DViewPosition>();
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector3 pos = { x,y,z };
|
DVector3 pos = { x,y,z };
|
||||||
|
@ -1839,9 +1839,9 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, SetViewPos, SetViewPos)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
IMPLEMENT_CLASS(FViewPosition, false, false);
|
IMPLEMENT_CLASS(DViewPosition, false, false);
|
||||||
DEFINE_FIELD_X(ViewPosition, FViewPosition, Offset)
|
DEFINE_FIELD_X(ViewPosition, DViewPosition, Offset)
|
||||||
DEFINE_FIELD_X(ViewPosition, FViewPosition, Flags)
|
DEFINE_FIELD_X(ViewPosition, DViewPosition, Flags)
|
||||||
|
|
||||||
DEFINE_FIELD(DThinker, Level)
|
DEFINE_FIELD(DThinker, Level)
|
||||||
DEFINE_FIELD(AActor, snext)
|
DEFINE_FIELD(AActor, snext)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue