metaforce/Runtime/Character/CAnimData.cpp

1059 lines
36 KiB
C++
Raw Normal View History

#include "CAnimData.hpp"
#include "CCharacterInfo.hpp"
#include "CCharLayoutInfo.hpp"
#include "Graphics/CSkinnedModel.hpp"
#include "CCharacterFactory.hpp"
#include "CAnimationManager.hpp"
#include "CTransitionManager.hpp"
2016-04-16 03:24:25 +00:00
#include "CAdditiveAnimPlayback.hpp"
#include "CBoolPOINode.hpp"
#include "CInt32POINode.hpp"
#include "CParticlePOINode.hpp"
#include "CSoundPOINode.hpp"
#include "CParticleGenInfo.hpp"
2016-04-14 21:42:47 +00:00
#include "IAnimReader.hpp"
#include "CAnimTreeNode.hpp"
2016-08-21 00:04:50 +00:00
#include "CAnimPerSegmentData.hpp"
#include "CSegStatementSet.hpp"
2016-08-21 20:39:18 +00:00
#include "CStateManager.hpp"
2016-09-04 02:27:35 +00:00
#include "CAnimPlaybackParms.hpp"
#include "CAnimTreeBlend.hpp"
#include "CPrimitive.hpp"
#include "CAllFormatsAnimSource.hpp"
#include "GameGlobalObjects.hpp"
namespace urde
{
2017-03-01 06:02:54 +00:00
static logvisor::Module Log("CAnimData");
rstl::reserved_vector<CBoolPOINode, 8>CAnimData::g_BoolPOINodes;
rstl::reserved_vector<CInt32POINode, 16> CAnimData::g_Int32POINodes;
rstl::reserved_vector<CParticlePOINode, 20> CAnimData::g_ParticlePOINodes;
rstl::reserved_vector<CSoundPOINode, 20> CAnimData::g_SoundPOINodes;
2017-07-10 04:55:51 +00:00
rstl::reserved_vector<CInt32POINode, 16> CAnimData::g_TransientInt32POINodes;
2016-04-14 03:32:27 +00:00
void CAnimData::FreeCache()
{
}
void CAnimData::InitializeCache()
{
}
2017-08-13 05:26:14 +00:00
CAnimData::CAnimData(CAssetId id,
2016-04-15 03:02:21 +00:00
const CCharacterInfo& character,
int defaultAnim, int charIdx, bool loop,
const TLockedToken<CCharLayoutInfo>& layout,
const TToken<CSkinnedModel>& model,
2016-04-29 10:08:46 +00:00
const rstl::optional_object<TToken<CMorphableSkinnedModel>>& iceModel,
const std::weak_ptr<CAnimSysContext>& ctx,
const std::shared_ptr<CAnimationManager>& animMgr,
const std::shared_ptr<CTransitionManager>& transMgr,
2016-09-12 04:53:28 +00:00
const TLockedToken<CCharacterFactory>& charFactory,
int drawInstCount)
2016-09-06 05:52:51 +00:00
: x0_charFactory(charFactory),
xc_charInfo(character),
xcc_layoutData(layout),
xd8_modelData(model),
xfc_animCtx(ctx.lock()),
x100_animMgr(animMgr),
x1d8_selfId(id),
x1fc_transMgr(transMgr),
x204_charIdx(charIdx),
x208_defaultAnim(defaultAnim),
x224_pose(layout->GetSegIdList().GetList().size()),
2016-09-12 04:53:28 +00:00
x2fc_poseBuilder(layout),
m_drawInstCount(drawInstCount)
{
x220_25_loop = loop;
2016-04-15 03:02:21 +00:00
if (iceModel)
xe4_iceModelData = *iceModel;
g_BoolPOINodes.resize(8);
g_Int32POINodes.resize(16);
g_ParticlePOINodes.resize(20);
g_SoundPOINodes.resize(20);
2017-07-10 04:55:51 +00:00
g_TransientInt32POINodes.resize(16);
x108_aabb = xd8_modelData->GetModel()->GetAABB();
x120_particleDB.CacheParticleDesc(xc_charInfo.GetParticleResData());
2017-03-01 06:02:54 +00:00
CHierarchyPoseBuilder pb(xcc_layoutData);
pb.BuildNoScale(x224_pose);
x220_30_poseBuilt = true;
if (defaultAnim == -1)
{
defaultAnim = 0;
Log.report(logvisor::Warning, "Character %s has invalid initial animation, so defaulting to first.",
2017-11-13 06:19:18 +00:00
character.GetCharacterName().data());
2017-03-01 06:02:54 +00:00
}
std::shared_ptr<CAnimTreeNode> treeNode =
GetAnimationManager()->GetAnimationTree(character.GetAnimationIndex(defaultAnim),
CMetaAnimTreeBuildOrders::NoSpecialOrders());
if (treeNode != x1f8_animRoot)
x1f8_animRoot = treeNode;
}
2017-11-24 08:01:06 +00:00
void CAnimData::InitializeEffects(CStateManager& mgr, TAreaId aId, const zeus::CVector3f& scale)
{
for (const auto& effects : xc_charInfo.GetEffectList())
{
for (const auto& effect : effects.second)
{
x120_particleDB.CacheParticleDesc(effect.GetParticleTag());
x120_particleDB.AddParticleEffect(effect.GetSegmentName(), effect.GetFlags(), CParticleData(), scale, mgr,
aId, true, x21c_particleLightIdx);
x120_particleDB.SetParticleEffectState(effect.GetComponentName(), false, mgr);
}
}
}
2017-08-13 05:26:14 +00:00
CAssetId CAnimData::GetEventResourceIdForAnimResourceId(CAssetId id) const
2016-04-14 03:32:27 +00:00
{
2016-04-16 03:24:25 +00:00
return x0_charFactory->GetEventResourceIdForAnimResourceId(id);
2016-04-14 03:32:27 +00:00
}
void CAnimData::AddAdditiveSegData(const CSegIdList& list, CSegStatementSet& stSet)
{
2016-09-04 02:27:35 +00:00
for (std::pair<u32, CAdditiveAnimPlayback>& additive : x434_additiveAnims)
if (additive.second.GetTargetWeight() > 0.00001f)
additive.second.AddToSegStatementSet(list, *xcc_layoutData.GetObj(), stSet);
}
2017-03-01 06:02:54 +00:00
SAdvancementResults CAnimData::AdvanceAdditiveAnim(std::shared_ptr<CAnimTreeNode>& anim, const CCharAnimTime& time)
2016-04-14 03:32:27 +00:00
{
2017-03-01 06:02:54 +00:00
SAdvancementResults ret = anim->VAdvanceView(time);
auto simplified = anim->Simplified();
if (simplified)
anim = CAnimTreeNode::Cast(std::move(*simplified));
2017-03-01 06:02:54 +00:00
return ret;
2016-04-14 03:32:27 +00:00
}
2016-08-21 20:39:18 +00:00
SAdvancementDeltas CAnimData::AdvanceAdditiveAnims(float dt)
2016-04-14 03:32:27 +00:00
{
CCharAnimTime time(dt);
2017-03-01 06:02:54 +00:00
SAdvancementDeltas deltas = {};
2016-09-04 02:27:35 +00:00
for (std::pair<u32, CAdditiveAnimPlayback>& additive : x434_additiveAnims)
{
2017-03-01 06:02:54 +00:00
std::shared_ptr<CAnimTreeNode>& anim = additive.second.GetAnim();
2016-09-04 02:27:35 +00:00
if (additive.second.IsActive())
{
2017-07-10 04:55:51 +00:00
while (time.GreaterThanZero() && std::fabs(time.GetSeconds()) >= 0.00001f)
{
2017-03-01 06:02:54 +00:00
x210_passedIntCount += anim->GetInt32POIList(time, g_Int32POINodes.data(), 16, x210_passedIntCount, 0);
x20c_passedBoolCount += anim->GetBoolPOIList(time, g_BoolPOINodes.data(), 8, x20c_passedBoolCount, 0);
x214_passedParticleCount += anim->GetParticlePOIList(time, g_ParticlePOINodes.data(), 8, x214_passedParticleCount, 0);
x218_passedSoundCount += anim->GetSoundPOIList(time, g_SoundPOINodes.data(), 8, x218_passedSoundCount, 0);
SAdvancementResults results = AdvanceAdditiveAnim(anim, time);
deltas.x0_posDelta += results.x8_deltas.x0_posDelta;
deltas.xc_rotDelta *= results.x8_deltas.xc_rotDelta;
time = results.x0_remTime;
}
}
else
{
2017-03-01 06:02:54 +00:00
CCharAnimTime remTime = anim->VGetTimeRemaining();
2017-07-10 04:55:51 +00:00
while (remTime.GreaterThanZero() && std::fabs(remTime.GetSeconds()) >= 0.00001f)
2017-03-01 06:02:54 +00:00
{
x210_passedIntCount += anim->GetInt32POIList(time, g_Int32POINodes.data(), 16, x210_passedIntCount, 0);
x20c_passedBoolCount += anim->GetBoolPOIList(time, g_BoolPOINodes.data(), 8, x20c_passedBoolCount, 0);
x214_passedParticleCount += anim->GetParticlePOIList(time, g_ParticlePOINodes.data(), 8, x214_passedParticleCount, 0);
x218_passedSoundCount += anim->GetSoundPOIList(time, g_SoundPOINodes.data(), 8, x218_passedSoundCount, 0);
SAdvancementResults results = AdvanceAdditiveAnim(anim, time);
deltas.x0_posDelta += results.x8_deltas.x0_posDelta;
deltas.xc_rotDelta *= results.x8_deltas.xc_rotDelta;
CCharAnimTime tmpTime = anim->VGetTimeRemaining();
if (tmpTime < results.x0_remTime)
remTime = tmpTime;
else
remTime = results.x0_remTime;
}
}
}
2016-08-23 03:12:50 +00:00
2017-03-01 06:02:54 +00:00
return deltas;
2016-04-14 03:32:27 +00:00
}
2016-08-21 20:39:18 +00:00
SAdvancementDeltas CAnimData::UpdateAdditiveAnims(float dt)
2016-04-14 03:32:27 +00:00
{
2017-03-01 06:02:54 +00:00
for (auto it = x434_additiveAnims.begin() ; it != x434_additiveAnims.end() ;)
{
it->second.Update(dt);
CCharAnimTime timeRem = it->second.GetAnim()->VGetTimeRemaining();
if (timeRem.EpsilonZero() && it->second.Get20())
it->second.FadeOut();
if (it->second.GetPhase() == EAdditivePlaybackPhase::FadedOut)
{
it = x434_additiveAnims.erase(it);
continue;
}
++it;
}
2016-08-21 20:39:18 +00:00
return AdvanceAdditiveAnims(dt);
2016-04-14 03:32:27 +00:00
}
2016-09-04 02:27:35 +00:00
bool CAnimData::IsAdditiveAnimation(u32 idx) const
{
u32 animIdx = xc_charInfo.GetAnimationIndex(idx);
return x0_charFactory->HasAdditiveInfo(animIdx);
}
bool CAnimData::IsAdditiveAnimationAdded(u32 idx) const
2016-04-14 03:32:27 +00:00
{
2016-09-04 02:27:35 +00:00
auto search = std::find_if(x434_additiveAnims.cbegin(), x434_additiveAnims.cend(),
[&](const std::pair<u32, CAdditiveAnimPlayback>& pair) -> bool {
return pair.first == idx;
});
if (search == x434_additiveAnims.cend())
return false;
return true;
2016-04-14 03:32:27 +00:00
}
const std::shared_ptr<CAnimTreeNode>& CAnimData::GetAdditiveAnimationTree(u32 idx) const
2016-04-14 03:32:27 +00:00
{
2016-09-04 02:27:35 +00:00
auto search = std::find_if(x434_additiveAnims.cbegin(), x434_additiveAnims.cend(),
[&](const std::pair<u32, CAdditiveAnimPlayback>& pair) -> bool {
return pair.first == idx;
});
return search->second.GetAnim();
2016-04-14 03:32:27 +00:00
}
2016-09-04 02:27:35 +00:00
bool CAnimData::IsAdditiveAnimationActive(u32 idx) const
2016-04-14 03:32:27 +00:00
{
2016-09-04 02:27:35 +00:00
auto search = std::find_if(x434_additiveAnims.cbegin(), x434_additiveAnims.cend(),
[&](const std::pair<u32, CAdditiveAnimPlayback>& pair) -> bool {
return pair.first == idx;
});
if (search == x434_additiveAnims.cend())
return false;
2016-09-04 02:27:35 +00:00
return search->second.IsActive();
2016-04-14 03:32:27 +00:00
}
2017-03-01 06:02:54 +00:00
void CAnimData::DelAdditiveAnimation(u32 idx)
2016-04-14 03:32:27 +00:00
{
2017-03-01 06:02:54 +00:00
u32 animIdx = xc_charInfo.GetAnimationIndex(idx);
for (std::pair<u32, CAdditiveAnimPlayback>& anim : x434_additiveAnims)
{
if (anim.first == animIdx &&
anim.second.GetPhase() != EAdditivePlaybackPhase::FadingOut &&
anim.second.GetPhase() != EAdditivePlaybackPhase::FadedOut)
{
anim.second.FadeOut();
return;
}
}
2016-04-14 03:32:27 +00:00
}
2017-03-01 06:02:54 +00:00
void CAnimData::AddAdditiveAnimation(u32 idx, float weight, bool active, bool b)
2016-04-14 03:32:27 +00:00
{
2017-03-01 06:02:54 +00:00
u32 animIdx = xc_charInfo.GetAnimationIndex(idx);
for (std::pair<u32, CAdditiveAnimPlayback>& anim : x434_additiveAnims)
{
if (anim.first == animIdx &&
anim.second.GetPhase() != EAdditivePlaybackPhase::FadingOut &&
anim.second.GetPhase() != EAdditivePlaybackPhase::FadedOut)
{
anim.second.SetActive(active);
anim.second.SetWeight(weight);
anim.second.Set20(!anim.second.IsActive() && b);
return;
}
}
std::shared_ptr<CAnimTreeNode> node =
GetAnimationManager()->GetAnimationTree(animIdx, CMetaAnimTreeBuildOrders::NoSpecialOrders());
const CAdditiveAnimationInfo& info = x0_charFactory->FindAdditiveInfo(animIdx);
x434_additiveAnims.emplace_back(std::make_pair(idx, CAdditiveAnimPlayback(node, weight, active, info, b)));
2016-04-14 03:32:27 +00:00
}
float CAnimData::GetAdditiveAnimationWeight(u32 idx) const
{
u32 animIdx = xc_charInfo.GetAnimationIndex(idx);
for (const std::pair<u32, CAdditiveAnimPlayback>& anim : x434_additiveAnims)
{
if (anim.first == animIdx)
return anim.second.GetTargetWeight();
}
return 0.f;
}
2016-04-14 03:32:27 +00:00
std::shared_ptr<CAnimationManager> CAnimData::GetAnimationManager()
{
2016-09-04 02:27:35 +00:00
return x100_animMgr;
2016-04-14 03:32:27 +00:00
}
2016-09-04 02:27:35 +00:00
void CAnimData::SetPhase(float ph)
2016-04-14 03:32:27 +00:00
{
2016-09-04 02:27:35 +00:00
x1f8_animRoot->VSetPhase(ph);
2016-04-14 03:32:27 +00:00
}
2016-09-04 02:27:35 +00:00
void CAnimData::Touch(const CSkinnedModel& model, int shadIdx) const
2016-04-14 03:32:27 +00:00
{
2016-09-04 02:27:35 +00:00
const_cast<CBooModel&>(*model.GetModelInst()).Touch(shadIdx);
2016-04-14 03:32:27 +00:00
}
2016-04-14 21:42:47 +00:00
SAdvancementDeltas CAnimData::GetAdvancementDeltas(const CCharAnimTime& a,
const CCharAnimTime& b) const
2016-04-14 03:32:27 +00:00
{
2016-09-04 02:27:35 +00:00
return x1f8_animRoot->VGetAdvancementResults(a, b).x8_deltas;
2016-04-14 03:32:27 +00:00
}
2017-07-10 04:55:51 +00:00
CCharAnimTime CAnimData::GetTimeOfUserEvent(EUserEventType type, const CCharAnimTime& time) const
2016-04-14 03:32:27 +00:00
{
2017-07-10 04:55:51 +00:00
u32 count = x1f8_animRoot->GetInt32POIList(time, g_TransientInt32POINodes.data(), 16, 0, 64);
for (int i=0 ; i<count ; ++i)
{
CInt32POINode& poi = g_TransientInt32POINodes[i];
if (poi.GetPoiType() == EPOIType::UserEvent &&
EUserEventType(poi.GetValue()) == type)
{
for (; i<count ; ++i)
g_TransientInt32POINodes[i] = CInt32POINode();
return poi.GetTime();
}
else
{
poi = CInt32POINode();
}
}
return CCharAnimTime::Infinity();
2016-04-14 03:32:27 +00:00
}
2016-09-04 02:27:35 +00:00
void CAnimData::MultiplyPlaybackRate(float mul)
2016-04-14 03:32:27 +00:00
{
2016-09-04 02:27:35 +00:00
x200_speedScale += mul;
2016-04-14 03:32:27 +00:00
}
2016-09-04 02:27:35 +00:00
void CAnimData::SetPlaybackRate(float set)
2016-04-14 03:32:27 +00:00
{
2016-09-04 02:27:35 +00:00
x200_speedScale = set;
2016-04-14 03:32:27 +00:00
}
2017-07-10 04:55:51 +00:00
void CAnimData::SetRandomPlaybackRate(CRandom16& r)
2016-04-14 03:32:27 +00:00
{
2017-07-10 04:55:51 +00:00
for (int i=0 ; i<x210_passedIntCount ; ++i)
{
CInt32POINode& poi = g_Int32POINodes[i];
if (poi.GetPoiType() == EPOIType::RandRate)
{
float tmp = (r.Next() % poi.GetValue()) / 100.f;
if ((r.Next() % 100) < 50)
x200_speedScale = 1.f + tmp;
else
x200_speedScale = 1.f - tmp;
break;
}
}
2016-04-14 03:32:27 +00:00
}
void CAnimData::CalcPlaybackAlignmentParms(const CAnimPlaybackParms& parms,
2016-09-04 02:27:35 +00:00
const std::shared_ptr<CAnimTreeNode>& node)
2016-04-14 03:32:27 +00:00
{
2017-07-10 04:55:51 +00:00
zeus::CQuaternion orient;
x1e8_alignRot = zeus::CQuaternion::skNoRotation;
x220_27_ = false;
if (parms.GetDeltaOrient() && parms.GetObjectXform())
{
ResetPOILists();
x210_passedIntCount += node->GetInt32POIList(CCharAnimTime::Infinity(), g_Int32POINodes.data(),
16, x210_passedIntCount, 64);
for (int i=0 ; i<x210_passedIntCount ; ++i)
{
CInt32POINode& poi = g_Int32POINodes[i];
if (poi.GetPoiType() == EPOIType::UserEvent &&
EUserEventType(poi.GetValue()) == EUserEventType::AlignTargetRot)
{
SAdvancementResults res = node->VGetAdvancementResults(poi.GetTime(), 0.f);
orient = zeus::CQuaternion::slerp(zeus::CQuaternion::skNoRotation,
*parms.GetDeltaOrient() *
zeus::CQuaternion(parms.GetObjectXform()->buildMatrix3f().inverted()) *
res.x8_deltas.xc_rotDelta.inverse(),
1.f / (60.f * poi.GetTime().GetSeconds()));
x1e8_alignRot = orient;
x220_27_ = true;
}
}
}
if (!x220_27_)
{
bool didAlign = false;
bool didStart = false;
zeus::CVector3f posStart, posAlign;
CCharAnimTime timeStart, timeAlign;
if (parms.GetTargetPos() && parms.GetObjectXform())
{
ResetPOILists();
x210_passedIntCount += node->GetInt32POIList(CCharAnimTime::Infinity(), g_Int32POINodes.data(),
16, x210_passedIntCount, 64);
for (int i=0 ; i<x210_passedIntCount ; ++i)
{
CInt32POINode& poi = g_Int32POINodes[i];
if (poi.GetPoiType() == EPOIType::UserEvent)
{
if (EUserEventType(poi.GetValue()) == EUserEventType::AlignTargetPosStart)
{
didStart = true;
SAdvancementResults res = node->VGetAdvancementResults(poi.GetTime(), 0.f);
posStart = res.x8_deltas.x0_posDelta;
timeStart = poi.GetTime();
if (parms.GetIsUseLocator())
posStart += GetLocatorTransform(poi.GetLocatorName(), &poi.GetTime()).origin;
if (didAlign)
break;
}
else if (EUserEventType(poi.GetValue()) == EUserEventType::AlignTargetPos)
{
didAlign = true;
SAdvancementResults res = node->VGetAdvancementResults(poi.GetTime(), 0.f);
posAlign = res.x8_deltas.x0_posDelta;
timeAlign = poi.GetTime();
if (parms.GetIsUseLocator())
posAlign += GetLocatorTransform(poi.GetLocatorName(), &poi.GetTime()).origin;
if (didStart)
break;
}
}
}
if (didAlign && didStart)
{
zeus::CVector3f scaleStart = *parms.GetObjectScale() * posStart;
zeus::CVector3f scaleAlign = *parms.GetObjectScale() * posAlign;
x1dc_alignPos = (parms.GetObjectXform()->inverse() * *parms.GetTargetPos() - scaleStart -
(scaleAlign - scaleStart)) / *parms.GetObjectScale() *
(1.f / (timeAlign.GetSeconds() - timeStart.GetSeconds()));
x220_28_ = true;
x220_26_aligningPos = false;
2017-07-10 04:55:51 +00:00
}
else
{
x1dc_alignPos = zeus::CVector3f::skZero;
x220_28_ = false;
x220_26_aligningPos = false;
2017-07-10 04:55:51 +00:00
}
}
}
else
{
bool didStart = false;
bool didAlign = false;
CCharAnimTime timeStart, timeAlign;
zeus::CVector3f startPos;
if (parms.GetTargetPos() && parms.GetObjectXform())
{
ResetPOILists();
x210_passedIntCount += node->GetInt32POIList(CCharAnimTime::Infinity(), g_Int32POINodes.data(),
16, x210_passedIntCount, 64);
for (int i=0 ; i<x210_passedIntCount ; ++i)
{
CInt32POINode& poi = g_Int32POINodes[i];
if (poi.GetPoiType() == EPOIType::UserEvent)
{
if (EUserEventType(poi.GetValue()) == EUserEventType::AlignTargetPosStart)
{
didStart = true;
timeStart = poi.GetTime();
if (didAlign)
break;
}
else if (EUserEventType(poi.GetValue()) == EUserEventType::AlignTargetPos)
{
didAlign = true;
timeAlign = poi.GetTime();
if (didStart)
break;
}
}
}
if (didAlign && didStart)
{
CCharAnimTime frameInterval(1.f / 60.f);
orient = zeus::CQuaternion::skNoRotation;
x1e8_alignRot = zeus::CQuaternion::skNoRotation;
x220_27_ = true;
CCharAnimTime time;
zeus::CVector3f pos;
zeus::CQuaternion quat;
bool foundStartPos = false;
while (time < timeAlign)
{
SAdvancementResults res = node->VGetAdvancementResults(frameInterval, time);
pos += quat.toTransform() * res.x8_deltas.x0_posDelta;
quat *= (res.x8_deltas.xc_rotDelta * orient);
if (!foundStartPos && time >= timeStart)
{
startPos = pos;
foundStartPos = true;
}
time += frameInterval;
}
zeus::CVector3f scaleStart = startPos * *parms.GetObjectScale();
zeus::CVector3f scaleAlign = pos * *parms.GetObjectScale();
x1dc_alignPos = (parms.GetObjectXform()->inverse() * *parms.GetTargetPos() - scaleStart -
(scaleAlign - scaleStart)) / *parms.GetObjectScale() *
(1.f / (timeAlign.GetSeconds() - timeStart.GetSeconds()));
x220_28_ = true;
x220_26_aligningPos = false;
2017-07-10 04:55:51 +00:00
}
else
{
x1dc_alignPos = zeus::CVector3f::skZero;
x220_28_ = false;
x220_26_aligningPos = false;
2017-07-10 04:55:51 +00:00
}
}
else
{
x1dc_alignPos = zeus::CVector3f::skZero;
x220_28_ = false;
x220_26_aligningPos = false;
2017-07-10 04:55:51 +00:00
}
}
2016-04-14 03:32:27 +00:00
}
zeus::CTransform CAnimData::GetLocatorTransform(CSegId id, const CCharAnimTime* time) const
{
2016-09-03 03:47:57 +00:00
if (id == 0xFF)
return {};
zeus::CTransform ret;
if (time || !x220_31_poseCached)
{
2016-09-03 03:47:57 +00:00
const_cast<CAnimData*>(this)->RecalcPoseBuilder(time);
const_cast<CAnimData*>(this)->x220_31_poseCached = time == nullptr;
}
2016-09-03 03:47:57 +00:00
2016-09-11 21:19:55 +00:00
if (!x220_30_poseBuilt)
x2fc_poseBuilder.BuildTransform(id, ret);
else
{
ret.setRotation(x224_pose.GetTransformMinusOffset(id));
ret.origin = x224_pose.GetOffset(id);
}
2016-09-03 03:47:57 +00:00
return ret;
2016-04-14 03:32:27 +00:00
}
2017-11-13 06:19:18 +00:00
zeus::CTransform CAnimData::GetLocatorTransform(std::string_view name, const CCharAnimTime* time) const
2016-04-14 03:32:27 +00:00
{
2016-09-03 03:47:57 +00:00
return GetLocatorTransform(xcc_layoutData->GetSegIdFromString(name), time);
2016-04-14 03:32:27 +00:00
}
2017-11-13 06:19:18 +00:00
bool CAnimData::IsAnimTimeRemaining(float rem, std::string_view name) const
2016-04-14 03:32:27 +00:00
{
2016-09-04 02:27:35 +00:00
if (!x1f8_animRoot)
return false;
2017-08-26 04:36:25 +00:00
return x1f8_animRoot->VGetTimeRemaining().GetSeconds() >= rem;
2016-04-14 03:32:27 +00:00
}
2017-11-13 06:19:18 +00:00
float CAnimData::GetAnimTimeRemaining(std::string_view name) const
2016-04-14 03:32:27 +00:00
{
2017-07-10 04:55:51 +00:00
float rem = x1f8_animRoot->VGetTimeRemaining().GetSeconds();
2016-09-04 02:27:35 +00:00
if (x200_speedScale)
return rem / x200_speedScale;
return rem;
2016-04-14 03:32:27 +00:00
}
2016-09-04 02:27:35 +00:00
float CAnimData::GetAnimationDuration(int animIn) const
2016-04-14 03:32:27 +00:00
{
2016-09-04 02:27:35 +00:00
std::shared_ptr<IMetaAnim> anim = x100_animMgr->GetMetaAnimation(xc_charInfo.GetAnimationIndex(animIn));
std::set<CPrimitive> prims;
anim->GetUniquePrimitives(prims);
SObjectTag tag{FOURCC('ANIM'), 0};
float durAccum = 0.f;
for (const CPrimitive& prim : prims)
{
tag.id = prim.GetAnimResId();
TLockedToken<CAllFormatsAnimSource> animRes = xfc_animCtx->xc_store.GetObj(tag);
CCharAnimTime dur;
switch (animRes->GetFormat())
{
case EAnimFormat::Uncompressed:
default:
{
const CAnimSource& src = animRes->GetAsCAnimSource();
dur = src.GetDuration();
break;
}
case EAnimFormat::BitstreamCompressed:
case EAnimFormat::BitstreamCompressed24:
{
const CFBStreamedCompression& src = animRes->GetAsCFBStreamedCompression();
dur = src.GetAnimationDuration();
break;
}
}
2017-07-10 04:55:51 +00:00
durAccum += dur.GetSeconds();
2016-09-04 02:27:35 +00:00
}
if (anim->GetType() == EMetaAnimType::Random)
return durAccum / float(prims.size());
return durAccum;
2016-04-14 03:32:27 +00:00
}
std::shared_ptr<CAnimSysContext> CAnimData::GetAnimSysContext() const
{
2016-09-04 02:27:35 +00:00
return xfc_animCtx;
2016-04-14 03:32:27 +00:00
}
std::shared_ptr<CAnimationManager> CAnimData::GetAnimationManager() const
{
2016-09-04 02:27:35 +00:00
return x100_animMgr;
2016-04-14 03:32:27 +00:00
}
2016-08-21 00:04:50 +00:00
void CAnimData::RecalcPoseBuilder(const CCharAnimTime* time)
2016-04-14 03:32:27 +00:00
{
2016-08-31 23:31:12 +00:00
if (!x1f8_animRoot)
return;
2016-08-21 00:04:50 +00:00
const CSegIdList& segIdList = GetCharLayoutInfo().GetSegIdList();
CSegStatementSet segSet;
if (time)
x1f8_animRoot->VGetSegStatementSet(segIdList, segSet, *time);
else
x1f8_animRoot->VGetSegStatementSet(segIdList, segSet);
AddAdditiveSegData(segIdList, segSet);
2016-08-21 00:04:50 +00:00
for (const CSegId& id : segIdList.GetList())
{
if (id == 3)
continue;
CAnimPerSegmentData& segData = segSet[id];
2016-09-09 04:19:19 +00:00
if (segData.x1c_hasOffset)
x2fc_poseBuilder.Insert(id, segData.x0_rotation, segData.x10_offset);
else
x2fc_poseBuilder.Insert(id, segData.x0_rotation);
2016-08-21 00:04:50 +00:00
}
2016-04-14 03:32:27 +00:00
}
2016-09-04 02:27:35 +00:00
void CAnimData::RenderAuxiliary(const zeus::CFrustum& frustum) const
2016-04-14 03:32:27 +00:00
{
2016-09-04 02:27:35 +00:00
const_cast<CParticleDatabase&>(x120_particleDB).AddToRendererClipped(frustum);
2016-04-14 03:32:27 +00:00
}
2016-08-21 20:39:18 +00:00
void CAnimData::Render(CSkinnedModel& model, const CModelFlags& drawFlags,
2016-04-29 10:08:46 +00:00
const rstl::optional_object<CVertexMorphEffect>& morphEffect,
2016-08-21 20:39:18 +00:00
const float* morphMagnitudes)
2016-04-14 03:32:27 +00:00
{
2016-08-21 20:39:18 +00:00
SetupRender(model, drawFlags, morphEffect, morphMagnitudes);
DrawSkinnedModel(model, drawFlags);
2016-04-14 03:32:27 +00:00
}
2016-08-21 20:39:18 +00:00
void CAnimData::SetupRender(CSkinnedModel& model,
const CModelFlags& drawFlags,
2016-04-29 10:08:46 +00:00
const rstl::optional_object<CVertexMorphEffect>& morphEffect,
2016-08-21 20:39:18 +00:00
const float* morphMagnitudes)
{
if (!x220_30_poseBuilt)
{
x2fc_poseBuilder.BuildNoScale(x224_pose);
x220_30_poseBuilt = true;
}
PoseSkinnedModel(model, x224_pose, drawFlags, morphEffect, morphMagnitudes);
}
void CAnimData::DrawSkinnedModel(CSkinnedModel& model, const CModelFlags& flags)
2016-04-14 03:32:27 +00:00
{
2016-08-21 20:39:18 +00:00
model.Draw(flags);
2016-04-14 03:32:27 +00:00
}
void CAnimData::PreRender()
{
2016-08-21 00:04:50 +00:00
if (!x220_31_poseCached)
{
RecalcPoseBuilder(nullptr);
x220_31_poseCached = true;
2016-08-21 20:39:18 +00:00
x220_30_poseBuilt = false;
2016-08-21 00:04:50 +00:00
}
2016-04-14 03:32:27 +00:00
}
void CAnimData::BuildPose()
{
2016-09-04 02:27:35 +00:00
if (!x220_31_poseCached)
{
RecalcPoseBuilder(nullptr);
x220_31_poseCached = true;
x220_30_poseBuilt = false;
}
if (!x220_30_poseBuilt)
{
x2fc_poseBuilder.BuildNoScale(x224_pose);
x220_30_poseBuilt = true;
}
2016-04-14 03:32:27 +00:00
}
2016-09-04 02:27:35 +00:00
void CAnimData::PrimitiveSetToTokenVector(const std::set<CPrimitive>& primSet,
std::vector<CToken>& tokensOut, bool preLock)
2016-04-14 03:32:27 +00:00
{
2016-09-04 02:27:35 +00:00
tokensOut.reserve(primSet.size());
SObjectTag tag{FOURCC('ANIM'), 0};
for (const CPrimitive& prim : primSet)
{
tag.id = prim.GetAnimResId();
tokensOut.push_back(g_SimplePool->GetObj(tag));
if (preLock)
tokensOut.back().Lock();
}
2016-04-14 03:32:27 +00:00
}
void CAnimData::GetAnimationPrimitives(const CAnimPlaybackParms& parms, std::set<CPrimitive>& primsOut) const
{
2016-09-04 02:27:35 +00:00
std::shared_ptr<IMetaAnim> animA =
2017-07-10 04:55:51 +00:00
x100_animMgr->GetMetaAnimation(xc_charInfo.GetAnimationIndex(parms.GetAnimationId()));
2016-09-04 02:27:35 +00:00
animA->GetUniquePrimitives(primsOut);
2017-07-10 04:55:51 +00:00
if (parms.GetSecondAnimationId() != -1)
2016-09-04 02:27:35 +00:00
{
std::shared_ptr<IMetaAnim> animB =
2017-07-10 04:55:51 +00:00
x100_animMgr->GetMetaAnimation(xc_charInfo.GetAnimationIndex(parms.GetSecondAnimationId()));
2016-09-04 02:27:35 +00:00
animB->GetUniquePrimitives(primsOut);
}
2016-04-14 03:32:27 +00:00
}
2016-09-04 02:27:35 +00:00
void CAnimData::SetAnimation(const CAnimPlaybackParms& parms, bool noTrans)
2016-04-14 03:32:27 +00:00
{
2017-07-10 04:55:51 +00:00
if (parms.GetAnimationId() == x40c_playbackParms.GetAnimationId() ||
(parms.GetSecondAnimationId() == x40c_playbackParms.GetSecondAnimationId() &&
parms.GetBlendFactor() == x40c_playbackParms.GetBlendFactor() &&
parms.GetBlendFactor() != 1.f) ||
parms.GetSecondAnimationId() == -1)
2016-09-04 02:27:35 +00:00
{
if (x220_29_animationJustStarted)
2016-09-04 02:27:35 +00:00
return;
}
2017-07-10 04:55:51 +00:00
x40c_playbackParms.SetAnimationId(parms.GetAnimationId());
x40c_playbackParms.SetSecondAnimationId(parms.GetSecondAnimationId());
x40c_playbackParms.SetBlendFactor(parms.GetBlendFactor());
2016-09-04 02:27:35 +00:00
x200_speedScale = 1.f;
2017-07-10 04:55:51 +00:00
x208_defaultAnim = parms.GetAnimationId();
2016-09-04 02:27:35 +00:00
2017-07-10 04:55:51 +00:00
u32 animIdxA = xc_charInfo.GetAnimationIndex(parms.GetAnimationId());
2016-09-04 02:27:35 +00:00
ResetPOILists();
std::shared_ptr<CAnimTreeNode> blendNode;
2017-07-10 04:55:51 +00:00
if (parms.GetSecondAnimationId() != -1)
2016-09-04 02:27:35 +00:00
{
2017-07-10 04:55:51 +00:00
u32 animIdxB = xc_charInfo.GetAnimationIndex(parms.GetSecondAnimationId());
2016-09-04 02:27:35 +00:00
std::shared_ptr<CAnimTreeNode> treeA =
x100_animMgr->GetAnimationTree(animIdxA, CMetaAnimTreeBuildOrders::NoSpecialOrders());
2016-09-04 02:27:35 +00:00
std::shared_ptr<CAnimTreeNode> treeB =
x100_animMgr->GetAnimationTree(animIdxB, CMetaAnimTreeBuildOrders::NoSpecialOrders());
2016-09-04 02:27:35 +00:00
2017-07-10 04:55:51 +00:00
blendNode = std::make_shared<CAnimTreeBlend>(false, treeA, treeB, parms.GetBlendFactor(),
2016-09-04 02:27:35 +00:00
CAnimTreeBlend::CreatePrimitiveName(treeA, treeB,
2017-07-10 04:55:51 +00:00
parms.GetBlendFactor()));
2016-09-04 02:27:35 +00:00
}
else
{
blendNode = x100_animMgr->GetAnimationTree(animIdxA, CMetaAnimTreeBuildOrders::NoSpecialOrders());
2016-09-04 02:27:35 +00:00
}
if (!noTrans && x1f8_animRoot)
2016-09-04 02:27:35 +00:00
x1f8_animRoot = x1fc_transMgr->GetTransitionTree(x1f8_animRoot, blendNode);
else
x1f8_animRoot = blendNode;
2017-07-10 04:55:51 +00:00
x220_24_animating = parms.GetIsPlayAnimation();
2016-09-04 02:27:35 +00:00
CalcPlaybackAlignmentParms(parms, blendNode);
ResetPOILists();
x220_29_animationJustStarted = true;
2016-04-14 03:32:27 +00:00
}
2017-06-03 06:03:07 +00:00
SAdvancementDeltas CAnimData::DoAdvance(float dt, bool& suspendParticles, CRandom16& random, bool advTree)
2016-04-14 03:32:27 +00:00
{
2017-06-03 06:03:07 +00:00
suspendParticles = false;
2016-08-21 20:39:18 +00:00
zeus::CVector3f offsetPre, offsetPost;
zeus::CQuaternion quatPre, quatPost;
ResetPOILists();
float scaleDt = dt * x200_speedScale;
if (x2fc_poseBuilder.HasRoot())
{
SAdvancementDeltas deltas = UpdateAdditiveAnims(scaleDt);
offsetPre = deltas.x0_posDelta;
quatPre = deltas.xc_rotDelta;
}
if (!x220_24_animating)
{
2017-06-03 06:03:07 +00:00
suspendParticles = true;
2016-08-21 20:39:18 +00:00
return {};
}
if (x220_29_animationJustStarted)
2016-08-21 20:39:18 +00:00
{
x220_29_animationJustStarted = false;
2017-06-03 06:03:07 +00:00
suspendParticles = true;
2016-08-21 20:39:18 +00:00
}
2016-09-02 17:50:03 +00:00
if (advTree && x1f8_animRoot)
2016-08-21 20:39:18 +00:00
{
SetRandomPlaybackRate(random);
CCharAnimTime time(scaleDt);
if (x220_25_loop)
{
while (time.GreaterThanZero() && !time.EpsilonZero())
{
x210_passedIntCount += x1f8_animRoot->GetInt32POIList(time, g_Int32POINodes.data(), 16, x210_passedIntCount, 0);
x20c_passedBoolCount += x1f8_animRoot->GetBoolPOIList(time, g_BoolPOINodes.data(), 16, x20c_passedBoolCount, 0);
x214_passedParticleCount += x1f8_animRoot->GetParticlePOIList(time, g_ParticlePOINodes.data(), 16, x214_passedParticleCount, 0);
x218_passedSoundCount += x1f8_animRoot->GetSoundPOIList(time, g_SoundPOINodes.data(), 16, x218_passedSoundCount, 0);
AdvanceAnim(time, offsetPost, quatPost);
}
}
else
{
CCharAnimTime remTime = x1f8_animRoot->VGetTimeRemaining();
2017-11-27 05:06:53 +00:00
while (!remTime.EpsilonZero() && !time.EpsilonZero())
2016-08-21 20:39:18 +00:00
{
x210_passedIntCount += x1f8_animRoot->GetInt32POIList(time, g_Int32POINodes.data(), 16, x210_passedIntCount, 0);
x20c_passedBoolCount += x1f8_animRoot->GetBoolPOIList(time, g_BoolPOINodes.data(), 16, x20c_passedBoolCount, 0);
x214_passedParticleCount += x1f8_animRoot->GetParticlePOIList(time, g_ParticlePOINodes.data(), 16, x214_passedParticleCount, 0);
x218_passedSoundCount += x1f8_animRoot->GetSoundPOIList(time, g_SoundPOINodes.data(), 16, x218_passedSoundCount, 0);
AdvanceAnim(time, offsetPost, quatPost);
remTime = x1f8_animRoot->VGetTimeRemaining();
2017-07-10 04:55:51 +00:00
time = std::max(0.f, std::min(remTime.GetSeconds(), time.GetSeconds()));
2016-08-21 20:39:18 +00:00
if (remTime.EpsilonZero())
{
x220_24_animating = false;
x1dc_alignPos = zeus::CVector3f::skZero;
2016-08-21 20:39:18 +00:00
x220_28_ = false;
x220_26_aligningPos = false;
2016-08-21 20:39:18 +00:00
}
}
}
x220_31_poseCached = false;
x220_30_poseBuilt = false;
}
return {offsetPost + offsetPre, quatPost * quatPre};
2016-04-14 03:32:27 +00:00
}
2016-08-21 20:39:18 +00:00
SAdvancementDeltas CAnimData::Advance(float dt, const zeus::CVector3f& scale,
2016-09-02 17:50:03 +00:00
CStateManager& stateMgr, TAreaId aid, bool advTree)
2016-04-14 03:32:27 +00:00
{
2017-06-03 06:03:07 +00:00
bool suspendParticles;
SAdvancementDeltas deltas = DoAdvance(dt, suspendParticles, *stateMgr.GetActiveRandom(), advTree);
if (suspendParticles)
2016-08-21 20:39:18 +00:00
x120_particleDB.SuspendAllActiveEffects(stateMgr);
for (CParticlePOINode& node : g_ParticlePOINodes)
{
if (node.GetCharacterIndex() == -1 || node.GetCharacterIndex() == x204_charIdx)
2016-08-21 20:39:18 +00:00
{
2017-06-03 06:03:07 +00:00
x120_particleDB.AddParticleEffect(node.GetString(), node.GetFlags(), node.GetParticleData(),
scale, stateMgr, aid, false, x21c_particleLightIdx);
2016-08-21 20:39:18 +00:00
}
}
2017-06-03 06:03:07 +00:00
return deltas;
2016-04-14 03:32:27 +00:00
}
2016-09-02 17:50:03 +00:00
SAdvancementDeltas CAnimData::AdvanceIgnoreParticles(float dt, CRandom16& random, bool advTree)
2016-04-14 03:32:27 +00:00
{
2017-06-03 06:03:07 +00:00
bool suspendParticles;
return DoAdvance(dt, suspendParticles, random, advTree);
2016-04-14 03:32:27 +00:00
}
2016-08-21 20:39:18 +00:00
void CAnimData::AdvanceAnim(CCharAnimTime& time, zeus::CVector3f& offset, zeus::CQuaternion& quat)
2016-04-14 03:32:27 +00:00
{
2016-08-21 20:39:18 +00:00
SAdvancementResults results;
std::experimental::optional<std::unique_ptr<IAnimReader>> simplified;
2016-08-21 20:39:18 +00:00
2017-08-18 01:30:15 +00:00
if (x104_animDir == EAnimDir::Forward)
2016-08-21 20:39:18 +00:00
{
results = x1f8_animRoot->VAdvanceView(time);
2017-03-01 06:02:54 +00:00
simplified = x1f8_animRoot->Simplified();
2016-08-21 20:39:18 +00:00
}
if (simplified)
x1f8_animRoot = CAnimTreeNode::Cast(std::move(*simplified));
2016-08-21 20:39:18 +00:00
if ((x220_28_ || x220_27_) && x210_passedIntCount > 0)
{
for (CInt32POINode& node : g_Int32POINodes)
{
if (node.GetPoiType() == EPOIType::UserEvent)
{
switch (EUserEventType(node.GetValue()))
{
case EUserEventType::AlignTargetPosStart:
{
x220_26_aligningPos = true;
2016-08-21 20:39:18 +00:00
break;
}
case EUserEventType::AlignTargetPos:
{
x1dc_alignPos = zeus::CVector3f::skZero;
2016-08-21 20:39:18 +00:00
x220_28_ = false;
x220_26_aligningPos = false;
2016-08-21 20:39:18 +00:00
break;
}
case EUserEventType::AlignTargetRot:
{
x1e8_alignRot = zeus::CQuaternion::skNoRotation;
2016-08-21 20:39:18 +00:00
x220_27_ = false;
break;
}
default: break;
}
}
}
}
offset += results.x8_deltas.x0_posDelta;
if (x220_26_aligningPos)
2017-07-10 04:55:51 +00:00
offset += x1dc_alignPos * time.GetSeconds();
2016-08-21 20:39:18 +00:00
zeus::CQuaternion rot = results.x8_deltas.xc_rotDelta * x1e8_alignRot;
2016-08-21 20:39:18 +00:00
quat = quat * rot;
x1dc_alignPos = rot.transform(x1dc_alignPos);
2016-08-21 20:39:18 +00:00
time = results.x0_remTime;
2016-04-14 03:32:27 +00:00
}
void CAnimData::SetXRayModel(const TLockedToken<CModel>& model, const TLockedToken<CSkinRules>& skinRules)
{
2016-09-12 04:53:28 +00:00
xf4_xrayModel = std::make_shared<CSkinnedModel>(model, skinRules, xd8_modelData->GetLayoutInfo(), 0, m_drawInstCount);
2016-04-14 03:32:27 +00:00
}
void CAnimData::SetInfraModel(const TLockedToken<CModel>& model, const TLockedToken<CSkinRules>& skinRules)
{
2016-09-12 04:53:28 +00:00
xf8_infraModel = std::make_shared<CSkinnedModel>(model, skinRules, xd8_modelData->GetLayoutInfo(), 0, m_drawInstCount);
2016-04-14 03:32:27 +00:00
}
2016-08-21 20:39:18 +00:00
void CAnimData::PoseSkinnedModel(CSkinnedModel& model, const CPoseAsTransforms& pose,
const CModelFlags& drawFlags,
2016-04-29 10:08:46 +00:00
const rstl::optional_object<CVertexMorphEffect>& morphEffect,
2016-08-21 20:39:18 +00:00
const float* morphMagnitudes)
2016-04-14 03:32:27 +00:00
{
2016-08-21 20:39:18 +00:00
model.Calculate(pose, drawFlags, morphEffect, morphMagnitudes);
2016-04-14 03:32:27 +00:00
}
2016-09-04 02:27:35 +00:00
void CAnimData::AdvanceParticles(const zeus::CTransform& xf, float dt,
const zeus::CVector3f& vec, CStateManager& stateMgr)
2016-04-14 03:32:27 +00:00
{
2016-09-04 02:27:35 +00:00
x120_particleDB.Update(dt, x224_pose, *xcc_layoutData, xf, vec, stateMgr);
2016-04-14 03:32:27 +00:00
}
2016-09-04 02:27:35 +00:00
float CAnimData::GetAverageVelocity(int animIn) const
2016-04-14 03:32:27 +00:00
{
2016-09-04 02:27:35 +00:00
std::shared_ptr<IMetaAnim> anim = x100_animMgr->GetMetaAnimation(xc_charInfo.GetAnimationIndex(animIn));
std::set<CPrimitive> prims;
anim->GetUniquePrimitives(prims);
SObjectTag tag{FOURCC('ANIM'), 0};
float velAccum = 0.f;
float durAccum = 0.f;
for (const CPrimitive& prim : prims)
{
tag.id = prim.GetAnimResId();
TLockedToken<CAllFormatsAnimSource> animRes = xfc_animCtx->xc_store.GetObj(tag);
CCharAnimTime dur;
float avgVel;
switch (animRes->GetFormat())
{
case EAnimFormat::Uncompressed:
default:
{
const CAnimSource& src = animRes->GetAsCAnimSource();
dur = src.GetDuration();
avgVel = src.GetAverageVelocity();
break;
}
case EAnimFormat::BitstreamCompressed:
case EAnimFormat::BitstreamCompressed24:
{
const CFBStreamedCompression& src = animRes->GetAsCFBStreamedCompression();
dur = src.GetAnimationDuration();
avgVel = src.GetAverageVelocity();
break;
}
}
2017-07-10 04:55:51 +00:00
velAccum += dur.GetSeconds() * avgVel;
durAccum += dur.GetSeconds();
2016-09-04 02:27:35 +00:00
}
if (durAccum > 0.f)
return velAccum / durAccum;
return 0.f;
2016-04-14 03:32:27 +00:00
}
void CAnimData::ResetPOILists()
{
2016-09-04 02:27:35 +00:00
x20c_passedBoolCount = 0;
x210_passedIntCount = 0;
x214_passedParticleCount = 0;
x218_passedSoundCount = 0;
2016-04-14 03:32:27 +00:00
}
2017-11-13 06:19:18 +00:00
CSegId CAnimData::GetLocatorSegId(std::string_view name) const
2016-04-14 03:32:27 +00:00
{
2016-09-04 02:27:35 +00:00
return xcc_layoutData->GetSegIdFromString(name);
2016-04-14 03:32:27 +00:00
}
zeus::CAABox CAnimData::GetBoundingBox(const zeus::CTransform& xf) const
{
2016-09-04 02:27:35 +00:00
return GetBoundingBox().getTransformedAABox(xf);
2016-04-14 03:32:27 +00:00
}
zeus::CAABox CAnimData::GetBoundingBox() const
{
2016-09-04 02:27:35 +00:00
auto aabbList = xc_charInfo.GetAnimBBoxList();
if (aabbList.empty())
return x108_aabb;
CAnimTreeEffectiveContribution contrib = x1f8_animRoot->GetContributionOfHighestInfluence();
auto search = std::find_if(aabbList.cbegin(), aabbList.cend(),
[&](const std::pair<std::string, zeus::CAABox>& other) -> bool {
return contrib.x4_name == other.first;
});
if (search == aabbList.cend())
return x108_aabb;
return search->second;
2016-04-14 03:32:27 +00:00
}
2017-05-06 05:21:42 +00:00
void CAnimData::SubstituteModelData(const TCachedToken<CSkinnedModel>& model)
{
xd8_modelData = model;
x108_aabb = xd8_modelData->GetModel()->GetAABB();
}
2017-11-13 06:19:18 +00:00
void CAnimData::SetParticleCEXTValue(std::string_view name, int idx, float value)
2017-06-03 06:03:07 +00:00
{
auto search = std::find_if(xc_charInfo.x98_effects.begin(), xc_charInfo.x98_effects.end(),
[&name](const auto& v) { return v.first == name; });
if (search != xc_charInfo.x98_effects.end() && search->second.size())
x120_particleDB.SetCEXTValue(search->second.front().GetComponentName(), idx, value);
}
}