Conform CElementGen with retail

This commit is contained in:
Jack Andersen 2017-06-03 15:01:09 -10:00
parent db8a7d3433
commit 6da6e37d42
17 changed files with 736 additions and 953 deletions

View File

@ -2316,28 +2316,6 @@ void CStateManager::SetCurrentAreaId(TAreaId aid)
x850_world->GetMapWorld()->RecalculateWorldSphere(*x8c0_mapWorldInfo, *x850_world);
}
void CStateManager::DeleteObjectRequest(TUniqueId id)
{
CEntity* entity = ObjectById(id);
if (!entity)
return;
if (entity->IsInGraveyard())
return;
entity->SetIsInGraveyard(true);
x854_objectGraveyard.push_back(entity->GetUniqueId());
entity->AcceptScriptMsg(EScriptObjectMessage::Deleted, kInvalidUniqueId, *this);
entity->SetIsScriptingBlocked(true);
if (TCastToPtr<CActor> actor = entity)
{
x874_sortedListManager->Remove(actor);
actor->SetUseInSortedLists(false);
}
}
CEntity* CStateManager::ObjectById(TUniqueId uid) { return GetAllObjectList().GetObjectById(uid); }
const CEntity* CStateManager::GetObjectById(TUniqueId uid) const { return GetAllObjectList().GetObjectById(uid); }

View File

@ -372,7 +372,6 @@ public:
void UpdateRoomAcoustics(TAreaId);
TAreaId GetNextAreaId() const { return x8cc_nextAreaId; }
void SetCurrentAreaId(TAreaId);
void DeleteObjectRequest(TUniqueId);
CEntity* ObjectById(TUniqueId uid);
const CEntity* GetObjectById(TUniqueId uid) const;
void AreaUnloaded(TAreaId);

View File

@ -3,6 +3,7 @@
#include "IOStreams.hpp"
#include "RetroTypes.hpp"
#include "zeus/CVector3f.hpp"
namespace urde
{
@ -34,7 +35,15 @@ public:
class CAuxiliaryParticleData
{
u32 x0_duration = 0;
SObjectTag x4_particle;
zeus::CVector3f xc_translation;
float x18_scale = 1.f;
public:
u32 GetDuration() const { return x0_duration; }
const SObjectTag& GetTag() const { return x4_particle; }
const zeus::CVector3f& GetTranslation() const { return xc_translation; }
float GetScale() const { return x18_scale; }
};
}

View File

@ -363,9 +363,49 @@ static int _getGraphicLightId(const T& system, const U& desc)
}
void CParticleDatabase::AddAuxiliaryParticleEffect(const std::string& name, int flags, const CAuxiliaryParticleData& data,
const zeus::CVector3f& scale, CStateManager& mgr, TAreaId aid, int lightIdx)
const zeus::CVector3f& scale, CStateManager& mgr, TAreaId aid, int lightId)
{
if (CParticleGenInfo* info = GetParticleEffect(name))
{
if (!info->GetIsActive())
{
info->SetParticleEmission(true, mgr);
info->SetIsActive(true);
info->SetIsGrabInitialData(true);
info->SetFlags(flags);
}
return;
}
zeus::CVector3f scaleVec;
if (flags & 0x2)
scaleVec.splat(data.GetScale());
else
scaleVec = scale * data.GetScale();
std::unique_ptr<CParticleGenInfo> newGen;
switch (data.GetTag().type)
{
case SBIG('PART'):
{
auto search = x0_particleDescs.find(data.GetTag().id);
if (search != x0_particleDescs.end())
{
auto sys = std::make_shared<CElementGen>(*search->second, CElementGen::EModelOrientationType::Normal,
CElementGen::EOptionalSystemFlags::One);
newGen = std::make_unique<CParticleGenInfoGeneric>(data.GetTag(), sys, data.GetDuration(), "NOT_A_VALID_LOCATOR",
scaleVec, CParticleData::EParentedMode::Initial, flags, mgr, aid,
lightId + _getGraphicLightId(sys, *search->second),
EParticleGenState::Started);
newGen->SetGlobalTranslation(data.GetTranslation(), mgr);
newGen->SetIsGrabInitialData(false);
InsertParticleGen(false, flags, name, std::move(newGen));
}
break;
}
default: break;
}
}
void CParticleDatabase::AddParticleEffect(const std::string& name, int flags, const CParticleData& data,

View File

@ -63,9 +63,9 @@ public:
void SetParticleEffectState(const std::string& name, bool active, CStateManager& mgr);
void SetCEXTValue(const std::string& name, int idx, float value);
void AddAuxiliaryParticleEffect(const std::string& name, int flags, const CAuxiliaryParticleData& data,
const zeus::CVector3f& scale, CStateManager& mgr, TAreaId aid, int lightIdx);
const zeus::CVector3f& scale, CStateManager& mgr, TAreaId aid, int lightId);
void AddParticleEffect(const std::string& name, int flags, const CParticleData& data,
const zeus::CVector3f& scale, CStateManager& mgr, TAreaId aid, bool oneShot, int lightIdx);
const zeus::CVector3f& scale, CStateManager& mgr, TAreaId aid, bool oneShot, int lightId);
void InsertParticleGen(bool oneShot, int flags, const std::string& name,
std::unique_ptr<CParticleGenInfo>&& gen);
};

