ShapeConf.hpp
Go to the documentation of this file.
1 /*
2  * Original work Copyright (c) 2006-2009 Erin Catto http://www.box2d.org
3  * Modified work Copyright (c) 2017 Louis Langholtz https://github.com/louis-langholtz/PlayRho
4  *
5  * This software is provided 'as-is', without any express or implied
6  * warranty. In no event will the authors be held liable for any damages
7  * arising from the use of this software.
8  *
9  * Permission is granted to anyone to use this software for any purpose,
10  * including commercial applications, and to alter it and redistribute it
11  * freely, subject to the following restrictions:
12  *
13  * 1. The origin of this software must not be misrepresented; you must not
14  * claim that you wrote the original software. If you use this software
15  * in a product, an acknowledgment in the product documentation would be
16  * appreciated but is not required.
17  * 2. Altered source versions must be plainly marked as such, and must not be
18  * misrepresented as being the original software.
19  * 3. This notice may not be removed or altered from any source distribution.
20  */
21 
22 #ifndef PLAYRHO_COLLISION_SHAPES_SHAPECONF_HPP
23 #define PLAYRHO_COLLISION_SHAPES_SHAPECONF_HPP
24 
25 #include <PlayRho/Common/Units.hpp>
28 
29 namespace playrho {
30 namespace d2 {
31 
35 {
45 
52 
59 };
60 
68 template <typename ConcreteConf>
70 {
71  // Note: don't use 'using ShapeConf::ShapeConf' here as it doesn't work in this context!
72 
74  PLAYRHO_CONSTEXPR inline ShapeBuilder() = default;
75 
77  PLAYRHO_CONSTEXPR inline explicit ShapeBuilder(const BaseShapeConf& value) noexcept:
78  BaseShapeConf{value}
79  {
80  // Intentionally empty.
81  }
82 
84  PLAYRHO_CONSTEXPR inline ConcreteConf& UseFriction(NonNegative<Real> value) noexcept;
85 
87  PLAYRHO_CONSTEXPR inline ConcreteConf& UseRestitution(Finite<Real> value) noexcept;
88 
90  PLAYRHO_CONSTEXPR inline ConcreteConf& UseDensity(NonNegative<AreaDensity> value) noexcept;
91 };
92 
93 template <typename ConcreteConf>
94 PLAYRHO_CONSTEXPR inline ConcreteConf&
96 {
97  friction = value;
98  return static_cast<ConcreteConf&>(*this);
99 }
100 
101 template <typename ConcreteConf>
102 PLAYRHO_CONSTEXPR inline ConcreteConf&
104 {
105  restitution = value;
106  return static_cast<ConcreteConf&>(*this);
107 }
108 
109 template <typename ConcreteConf>
110 PLAYRHO_CONSTEXPR inline ConcreteConf&
112 {
113  density = value;
114  return static_cast<ConcreteConf&>(*this);
115 }
116 
118 struct ShapeConf: public ShapeBuilder<ShapeConf>
119 {
121 };
122 
123 // Free functions...
124 
127 {
128  return arg.density;
129 }
130 
133 {
134  return arg.restitution;
135 }
136 
139 {
140  return arg.friction;
141 }
142 
143 } // namespace d2
144 } // namespace playrho
145 
146 #endif // PLAYRHO_COLLISION_SHAPES_SHAPECONF_HPP