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>
26
27namespace neogfx::game
28{
29 struct physics
30 {
32 std::optional<vec3> uniformGravity;
33
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}
double scalar
Definition numerical.hpp:63
static uint32_t field_count()
Definition physics.hpp:46
static const i_string & field_name(uint32_t aFieldIndex)
Definition physics.hpp:62
static const neolib::uuid & id()
Definition physics.hpp:36
static const i_string & name()
Definition physics.hpp:41
static component_data_field_type field_type(uint32_t aFieldIndex)
Definition physics.hpp:50
std::optional< vec3 > uniformGravity
Definition physics.hpp:32
scalar gravitationalConstant
Definition physics.hpp:31