View File

@ -16,7 +16,7 @@ CCollisionActorManager::CCollisionActorManager(CStateManager&, TUniqueId, TAreaI
void CCollisionActorManager::Destroy(CStateManager& mgr) const
{
for (const CJointCollisionDescription& desc : x0_jointDescriptions)
mgr.DeleteObjectRequest(desc.GetCollisionActorId());
mgr.FreeScriptObject(desc.GetCollisionActorId());
const_cast<CCollisionActorManager&>(*this).x13_ = true;
}

File diff suppressed because it is too large Load Diff

View File

@ -54,14 +54,7 @@ public:
zeus::CVector3f x4_viewPoint;
public:
CParticleListItem(s16 idx)
: x0_partIdx(idx)
{
++g_ParticleAliveCount;
}
~CParticleListItem()
{
--g_ParticleAliveCount;
}
: x0_partIdx(idx) {}
};
struct CParticle
{
@ -78,92 +71,94 @@ public:
private:
friend class CElementGenShaders;
TLockedToken<CGenDescription> x1c_genDesc;
EModelOrientationType x28_orientType;
std::vector<CParticleListItem> x30_particleLists;
std::vector<zeus::CMatrix3f> x60_parentMatrices;
u32 x4c_internalStartFrame = 0;
u32 x50_curFrame = 0;
double x58_curSeconds = 0.f;
float x60_timeDeltaScale;
u32 x64_prevFrame = -1;
bool x68_particleEmission = true;
float x6c_generatorRemainder = 0.f;
CGenDescription* x28_loadedGenDesc;
EModelOrientationType x2c_orientType;
std::vector<CParticle> x30_particles;
std::vector<u32> x40;
std::vector<zeus::CMatrix3f> x50_parentMatrices;
std::vector<std::array<float, 8>> x60_advValues;
u32 x70_internalStartFrame = 0;
u32 x74_curFrame = 0;
double x78_curSeconds = 0.f;
float x80_timeDeltaScale;
u32 x84_prevFrame = -1;
bool x88_particleEmission = true;
float x8c_generatorRemainder = 0.f;
int x90_MAXP = 0;
u16 x94_randomSeed = 99;
float x98_generatorRate = 1.f;
float x9c_cextValues[16] = {};
float x78_generatorRate = 1.f;
zeus::CVector3f x7c_translation;
zeus::CVector3f x88_globalTranslation;
zeus::CVector3f xdc_translation;
zeus::CVector3f xe8_globalTranslation;
zeus::CVector3f xf4_POFS;
zeus::CVector3f xa0_globalScale = {1.f, 1.f, 1.f};
zeus::CTransform xac_globalScaleTransform = zeus::CTransform::Identity();
zeus::CTransform xdc_globalScaleTransformInverse = zeus::CTransform::Identity();
zeus::CVector3f x10c_localScale = {1.f, 1.f, 1.f};
zeus::CTransform x118_localScaleTransform = zeus::CTransform::Identity();
zeus::CTransform x148_localScaleTransformInverse = zeus::CTransform::Identity();
zeus::CTransform x178_orientation = zeus::CTransform::Identity();
zeus::CTransform x1a8_orientationInverse = zeus::CTransform::Identity();
zeus::CTransform x1d8_globalOrientation = zeus::CTransform::Identity();
u32 x208_activeParticleCount = 0;
u32 x20c_recursiveParticleCount = 0;
u32 x210_curEmitterFrame = 0;
int x268_PSLT = 90;//0x7fffff;
zeus::CVector3f x218_PSIV;
bool x224_24_translationDirty = false;
bool x224_25_LIT_;
bool x224_26_AAPH;
bool x224_27_ZBUF;
bool x224_28_zTest = false;
bool x224_29_MBLR;
bool x224_30_VMD1;
bool x224_31_VMD2;
bool x225_24_VMD3;
bool x225_25_VMD4;
bool x225_28_warmedUp = false;
bool x225_29_modelsUseLights = false;
bool x226_enableOPTS;
int x228_MBSP = 0; int m_maxMBSP = 0;
zeus::CVector3f x100_globalScale = {1.f, 1.f, 1.f};
zeus::CTransform x10c_globalScaleTransform = zeus::CTransform::Identity();
zeus::CTransform x13c_globalScaleTransformInverse = zeus::CTransform::Identity();
zeus::CVector3f x16c_localScale = {1.f, 1.f, 1.f};
zeus::CTransform x178_localScaleTransform = zeus::CTransform::Identity();
zeus::CTransform x1a8_localScaleTransformInverse = zeus::CTransform::Identity();
zeus::CTransform x1d8_orientation = zeus::CTransform::Identity();
zeus::CTransform x208_orientationInverse = zeus::CTransform::Identity();
zeus::CTransform x22c_globalOrientation = zeus::CTransform::Identity();
u32 x25c_activeParticleCount = 0;
u32 x260_cumulativeParticles = 0;
u32 x264_recursiveParticleCount = 0;
int x268_PSLT;
union
{
struct
{
bool x26c_24_ : 1;
bool x26c_24_translationDirty : 1;
bool x26c_25_LIT_ : 1;
bool x26c_26_AAPH : 1;
bool x26c_27_ZBUF : 1;
bool x26c_28_zTest : 1;
bool x26c_29_ORNT : 1;
bool x26c_30_MBLR : 1;
bool x26c_31_LINE : 1;
bool x26d_24_FXLL : 1;
bool x26d_25_warmedUp : 1;
bool x26d_26_modelsUseLights : 1;
bool x26d_27_enableOPTS : 1;
bool x26d_28_enableADV : 1;
};
u32 _dummy = 0;
};
ERglLightBits x22c_backupLightActive = ERglLightBits::None;
int x270_MBSP = 0;
int m_maxMBSP = 0;
ERglLightBits x274_backupLightActive = ERglLightBits::None;
bool x278_hasVMD[4] = {};
CRandom16 x27c_randState;
std::vector<std::unique_ptr<CElementGen>> x290_activePartChildren;
CModVectorElement* x280_VELSources[4] = {};
std::vector<std::unique_ptr<CParticleGen>> x290_activePartChildren;
int x2a0_CSSD = 0;
std::vector<std::unique_ptr<CElementGen>> x248_finishPartChildren;
int x2a4_SISY = 16;
int x2a8_PISY = 16;
u32 x260_cumulativeParticles = 0; /* Retail */
std::vector<std::unique_ptr<CParticleSwoosh>> x260_swhcChildren;
int x2ac_SSSD = 0;
zeus::CVector3f x2b0_SSPO;
std::vector<std::unique_ptr<CParticleElectric>> x280_elscChildren;
int x2bc_SESD = 0;
zeus::CVector3f x2c0_SEPO;
float x2a0 = 0.f;
float x2a4 = 0.f;
zeus::CVector3f x2a8_aabbMin;
zeus::CVector3f x2b4_aabbMax;
float x2c0_maxSize = 0.f;
zeus::CAABox x2c4_systemBounds = zeus::CAABox::skInvertedBox;
float x2cc = 0.f;
float x2d0 = 0.f;
zeus::CVector3f x2d4_aabbMin;
zeus::CVector3f x2e0_aabbMax;
float x2ec_maxSize = 0.f;
zeus::CAABox x2f0_systemBounds = zeus::CAABox::skInvertedBox;
LightType x308_lightType;
zeus::CColor x2e0_LCLR = zeus::CColor::skWhite;
float x2e4_LINT = 1.f;
zeus::CVector3f x2e8_LOFF;
zeus::CVector3f x2f4_LDIR = {1.f, 0.f, 0.f};
zeus::CColor x30c_LCLR = zeus::CColor::skWhite;
float x310_LINT = 1.f;
zeus::CVector3f x314_LOFF;
zeus::CVector3f x320_LDIR = {1.f, 0.f, 0.f};
EFalloffType x32c_falloffType = EFalloffType::Linear;
float x304_LFOR = 1.f;
float x308_LSLA = 45.f;
zeus::CColor x30c_moduColor = {1.f, 1.f, 1.f, 1.f};
float x330_LFOR = 1.f;
float x334_LSLA = 45.f;
zeus::CColor x338_moduColor = {1.f, 1.f, 1.f, 1.f};
std::unique_ptr<CLineRenderer> m_lineRenderer;
CElementGenShaders::EShaderClass m_shaderClass;
@ -182,44 +177,27 @@ public:
CGenDescription* GetDesc() {return x1c_genDesc.GetObj();}
static s32 g_FreeIndex;
static bool g_StaticListInitialized;
static bool g_ParticleSystemInitialized;
static int g_ParticleAliveCount;
static int g_ParticleSystemAliveCount;
static bool sMoveRedToAlphaBuffer;
static void Initialize();
static void Shutdown();
void SetGeneratorRateScalar(float scalar)
{
if (scalar >= 0.0f)
x78_generatorRate = scalar;
else
x78_generatorRate = 0.0f;
for (std::unique_ptr<CElementGen>& child : x290_activePartChildren)
child->SetGeneratorRateScalar(x78_generatorRate);
for (std::unique_ptr<CElementGen>& child : x248_finishPartChildren)
child->SetGeneratorRateScalar(x78_generatorRate);
}
void UpdateAdvanceAccessParameters(u32 activeParticleCount, u32 particleFrame);
bool UpdateVelocitySource(u32 idx, u32 particleFrame, CParticle& particle);
void UpdateExistingParticles();
void CreateNewParticles(int);
void UpdatePSTranslationAndOrientation();
void UpdateChildParticleSystems(double);
CElementGen* ConstructChildParticleSystem(const TToken<CGenDescription>&);
std::unique_ptr<CParticleGen> ConstructChildParticleSystem(const TToken<CGenDescription>&);
void UpdateLightParameters();
void BuildParticleSystemBounds();
u32 GetEmitterTime() const
{
/* Game returns x74, guessing x50 is what it's asking for */
return x50_curFrame;
}
u32 GetEmitterTime() const { return x74_curFrame; }
u32 GetSystemCount();
u32 GetCumulativeParticleCount() const { return x260_cumulativeParticles; }
u32 GetParticleCountAllInternal() const;
u32 GetParticleCountAll() const {return x20c_recursiveParticleCount;}
u32 GetParticleCountAll() const { return x264_recursiveParticleCount; }
void EndLifetime();
void ForceParticleCreation(int amount);
float GetCEXTValue(int i) const { return x9c_cextValues[i]; }
@ -239,14 +217,17 @@ public:
void SetGlobalTranslation(const zeus::CVector3f&);
void SetGlobalScale(const zeus::CVector3f&);
void SetLocalScale(const zeus::CVector3f&);
void SetGlobalOrientAndTrans(const zeus::CTransform& xf);
void SetParticleEmission(bool);
void SetModulationColor(const zeus::CColor&);
void SetGeneratorRate(float rate);
const zeus::CTransform& GetOrientation() const;
const zeus::CVector3f& GetTranslation() const;
const zeus::CTransform& GetGlobalOrientation() const;
const zeus::CVector3f& GetGlobalTranslation() const;
const zeus::CVector3f& GetGlobalScale() const;
const zeus::CColor& GetModulationColor() const;
float GetGeneratorRate() const { return x98_generatorRate; }
bool IsSystemDeletable() const;
rstl::optional_object<zeus::CAABox> GetBounds() const;
u32 GetParticleCount() const;
@ -255,8 +236,9 @@ public:
bool GetParticleEmission() const;
void DestroyParticles();
void Reset();
FourCC Get4CharId() const { return FOURCC('PART'); }
size_t GetNumActiveChildParticles() const { return x290_activePartChildren.size(); }
CElementGen& GetActiveChildParticle(size_t idx) const { return *x290_activePartChildren[idx]; }
CParticleGen& GetActiveChildParticle(size_t idx) const { return *x290_activePartChildren[idx]; }
static void SetMoveRedToAlphaBuffer(bool);
};

