Making this work

This commit is contained in:
2025-08-21 10:47:57 +03:00
parent 52de5b16a8
commit d3b2ae30d5
9 changed files with 147 additions and 46 deletions

View File

@@ -22,6 +22,7 @@ Character::Character(Ogre::SceneManager *scnMgr, const Ogre::String &model,
, mGhostObject(nullptr)
, mWorld(world)
, mGoalDirection(0, 0, 0)
, mUpdate(false)
{
setupBody();
setupAnimations();
@@ -38,10 +39,12 @@ bool Character::frameStarted(const Ogre::FrameEvent &evt)
bool Character::frameRenderingQueued(const Ogre::FrameEvent &evt)
{
updateBody(evt.timeSinceLastFrame);
updateAnimations(evt.timeSinceLastFrame);
if (evt.timeSinceLastFrame > 0)
updateRootMotion(evt.timeSinceLastFrame);
if (mUpdate) {
updateBody(evt.timeSinceLastFrame);
updateAnimations(evt.timeSinceLastFrame);
if (evt.timeSinceLastFrame > 0)
updateRootMotion(evt.timeSinceLastFrame);
}
return true;
}

View File

@@ -38,6 +38,7 @@ class Character : public Ogre::FrameListener {
btCompoundShape *mCollisionShape;
btPairCachingGhostObject *mGhostObject;
Ogre::Bullet::DynamicsWorld *mWorld;
bool mUpdate;
public:
Character(Ogre::SceneManager *scnMgr, const Ogre::String &modelName,
@@ -112,4 +113,16 @@ public:
return mGoalDirection;
}
Ogre::Vector3 getPosition();
};
void enableUpdates()
{
mUpdate = true;
}
void disableUpdates()
{
mUpdate = false;
}
bool getUpdates()
{
return mUpdate;
}
};

View File

@@ -183,6 +183,7 @@ CharacterController::CharacterController(Ogre::SceneNode *camNode,
, mWorld(world)
, mCollisionShape(nullptr)
, mGhostObject(nullptr)
, mUpdate(false)
{
setupBody();
setupCamera();
@@ -445,11 +446,13 @@ bool CharacterController::mousePressed(const OgreBites::MouseButtonEvent &evt)
}
void CharacterController::frameRendered(const Ogre::FrameEvent &evt)
{
updateBody(evt.timeSinceLastFrame);
updateAnimations(evt.timeSinceLastFrame);
updateCamera(evt.timeSinceLastFrame);
if (evt.timeSinceLastFrame > 0)
updateRootMotion(evt.timeSinceLastFrame);
if (mUpdate) {
updateBody(evt.timeSinceLastFrame);
updateAnimations(evt.timeSinceLastFrame);
updateCamera(evt.timeSinceLastFrame);
if (evt.timeSinceLastFrame > 0)
updateRootMotion(evt.timeSinceLastFrame);
}
}
bool CharacterController::frameStarted(const Ogre::FrameEvent &evt)
{

View File

@@ -81,6 +81,8 @@ class CharacterController : public OgreBites::InputListener,
btCompoundShape *mCollisionShape;
btPairCachingGhostObject *mGhostObject;
bool mUpdate;
public:
CharacterController(Ogre::SceneNode *camNode, Ogre::Camera *cam,
Ogre::SceneManager *scnMgr,
@@ -159,4 +161,17 @@ private:
q = convert(from.getRotation());
v = convert(from.getOrigin());
}
public:
void enableUpdates()
{
mUpdate = true;
}
void disableUpdates()
{
mUpdate = false;
}
bool getUpdates()
{
return mUpdate;
}
};

View File

@@ -21,7 +21,8 @@
#define ENDLESS_TERRAIN_FILE_PREFIX Ogre::String("EndlessWorldTerrain")
#define ENDLESS_TERRAIN_FILE_SUFFIX Ogre::String("dat")
#define TERRAIN_WORLD_SIZE 4000.0f
#define TERRAIN_SIZE 513
// #define TERRAIN_SIZE 513
#define TERRAIN_SIZE 129
// #define HOLD_LOD_DISTANCE 3000.0
#define USE_PERLIN_DEFINER 0
template <typename T> T CLAMP(T value, T low, T high)