simvx.core.physics._server

PhysicsServer: singleton world manager and internal body record.

Private leaf module: import via the simvx.core.physics facade.

Module Contents

Classes

PhysicsServer

Central physics simulation manager.

Data

API

simvx.core.physics._server.log

‘getLogger(…)’

simvx.core.physics._server.__all__

[‘PhysicsServer’]

class simvx.core.physics._server.PhysicsServer(cell_size: float = 2.0)[source]

Central physics simulation manager.

Manages all physics bodies, runs broadphase/narrowphase collision detection, resolves contacts with impulse-based response, and provides raycasting.

Usage: server = PhysicsServer.get() server.gravity = Vec3(0, -9.8, 0)

Initialization

classmethod get() simvx.core.physics._server.PhysicsServer[source]

Return the singleton PhysicsServer, creating it if needed.

classmethod reset() None[source]

Reset the singleton (useful for tests).

property gravity: numpy.ndarray[source]

Global gravity vector. Default (0, -9.8, 0).

Accepts a Vec3, tuple, or ndarray when set.

add_body(body) None[source]

Register a physics body node with the server.

remove_body(body) None[source]

Unregister a physics body from the server.

add_joint(joint) None[source]

Register a joint constraint with the server for solving during step().

remove_joint(joint) None[source]

Unregister a joint constraint from the server.

step(dt: float) None[source]

Advance the physics simulation by dt seconds.

This performs:

  1. Sync positions from nodes

  2. Apply gravity and forces → integrate velocities

  3. Broadphase + narrowphase collision detection

  4. Iterative impulse-based collision response

  5. Integrate positions

  6. Write results back to nodes

  7. Emit body_entered/body_exited signals

raycast(origin, direction, max_dist: float = 1000.0, layer_mask: int = 4294967295) list[simvx.core.collision.RayHit][source]

Cast a ray through the physics world.

Args: origin: Ray start position (Vec3, tuple, or ndarray). direction: Ray direction (will be normalized). max_dist: Maximum ray length. layer_mask: Bitmask to filter bodies by collision layer.

Returns: List of RayHit sorted by distance.

get_overlapping_bodies(body) list[source]

Return all bodies currently overlapping the given body.

property body_count: int[source]