Compare commits

..

1 Commits

Author SHA1 Message Date
685b15933a Physics initialization update 2026-02-07 08:31:07 +03:00
3 changed files with 13 additions and 10 deletions

View File

@@ -104,6 +104,7 @@ void setupExteriorScene(Ogre::SceneManager *scnMgr, Ogre::SceneNode *cameraNode,
ecs.set<EngineData>({ scnMgr, 0.0f, 5.0f, (int)window->getWidth(),
(int)window->getHeight(), false });
ecs.set<Camera>({ cameraNode, camera, false });
PhysicsModule::configurePhysics();
ecs.add<GameData>();
ecs.add<Input>();
ecs.observer<GameState>("Game_Start_Scen_Startup")
@@ -261,7 +262,8 @@ void setupEditor(Ogre::SceneManager *scnMgr, Ogre::SceneNode *cameraNode,
#if 0
ecs.set<EditorSceneSwitch>({ 0 });
#endif
ecs.add<GameData>();
PhysicsModule::configurePhysics();
ecs.add<GameData>();
ecs.add<Input>();
ecs.add<WaterSurface>();
ecs.set<Sun>({ nullptr, nullptr, nullptr, nullptr });

View File

@@ -61,15 +61,6 @@ PhysicsModule::PhysicsModule(flecs::world &ecs)
ecs.component<CachedMass>();
ecs.import <TerrainModule>();
ecs.import <WaterModule>();
ecs.system<const EngineData, const Camera>("physics_init")
.kind(PhysicsPreUpdate)
.without<Physics>()
.each([&](const EngineData &e, const Camera &c) {
Physics &ph = ECS::get().ensure<Physics>();
ph.physics = new JoltPhysicsWrapper(e.mScnMgr,
c.mCameraNode);
ECS::modified<Physics>();
});
ecs.system<EngineData, Physics>("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<Physics>();
const EngineData &e = ECS::get<EngineData>();
const Camera &c = ECS::get<Camera>();
ph.physics = new JoltPhysicsWrapper(e.mScnMgr, c.mCameraNode);
ECS::modified<Physics>();
}
bool WaterBody::isInWater(const JPH::BodyID &id) const
{
flecs::entity e =

View File

@@ -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