View File

@ -107,6 +107,7 @@ public:
bool GetParticleEmission() const;
void DestroyParticles();
void Reset() {}
FourCC Get4CharId() const { return FOURCC('ELSC'); }
};
}

View File

@ -5,7 +5,7 @@ namespace urde
void CParticleGen::AddModifier(CWarp* mod)
{
x8_modifierList.push_back(mod);
x4_modifierList.push_back(mod);
}
}

View File

@ -15,7 +15,7 @@ namespace urde
class CParticleGen
{
std::list<CWarp*> x8_modifierList;
std::list<CWarp*> x4_modifierList;
public:
virtual ~CParticleGen() = default;
@ -29,12 +29,14 @@ public:
virtual void SetLocalScale(const zeus::CVector3f&)=0;
virtual void SetParticleEmission(bool)=0;
virtual void SetModulationColor(const zeus::CColor&)=0;
virtual void SetGeneratorRate(float rate) {}
virtual const zeus::CTransform& GetOrientation() const=0;
virtual const zeus::CVector3f& GetTranslation() const=0;
virtual const zeus::CTransform& GetGlobalOrientation() const=0;
virtual const zeus::CVector3f& GetGlobalTranslation() const=0;
virtual const zeus::CVector3f& GetGlobalScale() const=0;
virtual const zeus::CColor& GetModulationColor() const=0;
virtual float GetGeneratorRate() const { return 1.f; }
virtual bool IsSystemDeletable() const=0;
virtual rstl::optional_object<zeus::CAABox> GetBounds() const=0;
virtual u32 GetParticleCount() const=0;
@ -43,6 +45,7 @@ public:
virtual bool GetParticleEmission() const=0;
virtual void DestroyParticles()=0;
virtual void Reset()=0;
virtual FourCC Get4CharId() const=0;
virtual void AddModifier(CWarp* mod);
};

