GCC Code Coverage Report


./
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
0 of 38, 0 excluded
0.0%
Functions:
0 of 3, 0 excluded
0.0%
Branches:
0 of 64, 0 excluded
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 ✗ lines.emplace_back(DebugLine{from, to, color});
11 ✗ }
12
13 ✗ v3 world_from_ndc(const CompiledCamera& camera, const v3& ndc)
14 {
15 ✗ const auto clip_space_pos = v4{ndc, 1.0f};
16 ✗ const auto view_from_clip = camera.clip_from_view.get_inverted();
17 ✗ const auto view_space_pos = view_from_clip * clip_space_pos;
18 ✗ const auto view_space_pos_corrected = view_space_pos.to_vec3_persp_div();
19 ✗ const auto world_from_view = camera.view_from_world.get_inverted();
20 ✗ 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 ✗ const auto near_bot_left = world_from_ndc(camera, {-1.0f, -1.0f, -1.0f});
28 ✗ const auto near_bot_right = world_from_ndc(camera, {+1.0f, -1.0f, -1.0f});
29 ✗ const auto near_top_left = world_from_ndc(camera, {-1.0f, +1.0f, -1.0f});
30 ✗ const auto near_top_right = world_from_ndc(camera, {+1.0f, +1.0f, -1.0f});
31 ✗ const auto far_bot_left = world_from_ndc(camera, {-1.0f, -1.0f, +1.0f});
32 ✗ const auto far_bot_right = world_from_ndc(camera, {+1.0f, -1.0f, +1.0f});
33 ✗ const auto far_top_left = world_from_ndc(camera, {-1.0f, +1.0f, +1.0f});
34 ✗ const auto far_top_right = world_from_ndc(camera, {+1.0f, +1.0f, +1.0f});
35
36 ✗ debug->add_line(camera.position, near_bot_left, color);
37 ✗ debug->add_line(camera.position, near_top_left, color);
38 ✗ debug->add_line(camera.position, near_bot_right, color);
39 ✗ debug->add_line(camera.position, near_top_right, color);
40 ✗ debug->add_line(near_bot_left, near_bot_right, color);
41 ✗ debug->add_line(near_bot_right, near_top_right, color);
42 ✗ debug->add_line(near_top_right, near_top_left, color);
43 ✗ debug->add_line(near_top_left, near_bot_left, color);
44 ✗ debug->add_line(far_bot_left, far_bot_right, color);
45 ✗ debug->add_line(far_bot_right, far_top_right, color);
46 ✗ debug->add_line(far_top_right, far_top_left, color);
47 ✗ debug->add_line(far_top_left, far_bot_left, color);
48 ✗ debug->add_line(near_bot_left, far_bot_left, color);
49 ✗ debug->add_line(near_bot_right, far_bot_right, color);
50 ✗ debug->add_line(near_top_left, far_top_left, color);
51 ✗ debug->add_line(near_top_right, far_top_right, color);
52 ✗ }
53
54
55 }
56