Working on morph targets

This commit is contained in:
2025-10-07 23:14:15 +03:00
parent 19a1275a8a
commit 3645557520
14 changed files with 731 additions and 85 deletions

View File

@@ -203,17 +203,40 @@ CharacterAnimationModule::CharacterAnimationModule(flecs::world &ecs)
Ogre::Quaternion rot = ch.mBodyNode->getOrientation();
Ogre::Vector3 pos = ch.mBodyNode->getPosition();
Ogre::Vector3 boneMotion = ch.mBoneMotion;
v.velocity = Ogre::Math::lerp(
v.velocity, rot * boneMotion / eng.delta,
0.99f);
v.velocity = Ogre::Vector3::ZERO;
float safeDelta =
Ogre::Math::Clamp(eng.delta, 0.001f, 0.99f);
#if 0
if (!e.has<CharacterInActuator>()) {
v.velocity = Ogre::Math::lerp(
v.velocity,
rot * boneMotion / safeDelta, 0.99f);
} else {
// v.velocity = rot * boneMotion / safeDelta;
v.velocity = Ogre::Math::lerp(
v.velocity,
rot * boneMotion / safeDelta, 0.99f);
}
#endif
v.velocity = rot * boneMotion / safeDelta;
if (!e.has<CharacterDisablePhysics>() &&
!e.has<CharacterInActuator>()) {
if (eng.startupDelay <= 0.0f)
v.velocity += v.gvelocity;
v.velocity.y = Ogre::Math::Clamp(
v.velocity.y, -10.5f, 1000000.0f);
v.velocity.y = Ogre::Math::Clamp(v.velocity.y,
-10.5f, 10.0f);
}
// if (v.velocity.squaredLength() > 1.4f * 1.4f)
// v.velocity = v.velocity.normalisedCopy() * 1.4f;
// ch.mBoneMotion = Ogre::Vector3::ZERO;
// safety
// std::cout << "velocity: " << v.velocity << std::endl;
v.velocity.x =
Ogre::Math::Clamp(v.velocity.x, -16.0f, 16.0f);
v.velocity.z =
Ogre::Math::Clamp(v.velocity.z, -16.0f, 16.0f);
v.velocity.y =
Ogre::Math::Clamp(v.velocity.y, -10.5f, 10.0f);
});
ecs.system<const EngineData, const AnimationControl,
const CharacterBase, CharacterVelocity>("HandleSwimming")
@@ -258,6 +281,12 @@ CharacterAnimationModule::CharacterAnimationModule(flecs::world &ecs)
if (body.mController) {
Ogre::Vector3 rotMotion =
v.velocity * eng.delta;
rotMotion.x = Ogre::Math::Clamp(
rotMotion.x, -0.04f, 0.04f);
rotMotion.y = Ogre::Math::Clamp(
rotMotion.y, -0.025f, 0.1f);
rotMotion.z = Ogre::Math::Clamp(
rotMotion.z, -0.04f, 0.04f);
btVector3 currentPosition =
body.mGhostObject
->getWorldTransform()