Hooker Galore
An experimental game engine in which everything works through ECS.
For example window is created and managed via WindowSingleComponent
. WindowSystem
observes changes to this component and makes corresponding system calls.
Physics simulation is managed via PhysicsSingleComponent
. PhysicsInitializationSystem
, PhysicsSimulateSystem
and PhysicsFetchSystem
observe changes to this component
and make corresponding physics engine calls.
Supported platforms (via SDL2):
- Windows;
- Linux;
- Mac OS.
Supported rendering backends (via bgfx):
- Direct3D 9;
- Direct3D 11;
- Direct3D 12;
- Metal;
- OpenGL 2.1;
- OpenGL 3.1+;
- Vulkan.
Systems
- AAPassSystem — implements an FXAA render pass;
- CameraSystem — updates camera matrices (view, projection, inverse view, inverse projection) in
CameraSingleComponent
which are later used by other render systems; - DebugDrawPassSystem — draws debug primitives like points, lines, and glyphs;
- EditorCameraSystem — updates editor cameras;
- EditorFileSystem — manages "File" menu operations: new, open, save and save as;
- EditorGizmoSystem — shows gizmo that allows modifying transform of selected entity(s);
- EditorGridSystem — draws editor grid using debug draw;
- EditorHistorySystem — shows history overlay and performs undo-redo operations;
- EditorMenuSystem — shows editor menu (file, edit, and so on);
- EditorPresetSystem — shows preset overlay, which allows putting preset entities on the stage;
- EditorPropertyEditorSystem — shows property editor overlay, which allows to change existing components, add new components, and remove existing components;
- EditorSelectionSystem — shows entities overlay, processes LMB clicks to select entities using the picking pass texture;
- GeometryPassSystem — implements geometry pass for deferred rendering;
- HDRPassSystem — implements an HDR pass;
- ImguiFetchSystem — fetches input and window data to ImGui;
- ImguiPassSystem — draws ImGui on the screen;
- LightingPassSystem — implements lighting pass for deferred rendering;
- OutlinePassSystem — draws an outline around entities with
OutlineComponent
; - PhysicsCharacterControllerSystem — synchronizes character controller components and PhysX character controllers;
- PhysicsFetchSystem — waits until the end of asynchronous PhysX simulation and fetches data from it;
- PhysicsInitializationSystem — initializes PhysX;
- PhysicsRigidBodySystem — synchronizes rigid body components and PhysX rigid bodies;
- PhysicsShapeSystem — synchronizes shape components and PhysX shapes;
- PhysicsSimulateSystem — starts asynchronous physics simulation;
- PickingPassSystem — draws all entities with entity indices encoded in color. Asynchronously reads back the resulting texture (used for selection in the editor);
- QuadSystem — creates quad geometry and stores it in
QuadSingleComponent
. This quad is used in all screen space render passes; - RenderFetchSystem — prepares rendering backend for rendering;
- RenderSystem — presents image on the screen;
- ResourceSystem — asynchronously loads all resources (models, textures, and presents);
- SkyboxPassSystem — draws skybox;
- WindowSystem — fetches window events, synchronizes
WindowSingleComponent
with an actual window.
Components
- AAPassSingleComponent — stores
AAPassSystem
state (such as frame buffer handle, shader program handle, and more); - BlockoutComponent — makes entity's UV coordinates scale-dependent without changing vertex buffers;
- CameraSingleComponent — contains a pointer to an active camera and view, projection, inverse view, and inverse projection matrices of that camera;
- DebugDrawPassSingleComponent — stores
DebugDrawPassSystem
state (such as frame buffer handle, shader program handle, and more); - EditorCameraComponent — makes an entity a first-person flying camera managed by
EditorCameraSystem
; - EditorFileSingleComponent — stores which file menu's dialog window is currently open;
- EditorGizmoSingleComponent — stores which gizmo operation is currently active, whether it's in local space or in global space;
- EditorGridSingleComponent — stores whether editor grid is visible or not;
- EditorHistorySingleComponent — stores ring buffers of undo-redo actions;
- EditorMenuSingleComponent — stores menu items;
- EditorPresetSingleComponent — stores all loaded presets;
- EditorSelectionSingleComponent — stores which entities are selected;
- GeometryPassSingleComponent — stores
GeometryPassSystem
state (such as frame buffer handle, shader program handle, and more); - HDRPassSingleComponent — stores
HDRPassSystem
state (such as frame buffer handle, shader program handle, and more); - ImguiSingleComponent — stores ImGui render pass shader programs, textures, and more;
- LevelSingleComponent — stores which level to load;
- LightComponent — makes an entity a point light;
- LightingPassSingleComponent — stores
LightingPassSystem
state (such as frame buffer handle, shader program handle, and more); - MaterialComponent — defines entity's material;
- ModelComponent — defines entity's geometry;
- ModelSingleComponent — stores all loaded models;
- NameComponent — specifies the name of an entity;
- NameSingleComponent — stores mapping from name to an entity;
- NormalInputSingleComponent — stores input state;
- OutlineComponent — adds an outline to an entity;
- OutlinePassSingleComponent — stores
OutlinePassSystem
state (such as frame buffer handle, shader program handle, and more); - PhysicsBoxShapeComponent — adds a physical box shape to a rigid body;
- PhysicsBoxShapePrivateComponent — automatically added and removed by
PhysicsShapeSystem
, stores PhysX shape handle; - PhysicsCharacterControllerComponent — makes an entity a character controller;
- PhysicsCharacterControllerPrivateComponent — automatically added and removed by
PhysicsCharacterControllerSystem
, stores PhysX character controller handle; - PhysicsCharacterControllerSingleComponent — stores PhysX character controller manager;
- PhysicsSingleComponent — stores PhysX handles;
- PhysicsStaticRigidBodyComponent — makes an entity a rigid body;
- PhysicsStaticRigidBodyPrivateComponent — automatically added and removed by
PhysicsRigidBodySystem
, stores PhysX rigid body handle; - PickingPassSingleComponent — stores
PickingPassSystem
state (such as frame buffer handle, shader program handle, and more); - QuadSingleComponent — stores quad vertex and index buffers;
- RenderSingleComponent — stores current frame and whether to show debug info;
- SkyboxPassSingleComponent — stores
SkyboxPassSystem
state (such as frame buffer handle, shader program handle, and more); - TextureSingleComponent — stores all loaded textures;
- TransformComponent — stores linear transformation of an entity;
- WindowSingleComponent — stores window title, width, height, and more.
System execution order
System execution order is an important topic in every ECS game engine. Initially, this engine had a manual system order, but after a couple of dozen systems, it has become difficult to add new systems to that list.
Now each system has a small descriptor that defines before/after which systems a certain system must execute. System manager uses this information to order systems automatically.
SYSTEM_DESCRIPTOR(
SYSTEM(LightingPassSystem),
TAGS(render),
BEFORE("RenderSystem"),
AFTER("WindowSystem", "RenderFetchSystem", "CameraSystem", "GeometryPassSystem")
)
Tags are used to enable/disable certain systems (like physics or debug).
Fixed system execution order:
- PhysicsInitializationSystem;
- PhysicsCharacterControllerSystem;
- PhysicsRigidBodySystem;
- PhysicsShapeSystem;
- PhysicsSimulateSystem;
- PhysicsFetchSystem.
Normal system execution order:
- WindowSystem;
- RenderFetchSystem;
- ImguiFetchSystem;
- EditorMenuSystem;
- EditorSelectionSystem;
- EditorCameraSystem;
- CameraSystem;
- EditorPresetSystem;
- ResourceSystem;
- EditorFileSystem;
- EditorGizmoSystem;
- EditorPropertyEditorSystem;
- GeometryPassSystem;
- LightingPassSystem;
- SkyboxPassSystem;
- AAPassSystem;
- EditorGridSystem;
- DebugDrawPassSystem;
- EditorHistorySystem;
- HDRPassSystem;
- ImguiPassSystem;
- OutlinePassSystem;
- PickingPassSystem;
- QuadSystem;
- RenderSystem.
Screenshots
Overview of the editor.
PBR flight helmet.
PBR damaged helmet.
Add components dialog window.