2016-04-16 21:49:47 +00:00
|
|
|
#include "CParticleDatabase.hpp"
|
2017-03-01 06:02:54 +00:00
|
|
|
#include "CSimplePool.hpp"
|
|
|
|
#include "GameGlobalObjects.hpp"
|
2017-06-03 06:03:07 +00:00
|
|
|
#include "Character/CCharLayoutInfo.hpp"
|
|
|
|
#include "Character/CPoseAsTransforms.hpp"
|
|
|
|
#include "Particle/CElementGen.hpp"
|
|
|
|
#include "Particle/CParticleSwoosh.hpp"
|
|
|
|
#include "Particle/CParticleElectric.hpp"
|
2016-04-16 21:49:47 +00:00
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
|
|
|
|
2017-06-03 06:03:07 +00:00
|
|
|
CParticleDatabase::CParticleDatabase()
|
|
|
|
{
|
|
|
|
xb4_24_active = true;
|
2018-02-13 06:46:59 +00:00
|
|
|
xb4_25_anySystemsDrawnWithModel = false;
|
2017-06-03 06:03:07 +00:00
|
|
|
}
|
|
|
|
|
2017-11-24 08:01:06 +00:00
|
|
|
void CParticleDatabase::CacheParticleDesc(const SObjectTag &tag)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-04-16 21:49:47 +00:00
|
|
|
void CParticleDatabase::CacheParticleDesc(const CCharacterInfo::CParticleResData& desc)
|
|
|
|
{
|
2017-08-13 05:26:14 +00:00
|
|
|
for (CAssetId id : desc.x0_part)
|
2017-03-01 06:02:54 +00:00
|
|
|
{
|
|
|
|
auto search = x0_particleDescs.find(id);
|
|
|
|
if (search == x0_particleDescs.cend())
|
|
|
|
x0_particleDescs[id] = std::make_shared<TLockedToken<CGenDescription>>(
|
|
|
|
g_SimplePool->GetObj(SObjectTag{FOURCC('PART'), id}));
|
|
|
|
}
|
2017-08-13 05:26:14 +00:00
|
|
|
for (CAssetId id : desc.x10_swhc)
|
2017-03-01 06:02:54 +00:00
|
|
|
{
|
|
|
|
auto search = x14_swooshDescs.find(id);
|
|
|
|
if (search == x14_swooshDescs.cend())
|
|
|
|
x14_swooshDescs[id] = std::make_shared<TLockedToken<CSwooshDescription>>(
|
|
|
|
g_SimplePool->GetObj(SObjectTag{FOURCC('SWHC'), id}));
|
|
|
|
}
|
2017-08-13 05:26:14 +00:00
|
|
|
for (CAssetId id : desc.x20_elsc)
|
2017-03-01 06:02:54 +00:00
|
|
|
{
|
|
|
|
auto search = x28_electricDescs.find(id);
|
|
|
|
if (search == x28_electricDescs.cend())
|
|
|
|
x28_electricDescs[id] = std::make_shared<TLockedToken<CElectricDescription>>(
|
|
|
|
g_SimplePool->GetObj(SObjectTag{FOURCC('ELSC'), id}));
|
|
|
|
}
|
2016-04-16 21:49:47 +00:00
|
|
|
}
|
|
|
|
|
2017-06-03 06:03:07 +00:00
|
|
|
void CParticleDatabase::SetModulationColorAllActiveEffectsForParticleDB(const zeus::CColor& color,
|
|
|
|
std::map<std::string, std::unique_ptr<CParticleGenInfo>>& map)
|
|
|
|
{
|
|
|
|
for (auto& e : map)
|
|
|
|
{
|
|
|
|
if (e.second)
|
|
|
|
e.second->SetModulationColor(color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-21 20:39:18 +00:00
|
|
|
void CParticleDatabase::SetModulationColorAllActiveEffects(const zeus::CColor& color)
|
|
|
|
{
|
2017-06-03 06:03:07 +00:00
|
|
|
SetModulationColorAllActiveEffectsForParticleDB(color, x3c_rendererDrawLoop);
|
|
|
|
SetModulationColorAllActiveEffectsForParticleDB(color, x50_firstDrawLoop);
|
|
|
|
SetModulationColorAllActiveEffectsForParticleDB(color, x64_lastDrawLoop);
|
|
|
|
SetModulationColorAllActiveEffectsForParticleDB(color, x78_rendererDraw);
|
|
|
|
SetModulationColorAllActiveEffectsForParticleDB(color, x8c_firstDraw);
|
|
|
|
SetModulationColorAllActiveEffectsForParticleDB(color, xa0_lastDraw);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParticleDatabase::SuspendAllActiveEffectsForParticleDB(CStateManager& mgr,
|
|
|
|
std::map<std::string, std::unique_ptr<CParticleGenInfo>>& map)
|
|
|
|
{
|
|
|
|
for (auto& e : map)
|
|
|
|
{
|
|
|
|
e.second->SetParticleEmission(false, mgr);
|
|
|
|
}
|
2016-08-21 20:39:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CParticleDatabase::SuspendAllActiveEffects(CStateManager& stateMgr)
|
|
|
|
{
|
2017-06-03 06:03:07 +00:00
|
|
|
SuspendAllActiveEffectsForParticleDB(stateMgr, x3c_rendererDrawLoop);
|
|
|
|
SuspendAllActiveEffectsForParticleDB(stateMgr, x50_firstDrawLoop);
|
|
|
|
SuspendAllActiveEffectsForParticleDB(stateMgr, x64_lastDrawLoop);
|
2016-08-21 20:39:18 +00:00
|
|
|
}
|
|
|
|
|
2017-06-03 06:03:07 +00:00
|
|
|
void CParticleDatabase::DeleteAllLightsForParticleDB(CStateManager& mgr,
|
|
|
|
std::map<std::string, std::unique_ptr<CParticleGenInfo>>& map)
|
2016-08-21 20:39:18 +00:00
|
|
|
{
|
2017-06-03 06:03:07 +00:00
|
|
|
for (auto& e : map)
|
|
|
|
{
|
|
|
|
e.second->DeleteLight(mgr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParticleDatabase::DeleteAllLights(CStateManager& mgr)
|
|
|
|
{
|
|
|
|
DeleteAllLightsForParticleDB(mgr, x3c_rendererDrawLoop);
|
|
|
|
DeleteAllLightsForParticleDB(mgr, x50_firstDrawLoop);
|
|
|
|
DeleteAllLightsForParticleDB(mgr, x64_lastDrawLoop);
|
|
|
|
DeleteAllLightsForParticleDB(mgr, x78_rendererDraw);
|
|
|
|
DeleteAllLightsForParticleDB(mgr, x8c_firstDraw);
|
|
|
|
DeleteAllLightsForParticleDB(mgr, xa0_lastDraw);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParticleDatabase::UpdateParticleGenDB(float dt, const CPoseAsTransforms& pose, const CCharLayoutInfo& charInfo,
|
|
|
|
const zeus::CTransform& xf, const zeus::CVector3f& scale, CStateManager& stateMgr,
|
|
|
|
std::map<std::string, std::unique_ptr<CParticleGenInfo>>& map, bool deleteIfDone)
|
|
|
|
{
|
|
|
|
for (auto it = map.begin() ; it != map.end() ;)
|
|
|
|
{
|
|
|
|
CParticleGenInfo& info = *it->second;
|
|
|
|
if (info.GetIsActive())
|
|
|
|
{
|
|
|
|
if (info.GetState() == EParticleGenState::NotStarted)
|
|
|
|
{
|
|
|
|
CSegId segId = charInfo.GetSegIdFromString(info.GetLocatorName());
|
|
|
|
if (segId == 0xff)
|
|
|
|
{
|
|
|
|
++it;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!pose.ContainsDataFor(segId))
|
|
|
|
{
|
|
|
|
++it;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
const zeus::CVector3f& off = pose.GetOffset(segId);
|
|
|
|
switch (info.GetParentedMode())
|
|
|
|
{
|
|
|
|
case CParticleData::EParentedMode::Initial:
|
|
|
|
{
|
|
|
|
if (info.GetIsGrabInitialData())
|
|
|
|
{
|
|
|
|
zeus::CTransform segXf(
|
|
|
|
(info.GetFlags() & 0x10) ? zeus::CMatrix3f::skIdentityMatrix3f : pose.GetTransformMinusOffset(segId),
|
|
|
|
off * scale);
|
|
|
|
zeus::CTransform compXf = xf * segXf;
|
|
|
|
info.SetCurTransform(compXf.getRotation());
|
|
|
|
info.SetCurOffset(compXf.origin);
|
|
|
|
info.SetCurrentTime(0.f);
|
|
|
|
info.SetIsGrabInitialData(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
info.SetOrientation(info.GetCurTransform(), stateMgr);
|
|
|
|
info.SetTranslation(info.GetCurOffset(), stateMgr);
|
|
|
|
|
|
|
|
if (info.GetFlags() & 0x2000)
|
|
|
|
info.SetGlobalScale(info.GetCurScale() * scale);
|
|
|
|
else
|
|
|
|
info.SetGlobalScale(info.GetCurScale());
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CParticleData::EParentedMode::ContinuousEmitter:
|
|
|
|
case CParticleData::EParentedMode::ContinuousSystem:
|
|
|
|
{
|
|
|
|
if (info.GetIsGrabInitialData())
|
|
|
|
{
|
|
|
|
info.SetCurrentTime(0.f);
|
|
|
|
info.SetIsGrabInitialData(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
zeus::CTransform segXf(pose.GetTransformMinusOffset(segId), off * scale);
|
|
|
|
zeus::CTransform compXf = xf * segXf;
|
|
|
|
|
|
|
|
if (info.GetParentedMode() == CParticleData::EParentedMode::ContinuousEmitter)
|
|
|
|
{
|
|
|
|
info.SetTranslation(compXf.origin, stateMgr);
|
|
|
|
if (info.GetFlags() & 0x10)
|
|
|
|
info.SetOrientation(xf.getRotation(), stateMgr);
|
|
|
|
else
|
|
|
|
info.SetOrientation(compXf.getRotation(), stateMgr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
info.SetGlobalTranslation(compXf.origin, stateMgr);
|
|
|
|
if (info.GetFlags() & 0x10)
|
|
|
|
info.SetGlobalOrientation(xf.getRotation(), stateMgr);
|
|
|
|
else
|
|
|
|
info.SetGlobalOrientation(compXf.getRotation(), stateMgr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info.GetFlags() & 0x2000)
|
|
|
|
info.SetGlobalScale(info.GetCurScale() * scale);
|
|
|
|
else
|
|
|
|
info.SetGlobalScale(info.GetCurScale());
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
|
|
|
|
float sec = (info.GetInactiveStartTime() == 0.f) ? 10000000.f : info.GetInactiveStartTime();
|
|
|
|
if (info.GetCurrentTime() > sec)
|
|
|
|
{
|
|
|
|
info.SetIsActive(false);
|
|
|
|
info.SetParticleEmission(false, stateMgr);
|
|
|
|
info.MarkFinishTime();
|
|
|
|
if (info.GetFlags() & 1)
|
|
|
|
info.DestroyParticles();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
info.Update(dt, stateMgr);
|
|
|
|
|
|
|
|
if (!info.GetIsActive())
|
|
|
|
{
|
|
|
|
if (!info.HasActiveParticles() && info.GetCurrentTime() - info.GetFinishTime() > 5.f && deleteIfDone)
|
|
|
|
{
|
|
|
|
info.DeleteLight(stateMgr);
|
|
|
|
it = map.erase(it);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (info.IsSystemDeletable())
|
|
|
|
{
|
|
|
|
info.DeleteLight(stateMgr);
|
|
|
|
it = map.erase(it);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
info.OffsetTime(dt);
|
|
|
|
++it;
|
|
|
|
}
|
2016-08-21 20:39:18 +00:00
|
|
|
}
|
|
|
|
|
2016-09-04 02:27:35 +00:00
|
|
|
void CParticleDatabase::Update(float dt, const CPoseAsTransforms& pose, const CCharLayoutInfo& charInfo,
|
2017-06-03 06:03:07 +00:00
|
|
|
const zeus::CTransform& xf, const zeus::CVector3f& scale, CStateManager& stateMgr)
|
|
|
|
{
|
|
|
|
if (!xb4_24_active)
|
|
|
|
return;
|
|
|
|
|
|
|
|
UpdateParticleGenDB(dt, pose, charInfo, xf, scale, stateMgr, x3c_rendererDrawLoop, true);
|
|
|
|
UpdateParticleGenDB(dt, pose, charInfo, xf, scale, stateMgr, x50_firstDrawLoop, true);
|
|
|
|
UpdateParticleGenDB(dt, pose, charInfo, xf, scale, stateMgr, x64_lastDrawLoop, true);
|
|
|
|
UpdateParticleGenDB(dt, pose, charInfo, xf, scale, stateMgr, x78_rendererDraw, false);
|
|
|
|
UpdateParticleGenDB(dt, pose, charInfo, xf, scale, stateMgr, x8c_firstDraw, false);
|
|
|
|
UpdateParticleGenDB(dt, pose, charInfo, xf, scale, stateMgr, xa0_lastDraw, false);
|
|
|
|
|
2018-02-13 06:46:59 +00:00
|
|
|
xb4_25_anySystemsDrawnWithModel = (x50_firstDrawLoop.size() || x64_lastDrawLoop.size() || x8c_firstDraw.size() || xa0_lastDraw.size());
|
2017-06-03 06:03:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CParticleDatabase::RenderParticleGenMap(const std::map<std::string, std::unique_ptr<CParticleGenInfo>>& map)
|
|
|
|
{
|
|
|
|
for (auto& e : map)
|
|
|
|
{
|
|
|
|
e.second->Render();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParticleDatabase::RenderParticleGenMapMasked(const std::map<std::string, std::unique_ptr<CParticleGenInfo>>& map,
|
|
|
|
int mask, int target)
|
|
|
|
{
|
|
|
|
for (auto& e : map)
|
|
|
|
{
|
|
|
|
if ((e.second->GetFlags() & mask) == target)
|
|
|
|
e.second->Render();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParticleDatabase::AddToRendererClippedParticleGenMap(const std::map<std::string, std::unique_ptr<CParticleGenInfo>>& map,
|
|
|
|
const zeus::CFrustum& frustum)
|
|
|
|
{
|
|
|
|
for (auto& e : map)
|
|
|
|
{
|
|
|
|
if (frustum.aabbFrustumTest(*e.second->GetBounds()))
|
|
|
|
e.second->AddToRenderer();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParticleDatabase::AddToRendererClippedParticleGenMapMasked(const std::map<std::string, std::unique_ptr<CParticleGenInfo>>& map,
|
|
|
|
const zeus::CFrustum& frustum, int mask, int target)
|
|
|
|
{
|
|
|
|
for (auto& e : map)
|
|
|
|
{
|
|
|
|
if ((e.second->GetFlags() & mask) == target)
|
|
|
|
if (frustum.aabbFrustumTest(*e.second->GetBounds()))
|
|
|
|
e.second->AddToRenderer();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParticleDatabase::RenderSystemsToBeDrawnLastMasked(int mask, int target) const
|
|
|
|
{
|
|
|
|
RenderParticleGenMapMasked(xa0_lastDraw, mask, target);
|
|
|
|
RenderParticleGenMapMasked(x64_lastDrawLoop, mask, target);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParticleDatabase::RenderSystemsToBeDrawnLast() const
|
|
|
|
{
|
|
|
|
RenderParticleGenMap(xa0_lastDraw);
|
|
|
|
RenderParticleGenMap(x64_lastDrawLoop);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParticleDatabase::RenderSystemsToBeDrawnFirstMasked(int mask, int target) const
|
2016-09-04 02:27:35 +00:00
|
|
|
{
|
2017-06-03 06:03:07 +00:00
|
|
|
RenderParticleGenMapMasked(x8c_firstDraw, mask, target);
|
|
|
|
RenderParticleGenMapMasked(x50_firstDrawLoop, mask, target);
|
2016-09-04 02:27:35 +00:00
|
|
|
}
|
|
|
|
|
2017-06-03 06:03:07 +00:00
|
|
|
void CParticleDatabase::RenderSystemsToBeDrawnFirst() const
|
2016-09-04 02:27:35 +00:00
|
|
|
{
|
2017-06-03 06:03:07 +00:00
|
|
|
RenderParticleGenMap(x8c_firstDraw);
|
|
|
|
RenderParticleGenMap(x50_firstDrawLoop);
|
2016-09-04 02:27:35 +00:00
|
|
|
}
|
|
|
|
|
2017-06-03 06:03:07 +00:00
|
|
|
void CParticleDatabase::AddToRendererClippedMasked(const zeus::CFrustum& frustum, int mask, int target) const
|
2016-11-20 21:53:15 +00:00
|
|
|
{
|
2017-06-03 06:03:07 +00:00
|
|
|
AddToRendererClippedParticleGenMapMasked(x78_rendererDraw, frustum, mask, target);
|
|
|
|
AddToRendererClippedParticleGenMapMasked(x3c_rendererDrawLoop, frustum, mask, target);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParticleDatabase::AddToRendererClipped(const zeus::CFrustum& frustum) const
|
|
|
|
{
|
|
|
|
AddToRendererClippedParticleGenMap(x78_rendererDraw, frustum);
|
|
|
|
AddToRendererClippedParticleGenMap(x3c_rendererDrawLoop, frustum);
|
|
|
|
}
|
|
|
|
|
2017-11-13 06:19:18 +00:00
|
|
|
CParticleGenInfo* CParticleDatabase::GetParticleEffect(std::string_view name) const
|
2017-06-03 06:03:07 +00:00
|
|
|
{
|
2017-11-13 06:19:18 +00:00
|
|
|
auto search = x3c_rendererDrawLoop.find(name.data());
|
2017-06-03 06:03:07 +00:00
|
|
|
if (search != x3c_rendererDrawLoop.end())
|
|
|
|
return search->second.get();
|
2017-11-13 06:19:18 +00:00
|
|
|
search = x50_firstDrawLoop.find(name.data());
|
2017-06-03 06:03:07 +00:00
|
|
|
if (search != x50_firstDrawLoop.end())
|
|
|
|
return search->second.get();
|
2017-11-13 06:19:18 +00:00
|
|
|
search = x64_lastDrawLoop.find(name.data());
|
2017-06-03 06:03:07 +00:00
|
|
|
if (search != x64_lastDrawLoop.end())
|
|
|
|
return search->second.get();
|
2017-11-13 06:19:18 +00:00
|
|
|
search = x78_rendererDraw.find(name.data());
|
2017-06-03 06:03:07 +00:00
|
|
|
if (search != x78_rendererDraw.end())
|
|
|
|
return search->second.get();
|
2017-11-13 06:19:18 +00:00
|
|
|
search = x8c_firstDraw.find(name.data());
|
2017-06-03 06:03:07 +00:00
|
|
|
if (search != x8c_firstDraw.end())
|
|
|
|
return search->second.get();
|
2017-11-13 06:19:18 +00:00
|
|
|
search = xa0_lastDraw.find(name.data());
|
2017-06-03 06:03:07 +00:00
|
|
|
if (search != xa0_lastDraw.end())
|
|
|
|
return search->second.get();
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-11-13 06:19:18 +00:00
|
|
|
void CParticleDatabase::SetParticleEffectState(std::string_view name, bool active, CStateManager& mgr)
|
2017-06-03 06:03:07 +00:00
|
|
|
{
|
|
|
|
if (CParticleGenInfo* info = GetParticleEffect(name))
|
|
|
|
{
|
|
|
|
info->SetParticleEmission(active, mgr);
|
|
|
|
info->SetIsActive(active);
|
|
|
|
if (!active && (info->GetFlags() & 1) != 0)
|
|
|
|
info->DestroyParticles();
|
|
|
|
info->SetIsGrabInitialData(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-13 06:19:18 +00:00
|
|
|
void CParticleDatabase::SetCEXTValue(std::string_view name, int idx, float value)
|
2017-06-03 06:03:07 +00:00
|
|
|
{
|
|
|
|
if (CParticleGenInfo* info = GetParticleEffect(name))
|
|
|
|
{
|
|
|
|
static_cast<CElementGen*>(static_cast<CParticleGenInfoGeneric*>(info)->
|
|
|
|
GetParticleSystem().get())->SetCEXTValue(idx, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T, class U>
|
2017-08-13 05:26:14 +00:00
|
|
|
static s32 _getGraphicLightId(const T& system, const U& desc)
|
2017-06-03 06:03:07 +00:00
|
|
|
{
|
|
|
|
if (system->SystemHasLight())
|
2017-08-13 05:26:14 +00:00
|
|
|
return s32(desc.GetObjectTag()->id.Value());
|
2017-06-03 06:03:07 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2017-11-13 06:19:18 +00:00
|
|
|
void CParticleDatabase::AddAuxiliaryParticleEffect(std::string_view name, int flags, const CAuxiliaryParticleData& data,
|
2017-06-04 01:01:09 +00:00
|
|
|
const zeus::CVector3f& scale, CStateManager& mgr, TAreaId aid, int lightId)
|
2017-06-03 06:03:07 +00:00
|
|
|
{
|
2017-06-04 01:01:09 +00:00
|
|
|
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();
|
2017-06-03 06:03:07 +00:00
|
|
|
|
2017-06-04 01:01:09 +00:00
|
|
|
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())
|
|
|
|
{
|
2017-09-11 02:18:49 +00:00
|
|
|
auto sys = std::make_shared<CElementGen>(*search->second);
|
2017-06-04 01:01:09 +00:00
|
|
|
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;
|
|
|
|
}
|
2017-06-03 06:03:07 +00:00
|
|
|
}
|
|
|
|
|
2017-11-13 06:19:18 +00:00
|
|
|
void CParticleDatabase::AddParticleEffect(std::string_view name, int flags, const CParticleData& data,
|
2017-06-03 06:03:07 +00:00
|
|
|
const zeus::CVector3f& scale, CStateManager& mgr, TAreaId aid,
|
|
|
|
bool oneShot, 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())
|
|
|
|
{
|
2017-09-11 02:18:49 +00:00
|
|
|
auto sys = std::make_shared<CElementGen>(*search->second);
|
2017-06-03 06:03:07 +00:00
|
|
|
newGen = std::make_unique<CParticleGenInfoGeneric>(data.GetTag(), sys, data.GetDuration(), data.GetSegmentName(),
|
|
|
|
scaleVec, data.GetParentedMode(), flags, mgr, aid,
|
|
|
|
lightId + _getGraphicLightId(sys, *search->second),
|
|
|
|
EParticleGenState::NotStarted);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SBIG('SWHC'):
|
|
|
|
{
|
|
|
|
auto search = x14_swooshDescs.find(data.GetTag().id);
|
|
|
|
if (search != x14_swooshDescs.end())
|
|
|
|
{
|
|
|
|
auto sys = std::make_shared<CParticleSwoosh>(*search->second, 0);
|
|
|
|
newGen = std::make_unique<CParticleGenInfoGeneric>(data.GetTag(), sys, data.GetDuration(), data.GetSegmentName(),
|
|
|
|
scaleVec, data.GetParentedMode(), flags, mgr, aid,
|
|
|
|
-1, EParticleGenState::NotStarted);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SBIG('ELSC'):
|
|
|
|
{
|
|
|
|
auto search = x28_electricDescs.find(data.GetTag().id);
|
|
|
|
if (search != x28_electricDescs.end())
|
|
|
|
{
|
|
|
|
auto sys = std::make_shared<CParticleElectric>(*search->second);
|
|
|
|
newGen = std::make_unique<CParticleGenInfoGeneric>(data.GetTag(), sys, data.GetDuration(), data.GetSegmentName(),
|
|
|
|
scaleVec, data.GetParentedMode(), flags, mgr, aid,
|
|
|
|
lightId + _getGraphicLightId(sys, *search->second),
|
|
|
|
EParticleGenState::NotStarted);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newGen)
|
|
|
|
{
|
|
|
|
newGen->SetIsActive(true);
|
|
|
|
newGen->SetParticleEmission(true, mgr);
|
|
|
|
newGen->SetIsGrabInitialData(true);
|
|
|
|
InsertParticleGen(oneShot, flags, name, std::move(newGen));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-13 06:19:18 +00:00
|
|
|
void CParticleDatabase::InsertParticleGen(bool oneShot, int flags, std::string_view name,
|
2017-06-03 06:03:07 +00:00
|
|
|
std::unique_ptr<CParticleGenInfo>&& gen)
|
|
|
|
{
|
|
|
|
std::map<std::string, std::unique_ptr<CParticleGenInfo>>* useMap;
|
|
|
|
if (oneShot)
|
|
|
|
{
|
|
|
|
if (flags & 0x40)
|
|
|
|
useMap = &xa0_lastDraw;
|
|
|
|
else if (flags & 0x20)
|
|
|
|
useMap = &x8c_firstDraw;
|
|
|
|
else
|
|
|
|
useMap = &x78_rendererDraw;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (flags & 0x40)
|
|
|
|
useMap = &x64_lastDrawLoop;
|
|
|
|
else if (flags & 0x20)
|
|
|
|
useMap = &x50_firstDrawLoop;
|
|
|
|
else
|
|
|
|
useMap = &x3c_rendererDrawLoop;
|
|
|
|
}
|
|
|
|
|
2017-11-13 07:21:51 +00:00
|
|
|
useMap->insert(std::make_pair(std::string(name), std::move(gen)));
|
2016-11-20 21:53:15 +00:00
|
|
|
|
2017-06-03 06:03:07 +00:00
|
|
|
if (flags & 0x60)
|
2018-02-13 06:46:59 +00:00
|
|
|
xb4_25_anySystemsDrawnWithModel = true;
|
2016-11-20 21:53:15 +00:00
|
|
|
}
|
|
|
|
|
2016-04-16 21:49:47 +00:00
|
|
|
}
|