neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
box_collider.hpp
Go to the documentation of this file.
1// box_collider.hpp
2/*
3 neogfx C++ App/Game Engine
4 Copyright (c) 2018, 2020 Leigh Johnston. All Rights Reserved.
5
6 This program is free software: you can redistribute it and / or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#pragma once
21
22#include <neogfx/neogfx.hpp>
23#include <neolib/core/uuid.hpp>
26
27namespace neogfx::game
28{
30 {
31 uint64_t mask;
32 std::optional<aabb> untransformedAabb;
33 std::optional<aabb> previousAabb;
34 std::optional<aabb> currentAabb;
36
38 {
39 static const neolib::uuid& id()
40 {
41 static const neolib::uuid sId = { 0x55468971, 0xb33e, 0x4e54, 0xa563, { 0xb8, 0x98, 0x3f, 0x22, 0xa, 0xfc } };
42 return sId;
43 }
44 static const i_string& name()
45 {
46 static const string sName = "Box Collider";
47 return sName;
48 }
49 static uint32_t field_count()
50 {
51 return 5;
52 }
53 static component_data_field_type field_type(uint32_t aFieldIndex)
54 {
55 switch (aFieldIndex)
56 {
57 case 0:
58 return component_data_field_type::Uint64;
59 case 1:
60 case 2:
61 case 3:
62 return component_data_field_type::Aabb | component_data_field_type::Optional | component_data_field_type::Internal;
63 case 4:
64 return component_data_field_type::Uint32 | component_data_field_type::Internal;
65 default:
66 throw invalid_field_index();
67 }
68 }
69 static const i_string& field_name(uint32_t aFieldIndex)
70 {
71 static const string sFieldNames[] =
72 {
73 "Mask",
74 "AABB (Untransformed)",
75 "AABB (Previous)",
76 "AABB (Current)",
77 "Collision Event Id"
78 };
79 return sFieldNames[aFieldIndex];
80 }
81 };
82 };
83
85 {
86 uint64_t mask;
87 std::optional<aabb_2d> untransformedAabb;
88 std::optional<aabb_2d> previousAabb;
89 std::optional<aabb_2d> currentAabb;
91
93 {
94 static const neolib::uuid& id()
95 {
96 static const neolib::uuid sId = { 0xc3dcb106, 0xc862, 0x42a7, 0xa07b, { 0x90, 0x7f, 0x7e, 0x47, 0x17, 0x2a } };
97 return sId;
98 }
99 static const i_string& name()
100 {
101 static const string sName = "Box Collider (2D)";
102 return sName;
103 }
104 static uint32_t field_count()
105 {
106 return 5;
107 }
108 static component_data_field_type field_type(uint32_t aFieldIndex)
109 {
110 switch (aFieldIndex)
111 {
112 case 0:
113 return component_data_field_type::Uint64;
114 case 1:
115 case 2:
116 case 3:
117 return component_data_field_type::Aabb2d | component_data_field_type::Optional | component_data_field_type::Internal;
118 case 4:
119 return component_data_field_type::Uint32 | component_data_field_type::Internal;
120 default:
121 throw invalid_field_index();
122 }
123 }
124 static const i_string& field_name(uint32_t aFieldIndex)
125 {
126 static const string sFieldNames[] =
127 {
128 "Mask",
129 "AABB (Untransformed)",
130 "AABB (Previous)",
131 "AABB (Current)",
132 "Collision Event Id"
133 };
134 return sFieldNames[aFieldIndex];
135 }
136 };
137 };
138}
static const i_string & field_name(uint32_t aFieldIndex)
static const i_string & name()
static const neolib::uuid & id()
static component_data_field_type field_type(uint32_t aFieldIndex)
static const neolib::uuid & id()
static const i_string & name()
static component_data_field_type field_type(uint32_t aFieldIndex)
static const i_string & field_name(uint32_t aFieldIndex)
std::optional< aabb_2d > previousAabb
std::optional< aabb_2d > currentAabb
std::optional< aabb_2d > untransformedAabb
std::optional< aabb > previousAabb
std::optional< aabb > untransformedAabb
std::optional< aabb > currentAabb