View File

@ -13,6 +13,6 @@ int CParticleGlobals::g_ParticleLifetimePercentage = 0;
float CParticleGlobals::g_ParticleLifetimePercentageReal = 0.0;
float CParticleGlobals::g_ParticleLifetimePercentageRemainder = 0.0;
float CParticleGlobals::g_papValues[8] = { 0.f };
const std::array<float, 8>* CParticleGlobals::g_particleAccessParameters = nullptr;
CParticleGlobals::SParticleSystem* CParticleGlobals::g_currentParticleSystem = nullptr;
}

View File

@ -4,6 +4,7 @@
#include "zeus/CVector3f.hpp"
#include "zeus/CColor.hpp"
#include "RetroTypes.hpp"
#include <array>
namespace urde
{
@ -38,7 +39,7 @@ public:
g_ParticleLifetimePercentageRemainder = g_ParticleLifetimePercentageReal - g_ParticleLifetimePercentage;
}
static float g_papValues[8];
static const std::array<float, 8>* g_particleAccessParameters;
struct SParticleSystem
{

View File

@ -37,6 +37,7 @@ public:
bool GetParticleEmission() const;
void DestroyParticles();
void Reset() {}
FourCC Get4CharId() const { return FOURCC('SWHC'); }
};
}

View File

@ -235,49 +235,49 @@ bool CRECompareEquals::GetValue(int frame, float& valOut) const
bool CREParticleAccessParam1::GetValue(int /*frame*/, float& valOut) const
{
valOut = CParticleGlobals::g_papValues[0];
valOut = (*CParticleGlobals::g_particleAccessParameters)[0];
return false;
}
bool CREParticleAccessParam2::GetValue(int /*frame*/, float& valOut) const
{
valOut = CParticleGlobals::g_papValues[1];
valOut = (*CParticleGlobals::g_particleAccessParameters)[1];
return false;
}
bool CREParticleAccessParam3::GetValue(int /*frame*/, float& valOut) const
{
valOut = CParticleGlobals::g_papValues[2];
valOut = (*CParticleGlobals::g_particleAccessParameters)[2];
return false;
}
bool CREParticleAccessParam4::GetValue(int /*frame*/, float& valOut) const
{
valOut = CParticleGlobals::g_papValues[3];
valOut = (*CParticleGlobals::g_particleAccessParameters)[3];
return false;
}
bool CREParticleAccessParam5::GetValue(int /*frame*/, float& valOut) const
{
valOut = CParticleGlobals::g_papValues[4];
valOut = (*CParticleGlobals::g_particleAccessParameters)[4];
return false;
}
bool CREParticleAccessParam6::GetValue(int /*frame*/, float& valOut) const
{
valOut = CParticleGlobals::g_papValues[5];
valOut = (*CParticleGlobals::g_particleAccessParameters)[5];
return false;
}
bool CREParticleAccessParam7::GetValue(int /*frame*/, float& valOut) const
{
valOut = CParticleGlobals::g_papValues[6];
valOut = (*CParticleGlobals::g_particleAccessParameters)[6];
return false;
}
bool CREParticleAccessParam8::GetValue(int /*frame*/, float& valOut) const
{
valOut = CParticleGlobals::g_papValues[7];
valOut = (*CParticleGlobals::g_particleAccessParameters)[7];
return false;
}

View File

@ -74,7 +74,7 @@ void CScriptColorModulate::End(CStateManager& stateMgr)
CEntity::SendScriptMsgs(EScriptObjectState::MaxReached, stateMgr, EScriptObjectMessage::None);
if (!x54_31_)
stateMgr.DeleteObjectRequest(x8_uid);
if (x54_31_)
stateMgr.FreeScriptObject(x8_uid);
}
}

View File

@ -81,7 +81,7 @@ void CScriptShadowProjector::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId
x104_target = act->GetUniqueId();
}
if (x104_target == kInvalidUniqueId)
mgr.DeleteObjectRequest(GetUniqueId());
mgr.FreeScriptObject(GetUniqueId());
else
CreateProjectedShadow();