Monad Engine da02fba2
> Undercity Codex_
Loading...
Searching...
No Matches
Common.h
Go to the documentation of this file.
1#ifndef COMMON_H
2#define COMMON_H
3
4/**
5 * @file Common.h
6 * @ingroup mnd_types
7 * @brief Lightweight data-transfer structs shared across subsystems.
8 *
9 * These plain structs carry per-frame camera and light state from the Scene
10 * to the RenderQueue. They are intentionally value types — no ownership,
11 * no virtual methods — so they can be cheaply copied into the render pass.
12 *
13 * Flow:
14 * 1. Engine::Run() queries the active Scene for the main camera and lights.
15 * 2. The results are packed into CameraData and a vector of LightData.
16 * 3. RenderQueue::Draw() receives them and uploads the data as uniforms to
17 * each ShaderProgram before issuing draw calls.
18 */
19
20#pragma once
21
22#include "Constants.h"
23#include "Types.h"
24
25namespace mnd
26{
27
28/**
29 * @brief Per-frame camera matrices and world-space position.
30 *
31 * Produced by CameraComponent each frame and consumed by RenderQueue::Draw()
32 * to set the view/projection uniforms on every material that is drawn.
33 */
35{
36 mat4 viewMatrix; ///< World → Camera space transform (glm::lookAt result).
37 mat4 projectionMatrix; ///< Camera → Clip space transform (perspective or ortho).
38 vec3 position; ///< Camera world-space position, used for specular calculations.
39 f32 nearPlane = kCameraNearPlane; ///< Frustum near distance — used by post passes for depth linearisation.
41};
42
43/**
44 * @brief World-space position and RGB colour of a single point light.
45 *
46 * Collected by Scene::CollectLight() from all GameObjects that carry a
47 * LightComponent, then forwarded to RenderQueue::Draw() to set light uniforms.
48 */
50{
51 vec3 color; ///< Linear RGB light colour (1,1,1 = white full-intensity).
52 vec3 position; ///< World-space origin of the light source.
53};
54
55} // namespace mnd
56#endif
Engine-wide compile-time tunables and ANSI colour codes.
constexpr mnd::f32 kCameraFarPlane
Definition Constants.h:76
constexpr mnd::f32 kCameraNearPlane
Definition Constants.h:75
Engine-wide primitive type aliases and GLM math imports.
glm::mat4 mat4
4×4 column-major float matrix (model/view/projection).
Definition Types.h:63
glm::vec3 vec3
3-component float vector (e.g. world position, RGB colour, normals).
Definition Types.h:51
float f32
32-bit IEEE float — the standard GL scalar type.
Definition Types.h:40
Per-frame camera matrices and world-space position.
Definition Common.h:35
mat4 projectionMatrix
Camera → Clip space transform (perspective or ortho).
Definition Common.h:37
mat4 viewMatrix
World → Camera space transform (glm::lookAt result).
Definition Common.h:36
vec3 position
Camera world-space position, used for specular calculations.
Definition Common.h:38
f32 nearPlane
Frustum near distance — used by post passes for depth linearisation.
Definition Common.h:39
World-space position and RGB colour of a single point light.
Definition Common.h:50
vec3 color
Linear RGB light colour (1,1,1 = white full-intensity).
Definition Common.h:51
vec3 position
World-space origin of the light source.
Definition Common.h:52