./
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
0 / 38
0.0%
Branches:
0 / 64
0.0%
Functions:
0 / 3
0.0%

libs/render/src/eu/render/debug.cc
Line Branch Exec Source
1 #include "eu/render/debug.h"
2
3 #include "eu/render/camera.h"
4
5 namespace eu::render
6 {
7
8 ✗ void DebugRender::add_line(const v3& from, const v3& to, const Rgb& color)
9 {
10
0/2
✗ Branch 2 → 3 not taken.
✗ Branch 2 → 4 not taken.
✗ lines.emplace_back(DebugLine{from, to, color});
11 ✗ }
12
13 ✗ v3 world_from_ndc(const CompiledCamera& camera, const v3& ndc)
14 {
15
0/2
✗ Branch 2 → 3 not taken.
✗ Branch 2 → 13 not taken.
✗ const auto clip_space_pos = v4{ndc, 1.0f};
16
0/2
✗ Branch 3 → 4 not taken.
✗ Branch 3 → 13 not taken.
✗ const auto view_from_clip = camera.clip_from_view.get_inverted();
17
0/2
✗ Branch 4 → 5 not taken.
✗ Branch 4 → 13 not taken.
✗ const auto view_space_pos = view_from_clip * clip_space_pos;
18
0/2
✗ Branch 5 → 6 not taken.
✗ Branch 5 → 13 not taken.
✗ const auto view_space_pos_corrected = view_space_pos.to_vec3_persp_div();
19
0/2
✗ Branch 6 → 7 not taken.
✗ Branch 6 → 13 not taken.
✗ const auto world_from_view = camera.view_from_world.get_inverted();
20
0/4
✗ Branch 7 → 8 not taken.
✗ Branch 7 → 12 not taken.
✗ Branch 8 → 9 not taken.
✗ Branch 8 → 12 not taken.
✗ const auto world_space_pos = world_from_view * v4{ view_space_pos_corrected, 1.0f };
21 ✗ const auto out_world = v3{world_space_pos.x, world_space_pos.y, world_space_pos.z};
22 ✗ return out_world;
23 }
24
25 ✗ void draw_frustum(DebugRender* debug, const CompiledCamera& camera, const Rgb& color)
26 {
27
0/2
✗ Branch 3 → 4 not taken.
✗ Branch 3 → 35 not taken.
✗ const auto near_bot_left = world_from_ndc(camera, {-1.0f, -1.0f, -1.0f});
28
0/2
✗ Branch 5 → 6 not taken.
✗ Branch 5 → 36 not taken.
✗ const auto near_bot_right = world_from_ndc(camera, {+1.0f, -1.0f, -1.0f});
29
0/2
✗ Branch 7 → 8 not taken.
✗ Branch 7 → 37 not taken.
✗ const auto near_top_left = world_from_ndc(camera, {-1.0f, +1.0f, -1.0f});
30
0/2
✗ Branch 9 → 10 not taken.
✗ Branch 9 → 38 not taken.
✗ const auto near_top_right = world_from_ndc(camera, {+1.0f, +1.0f, -1.0f});
31
0/2
✗ Branch 11 → 12 not taken.
✗ Branch 11 → 39 not taken.
✗ const auto far_bot_left = world_from_ndc(camera, {-1.0f, -1.0f, +1.0f});
32
0/2
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 40 not taken.
✗ const auto far_bot_right = world_from_ndc(camera, {+1.0f, -1.0f, +1.0f});
33
0/2
✗ Branch 15 → 16 not taken.
✗ Branch 15 → 41 not taken.
✗ const auto far_top_left = world_from_ndc(camera, {-1.0f, +1.0f, +1.0f});
34
0/2
✗ Branch 17 → 18 not taken.
✗ Branch 17 → 42 not taken.
✗ const auto far_top_right = world_from_ndc(camera, {+1.0f, +1.0f, +1.0f});
35
36
0/2
✗ Branch 18 → 19 not taken.
✗ Branch 18 → 43 not taken.
✗ debug->add_line(camera.position, near_bot_left, color);
37
0/2
✗ Branch 19 → 20 not taken.
✗ Branch 19 → 43 not taken.
✗ debug->add_line(camera.position, near_top_left, color);
38
0/2
✗ Branch 20 → 21 not taken.
✗ Branch 20 → 43 not taken.
✗ debug->add_line(camera.position, near_bot_right, color);
39
0/2
✗ Branch 21 → 22 not taken.
✗ Branch 21 → 43 not taken.
✗ debug->add_line(camera.position, near_top_right, color);
40
0/2
✗ Branch 22 → 23 not taken.
✗ Branch 22 → 43 not taken.
✗ debug->add_line(near_bot_left, near_bot_right, color);
41
0/2
✗ Branch 23 → 24 not taken.
✗ Branch 23 → 43 not taken.
✗ debug->add_line(near_bot_right, near_top_right, color);
42
0/2
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 43 not taken.
✗ debug->add_line(near_top_right, near_top_left, color);
43
0/2
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 43 not taken.
✗ debug->add_line(near_top_left, near_bot_left, color);
44
0/2
✗ Branch 26 → 27 not taken.
✗ Branch 26 → 43 not taken.
✗ debug->add_line(far_bot_left, far_bot_right, color);
45
0/2
✗ Branch 27 → 28 not taken.
✗ Branch 27 → 43 not taken.
✗ debug->add_line(far_bot_right, far_top_right, color);
46
0/2
✗ Branch 28 → 29 not taken.
✗ Branch 28 → 43 not taken.
✗ debug->add_line(far_top_right, far_top_left, color);
47
0/2
✗ Branch 29 → 30 not taken.
✗ Branch 29 → 43 not taken.
✗ debug->add_line(far_top_left, far_bot_left, color);
48
0/2
✗ Branch 30 → 31 not taken.
✗ Branch 30 → 43 not taken.
✗ debug->add_line(near_bot_left, far_bot_left, color);
49
0/2
✗ Branch 31 → 32 not taken.
✗ Branch 31 → 43 not taken.
✗ debug->add_line(near_bot_right, far_bot_right, color);
50
0/2
✗ Branch 32 → 33 not taken.
✗ Branch 32 → 43 not taken.
✗ debug->add_line(near_top_left, far_top_left, color);
51
0/2
✗ Branch 33 → 34 not taken.
✗ Branch 33 → 43 not taken.
✗ debug->add_line(near_top_right, far_top_right, color);
52 ✗ }
53
54
55 }
56