Pushed scene change and animator component bug fix for models without rigs

This commit is contained in:
Xiao Qi 2023-02-04 02:32:35 +08:00
parent e88447bcf0
commit 33807de93d
2 changed files with 26 additions and 9 deletions

View File

@ -4841,7 +4841,7 @@
- EID: 217
Name: ===Anims===
IsActive: true
NumberOfChildren: 4
NumberOfChildren: 5
Components: ~
Scripts: ~
- EID: 221
@ -4920,3 +4920,22 @@
Clip: 76715962
IsActive: true
Scripts: ~
- EID: 216
Name: Obj5
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 1.23777485, y: 0.394771248, z: -8.23628521}
Rotate: {x: -0, y: -1.57079601, z: 0}
Scale: {x: 0.318525046, y: 0.318552583, z: 0.318525046}
IsActive: true
Renderable Component:
Mesh: 138773466
Material: 117923942
IsActive: true
Animator Component:
Rig: 82124728
Clip: 82124728
IsActive: true
Scripts: ~

View File

@ -23,6 +23,7 @@ of DigiPen Institute of Technology is prohibited.
#include "Graphics/SHVkUtil.h"
#include "Graphics/MiddleEnd/Interface/SHGraphicsSystem.h"
#include "ECS_Base/Managers/SHSystemManager.h"
#include "Graphics/MiddleEnd/Interface/SHMaterialInstance.h"
#include "Tools/SHDebugDraw.h"
namespace SHADE
@ -98,7 +99,7 @@ namespace SHADE
}
}
if (rig && currClip)
if (rig && rig->GetRootNode() && currClip)
{
updatePoseWithClip(0.0f);
}
@ -109,8 +110,11 @@ namespace SHADE
/*-----------------------------------------------------------------------------------*/
void SHAnimatorComponent::Update(float dt)
{
//Reset matrices
std::fill(boneMatrices.begin(), boneMatrices.end(), SHMatrix::Identity);
// Nothing to animate
if (!currClip || !isPlaying || !rig)
if (!currClip || !isPlaying || !rig || !rig->GetRootNode())
return;
// Update time on the playback
@ -120,12 +124,6 @@ namespace SHADE
currPlaybackTime = currPlaybackTime - currClip->GetTotalTime();
}
// Reset all matrices
for (auto& mat : boneMatrices)
{
mat = SHMatrix::Identity;
}
// Play the clip
updatePoseWithClip(currPlaybackTime);
}