![]() |
vkmEngine 1.0.15
A C++ game engine · vkmengine.com
|
Where a change belongs, what shape it takes, and what "finished" means. engine.md says what you are building and inside which limits; the bar for the code itself is implementation.md.
Before writing anything new, find the closest sibling and match it.
A new thing that cannot take its siblings' shape usually means the pattern was misread; a genuinely new kind of problem is rare.
A system that writes a pointer onto FrameContext owes it on every return path: clear the buffer at the top of update, then work (system/visibility/visibility_system.cpp). Bailing out without publishing leaves consumers last frame's answer.
A shape is right because of what the engine is, never because of who uses it (engine.md, "The engine and its users"). A game's need is a requirement the engine meets with a feature of its own; once met, the game uses that feature and keeps no copy of it. A second way kept for a game, an example or an old file is two designs, and the engine pays for both; a change carries its users with it (implementation.md).
If most of what you need exists, extend it. The reusable machinery: HierarchyOperations, the resource/generate/ helpers, SparseSet<T>, SlotAllocator, TypeRegistry<Base> (one slot per type), parallelFor() (platform/threading/thread_pool.h), the field reflection in core/reflect.h, and the event bus on ctx.events.
The directory tree encodes responsibility. Let it place your code:
| If the code is... | It belongs in... |
|---|---|
| Per-frame behavior over the scene | src/engine/system/<name>/ |
| Pure data attached to an entity | src/engine/ecs/component/<subject>/ |
| An operation on the entity graph many systems share (the hierarchy) | src/engine/ecs/ |
| A new asset kind - the Resource subclass | src/engine/resource/asset/ |
| Low-level container / handle / type machinery | src/engine/core/memory/ |
| Window, input, threading, dynamic library | src/engine/platform/<area>/ |
| Profiling and error-reporting facades | src/engine/debug/ |
| Scene / asset / component (de)serialization | src/engine/io/ |
| What goes on the wire, or who decides what | src/engine/net/ - not a system; see engine.md |
| GPU-specific work | src/backend/opengl/ |
| A shader | shaders/<pass>/ |
| Editor-only UI or interaction | src/editor/ - read 2.5 first |
| Importing an asset from its source art (cook-only) | src/tools/import/ |
| Loading what the runtime reads, or generating an asset | src/tools/loader/ or src/engine/resource/generate/ |
| Baking an asset into the form the runtime reads | src/tools/cook/ |
| Registering a system | app/engine_app.h |
| The prologue every host runs - root, log, module, the project's world | src/tools/project_boot.h |
| Gameplay | examples/<project>/src/ - never in the engine |
| A test of engine code | tests/<area>/<suite>_tests.cpp, the area named for the source folder it tests; tests/render/ is the GPU binary |
NetSession is owned by Engine and brackets the frame: a change about when the wire is read or written belongs in Engine::run, and a system asking who decides an entity calls ctx.net.simulates(ctx.scene, entity).
A new system comes alive at one addSystem<T>(stage) line in setupEngineApp (app/engine_app.h), its stage argued beside it. If code fits nowhere obvious, the design is off.
How a folder grows. A folder's root holds its entry point and what every part of it shares; a feature gets a subfolder named for it (system/physics/, net/) only when the folder needs one - more than a screenful of files, or two features someone would look for by name. Many members of one kind, named for that kind (pass/gl_*_pass, panels/*_panel), stay flat: the name pattern is the index. Nothing is named common, misc, utils or helpers: shared code sits at the root of the narrowest folder that shares it. Tests follow the source.
A one-line method on an existing class beats a new helper file; a new enum value beats a parallel type.
But it is the smallest change that does not add the fifth case (review.md). About to add a field, flag or branch beside three that arrived the same way, name and cost the change that removes the reason for cases; deciding to make it is the owner's (README.md).
Any plain struct is a component: scene.add<T>(e, ...). Surviving a save is a separate step, and skipping it fails silently - the component works all session and is absent next load.
Where a component needs more than the driver, see ../reference/io.md.
Replicating is a fourth step and fails the same silent way: netEncode / netDecode beside it, registered from the project's vkmSetupNetwork (networking.md). Replicate a cause only the authority knows, not an effect every end recomputes - an effect on the wire is a second writer.
Authoring is separate again. The inspector card, the Create-menu entry and the hierarchy badge are hand-written in src/editor/, and the component must be in VKM_EDITOR_COMPONENTS (editor/command/editor_commands.h) or undo cannot restore it and the inspector cannot edit it undoably (../reference/editor.md).
The compiler enforces none of these:
Passes are a backend detail and stay in src/backend/opengl/ (engine.md):
A new shader folder uses the loader's filenames (building.md). Check engine.md's rejected list before adding an effect.
Deliberation scales with what a decision carries; the quality bar does not. Ask of a small thing "what happens to everything else if this is wrong?" Anything naming a format, an order, a lifetime or an identity becomes a seam whether you meant it to or not, and gets the full argument now.
A change is rarely one file. Follow it outward:
It builds clean, with zero first-party warnings, and the suites pass - ctest --test-dir build, every suite (../reference/building.md). A bug fix comes with a test you have seen fail without the fix.
You used it - ran it and watched it work. Press Play, Pause, Stop; open the panel; load the scene and save it; look at the frame. Without a window, read the runtime's exit code (../reference/building.md). A visible result you have not looked at is not finished; if you could not look, say so.
A performance change carries its measurement, before and after, on the scenes it touches (building.md).
Docs ship with it. A stale reference page is believed.
It is committed in verified batches - one coherent change per commit, built and checked.
The message says why, briefly. Lowercase type(scope): summary under 72 characters, then a few lines of prose at about 80 columns: what the change does as a whole, and why - not a tour of what it touched. A commit that folds others in sums up its subject; it does not list what was folded. No line-initial - , no Co-Authored-By, no self-attribution trailer.
A change is finished when a reader cannot tell which lines are new from the style alone, only from the feature they add.