Adapted more debugging with Tracy, characters update

This commit is contained in:
2026-02-13 18:14:09 +03:00
parent 71b7f47bcd
commit a85152a675
23 changed files with 814 additions and 133 deletions

View File

@@ -14,12 +14,14 @@ namespace ECS
{
CharacterModule::CharacterModule(flecs::world &ecs)
{
ZoneScoped;
struct TriggerPhysicsChange {};
ecs.module<CharacterModule>();
ecs.component<Character>();
ecs.component<Player>();
ecs.component<CharacterBase>()
.on_remove([this](flecs::entity e, CharacterBase &ch) {
ZoneScoped;
// FIXME: clean up data
if (characterEntities.find(e) !=
characterEntities.end() ||
@@ -31,6 +33,7 @@ CharacterModule::CharacterModule(flecs::world &ecs)
})
.on_add([this](flecs::entity e, CharacterBase &ch) {
if (characterNodes.find(e) == characterNodes.end()) {
ZoneScoped;
OgreAssert(characterModels.find(e) !=
characterModels.end(),
"no model set");
@@ -61,6 +64,7 @@ CharacterModule::CharacterModule(flecs::world &ecs)
ecs.component<CharacterGravity>();
ecs.component<CharacterLocation>().on_set(
[this](flecs::entity e, CharacterLocation &loc) {
ZoneScoped;
characterOrientations[e] = loc.orientation;
characterPositions[e] = loc.position;
ECS::modified<CharacterModule>();
@@ -145,19 +149,22 @@ CharacterModule::CharacterModule(flecs::world &ecs)
else
input.fast = false;
input.control_prev = input.control;
float a = 0, b = 0, c = 0;
if (input.mouse_moved) {
updateCameraGoal(camera, -0.18f * input.mouse.x,
-0.12f * input.mouse.y, 0);
a += -0.18f * input.mouse.x;
b += -0.12f * input.mouse.y;
input.mouse_moved = false;
input.mouse.x = 0;
input.mouse.y = 0;
}
updateCameraGoal(camera, a, b, c);
}
if (input.wheel_moved) {
updateCameraGoal(camera, 0, 0,
-0.15f * input.wheel_y);
c += -0.15f * input.wheel_y;
input.wheel_moved = false;
input.wheel_y = 0;
}
updateCameraGoal(camera, a, b, c);
}
ECS::get().modified<ECS::Input>();
});
#define TURN_SPEED 500.0f // character turning in degrees per second
@@ -400,6 +407,7 @@ void CharacterModule::updateCameraGoal(Camera &camera, Ogre::Real deltaYaw,
Ogre::Real deltaPitch,
Ogre::Real deltaZoom)
{
ZoneScoped;
static float canonDist = 0;
camera.mCameraPivot->yaw(Ogre::Degree(deltaYaw), Ogre::Node::TS_PARENT);
if (!(camera.mPivotPitch + deltaPitch > 25 && deltaPitch > 0) &&
@@ -458,6 +466,7 @@ void applyWeightBasedScale(Ogre::Entity *ent,
const Ogre::String &targetBoneName,
const Ogre::Vector3 &scale)
{
ZoneScoped;
Ogre::MeshPtr mesh = ent->getMesh();
Ogre::SkeletonInstance *skel = ent->getSkeleton();
Ogre::Bone *targetBone = skel->getBone(targetBoneName);
@@ -545,6 +554,7 @@ void CharacterModule::createCharacter(flecs::entity e,
const Ogre::Quaternion &rotation,
const Ogre::String model)
{
ZoneScoped;
if (e.has<CharacterBase>() || e.has<AnimationControl>())
return;
if (characterNodes.find(e) != characterNodes.end())