|
Engine²
Open-source game engine written in C++.
|
Classes | |
| struct | ConstraintContext |
| struct | Vec3Hash |
| Hash function for glm::vec3 to use in unordered_map. More... | |
| struct | Vec3Equal |
| Equality function for glm::vec3 (exact comparison). More... | |
| struct | DeduplicatedMesh |
| Structure holding deduplicated mesh data for Jolt soft body. More... | |
| struct | CreateSettingsResult |
| Result of creating Jolt shared settings, includes vertex mapping. More... | |
Functions | |
| static void | OnCharacterControllerConstruct (Engine::Core::Registry ®istry, Engine::EntityId entityId) |
| static void | OnCharacterControllerDestroy (Engine::Core::Registry ®istry, Engine::EntityId entityId) |
| void | CharacterControllerUpdate (Engine::Core &core) |
| Update the character controller system. This will process all entities with character controllers and update their state based on input and physics interactions. | |
| void | InitCharacterControllerSystem (Engine::Core &core) |
| Initialize the character controller system. This will set up necessary resources and state for character controllers to function. | |
| void | ShutdownCharacterControllerSystem (Engine::Core &core) |
| Shutdown the character controller system. This will clean up any resources used by the system. | |
| Component::RigidBodyInternal * | GetBodyInternal (Engine::Entity entity, const char *constraintName, const char *bodyName) |
| void | FinalizeConstraint (ConstraintContext &ctx, Engine::Entity entity, JPH::Constraint *joltConstraint, Component::ConstraintType type, const Component::ConstraintSettings &settings, const char *constraintName) |
| void | DestroyConstraint (Engine::Core::Registry ®istry, Engine::EntityId entity, const char *constraintName) |
| template<typename ConstraintT> | |
| static bool | ValidateConstraint (const ConstraintT &constraint, const char *constraintName) |
| template<typename SettingsT, typename ConstraintT> | |
| static JPH::Constraint * | CreateJoltConstraint (ConstraintContext &ctx, SettingsT &joltSettings, const ConstraintT &constraint, Component::RigidBodyInternal *internalA, const char *constraintName) |
| template<Component::ConstraintType TYPE, typename CompT, typename SettingsT, typename Configurator, typename ExtraValidate> | |
| static void | CreateConstraintGeneric (Engine::Core::Registry ®istry, Engine::EntityId entity, const char *constraintName, Configurator &&configurator, ExtraValidate &&extraValidate) |
| static void | OnFixedConstraintConstruct (Engine::Core::Registry ®istry, Engine::EntityId entity) |
| static void | OnFixedConstraintDestroy (Engine::Core::Registry ®istry, Engine::EntityId entity) |
| static void | OnDistanceConstraintConstruct (Engine::Core::Registry ®istry, Engine::EntityId entity) |
| static void | OnDistanceConstraintDestroy (Engine::Core::Registry ®istry, Engine::EntityId entity) |
| static void | OnPointConstraintConstruct (Engine::Core::Registry ®istry, Engine::EntityId entity) |
| static void | OnPointConstraintDestroy (Engine::Core::Registry ®istry, Engine::EntityId entity) |
| void | InitConstraintSystem (Engine::Core &core) |
| void | InitJoltPhysics (Engine::Core &core) |
| Init internal elements needed by JoltPhysics. | |
| void | InitPhysicsManager (Engine::Core &core) |
| Init the PhysicsManager. | |
| void | PhysicsUpdate (Engine::Core &core) |
| Applies every update of the physics system. | |
| static JPH::RefConst< JPH::Shape > | CreateConvexHullFromMesh (const Object::Component::Mesh &mesh, const Component::ConvexHullMeshCollider *meshCollider, const glm::vec3 &scale) |
| Create a ConvexHullShape from mesh vertices. | |
| static JPH::RefConst< JPH::Shape > | CreateMeshShapeFromMesh (const Object::Component::Mesh &mesh, const Component::MeshCollider *meshCollider, const glm::vec3 &scale) |
| Create a MeshShape from mesh vertices and indices. | |
| static JPH::RefConst< JPH::Shape > | CreateShapeFromColliders (Engine::Core::Registry ®istry, Engine::EntityId entity) |
| Create a Jolt shape from collider components. | |
| static void | OnRigidBodyConstruct (Engine::Core::Registry ®istry, Engine::EntityId entityId) |
| Called when RigidBody component is added to an entity. | |
| static void | OnRigidBodyInternalConstruct (Engine::Core::Registry ®istry, Engine::EntityId entityId) |
| static void | OnRigidBodyDestroy (Engine::Core::Registry ®istry, Engine::EntityId entityId) |
| Called when RigidBody component is removed from an entity. | |
| static void | OnRigidBodyInternalDestroy (Engine::Core::Registry ®istry, Engine::EntityId entityId) |
| void | InitRigidBodySystem (Engine::Core &core) |
| Initialize RigidBody system and register entt hooks. | |
| void | ShutdownRigidBodySystem (Engine::Core &core) |
| Shutdown RigidBody system and unregister entt hooks. | |
| static std::vector< std::pair< uint32_t, uint32_t > > | GenerateEdgesFromFaces (const std::vector< uint32_t > &faceIndices) |
| Generate edge constraints from triangle face indices. | |
| static DeduplicatedMesh | DeduplicateMesh (const Object::Component::Mesh &mesh) |
| Convert a potentially "flat" mesh (with duplicated vertices) to an indexed mesh with unique vertices. | |
| static CreateSettingsResult | CreateJoltSharedSettings (const Component::SoftBody &softBody, const Object::Component::Mesh &mesh, const glm::vec3 &scale=glm::vec3(1.0f)) |
| Convert SoftBody component to Jolt SoftBodySharedSettings. | |
| static JPH::SoftBodyCreationSettings | CreateJoltCreationSettings (const Component::SoftBody &softBody, const JPH::Ref< JPH::SoftBodySharedSettings > &sharedSettings, const JPH::RVec3 &position, const JPH::Quat &rotation) |
| Create Jolt SoftBodyCreationSettings from component. | |
| static void | OnSoftBodyConstruct (Engine::Core::Registry ®istry, Engine::EntityId entityId) |
| static void | OnSoftBodyInternalConstruct (Engine::Core::Registry ®istry, Engine::EntityId entityId) |
| static void | OnSoftBodyDestroy (Engine::Core::Registry ®istry, Engine::EntityId entityId) |
| static void | OnSoftBodyInternalDestroy (Engine::Core::Registry ®istry, Engine::EntityId entityId) |
| void | InitSoftBodySystem (Engine::Core &core) |
| Initialize the soft body system. | |
| void | ShutdownSoftBodySystem (Engine::Core &core) |
| Shutdown the soft body system. | |
| void | SyncSoftBodyVertices (Engine::Core &core) |
| Synchronize soft body vertex positions to mesh data. | |
| void | SyncTransformWithPhysics (Engine::Core &core) |
| Synchronize Transform components with Jolt Physics body positions. | |
| void | VehicleControlSystem (Engine::Core &core) |
| Apply vehicle controller inputs to Jolt vehicle constraints. | |
| void | VehicleRPMUpdate (Engine::Core &core) |
| Update per-vehicle RPM telemetry from Jolt controller. Runs in FixedTimeUpdate. | |
| static void | CreateJoltWheelSettings (JPH::WheelSettingsWV &joltWheel, const Component::WheelSettings &wheelSettings, const glm::vec3 &position, bool isRear) |
| Create Jolt wheel settings from Physics wheel configuration. | |
| static void | OnVehicleConstruct (Engine::Core::Registry ®istry, Engine::EntityId entityId) |
| Called when Vehicle component is added to an entity. | |
| static void | OnVehicleDestroy (Engine::Core::Registry ®istry, Engine::EntityId entityId) |
| Called when Vehicle component is removed from an entity. | |
| void | InitVehicleSystem (Engine::Core &core) |
| Initialize the vehicle system with entt lifecycle hooks. | |
| void | WheelTransformSyncSystem (Engine::Core &core) |
| Sync wheel entity transforms with Jolt vehicle wheel positions. | |
| void Physics::System::CharacterControllerUpdate | ( | Engine::Core & | core | ) |
Update the character controller system. This will process all entities with character controllers and update their state based on input and physics interactions.
| core | The engine core to update the system with. |
|
static |
|
static |
Create a ConvexHullShape from mesh vertices.
| mesh | The mesh component containing vertices |
| meshCollider | Pointer to ConvexHullMeshCollider settings (nullable). If null, default settings are used. |
| scale | Scale to apply to the mesh vertices (from Transform component) |
|
static |
|
static |
Create Jolt SoftBodyCreationSettings from component.
|
static |
Convert SoftBody component to Jolt SoftBodySharedSettings.
| softBody | The soft body component with settings and physics data |
| mesh | The mesh containing vertices and face indices |
| scale | The scale factor from Transform to apply to vertices (default: 1.0) |
|
static |
Create Jolt wheel settings from Physics wheel configuration.
|
static |
Create a MeshShape from mesh vertices and indices.
| mesh | The mesh component containing vertices and indices |
| meshCollider | Pointer to MeshCollider settings (nullable) |
| scale | Scale to apply to the mesh vertices (from Transform component) |
|
static |
Create a Jolt shape from collider components.
|
static |
Convert a potentially "flat" mesh (with duplicated vertices) to an indexed mesh with unique vertices.
OBJLoader creates meshes where each face has its own copy of vertices, resulting in indices like [0, 1, 2, 3, 4, 5, ...] where vertices are duplicated. Jolt SoftBody needs a proper indexed mesh with shared vertices for constraint creation.
| mesh | The input mesh (potentially with duplicated vertices) |
| void Physics::System::DestroyConstraint | ( | Engine::Core::Registry & | registry, |
| Engine::EntityId | entity, | ||
| const char * | constraintName ) |
| void Physics::System::FinalizeConstraint | ( | ConstraintContext & | ctx, |
| Engine::Entity | entity, | ||
| JPH::Constraint * | joltConstraint, | ||
| Component::ConstraintType | type, | ||
| const Component::ConstraintSettings & | settings, | ||
| const char * | constraintName ) |
|
static |
| Component::RigidBodyInternal * Physics::System::GetBodyInternal | ( | Engine::Entity | entity, |
| const char * | constraintName, | ||
| const char * | bodyName ) |
| void Physics::System::InitCharacterControllerSystem | ( | Engine::Core & | core | ) |
Initialize the character controller system. This will set up necessary resources and state for character controllers to function.
| core | The engine core to initialize the system with. |
| void Physics::System::InitConstraintSystem | ( | Engine::Core & | core | ) |
| void Physics::System::InitJoltPhysics | ( | Engine::Core & | core | ) |
Init internal elements needed by JoltPhysics.
| core | core |
| void Physics::System::InitPhysicsManager | ( | Engine::Core & | core | ) |
Init the PhysicsManager.
| core | core |
| void Physics::System::InitRigidBodySystem | ( | Engine::Core & | core | ) |
Initialize RigidBody system and register entt hooks.
This system sets up the entt hooks for RigidBody component:
| core | The engine core |
| void Physics::System::InitSoftBodySystem | ( | Engine::Core & | core | ) |
Initialize the soft body system.
Registers entt hooks for SoftBody component creation and destruction. Should be called during physics plugin initialization.
| core | Reference to the engine core |
| void Physics::System::InitVehicleSystem | ( | Engine::Core & | core | ) |
Initialize the vehicle system with entt lifecycle hooks.
Registers callbacks for Vehicle component construction and destruction. Must be called during Engine startup (Scheduler::Startup).
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Called when RigidBody component is added to an entity.
|
static |
Called when RigidBody component is removed from an entity.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Called when Vehicle component is added to an entity.
Creates:
Note: Jolt's WheeledVehicle does NOT use separate physics bodies for wheels. Wheels are simulated via raycasts/shape casts from the chassis.
|
static |
Called when Vehicle component is removed from an entity.
Destroys:
| void Physics::System::PhysicsUpdate | ( | Engine::Core & | core | ) |
Applies every update of the physics system.
After physics update, flush any buffered contact events from worker threads to the EventManager in the core.
| core | core |
| void Physics::System::ShutdownCharacterControllerSystem | ( | Engine::Core & | core | ) |
Shutdown the character controller system. This will clean up any resources used by the system.
| core | The engine core to shut down the system from. |
| void Physics::System::ShutdownRigidBodySystem | ( | Engine::Core & | core | ) |
Shutdown RigidBody system and unregister entt hooks.
This system disconnects the entt hooks for RigidBody component.
| core | The engine core |
| void Physics::System::ShutdownSoftBodySystem | ( | Engine::Core & | core | ) |
Shutdown the soft body system.
Cleans up any remaining soft bodies.
| core | Reference to the engine core |
| void Physics::System::SyncSoftBodyVertices | ( | Engine::Core & | core | ) |
Synchronize soft body vertex positions to mesh data.
Updates vertex positions from Jolt soft body simulation. Should be called after physics update.
| core | Reference to the engine core |
| void Physics::System::SyncTransformWithPhysics | ( | Engine::Core & | core | ) |
Synchronize Transform components with Jolt Physics body positions.
This system should run in the FixedTimeUpdate scheduler AFTER PhysicsUpdate. It reads the position and rotation from Jolt bodies and updates the corresponding Transform components.
Only dynamic and kinematic bodies are synchronized (static bodies don't move).
| core | The engine core |
|
static |
| void Physics::System::VehicleControlSystem | ( | Engine::Core & | core | ) |
Apply vehicle controller inputs to Jolt vehicle constraints.
Should run every physics tick (FixedTimeUpdate scheduler). Reads VehicleController component values and applies them to the WheeledVehicleController.
| void Physics::System::VehicleRPMUpdate | ( | Engine::Core & | core | ) |
Update per-vehicle RPM telemetry from Jolt controller. Runs in FixedTimeUpdate.
| void Physics::System::WheelTransformSyncSystem | ( | Engine::Core & | core | ) |
Sync wheel entity transforms with Jolt vehicle wheel positions.
Should run every physics tick (FixedTimeUpdate scheduler) AFTER PhysicsUpdate. Updates the Transform component of each wheel entity to match the computed wheel position and rotation from the vehicle constraint.