diff --git a/src/gamedata/GameData.cpp b/src/gamedata/GameData.cpp index f5f5ccc..1167068 100644 --- a/src/gamedata/GameData.cpp +++ b/src/gamedata/GameData.cpp @@ -104,6 +104,7 @@ void setupExteriorScene(Ogre::SceneManager *scnMgr, Ogre::SceneNode *cameraNode, ecs.set({ scnMgr, 0.0f, 5.0f, (int)window->getWidth(), (int)window->getHeight(), false }); ecs.set({ cameraNode, camera, false }); + PhysicsModule::configurePhysics(); ecs.add(); ecs.add(); ecs.observer("Game_Start_Scen_Startup") @@ -261,7 +262,8 @@ void setupEditor(Ogre::SceneManager *scnMgr, Ogre::SceneNode *cameraNode, #if 0 ecs.set({ 0 }); #endif - ecs.add(); + PhysicsModule::configurePhysics(); + ecs.add(); ecs.add(); ecs.add(); ecs.set({ nullptr, nullptr, nullptr, nullptr }); diff --git a/src/gamedata/PhysicsModule.cpp b/src/gamedata/PhysicsModule.cpp index 62d0dde..2dc3755 100644 --- a/src/gamedata/PhysicsModule.cpp +++ b/src/gamedata/PhysicsModule.cpp @@ -61,15 +61,6 @@ PhysicsModule::PhysicsModule(flecs::world &ecs) ecs.component(); ecs.import (); ecs.import (); - ecs.system("physics_init") - .kind(PhysicsPreUpdate) - .without() - .each([&](const EngineData &e, const Camera &c) { - Physics &ph = ECS::get().ensure(); - ph.physics = new JoltPhysicsWrapper(e.mScnMgr, - c.mCameraNode); - ECS::modified(); - }); ecs.system("physics_update") .kind(PhysicsUpdate) .each([&](EngineData &e, Physics &ph) { @@ -633,6 +624,15 @@ void PhysicsModule::setDebugDraw(bool enable) { JoltPhysicsWrapper::getSingleton().setDebugDraw(enable); } + +void PhysicsModule::configurePhysics() +{ + Physics &ph = ECS::get().ensure(); + const EngineData &e = ECS::get(); + const Camera &c = ECS::get(); + ph.physics = new JoltPhysicsWrapper(e.mScnMgr, c.mCameraNode); + ECS::modified(); +} bool WaterBody::isInWater(const JPH::BodyID &id) const { flecs::entity e = diff --git a/src/gamedata/PhysicsModule.h b/src/gamedata/PhysicsModule.h index 5ec9db1..8701ad9 100644 --- a/src/gamedata/PhysicsModule.h +++ b/src/gamedata/PhysicsModule.h @@ -61,6 +61,7 @@ struct PhysicsModule { const Ogre::Vector3 &endPos, Ogre::Vector3 &position, JPH::BodyID &id); static void setDebugDraw(bool enable); + static void configurePhysics(); }; } #endif