mitiru::physics3d
3D physics: rigid bodies, colliders, raycasts, constraint solver.
3D physics: rigid bodies, colliders, raycasts, constraint solver.
| Name | Kind | Items |
|---|---|---|
BroadPhaseProxy3D | struct | 2 |
BroadPhase3D | class | 13 |
AABBCollider3D | struct | 3 |
OBBCollider3D | struct | 1 |
CapsuleCollider | struct | 16 |
ConvexShape | struct | 2 |
DistanceConstraint | class | 7 |
HingeConstraint | class | 5 |
ContactSolver3D | class | 9 |
EpaFace | struct | 1 |
NarrowPhase3D | class | 11 |
DebugDrawFlags | enum | 11 |
DebugColor3D | struct | 8 |
PhysicsDebugRenderer3D | class | 17 |
PhysicsSystem3D | class | 20 |
ColliderType3D | enum | 4 |
BroadphaseProxy | struct | 1 |
PhysicsWorld3D | class | 27 |
RigidBody3D | class | 36 |
struct BroadPhaseProxy3D 2
[[nodiscard]] constexpr float minX() const noexcept[[nodiscard]] constexpr float maxX() const noexceptclass BroadPhase3D 13
BroadPhase3D() = defaultexplicit BroadPhase3D(float margin) noexceptvoid setMargin(float margin) noexcept[[nodiscard]] constexpr float margin() const noexceptvoid clear() noexceptvoid addProxy(BodyId bodyId, std::size_t colliderIndex, const AABBCollider3D& aabb) noexceptvoid sweep() noexcept[[nodiscard]] const std::vector<BroadPhasePair3D>& candidatePairs() const noexcept[[nodiscard]] std::size_t pairCount() const noexcept[[nodiscard]] std::size_t proxyCount() const noexcept[[nodiscard]] static AABBCollider3D computeAABB( const SphereCollider& sphere) noexcept[[nodiscard]] static constexpr AABBCollider3D computeAABB( const AABBCollider3D& aabb) noexcept[[nodiscard]] static AABBCollider3D computeAABB( const CapsuleCollider& capsule) noexceptstruct AABBCollider3D 3
[[nodiscard]] constexpr sgc::Vec3f center() const noexcept[[nodiscard]] constexpr sgc::Vec3f halfExtents() const noexcept[[nodiscard]] static constexpr AABBCollider3D fromCenterExtents( const sgc::Vec3f& center, const sgc::Vec3f& halfExtents) noexceptstruct OBBCollider3D 1
[[nodiscard]] sgc::Vec3f axis(int axisIndex) const noexceptstruct CapsuleCollider 16
[[nodiscard]] constexpr sgc::Vec3f center() const noexcept[[nodiscard]] sgc::Vec3f axisDirection() const noexcept[[nodiscard]] float axisLength() const noexcept[[nodiscard]] inline ContactInfo3D testSphereSphere( const SphereCollider& a, const SphereCollider& b) noexcept[[nodiscard]] inline constexpr sgc::Vec3f closestPointOnAABB( const sgc::Vec3f& point, const AABBCollider3D& aabb) noexcept[[nodiscard]] inline ContactInfo3D testSphereAABB( const SphereCollider& sphere, const AABBCollider3D& aabb) noexcept[[nodiscard]] inline ContactInfo3D testAABBAABB( const AABBCollider3D& a, const AABBCollider3D& b) noexcept[[nodiscard]] inline std::optional<RayHit3D> raycastSphere( const Ray3D& ray, const SphereCollider& sphere, float maxDist = 1e6f) noexcept[[nodiscard]] inline std::optional<RayHit3D> raycastAABB( const Ray3D& ray, const AABBCollider3D& aabb, float maxDist = 1e6f) noexcept[[nodiscard]] inline sgc::Vec3f gjkSupport( const ConvexShape& a, const ConvexShape& b, const sgc::Vec3f& direction) noexcept[[nodiscard]] inline constexpr sgc::Vec3f tripleProduct( const sgc::Vec3f& a, const sgc::Vec3f& b, const sgc::Vec3f& c) noexcept[[nodiscard]] inline bool gjkIntersect(const ConvexShape& a, const ConvexShape& b) noexcept[[nodiscard]] inline sgc::Vec3f closestPointOnSegment( const sgc::Vec3f& point, const sgc::Vec3f& segA, const sgc::Vec3f& segB) noexceptinline void closestPointsSegmentSegment( const sgc::Vec3f& a0, const sgc::Vec3f& a1, const sgc::Vec3f& b0, const sgc::Vec3f& b1, sgc::Vec3f& outA, sgc::Vec3f& outB) noexcept[[nodiscard]] inline ContactInfo3D testSphereCapsule( const SphereCollider& sphere, const CapsuleCollider& capsule) noexcept[[nodiscard]] inline ContactInfo3D testCapsuleCapsule( const CapsuleCollider& a, const CapsuleCollider& b) noexceptstruct ConvexShape 2
std::vector<sgc::Vec3f> vertices[[nodiscard]] sgc::Vec3f support(const sgc::Vec3f& direction) const noexceptclass DistanceConstraint 7
DistanceConstraint( RigidBody3D* bodyA, RigidBody3D* bodyB, float restLength, float stiffness = 1.0f) noexceptvoid setAnchors(const sgc::Vec3f& anchorA, const sgc::Vec3f& anchorB) noexceptvoid solve([[maybe_unused]] float dt) noexceptvoid solveVelocity([[maybe_unused]] float dt) noexcept[[nodiscard]] constexpr float restLength() const noexceptvoid setRestLength(float len) noexcept[[nodiscard]] constexpr float stiffness() const noexceptclass HingeConstraint 5
HingeConstraint( RigidBody3D* bodyA, RigidBody3D* bodyB, const sgc::Vec3f& worldPivot, const sgc::Vec3f& worldAxis) noexceptvoid setLimits(float minAngle, float maxAngle) noexcept[[nodiscard]] constexpr bool hasLimits() const noexceptvoid solve([[maybe_unused]] float dt) noexcept[[nodiscard]] const sgc::Vec3f& axis() const noexceptclass ContactSolver3D 9
ContactSolver3D() = defaultexplicit ContactSolver3D(const ContactSolverConfig3D& config) noexceptvoid configure(const ContactSolverConfig3D& config) noexcept[[nodiscard]] constexpr const ContactSolverConfig3D& config() const noexceptvoid prepare( std::vector<ContactManifold3D>& manifolds, const std::unordered_map<BodyId, std::unique_ptr<RigidBody3D>>& bodies) noexceptvoid warmStart( const std::vector<ContactManifold3D>& manifolds, std::unordered_map<BodyId, std::unique_ptr<RigidBody3D>>& bodies) noexceptvoid solve( std::vector<ContactManifold3D>& manifolds, std::unordered_map<BodyId, std::unique_ptr<RigidBody3D>>& bodies) noexceptvoid solvePositions( const std::vector<ContactManifold3D>& manifolds, std::unordered_map<BodyId, std::unique_ptr<RigidBody3D>>& bodies) noexcept[[nodiscard]] static std::size_t manifoldCount( const std::vector<ContactManifold3D>& manifolds) noexceptstruct EpaFace 1
std::array<sgc::Vec3f, 3> verticesclass NarrowPhase3D 11
NarrowPhase3D() = defaultvoid setMaxIterations(int iterations) noexcept[[nodiscard]] constexpr int maxIterations() const noexcept[[nodiscard]] static NarrowPhaseResult3D testSphereSphere( const SphereCollider& a, const SphereCollider& b) noexcept[[nodiscard]] static NarrowPhaseResult3D testSphereBox( const SphereCollider& sphere, const AABBCollider3D& aabb) noexcept[[nodiscard]] static NarrowPhaseResult3D testBoxBox( const AABBCollider3D& a, const AABBCollider3D& b) noexcept[[nodiscard]] static NarrowPhaseResult3D testSphereCapsule( const SphereCollider& sphere, const CapsuleCollider& capsule) noexcept[[nodiscard]] static NarrowPhaseResult3D testCapsuleCapsule( const CapsuleCollider& a, const CapsuleCollider& b) noexcept[[nodiscard]] NarrowPhaseResult3D testConvexConvex( const ConvexShape& a, const ConvexShape& b) const noexcept[[nodiscard]] static ConvexShape sphereToConvex( const SphereCollider& sphere, int subdivisions = 2) noexcept[[nodiscard]] static ConvexShape aabbToConvex(const AABBCollider3D& aabb) noexceptenum DebugDrawFlags : uint32_t 11
None = 0Colliders = 1 << 0Contacts = 1 << 1Velocities = 1 << 2Constraints = 1 << 3AABBs = 1 << 4CenterOfMass = 1 << 5All = 0xFFFFFFFF[[nodiscard]] inline constexpr DebugDrawFlags operator|( DebugDrawFlags a, DebugDrawFlags b) noexcept[[nodiscard]] inline constexpr DebugDrawFlags operator&( DebugDrawFlags a, DebugDrawFlags b) noexcept[[nodiscard]] inline constexpr bool hasFlag( DebugDrawFlags flags, DebugDrawFlags flag) noexceptstruct DebugColor3D 8
[[nodiscard]] static constexpr DebugColor3D green() noexcept[[nodiscard]] static constexpr DebugColor3D red() noexcept[[nodiscard]] static constexpr DebugColor3D blue() noexcept[[nodiscard]] static constexpr DebugColor3D yellow() noexcept[[nodiscard]] static constexpr DebugColor3D cyan() noexcept[[nodiscard]] static constexpr DebugColor3D magenta() noexcept[[nodiscard]] static constexpr DebugColor3D white() noexcept[[nodiscard]] static constexpr DebugColor3D gray() noexceptclass PhysicsDebugRenderer3D 17
PhysicsDebugRenderer3D() = defaultvoid setFlags(DebugDrawFlags flags) noexcept[[nodiscard]] constexpr DebugDrawFlags flags() const noexceptvoid setVelocityScale(float scale) noexceptvoid setNormalLength(float length) noexceptvoid setSphereSegments(int segments) noexceptvoid clear() noexceptvoid gather( const PhysicsWorld3D& world, const std::vector<ContactManifold3D>& manifolds = {}) noexceptvoid addCollider(const BodyCollider& collider) noexceptvoid addContact(const sgc::Vec3f& point, const sgc::Vec3f& normal, float depth) noexceptvoid addVelocity(const sgc::Vec3f& position, const sgc::Vec3f& velocity) noexcept[[nodiscard]] const std::vector<DebugLine3D>& lines() const noexcept[[nodiscard]] const std::vector<DebugPoint3D>& points() const noexcept[[nodiscard]] std::size_t lineCount() const noexcept[[nodiscard]] std::size_t pointCount() const noexceptvoid gatherBody(const RigidBody3D& body, const BodyCollider& collider) noexceptusing CollisionCallback3DEcs = std::function<void(const CollisionEvent3D&)>;class PhysicsSystem3D : public scene::ISystem 20
explicit PhysicsSystem3D(const PhysicsSystem3DConfig& config = {})[[nodiscard]] std::string name() const overridevoid update(scene::GameWorld& gameWorld, float dt) overridevoid setGravity(const sgc::Vec3f& gravity) noexcept[[nodiscard]] const sgc::Vec3f& gravity() const noexcept[[nodiscard]] const PhysicsSystem3DConfig& config() const noexceptvoid registerCollisionCallback(CollisionCallback3DEcs callback)void addDistanceConstraint(DistanceConstraint constraint) noexceptvoid addHingeConstraint(HingeConstraint constraint) noexceptvoid setDebugDrawEnabled(bool enabled) noexceptvoid setDebugDrawFlags(DebugDrawFlags flags) noexcept[[nodiscard]] const PhysicsDebugRenderer3D& debugRenderer() const noexcept[[nodiscard]] std::size_t bodyCount() const noexcept[[nodiscard]] std::size_t colliderCount() const noexcept[[nodiscard]] std::size_t lastContactCount() const noexcept[[nodiscard]] std::size_t lastBroadPhasePairCount() const noexcept[[nodiscard]] std::optional<RayHit3D> raycast( const Ray3D& ray, float maxDist = 1e6f) const noexcept[[nodiscard]] PhysicsWorld3D& physicsWorld() noexcept[[nodiscard]] const PhysicsWorld3D& physicsWorld() const noexcept[[nodiscard]] const std::vector<ContactManifold3D>& lastManifolds() const noexceptenum ColliderType3D 4
SphereAABBCapsuleusing CollisionCallback3D = std::function<void(const WorldContact3D&)>;struct BroadphaseProxy 1
[[nodiscard]] constexpr float minX() const noexceptclass PhysicsWorld3D 27
PhysicsWorld3D() = defaultvoid setGravity(const sgc::Vec3f& gravity) noexcept[[nodiscard]] constexpr const sgc::Vec3f& gravity() const noexceptRigidBody3D& addBody() noexceptvoid removeBody(BodyId id) noexcept[[nodiscard]] RigidBody3D* getBody(BodyId id) noexcept[[nodiscard]] const RigidBody3D* getBody(BodyId id) const noexcept[[nodiscard]] std::size_t bodyCount() const noexceptvoid addSphereCollider(BodyId bodyId, const SphereCollider& sphere) noexceptvoid addAABBCollider(BodyId bodyId, const AABBCollider3D& aabb) noexceptvoid addCapsuleCollider(BodyId bodyId, const CapsuleCollider& capsule) noexcept[[nodiscard]] std::size_t colliderCount() const noexceptvoid addDistanceConstraint(DistanceConstraint constraint) noexceptvoid addHingeConstraint(HingeConstraint constraint) noexcept[[nodiscard]] std::size_t constraintCount() const noexceptvoid registerCollisionCallback(CollisionCallback3D callback) noexceptvoid setSolverIterations(int iterations) noexceptvoid step(float dt) noexcept[[nodiscard]] std::size_t lastContactCount() const noexcept[[nodiscard]] std::unordered_map<BodyId, std::unique_ptr<RigidBody3D>>& bodies() noexcept[[nodiscard]] const std::unordered_map<BodyId, std::unique_ptr<RigidBody3D>>& bodies() const noexcept[[nodiscard]] std::vector<BodyCollider>& colliders() noexcept[[nodiscard]] const std::vector<BodyCollider>& colliders() const noexcept[[nodiscard]] static AABBCollider3D computeAABB(const BodyCollider& collider) noexcept[[nodiscard]] std::optional<RayHit3D> raycast( const Ray3D& ray, float maxDist = 1e6f) const noexceptusing BodyId = uint32_t;inline constexpr BodyId INVALID_BODY_ID = 0class RigidBody3D 36
RigidBody3D() noexceptexplicit RigidBody3D(float mass) noexcept[[nodiscard]] constexpr const sgc::Vec3f& position() const noexceptvoid setPosition(const sgc::Vec3f& pos) noexcept[[nodiscard]] constexpr const sgc::Quaternionf& rotation() const noexceptvoid setRotation(const sgc::Quaternionf& rot) noexcept[[nodiscard]] constexpr float mass() const noexcept[[nodiscard]] constexpr float inverseMass() const noexceptvoid setMass(float mass) noexcept[[nodiscard]] constexpr const sgc::Mat3f& inertiaTensor() const noexcept[[nodiscard]] constexpr const sgc::Mat3f& inverseInertiaTensor() const noexceptvoid setInertiaTensor(const sgc::Mat3f& tensor) noexceptvoid setBoxInertiaTensor(const sgc::Vec3f& halfExtents) noexceptvoid setSphereInertiaTensor(float radius) noexcept[[nodiscard]] constexpr bool isStatic() const noexcept[[nodiscard]] constexpr const sgc::Vec3f& linearVelocity() const noexceptvoid setLinearVelocity(const sgc::Vec3f& vel) noexcept[[nodiscard]] constexpr const sgc::Vec3f& angularVelocity() const noexceptvoid setAngularVelocity(const sgc::Vec3f& vel) noexcept[[nodiscard]] constexpr float linearDamping() const noexceptvoid setLinearDamping(float damping) noexcept[[nodiscard]] constexpr float angularDamping() const noexceptvoid setAngularDamping(float damping) noexcept[[nodiscard]] constexpr float restitution() const noexceptvoid setRestitution(float e) noexcept[[nodiscard]] constexpr float friction() const noexceptvoid setFriction(float f) noexceptvoid applyForce(const sgc::Vec3f& force) noexceptvoid applyTorque(const sgc::Vec3f& torque) noexceptvoid applyForceAtPoint(const sgc::Vec3f& force, const sgc::Vec3f& worldPoint) noexceptvoid applyImpulse(const sgc::Vec3f& impulse) noexceptvoid applyImpulseAtPoint(const sgc::Vec3f& impulse, const sgc::Vec3f& worldPoint) noexceptvoid clearForces() noexceptvoid integrate(float dt) noexcept[[nodiscard]] constexpr BodyId id() const noexceptvoid setId(BodyId id) noexceptSourced from docs/API_CATALOG.md, auto-generated by tools/generate_api_catalog.py.