Changeset View
Changeset View
Standalone View
Standalone View
source/graphics/Model.cpp
Show First 20 Lines • Show All 444 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
// SetAnimation: set the given animation as the current animation on this model; | // SetAnimation: set the given animation as the current animation on this model; | ||||
// return false on error, else true | // return false on error, else true | ||||
bool CModel::SetAnimation(CSkeletonAnim* anim, bool once) | bool CModel::SetAnimation(CSkeletonAnim* anim, bool once) | ||||
{ | { | ||||
m_Anim = NULL; // in case something fails | m_Anim = NULL; // in case something fails | ||||
Stan: We just need to make sure that's set. nullptr? | |||||
if (anim) | if (anim) | ||||
{ | { | ||||
m_Flags &= ~MODELFLAG_NOLOOPANIMATION; | m_Flags &= ~MODELFLAG_NOLOOPANIMATION; | ||||
if (once) | if (once) | ||||
m_Flags |= MODELFLAG_NOLOOPANIMATION; | m_Flags |= MODELFLAG_NOLOOPANIMATION; | ||||
if (!m_BoneMatrices && anim->m_AnimDef) | // Not rigged or animation is not valid. | ||||
{ | if (!m_BoneMatrices || !anim->m_AnimDef) | ||||
Not Done Inline ActionsI think the proper word here is "rigged". Stan: I think the proper word here is "rigged". | |||||
// not boned, can't animate | |||||
return false; | |||||
} | |||||
if (m_BoneMatrices && !anim->m_AnimDef) | |||||
{ | |||||
// boned, but animation isn't valid | |||||
// (e.g. the default (static) idle animation on an animated unit) | |||||
return false; | return false; | ||||
} | |||||
if (anim->m_AnimDef && anim->m_AnimDef->GetNumKeys() != m_pModelDef->GetNumBones()) | if (anim->m_AnimDef->GetNumKeys() != m_pModelDef->GetNumBones()) | ||||
{ | { | ||||
// mismatch between model's skeleton and animation's skeleton | // Mismatch between model's skeleton and animation's skeleton. | ||||
Not Done Inline ActionsNeeds rebase after rP23225 Stan: Needs rebase after rP23225 | |||||
StanUnsubmitted Not Done Inline ActionsI guess nuke? Stan: I guess nuke? | |||||
LOGERROR("Mismatch between model's skeleton and animation's skeleton (%s.dae has %lu model bones while the animation %s has %lu animation keys.)", | LOGERROR("Mismatch between model's skeleton and animation's skeleton (%s.dae has %lu model bones while the animation %s has %lu animation keys.)", | ||||
m_pModelDef->GetName().string8().c_str() , | m_pModelDef->GetName().string8().c_str() , | ||||
static_cast<unsigned long>(m_pModelDef->GetNumBones()), | static_cast<unsigned long>(m_pModelDef->GetNumBones()), | ||||
anim->m_Name.c_str(), | anim->m_Name.c_str(), | ||||
static_cast<unsigned long>(anim->m_AnimDef->GetNumKeys())); | static_cast<unsigned long>(anim->m_AnimDef->GetNumKeys())); | ||||
return false; | return false; | ||||
} | } | ||||
// reset the cached bounds when the animation is changed | // Reset the cached bounds when the animation is changed. | ||||
m_ObjectBounds.SetEmpty(); | m_ObjectBounds.SetEmpty(); | ||||
InvalidateBounds(); | InvalidateBounds(); | ||||
// start anim from beginning | // Start anim from beginning. | ||||
m_AnimTime = 0; | m_AnimTime = 0; | ||||
} | } | ||||
m_Anim = anim; | m_Anim = anim; | ||||
Not Done Inline ActionsWhy do we set anim if !anim? Stan: Why do we set anim if !anim? | |||||
Done Inline ActionsYou would need to ask philip rP1920, probably should be inside the if, but it changes nothing if condition is false so does not matter Silier: You would need to ask philip rP1920, probably should be inside the if, but it changes nothing… | |||||
return true; | return true; | ||||
} | } | ||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
// CopyAnimation | // CopyAnimation | ||||
void CModel::CopyAnimationFrom(CModel* source) | void CModel::CopyAnimationFrom(CModel* source) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 178 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
We just need to make sure that's set. nullptr?