Skip to content

Commit

Permalink
Fix #1
Browse files Browse the repository at this point in the history
  • Loading branch information
dfdyz authored and asuka-mio committed Feb 13, 2022
1 parent a25105e commit e042ddd
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion KAIMyEntitySaba.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,20 @@ void KAIMyEntitySaba::DeleteModel(Model *model)

void KAIMyEntitySaba::UpdateModel(Model *model)
{
int maxAnim = 0;
double deltaTime = saba::GetTime() - model->prevSabaTime;
model->prevSabaTime = saba::GetTime();
double elapsed = deltaTime;
if (elapsed > PHYSICS_ELAPSED)
elapsed = PHYSICS_ELAPSED;
for (size_t i = 0; i < model->vmdAnimCount; ++i)
{
auto vmdAnim = model->vmdAnims[i];
if (vmdAnim != nullptr)
{
maxAnim = i;
}
}
model->mmdModel->BeginAnimation();
for (size_t i = 0; i < model->vmdAnimCount; ++i)
{
Expand All @@ -91,7 +100,22 @@ void KAIMyEntitySaba::UpdateModel(Model *model)
if (animTime * FPS > vmdAnim->GetMaxKeyTime())
animTime = 0.0;
model->animTimes[i] = animTime;
model->mmdModel->UpdateAllAnimation(vmdAnim, animTime * FPS, elapsed);

if (i == maxAnim)
{
model->mmdModel->UpdateAllAnimation(vmdAnim, animTime * FPS, elapsed);
}
else
{
float vmdFrame = animTime * FPS;
if (vmdAnim != nullptr)
{
vmdAnim->Evaluate(vmdFrame);
}
model->mmdModel->UpdateMorphAnimation();
model->mmdModel->UpdateNodeAnimation(false);
}

}
}
model->mmdModel->EndAnimation();
Expand Down

0 comments on commit e042ddd

Please sign in to comment.