Antkeeper  0.0.1
collider-material.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Christopher J. Howard
3  *
4  * This file is part of Antkeeper source code.
5  *
6  * Antkeeper source code 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  * Antkeeper source code 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 Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef ANTKEEPER_PHYSICS_COLLIDER_MATERIAL_HPP
21 #define ANTKEEPER_PHYSICS_COLLIDER_MATERIAL_HPP
22 
25 
26 namespace physics {
27 
32 {
33 public:
42  inline constexpr collider_material(float restitution, float static_friction, float dynamic_friction) noexcept:
43  m_restitution{restitution},
44  m_static_friction{static_friction},
45  m_dynamic_friction{dynamic_friction}
46  {}
47  constexpr collider_material() noexcept = default;
49 
55  inline constexpr void set_restitution(float restitution) noexcept
56  {
57  m_restitution = restitution;
58  }
59 
65  inline constexpr void set_static_friction(float friction) noexcept
66  {
67  m_static_friction = friction;
68  }
69 
75  inline constexpr void set_dynamic_friction(float friction) noexcept
76  {
77  m_dynamic_friction = friction;
78  }
79 
85  inline constexpr void set_restitution_combine_mode(restitution_combine_mode mode) noexcept
86  {
87  m_restitution_combine_mode = mode;
88  }
89 
95  inline constexpr void set_friction_combine_mode(friction_combine_mode mode) noexcept
96  {
97  m_friction_combine_mode = mode;
98  }
99 
105  inline constexpr void set_density(float density) noexcept
106  {
107  m_density = density;
108  }
109 
111  [[nodiscard]] inline constexpr float get_restitution() const noexcept
112  {
113  return m_restitution;
114  }
115 
117  [[nodiscard]] inline constexpr float get_static_friction() const noexcept
118  {
119  return m_static_friction;
120  }
121 
123  [[nodiscard]] inline constexpr float get_dynamic_friction() const noexcept
124  {
125  return m_dynamic_friction;
126  }
127 
129  [[nodiscard]] inline constexpr restitution_combine_mode get_restitution_combine_mode() const noexcept
130  {
131  return m_restitution_combine_mode;
132  }
133 
135  [[nodiscard]] inline constexpr friction_combine_mode get_friction_combine_mode() const noexcept
136  {
137  return m_friction_combine_mode;
138  }
139 
141  [[nodiscard]] inline constexpr float get_density() const noexcept
142  {
143  return m_density;
144  }
145 
146 private:
148  float m_restitution{};
149 
151  float m_static_friction{};
152 
154  float m_dynamic_friction{};
155 
158 
160  friction_combine_mode m_friction_combine_mode{friction_combine_mode::average};
161 
163  float m_density{1.0f};
164 };
165 
166 } // namespace physics
167 
168 #endif // ANTKEEPER_PHYSICS_COLLIDER_MATERIAL_HPP
Describes the collision response of a collider.
constexpr void set_restitution_combine_mode(restitution_combine_mode mode) noexcept
Sets the restitution combine mode of the material.
constexpr void set_dynamic_friction(float friction) noexcept
Sets the dynamic friction of the material.
constexpr float get_dynamic_friction() const noexcept
Returns the dynamic friction of the material.
constexpr restitution_combine_mode get_restitution_combine_mode() const noexcept
Returns the restitution combine mode.
constexpr collider_material() noexcept=default
Constructs a collider material.
constexpr void set_static_friction(float friction) noexcept
Sets the static friction of the material.
constexpr void set_density(float density) noexcept
Sets the density of the material.
constexpr friction_combine_mode get_friction_combine_mode() const noexcept
Returns the friction combine mode.
constexpr collider_material(float restitution, float static_friction, float dynamic_friction) noexcept
Constructs a collider material.
constexpr void set_restitution(float restitution) noexcept
Sets the of restitution of the material.
constexpr float get_restitution() const noexcept
Returns the restitution of the material.
constexpr float get_static_friction() const noexcept
Returns the static friction of the material.
constexpr float get_density() const noexcept
Returns the density of the material.
constexpr void set_friction_combine_mode(friction_combine_mode mode) noexcept
Sets the friction combine mode of the material.
Physics.
Definition: constants.hpp:23
restitution_combine_mode
Specifies how coefficients of restitution should be calculated.
Definition: restitution.hpp:33
@ average
Coefficient of restitution is calculated as (a + b) / 2.
friction_combine_mode
Specifies how coefficients of friction should be calculated.
Definition: friction.hpp:33
@ average
Coefficient of friction is calculated as (a + b) / 2.