neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
physics.hpp
Go to the documentation of this file.
1
// physics.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
>
24
#include <
neolib/core/string.hpp
>
25
#include <
neogfx/game/i_component_data.hpp
>
26
27
namespace
neogfx::game
28
{
29
struct
physics
30
{
31
scalar
gravitationalConstant
;
32
std::optional<vec3>
uniformGravity
;
33
34
struct
meta
:
i_component_data::meta
35
{
36
static
const
neolib::uuid
&
id
()
37
{
38
static
const
neolib::uuid
sId = { 0x9798003a, 0x655c, 0x409a, 0xbded, { 0xc1, 0x7f, 0xf5, 0xd3, 0x4c, 0x79 } };
39
return
sId;
40
}
41
static
const
i_string
&
name
()
42
{
43
static
const
string
sName =
"Physics"
;
44
return
sName;
45
}
46
static
uint32_t
field_count
()
47
{
48
return
2;
49
}
50
static
component_data_field_type
field_type
(uint32_t aFieldIndex)
51
{
52
switch
(aFieldIndex)
53
{
54
case
0:
55
return
component_data_field_type::Scalar;
56
case
1:
57
return
component_data_field_type::Vec3 | component_data_field_type::Optional;
58
default
:
59
throw
invalid_field_index
();
60
}
61
}
62
static
const
i_string
&
field_name
(uint32_t aFieldIndex)
63
{
64
static
const
string
sFieldNames[] =
65
{
66
"Gravitational Constant"
,
67
"Uniform Gravity"
68
};
69
return
sFieldNames[aFieldIndex];
70
}
71
};
72
};
73
}
neolib::i_string
Definition
i_string.hpp:49
neogfx::game
Definition
aabb_octree.hpp:31
neolib::ecs::component_data_field_type
component_data_field_type
Definition
i_component_data.hpp:52
neolib::math::scalar
double scalar
Definition
numerical.hpp:63
i_component_data.hpp
neogfx.hpp
string.hpp
neogfx::game::physics::meta
Definition
physics.hpp:35
neogfx::game::physics::meta::field_count
static uint32_t field_count()
Definition
physics.hpp:46
neogfx::game::physics::meta::field_name
static const i_string & field_name(uint32_t aFieldIndex)
Definition
physics.hpp:62
neogfx::game::physics::meta::id
static const neolib::uuid & id()
Definition
physics.hpp:36
neogfx::game::physics::meta::name
static const i_string & name()
Definition
physics.hpp:41
neogfx::game::physics::meta::field_type
static component_data_field_type field_type(uint32_t aFieldIndex)
Definition
physics.hpp:50
neogfx::game::physics
Definition
physics.hpp:30
neogfx::game::physics::uniformGravity
std::optional< vec3 > uniformGravity
Definition
physics.hpp:32
neogfx::game::physics::gravitationalConstant
scalar gravitationalConstant
Definition
physics.hpp:31
neolib::ecs::i_component_data::meta::invalid_field_index
Definition
i_component_data.hpp:134
neolib::ecs::i_component_data::meta
Definition
i_component_data.hpp:133
neolib::uuid
Definition
uuid.hpp:51
uuid.hpp
include
neogfx
game
physics.hpp
Generated by
1.9.8