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

@@ -244,6 +244,7 @@ public:
float panel_width;
void initGui();
};
#define WATER
class App : public OgreBites::ApplicationContext {
std::unique_ptr<Ogre::Bullet::DynamicsWorld> mDynWorld;
std::unique_ptr<Ogre::Bullet::DebugDrawer> mDbgDraw;
@@ -258,7 +259,9 @@ class App : public OgreBites::ApplicationContext {
TerrainSetup m_terrain;
Ogre::Light *mSun;
SkyBoxRenderer *sky;
#ifdef WATER
Water m_water;
#endif
class KeyboardListener : public OgreBites::InputListener,
public Ogre::FrameListener {
App *mApp;
@@ -361,6 +364,10 @@ class App : public OgreBites::ApplicationContext {
fps_timer.reset();
}
update(evt.timeSinceLastFrame);
if (mApp->getCharacterController() && gui_active)
mApp->getCharacterController()->disableUpdates();
else if (mApp->getCharacterController() && !gui_active)
mApp->getCharacterController()->enableUpdates();
if (!gui_active) {
mApp->updateSun(evt.timeSinceLastFrame);
mApp->updateTerrain(evt.timeSinceLastFrame);
@@ -407,7 +414,11 @@ public:
}
void dump_water()
{
#if 0
#ifdef WATER
m_water.dump_textures();
#endif
#endif
}
void initCamera()
@@ -457,7 +468,10 @@ public:
std::cout << "Init camera" << "\n";
initCamera();
std::cout << "Set up water" << "\n";
m_water.createWater(getRenderWindow(), mCamera);
#ifdef WATER
m_water.createWater(getRenderWindow(), mCamera,
mDynWorld.get());
#endif
std::cout << "Set up cursor" << "\n";
Ogre::ResourceGroupManager::getSingleton()
.initialiseAllResourceGroups();
@@ -467,7 +481,9 @@ public:
createContent();
std::cout << "Setup terrain" << "\n";
setupTerrain();
#ifdef WATER
m_water.init();
#endif
setupPlayer();
setupInput();
}
@@ -535,13 +551,23 @@ public:
void updateTerrain(float delta)
{
}
// TODO: implement rough water level calculation
float getWaterLevel(const Ogre::Vector3 &position)
{
Ogre::Vector3::UNIT_Y;
float etime =
Ogre::ControllerManager::getSingleton().getElapsedTime();
return 0.0f;
}
void updateWorld(float delta)
{
mDynWorld->getBtWorld()->stepSimulation(delta, 10);
mDynWorld->getBtWorld()->stepSimulation(delta, 60);
}
void updateWater(float delta)
{
#ifdef WATER
m_water.updateWater(delta);
#endif
}
void setupInput()
{
@@ -608,6 +634,10 @@ public:
m_terrain.setupTerrain(mCamera, mSun, mDynWorld.get(),
mDbgDraw.get());
}
CharacterController *getCharacterController()
{
return mCharacterController;
}
};
void EditUI::buildings_editor()