CameraSystem
- Module
- Camera
- Header
#include "Camera/CameraSystem.h"- Namespace
Mowo
Public functions
| Returns | Name | Description |
|---|---|---|
CameraSystem& | Get | |
void | RegisterCamera | |
Entity | GetMainCamera | Get main camera (first camera with isMain=true, or first available) |
void | SetMainCamera | |
void | ReelectMainCamera | Re-evaluate isMain flags over the registered list (cheap — does not scan the world). |
void | SetCinematicOverride | |
void | ClearCinematicOverride | |
bool | HasCinematicOverride | |
void | SetViewTarget | View-target handover with a timed blend (the PlayerCameraManager essential): the current evaluated view is captured as the FROM pose and eased (smoothstep) into the new target's LIVE pose over blendTimeSeconds. |
bool | IsViewBlending | |
void | PushViewTarget | View-target STACK on top of SetViewTarget — the cutscene/kill-cam shape: Push hands authority to target remembering who had it, Pop blends back to the remembered holder (or the elected main camera when the stack empties / the remembered entity died with its world). |
void | PopViewTarget | |
size_t | GetViewTargetStackDepth | |
void | AddModifier | Camera modifiers — view mutators applied AFTER the blend on every main-view evaluation. |
void | ClearModifiers | |
size_t | GetModifierCount | |
const std::vector<Entity>& | GetAllCameras | |
void | UpdateAspectRatios | Update camera aspect ratios (call when window resizes) |
bool | GetMainCameraMatrices | |
bool | GetMainSceneRendererCamera | |
bool | BuildSceneRendererCamera | Build a SceneRendererCamera for an arbitrary camera entity. |
std::vector<Entity> | GetCamerasSortedByRenderOrder | List of camera entities sorted by CameraComponent::renderOrder (ascending — earlier renderOrder is drawn first, later ones can overdraw for PiP). |
Entity | GetCameraAtViewportPosition | Find best camera for viewport position (for multi-camera setups) |
void | Clear | Clear all registrations (e.g., on scene load) |
void | ClearWorld | Drop every registration that belongs to world. |
Function details
Get
static CameraSystem& Get()RegisterCamera
void RegisterCamera(Entity entity)GetMainCamera
Entity GetMainCamera() constGet main camera (first camera with isMain=true, or first available)
SetMainCamera
void SetMainCamera(Entity entity)ReelectMainCamera
void ReelectMainCamera()Re-evaluate isMain flags over the registered list (cheap — does not scan the world). Lets callers cache the registration pass while still honoring runtime isMain flips.
SetCinematicOverride
void SetCinematicOverride(Entity entity)ClearCinematicOverride
void ClearCinematicOverride()HasCinematicOverride
bool HasCinematicOverride() constSetViewTarget
void SetViewTarget(Entity target, float blendTimeSeconds = 0.0f)View-target handover with a timed blend (the PlayerCameraManager essential): the current evaluated view is captured as the FROM pose and eased (smoothstep) into the new target's LIVE pose over blendTimeSeconds. blendTime <= 0 cuts instantly. An invalid target hands authority back to the elected main camera (with the same blend). Retargeting mid-blend re-captures the blended pose, so chained cuts stay continuous. Time source is the real-time clock — a paused game can still blend its cameras.
IsViewBlending
bool IsViewBlending() constPushViewTarget
void PushViewTarget(Entity target, float blendTimeSeconds = 0.0f)View-target STACK on top of SetViewTarget — the cutscene/kill-cam shape: Push hands authority to target remembering who had it, Pop blends back to the remembered holder (or the elected main camera when the stack empties / the remembered entity died with its world). The stack stores TARGETS, not poses — a popped camera re-evaluates live, so it may have moved while covered.
PopViewTarget
void PopViewTarget(float blendTimeSeconds = 0.0f)GetViewTargetStackDepth
size_t GetViewTargetStackDepth() constAddModifier
void AddModifier(std::shared_ptr<ICameraModifier> modifier)Camera modifiers — view mutators applied AFTER the blend on every main-view evaluation. A modifier returning false is removed, so one-shots (FCameraShake) clean themselves up.
ClearModifiers
void ClearModifiers()GetModifierCount
size_t GetModifierCount() constGetAllCameras
const std::vector<Entity>& GetAllCameras() constUpdateAspectRatios
void UpdateAspectRatios(float screenWidth, float screenHeight)Update camera aspect ratios (call when window resizes)
GetMainCameraMatrices
bool GetMainCameraMatrices(Mat4& outView, Mat4& outProj, Vec3& outPos, Vec3& outForward, Vec3& outUp)GetMainSceneRendererCamera
bool GetMainSceneRendererCamera(SceneRendererCamera& out, float aspectRatio)BuildSceneRendererCamera
bool BuildSceneRendererCamera(Entity camEntity, float aspectRatio, SceneRendererCamera& out)Build a SceneRendererCamera for an arbitrary camera entity. Used by multi-camera setups that iterate every registered camera and render each into its assigned viewport. Returns false if the entity is invalid or lacks Camera + Transform components.
GetCamerasSortedByRenderOrder
std::vector<Entity> GetCamerasSortedByRenderOrder() constList of camera entities sorted by CameraComponent::renderOrder (ascending — earlier renderOrder is drawn first, later ones can overdraw for PiP). Skips cameras whose component is disabled.
GetCameraAtViewportPosition
Entity GetCameraAtViewportPosition(float x, float y) constFind best camera for viewport position (for multi-camera setups)
Clear
void Clear()Clear all registrations (e.g., on scene load)
ClearWorld
void ClearWorld(World* world)Drop every registration that belongs to world. A registered Entity holds a raw World*, so the registry MUST be purged before the world it points at is destroyed — a scene unload, map travel or editor shutdown otherwise leaves handles that read freed memory on the next lookup.