Camera System
SafiCamera is an ECS component that describes a viewpoint. Attach it to an entity (alongside SafiTransform) and tag exactly one such entity with SafiActiveCamera — the engine's render system picks that viewpoint up automatically.
Struct
The render system builds view from eye / forward / up every frame. If eye is all-zero (the default for a freshly-created component), it falls back to the legacy eye = target + (0,0,3) convention so code that only sets target keeps working.
Active camera
Attach SafiActiveCamera to exactly one entity that also has SafiCamera. The render system queries (SafiCamera, SafiActiveCamera) and uses the first match. Swapping cameras = moving the tag. The editor camera uses this tag to take over the view in Edit mode and restore the gameplay camera on Play.
Creating a camera
Or, for a "look at a point" style:
Helpers
safi/render/camera.h exposes two helpers that any system (picking, gizmos, screen-space tools) can share:
These reuse exactly the pose logic the render system applies, so "what the user sees" and "what a raycast hits" can never drift out of sync.
Serialization
SafiCamera serialises with the full pose (target, eye, forward, up). Scene files written before the pose fields existed still load — the deserializer synthesises eye / forward / up from the old target-only convention. See Scene Serialization.
See also
- Camera Math —
safi_camera_screen_rayand friends - Editor Camera — Edit-mode fly-cam that writes the pose
- Transform
- Render Overview