Package jsim.core
Class PhysicsWorld
java.lang.Object
jsim.core.PhysicsWorld
The central simulation world.
Advances through a strict deterministic pipeline on each call to step(double):
- Clear force/torque accumulators on all bodies.
- Apply all registered force generators (gravity, drag, magnus, actuators).
- Broadphase — AABB overlap test, produces candidate pairs.
- Narrowphase — geometry-accurate contact generation.
- Solve — iterative impulse projection (normal + friction).
- Integrate — semi-implicit Euler: v += a·dt, x += v·dt; quaternion update.
- Positional correction — Baumgarte (baked into solver bias).
- Update derived state — AABB refresh, quaternion normalisation, inertia refresh.
The API layer (SimWorld) owns this object and delegates to it.
External code should not reference this class directly.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a world with default solver iteration count.PhysicsWorld(int solverIterations) Creates a world with the given solver iteration count. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a body to the world and assign it a unique ID.voidRegister an additional force generator (e.g.Read-only view of all bodies for sensors/tracking.voidremoveBody(RigidBody body) Remove a body from the world.voidUnregister a previously added force generator.voidstep(double dt) Advance the simulation by exactlydtseconds.
-
Constructor Details
-
PhysicsWorld
public PhysicsWorld()Creates a world with default solver iteration count. -
PhysicsWorld
public PhysicsWorld(int solverIterations) Creates a world with the given solver iteration count.- Parameters:
solverIterations- number of impulse-solver iterations per tick
-
-
Method Details
-
addBody
Add a body to the world and assign it a unique ID.- Parameters:
body- the body to register
-
removeBody
Remove a body from the world.- Parameters:
body- the body to remove
-
addForceGenerator
Register an additional force generator (e.g. actuator, drag, magnus).- Parameters:
fg- the force generator to add
-
removeForceGenerator
Unregister a previously added force generator.- Parameters:
fg- the force generator to remove
-
getBodies
Read-only view of all bodies for sensors/tracking.- Returns:
- unmodifiable list of all registered bodies
-
step
public void step(double dt) Advance the simulation by exactlydtseconds. Always use a fixed timestep for determinism.- Parameters:
dt- timestep in seconds
-