![]() |
vkmEngine 1.0.15
A C++ game engine · vkmengine.com
|
Everything a game puts in a world is an entity carrying components. Scene is the registry that holds them: an entity is a handle, a component is a plain struct, and any type can be a component - no registration, no base class.
An EntityId wraps a StorageIndex (a slot and a generation):
Each header documents its fields.
| Component | File | What it is |
|---|---|---|
| Transform | component/core/transform.h | Local position, rotation and scale |
| WorldTransform | component/core/world_transform.h | The world matrix, resolved each frame by HierarchySystem |
| Camera | component/render/camera.h | Projection, depth of field, viewmodel field of view; findActiveCamera finds the one in use |
| Mesh | component/render/mesh.h | A mesh and the material it is drawn with, shadow casting, which views see it (SeenBy), and whether it ever moves (movable - Visibility) |
| Light | component/render/light.h | Directional, Point, Spot, Rect or Disk light (Lighting) |
| Animation | component/animation/animation.h | Position, rotation and scale tracks for this entity's own Transform |
| Animator | component/animation/animator.h | Plays a clip on a skeleton - one per rigged character, not per mesh |
| BoneSocket | component/animation/bone_socket.h | What rides a joint of the rig it is parented to, at an offset |
| Hierarchy | component/core/hierarchy.h | Parent, first/last child and sibling links (below) |
| Name | component/core/name.h | char value[64] - the entity's display name, in the editor and in log lines |
| NetLocal | component/core/net_local.h | Nothing - its presence keeps the entity and everything below it off the wire (Networking) |
| Collider | component/physics/collider.h | One or more ColliderParts (Box, Capsule, Mesh or Terrain) + isTrigger + enabled |
| CharacterController | component/physics/character_controller.h | Move, jump, climb and crouch input in; ground contact out (Physics) |
| Rigidbody | component/physics/rigidbody.h | A Dynamic, Kinematic or Static body, plus the support and blocking outputs |
| ReflectionProbe | component/render/reflection_probe.h | Local IBL probe over an influence box |
| PlanarReflector | component/render/planar_reflector.h | A flat mirror: glossy surfaces on its rectangle reflect the scene drawn again from the mirrored camera |
| AudioSource | component/audio/audio_source.h | A clip to play, spatial or not; playing is runtime state (Audio) |
| AudioListener | component/audio/audio_listener.h | The ear every spatial source is heard relative to |
| Decal | component/render/decal.h | A material projected onto whatever its box covers |
| LOD | component/render/lod.h | Mesh levels, each with a maxDistance, chosen by the camera's distance and bias |
| IrradianceVolume | component/render/irradiance_volume.h | The baked SH-L1 grid indirect diffuse comes from |
| Ocean | component/render/ocean.h | The spectrum a waves material's surface moves by. One a scene (findOcean); see rendering.md |
| Terrain | component/render/terrain.h | The terrain drawn where the entity stands, and whether it casts shadows (Terrain) |
| ParticleEmitter | component/render/particle_emitter.h | How particles are emitted; the live particles are ParticleSystem's |
| ParticleTrigger | component/render/particle_emitter.h | Makes a child's emitter spawn on its parent's particles' births, deaths or strikes |
| Joint | component/physics/joint.h | A JointType constraint to the connected entity |
| Ragdoll | component/physics/ragdoll.h | One RagdollBone per simulated bone, each naming the body entity that simulates it |
| ScriptComponent | system/script/script_component.h | The behaviors attached to this entity, owned as unique_ptr<Behavior>; see Scripting |
| PrefabInstance | component/prefab/prefab_instance.h | Marks an instance root: the source prefab and its overrides |
| PrefabEntity | component/prefab/prefab_entity.h | uid - what an override addresses |
| NetSpawn | component/prefab/net_spawn.h | Runtime only: what NetSession::spawn built (Networking) |
| MissingAssets | component/core/missing_assets.h | Asset names a load could not resolve, kept for the next save (IO) |
| UICanvas | component/ui/ui_canvas.h | The root of one screen-space UI tree |
| UIElement | component/ui/ui_element.h | An element's rect - anchor, pivot, position, size - and the resolved screenRect |
| UIImage | component/ui/ui_image.h | Fills its element's rect with a tint, a shape and an optional texture |
| UIText | component/ui/ui_text.h | Text in a named font |
| UIButton | component/ui/ui_button.h | A pressable element: four state colours, a shape, an eventId |
| UIScroll | component/ui/ui_scroll.h | Scrolls its content by offset |
| UISlider | component/ui/ui_slider.h | A value between minValue and maxValue, laid out on its fill and knob entities |
| UIToggle | component/ui/ui_toggle.h | An on/off switch that slides its knob entity |
| UIChoice | component/ui/ui_choice.h | One of its options, stepped by its back and next buttons and shown in its text |
Notes the table cannot hold:
Components carry static helpers where the math belongs to them:
camera.aspect <= 0 (the default) means "track the viewport I render into"; a positive aspect wins over viewportAspect.
For index-based or parallel iteration, take the storage, which is null until some entity has added that type:
Parenting is the Hierarchy component, changed only through HierarchyOperations (Hierarchy). Scene::destroyEntity destroys one entity: its children move up to its parent (or become roots), each keeping its world pose.
Each component type gets a SparseSet<T>: densely packed data, a sparse array from entity slot to dense index, and swap-and-pop removal. The scene keeps its sets in a TypeRegistry indexed by typeId<T>(), so a new component type needs no change to Scene. Entity slots come from a SlotAllocator with a free list. Scene::createEntityAt(slotIndex) exists for the scene loader, which recreates entities at their saved slots so saved references resolve directly.