-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtriangle_intent.h
More file actions
52 lines (45 loc) · 1.72 KB
/
triangle_intent.h
File metadata and controls
52 lines (45 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#pragma once
namespace Game::Render
{
template <typename T>
void triangle_intent([[maybe_unused]] T &syscall, System::ECS::Query<Triangle, IntentHandle> &query)
{
for (auto &[id, comps]: query)
{
const size_t &intent_id = comps.get<IntentHandle>().handle_id;
std::optional<System::Render::DrawIntent> &intent = System::Render::IntentStorage::get_intent(intent_id);
const Triangle &triangle = comps.get<Triangle>();
if (!intent.has_value())
{
intent = System::Render::DrawIntent{};
}
if (!intent.has_value())
{
intent = System::Render::DrawIntent{};
}
switch (intent.value().kind)
{
case System::Render::DrawKind::KIND_UNKNOWN:
intent.value().kind = System::Render::DrawKind::KIND_TRIANGLE;
case System::Render::DrawKind::KIND_TRIANGLE:
break;
default:
return;
}
if (!std::holds_alternative<System::Render::TriangleDrawDesc>(intent.value().special))
{
intent.value().special = System::Render::TriangleDrawDesc{};
}
auto &common = intent.value().common;
common.layer = triangle.layer;
common.order = triangle.order;
auto &[u0, v0, u1, v1, u2, v2] = std::get<System::Render::TriangleDrawDesc>(intent.value().special);
u0 = triangle.points[0].x;
v0 = triangle.points[0].y;
u1 = triangle.points[1].x;
v1 = triangle.points[1].y;
u2 = triangle.points[2].x;
v2 = triangle.points[2].y;
}
}
}