Gorilla.Physics Unit Reference
Overview
The Gorilla.Physics unit provides TGorillaPhysicsSystem, the main physics simulation component in Gorilla3D. It supports multiple physics drivers (Q3, JOLT), various collider shapes, joints, forces, impulses, and collision events. Place it in a viewport and call Step() on a timer to run the simulation.
Class Hierarchy
TComponent
└── TControl3D
└── TGorillaControl
└── TGorillaPhysicsSystem
TGorillaPhysicsSystem
Published Properties
| Property |
Type |
Description |
Driver |
TGorillaPhysicsDriverType |
Physics engine driver: Q3Physics, JOLTPhysics, CustomPhysics |
Active |
Boolean |
Activate/deactivate physics. Still requires calling Step() |
Async |
Boolean |
Enable asynchronous (background thread) computation |
RenderColliders |
Boolean |
Render collider shapes at runtime for debugging |
Accuracy |
Integer |
Computation accuracy (1..25). Higher = more accurate but slower. Default: 10 |
Gravity |
TPoint3D |
Global gravity vector |
Colliders |
TGorillaPhysicsColliderPrefabs |
Design-time collider prefab collection |
Joints |
TGorillaPhysicsJointPrefabs |
Design-time joint prefab collection |
Published Events
| Event |
Type |
Description |
OnBeginContact |
TOnGorillaPhysicsNotifyContact |
Fired when two bodies begin colliding |
OnEndContact |
TOnGorillaPhysicsNotifyContact |
Fired when two bodies stop colliding |
OnBeginStep |
TNotifyEvent |
Start of a computation cycle (not synchronized) |
OnEndStep |
TNotifyEvent |
End of a computation cycle (not synchronized) |
OnBeginUpdate |
TNotifyEvent |
Start of bodies update (not synchronized) |
OnEndUpdate |
TNotifyEvent |
End of bodies update (not synchronized) |
OnCollidersRegistered |
TNotifyEvent |
All collider prefabs registered |
OnCollidersUnregistered |
TNotifyEvent |
All collider prefabs unregistered |
OnJointsRegistered |
TNotifyEvent |
All joint prefabs registered |
OnJointsUnregistered |
TNotifyEvent |
All joint prefabs unregistered |
Public Properties
| Property |
Type |
Description |
DriverInstance |
TGorillaPhysicsDriver |
Direct access to the physics driver instance |
Engine |
TObject |
Internal physics engine object |
EventCache |
TGorillaPhysicsEventCache |
Collider/joint event cache for fast body-event mapping |
Collider Methods
| Method |
Description |
AddBoxCollider(AControl, APrefab) |
Add box collider, auto-sized from control |
AddBoxCollider(AControl, APrefab, ASize) |
Add box collider with explicit size |
AddSphereCollider(AControl, APrefab, ARadius) |
Add sphere collider |
AddCapsuleCollider(AControl, APrefab, ARadius, AHeight) |
Add capsule collider |
AddCylinderCollider(AControl, APrefab, AHalfHeight, ARadius, AConvexRadius) |
Add cylinder collider (Q3 + JOLT) |
AddConeCollider(AControl, APrefab, AHeight, ARadius) |
Add cone collider (Q3 + JOLT) |
AddConvexHullCollider(AControl, APrefab, APointCount, APoints) |
Add convex hull collider (Q3 + JOLT) |
AddTerrainCollider(AMesh, APrefab) |
Add terrain collider (TCustomMesh or TGorillaMesh) |
AddMeshCollider(AMesh, APrefab) |
Add mesh collider (experimental) |
AddParticleCollider(AData, AType, APrefab, ATransformation, ARadius, ABody) |
Add particle collider |
RemoveCollider(AMesh) |
Remove collider by control |
RemoveCollider(ABody) |
Remove collider by body reference |
Transform Methods
| Method |
Description |
RemoteMeshTransform(ACtrl) |
Sync control transform to physics |
RemoteBodyTransform(ABody/ACtrl, ATranslation, ARotationAngle) |
Set body position and rotation |
RemoteBodyTransform(ABody/ACtrl, ATranslation, ARotation) |
Set body position and rotation matrix |
Force / Impulse Methods
| Method |
Description |
RemoteBodyImpulse(ABody/ACtrl, AImpulse) |
Apply instantaneous impulse |
RemoteBodyForce(ABody/ACtrl, AForce, ADirect) |
Apply continuous force |
RemoteBodyVelocity(ABody/ACtrl, AVelocity, ADirect) |
Set linear velocity directly |
RemoteBodyAngularVelocity(ABody/ACtrl, AVelocity) |
Set angular velocity directly |
RemoteBodyAngularImpulse(ABody/ACtrl, AImpulse, APt) |
Apply angular impulse |
Lifecycle Methods
| Method |
Description |
Step() |
Execute one physics simulation step. Call on a ~33ms timer |
GetDeltaTime() |
Returns time since last step in milliseconds |
Block() |
Block physics system for thread-safe body access (async mode) |
Unblock() |
Unblock after Block() |
Class Methods
| Method |
Description |
RegisterDriverClass(AEngineName, AClass) |
Register a custom physics driver |
UnregisterDriverClass(AEngineName/AClass) |
Unregister a physics driver |
GetDriverClass(AEngineName/AType) |
Get registered driver class |
See Also