Big update

This commit is contained in:
2026-03-07 03:14:10 +03:00
parent f8f69d3b88
commit a998771486
33 changed files with 1788 additions and 577 deletions

View File

@@ -674,24 +674,24 @@ void Model::Draw(const glm::mat4& model, SkeletonInstance* instance /*= nullptr*
}
// debug draw
if (instance)
{
glm::mat4 worldMat;
glm::mat4 worldMatParent;
for (int i = 0; i < instance->m_jointMatrices.size(); i++)
{
worldMat = model * instance->m_jointMatrices[i];
glm::vec3 worldPos = worldMat[3];
// g_debugRender->DrawAxis(worldPos);
//if (instance)
//{
// glm::mat4 worldMat;
// glm::mat4 worldMatParent;
// for (int i = 0; i < instance->m_jointMatrices.size(); i++)
// {
// worldMat = model * instance->m_jointMatrices[i];
// glm::vec3 worldPos = worldMat[3];
// // g_debugRender->DrawAxis(worldPos);
const Joint& joint = instance->m_joints[i];
if (joint.parentId != -1)
{
worldMatParent = model * instance->m_jointMatrices[joint.parentId];
g_debugRender->DrawLine(worldMat[3], worldMatParent[3], glm::vec3(1.0f, 1.0f, 1.0f));
}
}
}
// const Joint& joint = instance->m_joints[i];
// if (joint.parentId != -1)
// {
// worldMatParent = model * instance->m_jointMatrices[joint.parentId];
// g_debugRender->DrawLine(worldMat[3], worldMatParent[3], glm::vec3(1.0f, 1.0f, 1.0f));
// }
// }
//}
}
@@ -764,7 +764,7 @@ void Model::UpdateSkeletonInstance(SkeletonInstance* instance, float dt)
instance->m_time += dt;
float frameTime = 1.0f / animation.framerate;
float totalDuration = animation.numFrames * frameTime;
float totalDuration = (animation.numFrames - 1) * frameTime;
if (instance->m_time >= totalDuration && instance->m_looped)
instance->m_time = 0.0f;
@@ -772,11 +772,17 @@ void Model::UpdateSkeletonInstance(SkeletonInstance* instance, float dt)
float animationFrame = instance->m_time / frameTime;
int frameA = (int)(floor(animationFrame));
int frameB = (frameA + 1) % animation.numFrames;
float t = animationFrame - frameA;
if (!instance->m_looped && frameA >= animation.numFrames - 1)
frameA = animation.numFrames - 1;
float t = animationFrame - frameA;
if (instance->m_time >= totalDuration)
{
frameA = animation.numFrames - 1;
frameB = animation.numFrames - 1;
t = 0.0f;
}
for (int i = 0; i < instance->m_joints.size(); ++i)
{