// // Generated by Brutal.Jolt.Generate; do not edit by hand. #nullable enable using Brutal.Interop; using Brutal.Numerics; namespace Brutal.JoltApi { /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:29 ///
/// class PhysicsSystem : public NonCopyable ///
///
/// /// /// The main class for the physics system. It contains all rigid bodies and simulates them. /// /// The main simulation is performed by the Update() call on multiple threads (if the JobSystem is configured to use them). Please refer to the general architecture overview in the Docs folder for more information. /// /// [InteropHandle] public readonly partial struct PhysicsSystem : IDisposable { /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:35 ///
/// PhysicsSystem() ///
///
/// /// /// Constructor / Destructor /// /// public static PhysicsSystem Create() => Jolt.PInvoke.PhysicsSystem_Create(); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:59 ///
/// void Init(uint inMaxBodies, uint inNumBodyMutexes, uint inMaxBodyPairs, uint inMaxContactConstraints, const BroadPhaseLayerInterface &inBroadPhaseLayerInterface, const ObjectVsBroadPhaseLayerFilter &inObjectVsBroadPhaseLayerFilter, const ObjectLayerPairFilter &inObjectLayerPairFilter) ///
///
/// /// /// 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. /// @param inMaxBodyPairs Maximum amount of body pairs to process (anything else will fall through the world), this number should generally be much higher than the max amount of contact points as there will be lots of bodies close that are not actually touching. /// @param inMaxContactConstraints Maximum amount of contact constraints to process (anything else will fall through the world). /// @param inBroadPhaseLayerInterface Information on the mapping of object layers to broad phase layers. Since this is a virtual interface, the instance needs to stay alive during the lifetime of the PhysicsSystem. /// @param inObjectVsBroadPhaseLayerFilter Filter callback function that is used to determine if an object layer collides with a broad phase layer. Since this is a virtual interface, the instance needs to stay alive during the lifetime of the PhysicsSystem. /// @param inObjectLayerPairFilter Filter callback function that is used to determine if two object layers collide. Since this is a virtual interface, the instance needs to stay alive during the lifetime of the PhysicsSystem. /// /// public void Init(uint maxBodies, uint numBodyMutexes, uint maxBodyPairs, uint maxContactConstraints, BroadPhaseLayerInterface broadPhaseLayerInterface, ObjectVsBroadPhaseLayerFilter objectVsBroadPhaseLayerFilter, ObjectLayerPairFilter objectLayerPairFilter) => Jolt.PInvoke.PhysicsSystem_Init(this, maxBodies, numBodyMutexes, maxBodyPairs, maxContactConstraints, broadPhaseLayerInterface, objectVsBroadPhaseLayerFilter, objectLayerPairFilter); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:62 ///
/// void SetBodyActivationListener(BodyActivationListener *inListener) ///
///
/// /// /// Listener that is notified whenever a body is activated/deactivated /// /// public void SetBodyActivationListener(BodyActivationListener listener) => Jolt.PInvoke.PhysicsSystem_SetBodyActivationListener(this, listener); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:63 ///
/// BodyActivationListener * GetBodyActivationListener() const ///
///
/// /// /// The returned handle is borrowed from its owner; don't Dispose it. /// /// public BodyActivationListener GetBodyActivationListener() => Jolt.PInvoke.PhysicsSystem_GetBodyActivationListener(this); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:67 ///
/// void SetContactListener(ContactListener *inListener) ///
///
/// /// /// Listener that is notified whenever a contact point between two bodies is added/updated/removed. /// You can't change contact listener during PhysicsSystem::Update but it can be changed at any other time. /// /// public void SetContactListener(ContactListener listener) => Jolt.PInvoke.PhysicsSystem_SetContactListener(this, listener); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:68 ///
/// ContactListener * GetContactListener() const ///
///
/// /// /// The returned handle is borrowed from its owner; don't Dispose it. /// /// public ContactListener GetContactListener() => Jolt.PInvoke.PhysicsSystem_GetContactListener(this); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:71 ///
/// void SetSoftBodyContactListener(SoftBodyContactListener *inListener) ///
///
/// /// /// Listener that is notified whenever a contact point between a soft body and another body /// /// public void SetSoftBodyContactListener(SoftBodyContactListener listener) => Jolt.PInvoke.PhysicsSystem_SetSoftBodyContactListener(this, listener); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:72 ///
/// SoftBodyContactListener * GetSoftBodyContactListener() const ///
///
/// /// /// The returned handle is borrowed from its owner; don't Dispose it. /// /// public SoftBodyContactListener GetSoftBodyContactListener() => Jolt.PInvoke.PhysicsSystem_GetSoftBodyContactListener(this); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:89 ///
/// void SetSimShapeFilter(const SimShapeFilter *inShapeFilter) ///
///
/// /// /// Set/get the shape filter that will be used during simulation. This can be used to exclude shapes within a body from colliding with each other. /// E.g. if you have a high detail and a low detail collision model, you can attach them to the same body in a StaticCompoundShape and use the ShapeFilter /// to exclude the high detail collision model when simulating and exclude the low detail collision model when casting rays. Note that in this case /// you would need to pass the inverse of inShapeFilter to the CastRay function. Pass a nullptr to disable the shape filter. /// The PhysicsSystem does not own the ShapeFilter, make sure it stays alive during the lifetime of the PhysicsSystem. /// /// public void SetSimShapeFilter(SimShapeFilter shapeFilter) => Jolt.PInvoke.PhysicsSystem_SetSimShapeFilter(this, shapeFilter); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:90 ///
/// const SimShapeFilter * GetSimShapeFilter() const ///
///
/// /// /// The returned handle is borrowed from its owner; don't Dispose it. /// /// public SimShapeFilter GetSimShapeFilter() => Jolt.PInvoke.PhysicsSystem_GetSimShapeFilter(this); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:111 ///
/// void SetPhysicsSettings(const PhysicsSettings &inSettings) ///
///
/// /// /// Control the main constants of the physics simulation /// /// public void SetPhysicsSettings(ref PhysicsSettings settings) => Jolt.PInvoke.PhysicsSystem_SetPhysicsSettings(this, ref settings); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:115 ///
/// const BodyInterface & GetBodyInterface() const ///
///
/// /// /// Access to the body interface. This interface allows to to create / remove bodies and to change their /// properties. /// /// /// The returned handle is borrowed from its owner; don't Dispose it. /// /// public BodyInterface GetBodyInterface() => Jolt.PInvoke.PhysicsSystem_GetBodyInterface(this); /// /// /// Version that does not lock the bodies, use with great care! /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:117 ///
/// const BodyInterface & GetBodyInterfaceNoLock() const ///
///
/// /// /// The returned handle is borrowed from its owner; don't Dispose it. /// /// public BodyInterface GetBodyInterfaceNoLock() => Jolt.PInvoke.PhysicsSystem_GetBodyInterfaceNoLock(this); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:121 ///
/// const BroadPhaseQuery & GetBroadPhaseQuery() const ///
///
/// /// /// Access to the broadphase interface that allows coarse collision queries /// /// /// The returned handle is borrowed from its owner; don't Dispose it. /// /// public BroadPhaseQuery GetBroadPhaseQuery() => Jolt.PInvoke.PhysicsSystem_GetBroadPhaseQuery(this); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:124 ///
/// const NarrowPhaseQuery & GetNarrowPhaseQuery() const ///
///
/// /// /// Interface that allows fine collision queries against first the broad phase and then the narrow phase. /// /// /// The returned handle is borrowed from its owner; don't Dispose it. /// /// public NarrowPhaseQuery GetNarrowPhaseQuery() => Jolt.PInvoke.PhysicsSystem_GetNarrowPhaseQuery(this); /// /// /// Version that does not lock the bodies, use with great care! /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:125 ///
/// const NarrowPhaseQuery & GetNarrowPhaseQueryNoLock() const ///
///
/// /// /// The returned handle is borrowed from its owner; don't Dispose it. /// /// public NarrowPhaseQuery GetNarrowPhaseQueryNoLock() => Jolt.PInvoke.PhysicsSystem_GetNarrowPhaseQueryNoLock(this); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:128 ///
/// void AddConstraint(Constraint *inConstraint) ///
///
/// /// /// Add constraint to the world /// /// public void AddConstraint(Constraint constraint) => Jolt.PInvoke.PhysicsSystem_AddConstraint(this, constraint); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:131 ///
/// void RemoveConstraint(Constraint *inConstraint) ///
///
/// /// /// Remove constraint from the world /// /// public void RemoveConstraint(Constraint constraint) => Jolt.PInvoke.PhysicsSystem_RemoveConstraint(this, constraint); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:148 ///
/// void OptimizeBroadPhase() ///
///
/// /// /// Optimize the broadphase, needed only if you've added many bodies prior to calling Update() for the first time. /// Don't call this every frame as PhysicsSystem::Update spreads out the same work over multiple frames. /// If you add many bodies through BodyInterface::AddBodiesPrepare/AddBodiesFinalize and if the bodies in a batch are /// in a roughly unoccupied space (e.g. a new level section) then a call to OptimizeBroadPhase is also not needed /// as batch adding creates an efficient bounding volume hierarchy. /// Don't call this function while bodies are being modified from another thread or use the locking BodyInterface to modify bodies. /// /// public void OptimizeBroadPhase() => Jolt.PInvoke.PhysicsSystem_OptimizeBroadPhase(this); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:151 ///
/// void AddStepListener(PhysicsStepListener *inListener) ///
///
/// /// /// Adds a new step listener /// /// public void AddStepListener(PhysicsStepListener listener) => Jolt.PInvoke.PhysicsSystem_AddStepListener(this, listener); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:154 ///
/// void RemoveStepListener(PhysicsStepListener *inListener) ///
///
/// /// /// Removes a step listener /// /// public void RemoveStepListener(PhysicsStepListener listener) => Jolt.PInvoke.PhysicsSystem_RemoveStepListener(this, listener); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:162 ///
/// EPhysicsUpdateError Update(float inDeltaTime, int inCollisionSteps, TempAllocator *inTempAllocator, JobSystem *inJobSystem) ///
///
/// /// /// Simulate the system. /// The world steps for a total of inDeltaTime seconds. This is divided in inCollisionSteps iterations. /// Each iteration consists of collision detection followed by an integration step. /// This function internally spawns jobs using inJobSystem and waits for them to complete, so no jobs will be running when this function returns. /// The temp allocator is used, for example, to store the list of bodies that are in contact, how they form islands together /// and data to solve the contacts between bodies. At the end of the Update call, all allocated memory will have been freed. /// /// public EPhysicsUpdateError Update(float deltaTime, int collisionSteps, TempAllocator tempAllocator, JobSystem jobSystem) => Jolt.PInvoke.PhysicsSystem_Update(this, deltaTime, collisionSteps, tempAllocator, jobSystem); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:171 ///
/// void SaveBodyState(const Body &inBody, StateRecorder &inStream) const ///
///
/// /// /// Saving state of a single body. /// /// public void SaveBodyState(Body body, StateRecorder stream) => Jolt.PInvoke.PhysicsSystem_SaveBodyState(this, body, stream); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:174 ///
/// void RestoreBodyState(Body &ioBody, StateRecorder &inStream) ///
///
/// /// /// Restoring state of a single body. /// /// public void RestoreBodyState(Body body, StateRecorder stream) => Jolt.PInvoke.PhysicsSystem_RestoreBodyState(this, body, stream); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:181 ///
/// void DrawBodies(const BodyManager::DrawSettings &inSettings, DebugRenderer *inRenderer, const BodyDrawFilter *inBodyFilter = nullptr) ///
///
/// /// /// Draw the state of the bodies (debugging purposes) /// /// public void DrawBodies(ref BodyManager.DrawSettings settings, DebugRenderer renderer, BodyDrawFilter bodyFilter) => Jolt.PInvoke.PhysicsSystem_DrawBodies(this, ref settings, renderer, bodyFilter); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:184 ///
/// void DrawConstraints(DebugRenderer *inRenderer) ///
///
/// /// /// Draw the constraints only (debugging purposes) /// /// public void DrawConstraints(DebugRenderer renderer) => Jolt.PInvoke.PhysicsSystem_DrawConstraints(this, renderer); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:187 ///
/// void DrawConstraintLimits(DebugRenderer *inRenderer) ///
///
/// /// /// Draw the constraint limits only (debugging purposes) /// /// public void DrawConstraintLimits(DebugRenderer renderer) => Jolt.PInvoke.PhysicsSystem_DrawConstraintLimits(this, renderer); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:190 ///
/// void DrawConstraintReferenceFrame(DebugRenderer *inRenderer) ///
///
/// /// /// Draw the constraint reference frames only (debugging purposes) /// /// public void DrawConstraintReferenceFrame(DebugRenderer renderer) => Jolt.PInvoke.PhysicsSystem_DrawConstraintReferenceFrame(this, renderer); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:194 ///
/// void SetGravity(Vec3Arg inGravity) ///
///
/// /// /// Set gravity value /// /// public void SetGravity(float3 gravity) => Jolt.PInvoke.PhysicsSystem_SetGravity(this, gravity); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:195 ///
/// Vec3 GetGravity() const ///
///
public float3 GetGravity() => Jolt.PInvoke.PhysicsSystem_GetGravity(this); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:198 ///
/// inline const BodyLockInterfaceNoLock & GetBodyLockInterfaceNoLock() const ///
///
/// /// /// Returns a locking interface that won't actually lock the body. Use with great care! /// /// /// The returned handle is borrowed from its owner; don't Dispose it. /// /// public BodyLockInterfaceNoLock GetBodyLockInterfaceNoLock() => Jolt.PInvoke.PhysicsSystem_GetBodyLockInterfaceNoLock(this); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:201 ///
/// inline const BodyLockInterfaceLocking & GetBodyLockInterface() const ///
///
/// /// /// Returns a locking interface that locks the body so other threads cannot modify it. /// /// /// The returned handle is borrowed from its owner; don't Dispose it. /// /// public BodyLockInterfaceLocking GetBodyLockInterface() => Jolt.PInvoke.PhysicsSystem_GetBodyLockInterface(this); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:204 ///
/// const ObjectVsBroadPhaseLayerFilter &GetObjectVsBroadPhaseLayerFilter() const ///
///
/// /// /// Broadphase layer filter that decides if two objects can collide, this was passed to the Init function. /// /// /// The returned handle is borrowed from its owner; don't Dispose it. /// /// public ObjectVsBroadPhaseLayerFilter GetObjectVsBroadPhaseLayerFilter() => Jolt.PInvoke.PhysicsSystem_GetObjectVsBroadPhaseLayerFilter(this); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:207 ///
/// const ObjectLayerPairFilter &GetObjectLayerPairFilter() const ///
///
/// /// /// Object layer filter that decides if two objects can collide, this was passed to the Init function. /// /// /// The returned handle is borrowed from its owner; don't Dispose it. /// /// public ObjectLayerPairFilter GetObjectLayerPairFilter() => Jolt.PInvoke.PhysicsSystem_GetObjectLayerPairFilter(this); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:216 ///
/// uint GetNumBodies() const ///
///
/// /// /// Gets the current amount of bodies that are in the body manager /// /// public uint GetNumBodies() => Jolt.PInvoke.PhysicsSystem_GetNumBodies(this); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:219 ///
/// uint32 GetNumActiveBodies(EBodyType inType) const ///
///
/// /// /// Gets the current amount of active bodies that are in the body manager /// /// public uint GetNumActiveBodies(EBodyType type) => Jolt.PInvoke.PhysicsSystem_GetNumActiveBodies(this, type); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:222 ///
/// uint GetMaxBodies() const ///
///
/// /// /// Get the maximum amount of bodies that this physics system supports /// /// public uint GetMaxBodies() => Jolt.PInvoke.PhysicsSystem_GetMaxBodies(this); /// /// /// C++: /// Jolt/Physics/PhysicsSystem.h:248 ///
/// bool WereBodiesInContact(const BodyID &inBody1ID, const BodyID &inBody2ID) const ///
///
/// /// /// Check if 2 bodies were in contact during the last simulation step. Since contacts are only detected between active bodies, so at least one of the bodies must be active in order for this function to work. /// It queries the state at the time of the last PhysicsSystem::Update and will return true if the bodies were in contact, even if one of the bodies was moved / removed afterwards. /// This function can be called from any thread when the PhysicsSystem::Update is not running. During PhysicsSystem::Update this function is only valid during contact callbacks: /// - During the ContactListener::OnContactAdded callback this function can be used to determine if a different contact pair between the bodies was active in the previous simulation step (function returns true) or if this is the first step that the bodies are touching (function returns false). /// - During the ContactListener::OnContactRemoved callback this function can be used to determine if this is the last contact pair between the bodies (function returns false) or if there are other contacts still present (function returns true). /// /// public bool WereBodiesInContact(uint body1ID, uint body2ID) => Jolt.PInvoke.PhysicsSystem_WereBodiesInContact(this, body1ID, body2ID); public void Dispose() => Jolt.PInvoke.PhysicsSystem_Destroy(this); } }