mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-02-22 20:11:14 +00:00
move visual thinker definition into its own header
This commit is contained in:
parent
3622e2bb2a
commit
174344ddf1
9 changed files with 80 additions and 64 deletions
|
@ -46,6 +46,8 @@
|
||||||
#include "symbols.h"
|
#include "symbols.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
|
#include "p_visualthinker.h"
|
||||||
|
|
||||||
// MACROS ------------------------------------------------------------------
|
// MACROS ------------------------------------------------------------------
|
||||||
|
|
||||||
// TYPES -------------------------------------------------------------------
|
// TYPES -------------------------------------------------------------------
|
||||||
|
@ -421,7 +423,7 @@ PClass *PClass::FindClass (FName zaname)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
DObject *PClass::CreateNew()
|
DObject *PClass::CreateNew(int *statnum)
|
||||||
{
|
{
|
||||||
uint8_t *mem = (uint8_t *)M_Malloc (Size);
|
uint8_t *mem = (uint8_t *)M_Malloc (Size);
|
||||||
assert (mem != nullptr);
|
assert (mem != nullptr);
|
||||||
|
@ -444,6 +446,12 @@ DObject *PClass::CreateNew()
|
||||||
|
|
||||||
((DObject *)mem)->SetClass (const_cast<PClass *>(this));
|
((DObject *)mem)->SetClass (const_cast<PClass *>(this));
|
||||||
InitializeSpecials(mem, Defaults, &PClass::SpecialInits);
|
InitializeSpecials(mem, Defaults, &PClass::SpecialInits);
|
||||||
|
|
||||||
|
if(statnum && ((DObject *)mem)->IsKindOf(RUNTIME_CLASS(DVisualThinker)))
|
||||||
|
{
|
||||||
|
*statnum = STAT_VISUALTHINKER;
|
||||||
|
}
|
||||||
|
|
||||||
return (DObject *)mem;
|
return (DObject *)mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ public:
|
||||||
PClass();
|
PClass();
|
||||||
~PClass();
|
~PClass();
|
||||||
void InsertIntoHash(bool native);
|
void InsertIntoHash(bool native);
|
||||||
DObject *CreateNew();
|
DObject *CreateNew(int *statnum = nullptr);
|
||||||
PClass *CreateDerivedClass(FName name, unsigned int size, bool *newlycreated = nullptr, int fileno = 0);
|
PClass *CreateDerivedClass(FName name, unsigned int size, bool *newlycreated = nullptr, int fileno = 0);
|
||||||
|
|
||||||
void InitializeActorInfo();
|
void InitializeActorInfo();
|
||||||
|
|
|
@ -425,11 +425,9 @@ public:
|
||||||
|
|
||||||
DThinker *CreateThinker(PClass *cls, int statnum = STAT_DEFAULT)
|
DThinker *CreateThinker(PClass *cls, int statnum = STAT_DEFAULT)
|
||||||
{
|
{
|
||||||
DThinker *thinker = static_cast<DThinker*>(cls->CreateNew());
|
DThinker *thinker = static_cast<DThinker*>(cls->CreateNew(&statnum));
|
||||||
assert(thinker->IsKindOf(RUNTIME_CLASS(DThinker)));
|
assert(thinker->IsKindOf(RUNTIME_CLASS(DThinker)));
|
||||||
thinker->ObjectFlags |= OF_JustSpawned;
|
thinker->ObjectFlags |= OF_JustSpawned;
|
||||||
if (thinker->IsKindOf(RUNTIME_CLASS(DVisualThinker))) // [MC] This absolutely must happen for this class!
|
|
||||||
statnum = STAT_VISUALTHINKER;
|
|
||||||
Thinkers.Link(thinker, statnum);
|
Thinkers.Link(thinker, statnum);
|
||||||
thinker->Level = this;
|
thinker->Level = this;
|
||||||
return thinker;
|
return thinker;
|
||||||
|
|
|
@ -46,6 +46,8 @@
|
||||||
#include "g_cvars.h"
|
#include "g_cvars.h"
|
||||||
#include "d_main.h"
|
#include "d_main.h"
|
||||||
|
|
||||||
|
#include "p_visualthinker.h"
|
||||||
|
|
||||||
static int ThinkCount;
|
static int ThinkCount;
|
||||||
static cycle_t ThinkCycles;
|
static cycle_t ThinkCycles;
|
||||||
extern cycle_t BotSupportCycles;
|
extern cycle_t BotSupportCycles;
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
#include "actorinlines.h"
|
#include "actorinlines.h"
|
||||||
#include "g_game.h"
|
#include "g_game.h"
|
||||||
#include "serializer_doom.h"
|
#include "serializer_doom.h"
|
||||||
|
#include "p_visualthinker.h"
|
||||||
|
|
||||||
#include "hwrenderer/scene/hw_drawstructs.h"
|
#include "hwrenderer/scene/hw_drawstructs.h"
|
||||||
|
|
||||||
|
|
|
@ -148,61 +148,3 @@ void P_DrawRailTrail(AActor *source, TArray<SPortalHit> &portalhits, int color1,
|
||||||
void P_DrawSplash (FLevelLocals *Level, int count, const DVector3 &pos, DAngle angle, int kind);
|
void P_DrawSplash (FLevelLocals *Level, int count, const DVector3 &pos, DAngle angle, int kind);
|
||||||
void P_DrawSplash2 (FLevelLocals *Level, int count, const DVector3 &pos, DAngle angle, int updown, int kind);
|
void P_DrawSplash2 (FLevelLocals *Level, int count, const DVector3 &pos, DAngle angle, int updown, int kind);
|
||||||
void P_DisconnectEffect (AActor *actor);
|
void P_DisconnectEffect (AActor *actor);
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
// VisualThinkers
|
|
||||||
// by Major Cooke
|
|
||||||
// Credit to phantombeta, RicardoLuis0 & RaveYard for aid
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
class HWSprite;
|
|
||||||
struct FTranslationID;
|
|
||||||
|
|
||||||
enum EVisualThinkerFlags
|
|
||||||
{
|
|
||||||
VTF_FlipOffsetX = 1 << 0,
|
|
||||||
VTF_FlipOffsetY = 1 << 1,
|
|
||||||
VTF_FlipX = 1 << 2,
|
|
||||||
VTF_FlipY = 1 << 3, // flip the sprite on the x/y axis.
|
|
||||||
VTF_DontInterpolate = 1 << 4, // disable all interpolation
|
|
||||||
VTF_AddLightLevel = 1 << 5, // adds sector light level to 'LightLevel'
|
|
||||||
};
|
|
||||||
|
|
||||||
class DVisualThinker : public DThinker
|
|
||||||
{
|
|
||||||
DECLARE_CLASS(DVisualThinker, DThinker);
|
|
||||||
public:
|
|
||||||
DVector3 Prev;
|
|
||||||
DVector2 Scale,
|
|
||||||
Offset;
|
|
||||||
float PrevRoll;
|
|
||||||
int16_t LightLevel;
|
|
||||||
FTranslationID Translation;
|
|
||||||
FTextureID AnimatedTexture;
|
|
||||||
sector_t *cursector;
|
|
||||||
|
|
||||||
int flags;
|
|
||||||
|
|
||||||
// internal only variables
|
|
||||||
particle_t PT;
|
|
||||||
HWSprite *spr; //in an effort to cache the result.
|
|
||||||
|
|
||||||
DVisualThinker();
|
|
||||||
void Construct();
|
|
||||||
void OnDestroy() override;
|
|
||||||
|
|
||||||
static DVisualThinker* NewVisualThinker(FLevelLocals* Level, PClass* type);
|
|
||||||
void SetTranslation(FName trname);
|
|
||||||
int GetRenderStyle();
|
|
||||||
bool isFrozen();
|
|
||||||
int GetLightLevel(sector_t *rendersector) const;
|
|
||||||
FVector3 InterpolatedPosition(double ticFrac) const;
|
|
||||||
float InterpolatedRoll(double ticFrac) const;
|
|
||||||
|
|
||||||
void Tick() override;
|
|
||||||
void UpdateSpriteInfo();
|
|
||||||
void Serialize(FSerializer& arc) override;
|
|
||||||
|
|
||||||
float GetOffset(bool y) const;
|
|
||||||
};
|
|
61
src/playsim/p_visualthinker.h
Normal file
61
src/playsim/p_visualthinker.h
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "palettecontainer.h"
|
||||||
|
#include "hwrenderer/scene/hw_drawstructs.h"
|
||||||
|
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// VisualThinkers
|
||||||
|
// by Major Cooke
|
||||||
|
// Credit to phantombeta, RicardoLuis0 & RaveYard for aid
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
enum EVisualThinkerFlags
|
||||||
|
{
|
||||||
|
VTF_FlipOffsetX = 1 << 0,
|
||||||
|
VTF_FlipOffsetY = 1 << 1,
|
||||||
|
VTF_FlipX = 1 << 2,
|
||||||
|
VTF_FlipY = 1 << 3, // flip the sprite on the x/y axis.
|
||||||
|
VTF_DontInterpolate = 1 << 4, // disable all interpolation
|
||||||
|
VTF_AddLightLevel = 1 << 5, // adds sector light level to 'LightLevel'
|
||||||
|
};
|
||||||
|
|
||||||
|
class DVisualThinker : public DThinker
|
||||||
|
{
|
||||||
|
DECLARE_CLASS(DVisualThinker, DThinker);
|
||||||
|
public:
|
||||||
|
DVector3 Prev;
|
||||||
|
DVector2 Scale,
|
||||||
|
Offset;
|
||||||
|
float PrevRoll;
|
||||||
|
int16_t LightLevel;
|
||||||
|
FTranslationID Translation;
|
||||||
|
FTextureID AnimatedTexture;
|
||||||
|
sector_t *cursector;
|
||||||
|
|
||||||
|
int flags;
|
||||||
|
|
||||||
|
// internal only variables
|
||||||
|
particle_t PT;
|
||||||
|
HWSprite *spr; //in an effort to cache the result.
|
||||||
|
|
||||||
|
DVisualThinker();
|
||||||
|
void Construct();
|
||||||
|
void OnDestroy() override;
|
||||||
|
|
||||||
|
static DVisualThinker* NewVisualThinker(FLevelLocals* Level, PClass* type);
|
||||||
|
void SetTranslation(FName trname);
|
||||||
|
int GetRenderStyle();
|
||||||
|
bool isFrozen();
|
||||||
|
int GetLightLevel(sector_t *rendersector) const;
|
||||||
|
FVector3 InterpolatedPosition(double ticFrac) const;
|
||||||
|
float InterpolatedRoll(double ticFrac) const;
|
||||||
|
|
||||||
|
void Tick() override;
|
||||||
|
void UpdateSpriteInfo();
|
||||||
|
void Serialize(FSerializer& arc) override;
|
||||||
|
|
||||||
|
float GetOffset(bool y) const;
|
||||||
|
};
|
|
@ -44,6 +44,8 @@
|
||||||
#include "hw_vertexbuilder.h"
|
#include "hw_vertexbuilder.h"
|
||||||
#include "hw_walldispatcher.h"
|
#include "hw_walldispatcher.h"
|
||||||
|
|
||||||
|
#include "p_visualthinker.h"
|
||||||
|
|
||||||
#ifdef ARCH_IA32
|
#ifdef ARCH_IA32
|
||||||
#include <immintrin.h>
|
#include <immintrin.h>
|
||||||
#endif // ARCH_IA32
|
#endif // ARCH_IA32
|
||||||
|
|
|
@ -60,6 +60,8 @@
|
||||||
#include "hw_renderstate.h"
|
#include "hw_renderstate.h"
|
||||||
#include "quaternion.h"
|
#include "quaternion.h"
|
||||||
|
|
||||||
|
#include "p_visualthinker.h"
|
||||||
|
|
||||||
extern TArray<spritedef_t> sprites;
|
extern TArray<spritedef_t> sprites;
|
||||||
extern TArray<spriteframe_t> SpriteFrames;
|
extern TArray<spriteframe_t> SpriteFrames;
|
||||||
extern uint32_t r_renderercaps;
|
extern uint32_t r_renderercaps;
|
||||||
|
|
Loading…
Reference in a new issue