Source code for simvx.core.physics

"""SimVX Physics: rigid bodies, areas, joints and spatial queries.

The public physics surface is one ``PhysicsBody2D/3D`` node with
a runtime-mutable :class:`BodyMode` (``STATIC | KINEMATIC | DYNAMIC``),
``CharacterBody2D/3D`` (a ``KINEMATIC`` body plus a collide-and-slide movement
helper, not a separate kind of thing), ``Area2D/3D`` + ``GravityArea2D/3D``
triggers, ``CollisionShape2D/3D`` carriers fed by :class:`Shape` /
:class:`Shape2D` resources, joints, and the ``self.physics`` /
``self.physics_2d`` spatial-query wrappers. All three node families share the
:class:`PhysicsObject2D` / :class:`PhysicsObject3D` base, which is the name for
"a node with a body in the physics world". Bodies resolve their world through a
:class:`PhysicsRoot` / :class:`PhysicsRoot2D` ancestor (or an implicit default
world).

Usage:
    from simvx.core import BodyMode, CollisionShape3D, PhysicsBody3D, SphereShape3D

    class Ball(PhysicsBody3D):
        def on_ready(self):
            self.add_child(CollisionShape3D(shape=SphereShape3D(0.5)))

    ball = Ball(mode=BodyMode.DYNAMIC)   # or the mode name: Ball(mode="dynamic")

``mode`` is inherited from :class:`PhysicsBody3D`: set it per instance or in
the scene file. Re-declaring it as a fresh ``Property`` on a subclass replaces
the engine's descriptor and disables both the string spelling and the hook that
pushes a runtime mode flip into the physics world.
"""

from .backends import (
    BUILTIN,
    BackendEntry,
    register_backend,
    resolve_backend_name,
    resolve_world_factory,
    resolve_world_factory_2d,
)
from .capability import Capability
from .material import CombineMode, PhysicsMaterial
from .nodes import (
    Area3D,
    CharacterBody3D,
    CollisionShape3D,
    Contact,
    FixedJoint3D,
    GravityArea3D,
    HingeJoint3D,
    Joint3D,
    PhysicsBody3D,
    PhysicsObject3D,
    PinJoint3D,
    SpringJoint3D,
)
from .nodes2d import (
    Area2D,
    CharacterBody2D,
    CollisionShape2D,
    Contact2D,
    FixedJoint2D,
    GravityArea2D,
    GrooveJoint2D,
    HingeJoint2D,
    Joint2D,
    PhysicsBody2D,
    PhysicsObject2D,
    PinJoint2D,
    SpringJoint2D,
)
from .query import PhysicsQuery, RayHit, ShapeHit
from .query2d import PhysicsQuery2D, RayHit2D, ShapeHit2D
from .root import (
    PhysicsRoot,
    PhysicsRoot2D,
    resolve_world,
    resolve_world_2d,
)
from .shapes import (
    BoxShape3D,
    CapsuleShape3D,
    ConcaveMeshShape3D,
    ConvexHullShape3D,
    CylinderShape3D,
    Shape,
    SphereShape3D,
)
from .shapes2d import (
    CapsuleShape2D,
    CircleShape2D,
    ConcavePolygonShape2D,
    ConvexPolygonShape2D,
    RectangleShape2D,
    SegmentShape2D,
    Shape2D,
)
from .world import BodyMode, PhysicsWorld, SweepHit
from .world2d import Physics2DWorld, SweepHit2D

__all__ = [
    # material
    "BodyMode",
    "CombineMode",
    "PhysicsMaterial",
    "Contact",
    "Contact2D",
    # shapes
    "Shape",
    "SphereShape3D",
    "BoxShape3D",
    "CapsuleShape3D",
    "CylinderShape3D",
    "ConvexHullShape3D",
    "ConcaveMeshShape3D",
    "Shape2D",
    "CircleShape2D",
    "RectangleShape2D",
    "CapsuleShape2D",
    "SegmentShape2D",
    "ConvexPolygonShape2D",
    "ConcavePolygonShape2D",
    # body / character / shape-carrier / area nodes (3D)
    "CollisionShape3D",
    "PhysicsObject3D",
    "PhysicsBody3D",
    "CharacterBody3D",
    "Area3D",
    "GravityArea3D",
    # body / character / shape-carrier / area nodes (2D)
    "CollisionShape2D",
    "PhysicsObject2D",
    "PhysicsBody2D",
    "CharacterBody2D",
    "Area2D",
    "GravityArea2D",
    # joints (3D)
    "Joint3D",
    "FixedJoint3D",
    "PinJoint3D",
    "HingeJoint3D",
    "SpringJoint3D",
    # joints (2D)
    "Joint2D",
    "FixedJoint2D",
    "PinJoint2D",
    "HingeJoint2D",
    "SpringJoint2D",
    "GrooveJoint2D",
    # query
    "PhysicsQuery",
    "RayHit",
    "ShapeHit",
    "PhysicsQuery2D",
    "RayHit2D",
    "ShapeHit2D",
    "SweepHit",
    "SweepHit2D",
    # world / root / backends
    "PhysicsWorld",
    "Physics2DWorld",
    "PhysicsRoot",
    "PhysicsRoot2D",
    "resolve_world",
    "resolve_world_2d",
    "Capability",
    "BUILTIN",
    "BackendEntry",
    "register_backend",
    "resolve_backend_name",
    "resolve_world_factory",
    "resolve_world_factory_2d",
]