|
JSim 2026.06.01-p(1)
|
Unified physics scene manager for rigid bodies, assemblies, ball simulators, and global forces. More...
#include <physics_world.hpp>
Classes | |
| struct | MaterialInteraction |
| Material-pair contact interaction override entry. More... | |
Public Member Functions | |
| PhysicsWorld (const PhysicsConfig &config=PhysicsConfig()) | |
| Constructs a world with an initial configuration snapshot. | |
| RigidBody & | createBody (double mass_kg) |
| Creates and registers a dynamic rigid body. | |
| RigidAssembly & | createAssembly () |
| Creates and registers a rigid assembly container. | |
| EnvironmentalBoundary & | addBoundary () |
| Adds a new environmental boundary primitive. | |
| std::vector< EnvironmentalBoundary > & | boundaries () |
| Mutable access to boundary storage. | |
| const std::vector< EnvironmentalBoundary > & | boundaries () const |
| Immutable access to boundary storage. | |
| void | addGlobalForceGenerator (const std::shared_ptr< ForceGenerator > &generator) |
| Registers a world-level force generator. | |
| void | setMaterialInteraction (const MaterialInteraction &interaction) |
| Registers or updates one material interaction override row. | |
| void | clearMaterialInteractions () |
| Clears all material interaction override rows. | |
| std::vector< RigidBody > & | bodies () |
| Mutable access to all rigid bodies currently registered in the world. | |
| const std::vector< RigidBody > & | bodies () const |
| Immutable access to all rigid bodies currently registered in the world. | |
| std::vector< RigidAssembly > & | assemblies () |
| Mutable access to all rigid assemblies currently registered in the world. | |
| const std::vector< RigidAssembly > & | assemblies () const |
| Immutable access to all rigid assemblies currently registered in the world. | |
| Gamepiece & | createGamepiece (const Gamepiece::Config &config=Gamepiece::Config(), const Gamepiece::Properties &properties=Gamepiece::Properties()) |
| Creates and registers a generic gamepiece. | |
| BallPhysicsSim3D & | createBall (const Gamepiece::Config &config=Gamepiece::Config(), const Gamepiece::Properties &properties=Gamepiece::Properties()) |
| Backwards-compatible helper that creates a ball simulator. | |
| std::vector< Gamepiece > & | gamepieces () |
| Mutable access to all registered gamepieces. | |
| const std::vector< Gamepiece > & | gamepieces () const |
| Immutable access to all registered gamepieces. | |
| std::vector< Gamepiece > & | balls () |
| Backwards-compatible accessor name for registered balls (gamepieces). | |
| const std::vector< Gamepiece > & | balls () const |
| Backwards-compatible const accessor for registered balls (gamepieces). | |
| void | step () |
| Advances simulation by exactly one fixed timestep. | |
| std::size_t | stepCount () const |
| Number of completed fixed-timestep iterations since construction/reset. | |
| double | accumulatedSimTimeS () const |
| Total accumulated simulation time in seconds. | |
| PhysicsConfig & | config () |
| Mutable access to world configuration. | |
| const PhysicsConfig & | config () const |
| Read-only access to world configuration. | |
| void | setGravity (double gx_mps2, double gy_mps2, double gz_mps2) |
| Sets world gravity acceleration from scalar components. | |
| void | gravity (double *gx_mps2, double *gy_mps2, double *gz_mps2) const |
| Reads world gravity acceleration into optional scalar outputs. | |
Unified physics scene manager for rigid bodies, assemblies, ball simulators, and global forces.
PhysicsWorld is the central orchestration object for the native simulation runtime. It owns all registered entities and advances them in lock-step using a fixed timestep from PhysicsConfig.
High-level responsibilities:
Determinism and ordering:
|
inlineexplicit |
Constructs a world with an initial configuration snapshot.
| config | Initial world settings copied into internal storage. |
|
inline |
Total accumulated simulation time in seconds.
| EnvironmentalBoundary & frcsim::PhysicsWorld::addBoundary | ( | ) |
Adds a new environmental boundary primitive.
Callers can then configure geometry, behavior, material id, and collision filters directly through the returned reference.
| void frcsim::PhysicsWorld::addGlobalForceGenerator | ( | const std::shared_ptr< ForceGenerator > & | generator | ) |
Registers a world-level force generator.
| generator | Shared pointer to a force generator implementation. |
Force generators are evaluated during step and can apply additional forces to bodies independent of per-body material settings.
|
inline |
Mutable access to all rigid assemblies currently registered in the world.
|
inline |
Immutable access to all rigid assemblies currently registered in the world.
|
inline |
Backwards-compatible accessor name for registered balls (gamepieces).
|
inline |
Backwards-compatible const accessor for registered balls (gamepieces).
|
inline |
Mutable access to all rigid bodies currently registered in the world.
|
inline |
Immutable access to all rigid bodies currently registered in the world.
|
inline |
Mutable access to boundary storage.
|
inline |
Immutable access to boundary storage.
| void frcsim::PhysicsWorld::clearMaterialInteractions | ( | ) |
Clears all material interaction override rows.
After calling this, contact response falls back to default body/boundary material coefficients.
|
inline |
Mutable access to world configuration.
|
inline |
Read-only access to world configuration.
| RigidAssembly & frcsim::PhysicsWorld::createAssembly | ( | ) |
Creates and registers a rigid assembly container.
| BallPhysicsSim3D & frcsim::PhysicsWorld::createBall | ( | const Gamepiece::Config & | config = Gamepiece::Config(), |
| const Gamepiece::Properties & | properties = Gamepiece::Properties() ) |
Backwards-compatible helper that creates a ball simulator.
Internally this delegates to createGamepiece and returns a reference to the underlying BallPhysicsSim3D base so existing callers continue to function.
| RigidBody & frcsim::PhysicsWorld::createBody | ( | double | mass_kg | ) |
Creates and registers a dynamic rigid body.
| mass_kg | Body mass in kilograms. Non-positive values are sanitized by RigidBody. |
| Gamepiece & frcsim::PhysicsWorld::createGamepiece | ( | const Gamepiece::Config & | config = Gamepiece::Config(), |
| const Gamepiece::Properties & | properties = Gamepiece::Properties() ) |
Creates and registers a generic gamepiece.
| config | Environment and behavior configuration for the gamepiece when it uses spherical hitboxes. Future hitbox types may be added. |
| properties | Physical properties for the simulated gamepiece. |
|
inline |
Mutable access to all registered gamepieces.
|
inline |
Immutable access to all registered gamepieces.
|
inline |
Reads world gravity acceleration into optional scalar outputs.
| gx_mps2 | Optional output pointer for gravity x in m/s^2. |
| gy_mps2 | Optional output pointer for gravity y in m/s^2. |
| gz_mps2 | Optional output pointer for gravity z in m/s^2. |
Any pointer may be null, allowing callers to request only selected axes.
|
inline |
Sets world gravity acceleration from scalar components.
| gx_mps2 | Gravity x component in meters per second squared. |
| gy_mps2 | Gravity y component in meters per second squared. |
| gz_mps2 | Gravity z component in meters per second squared. |
Calling this method also enables gravity in PhysicsConfig, making the new vector effective for subsequent step calls.
| void frcsim::PhysicsWorld::setMaterialInteraction | ( | const MaterialInteraction & | interaction | ) |
Registers or updates one material interaction override row.
| interaction | Interaction record to insert or replace. |
| void frcsim::PhysicsWorld::step | ( | ) |
Advances simulation by exactly one fixed timestep.
The step procedure applies configured forces, integrates rigid-body states, resolves supported contact responses, updates assemblies, and advances all ball simulators. Internal counters for step count and simulated time are incremented after successful completion.
|
inline |
Number of completed fixed-timestep iterations since construction/reset.