feat: modules moved and engine moved to submodule

This commit is contained in:
Jan van der Weide 2025-04-12 18:40:44 +02:00
parent dfb5e645cd
commit c33d2130cc
5136 changed files with 225275 additions and 64485 deletions

View file

@ -35,6 +35,19 @@ public:
PhysicsSystem() : mContactManager(mPhysicsSettings) JPH_IF_ENABLE_ASSERTS(, mConstraintManager(&mBodyManager)) { }
~PhysicsSystem();
/// The maximum value that can be passed to Init for inMaxBodies.
static constexpr uint cMaxBodiesLimit = BodyID::cMaxBodyIndex + 1;
/// The maximum value that can be passed to Init for inMaxBodyPairs.
/// Note you should really use a lower value, using this value will cost a lot of memory!
/// On a 32 bit platform, you'll run out of memory way before you reach this limit.
static constexpr uint cMaxBodyPairsLimit = ContactConstraintManager::cMaxBodyPairsLimit;
/// The maximum value that can be passed to Init for inMaxContactConstraints.
/// Note you should really use a lower value, using this value will cost a lot of memory!
/// On a 32 bit platform, you'll run out of memory way before you reach this limit.
static constexpr uint cMaxContactConstraintsLimit = ContactConstraintManager::cMaxContactConstraintsLimit;
/// Initialize the system.
/// @param inMaxBodies Maximum number of bodies to support.
/// @param inNumBodyMutexes Number of body mutexes to use. Should be a power of 2 in the range [1, 64], use 0 to auto detect.
@ -76,6 +89,24 @@ public:
void SetSimShapeFilter(const SimShapeFilter *inShapeFilter) { mSimShapeFilter = inShapeFilter; }
const SimShapeFilter * GetSimShapeFilter() const { return mSimShapeFilter; }
/// Advanced use only: This function is similar to CollisionDispatch::sCollideShapeVsShape but only used to collide bodies during simulation.
/// inBody1 The first body to collide.
/// inBody2 The second body to collide.
/// inCenterOfMassTransform1 The center of mass transform of the first body (note this will not be the actual world space position of the body, it will be made relative to some position so we can drop down to single precision).
/// inCenterOfMassTransform2 The center of mass transform of the second body.
/// ioCollideShapeSettings Settings that control the collision detection. Note that the implementation can freely overwrite the shape settings if needed, the caller provides a temporary that will not be used after the function returns.
/// ioCollector The collector that will receive the contact points.
/// inShapeFilter The shape filter that can be used to exclude shapes from colliding with each other.
using SimCollideBodyVsBody = std::function<void(const Body &inBody1, const Body &inBody2, Mat44Arg inCenterOfMassTransform1, Mat44Arg inCenterOfMassTransform2, CollideShapeSettings &ioCollideShapeSettings, CollideShapeCollector &ioCollector, const ShapeFilter &inShapeFilter)>;
/// Advanced use only: Set the function that will be used to collide two bodies during simulation.
/// This function is expected to eventually call CollideShapeCollector::AddHit all contact points between the shapes of body 1 and 2 in their given transforms.
void SetSimCollideBodyVsBody(const SimCollideBodyVsBody &inBodyVsBody) { mSimCollideBodyVsBody = inBodyVsBody; }
const SimCollideBodyVsBody &GetSimCollideBodyVsBody() const { return mSimCollideBodyVsBody; }
/// Advanced use only: Default function that is used to collide two bodies during simulation.
static void sDefaultSimCollideBodyVsBody(const Body &inBody1, const Body &inBody2, Mat44Arg inCenterOfMassTransform1, Mat44Arg inCenterOfMassTransform2, CollideShapeSettings &ioCollideShapeSettings, CollideShapeCollector &ioCollector, const ShapeFilter &inShapeFilter);
/// Control the main constants of the physics simulation
void SetPhysicsSettings(const PhysicsSettings &inSettings) { mPhysicsSettings = inSettings; }
const PhysicsSettings & GetPhysicsSettings() const { return mPhysicsSettings; }
@ -308,6 +339,9 @@ private:
/// The shape filter that is used to filter out sub shapes during simulation
const SimShapeFilter * mSimShapeFilter = nullptr;
/// The collision function that is used to collide two shapes during simulation
SimCollideBodyVsBody mSimCollideBodyVsBody = &sDefaultSimCollideBodyVsBody;
/// Simulation settings
PhysicsSettings mPhysicsSettings;