converted to Jolt physics

This commit is contained in:
2025-11-23 02:00:31 +03:00
parent 3f0484e87c
commit cd82fb0eed
52 changed files with 4302 additions and 1458 deletions

View File

@@ -12,6 +12,7 @@
#include "WaterModule.h"
namespace ECS
{
#if 0
class WaterPhysicsAction : public btActionInterface {
btPairCachingGhostObject *mWaterBody;
btManifoldArray mManifoldArray;
@@ -53,13 +54,13 @@ public:
return (mInWater.find(body) != mInWater.end());
}
};
#endif
static const uint32_t WATER_MASK = 0xF00;
WaterModule::WaterModule(flecs::world &ecs)
{
ecs.module<WaterModule>();
ecs.component<WaterSurface>()
.on_add([](flecs::entity e, WaterSurface &water) {
ECS::get().add<WaterBody>();
water.mAbove = false;
water.mDepthMaterial = nullptr;
water.mDepthTech = nullptr;
@@ -457,10 +458,14 @@ WaterModule::WaterModule(flecs::world &ecs)
eng.mScnMgr->getRenderQueue()->setRenderableListener(
&water.mRenderTargetListener);
std::cout << "Water setup done\n";
ECS::get().add<WaterAlmostReady>();
})
.add(flecs::Singleton);
#if 0
ecs.component<WaterBody>().add(flecs::Singleton);
ecs.component<WaterBody>()
.on_add([this](WaterBody &body) {
#if 0
body.mShapeAabbMax = btVector3(0, 0, 0);
body.mShapeAabbMin = btVector3(0, 0, 0);
body.mSurface.clear();
@@ -489,9 +494,11 @@ WaterModule::WaterModule(flecs::world &ecs)
.get<EngineData>()
.mWorld->getBtWorld()
->addAction(body.action);
#endif
ECS::get().add<WaterReady>();
})
.add(flecs::Singleton);
#endif
ecs.system<const EngineData, const Camera, WaterSurface>("UpdateWater")
.kind(flecs::OnUpdate)
.with<WaterReady>()
@@ -520,6 +527,7 @@ WaterModule::WaterModule(flecs::world &ecs)
// water.mRenderTargetListener.mInDepth = false;
// water.mWaterEnt->setVisible(true);
});
#if 0
ecs.system<const EngineData, const WaterSurface, WaterBody>(
"UpdateWaterBody")
.kind(flecs::OnUpdate)
@@ -527,6 +535,7 @@ WaterModule::WaterModule(flecs::world &ecs)
.each([this](const EngineData &eng, const WaterSurface &water,
WaterBody &body) {
int i;
#if 0
OgreAssert(body.mWaterBody, "Water not ready");
std::set<btCollisionObject *> currentOverlaps;
Ogre::Vector3 waterPos =
@@ -542,6 +551,7 @@ WaterModule::WaterModule(flecs::world &ecs)
body.mWaterBody->getWorldTransform().setOrigin(
Ogre::Bullet::convert(waterBodyPos +
d));
#endif
#if 0
btCompoundShape *mshape =
static_cast<btCompoundShape *>(
@@ -646,6 +656,7 @@ WaterModule::WaterModule(flecs::world &ecs)
}
#endif
});
#endif
}
struct shapeParams {
float offsetX, offsetY, offsetZ;
@@ -654,6 +665,7 @@ struct shapeParams {
static struct shapeParams childShapes[] = {
{ 0.0f, 0.0f, 0.0f, 100.0f, 100.0f, 100.0f },
};
#if 0
void WaterModule::createWaterShape(WaterBody *water)
{
int i = 0;
@@ -684,6 +696,7 @@ void WaterModule::createWaterShape(WaterBody *water)
shape->recalculateLocalAabb();
water->mWaterShape = shape;
}
#endif
void WaterSurface::RenderTextureListener::preRenderTargetUpdate(
const Ogre::RenderTargetEvent &evt)
{
@@ -712,6 +725,7 @@ bool WaterSurface::RenderTextureListener::renderableQueued(
*ppTech = mSurface->mDepthTech;
return true;
}
#if 0
struct DeepPenetrationContactResultCallback : public btManifoldResult {
DeepPenetrationContactResultCallback(
const btCollisionObjectWrapper *body0Wrap,
@@ -954,8 +968,11 @@ void WaterPhysicsAction::debugDraw(btIDebugDraw *debugDrawer)
void WaterPhysicsAction::setupBody()
{
}
#endif
#if 0
bool WaterBody::isInWater(const btCollisionObject *body) const
{
return static_cast<WaterPhysicsAction *>(action)->isInWater(body);
}
#endif
}