1 /********************************************************************************
2 * ReactPhysics3D physics library, http://www.reactphysics3d.com                 *
3 * Copyright (c) 2010-2020 Daniel Chappuis                                       *
4 *********************************************************************************
5 *                                                                               *
6 * This software is provided 'as-is', without any express or implied warranty.   *
7 * In no event will the authors be held liable for any damages arising from the  *
8 * use of this software.                                                         *
9 *                                                                               *
10 * Permission is granted to anyone to use this software for any purpose,         *
11 * including commercial applications, and to alter it and redistribute it        *
12 * freely, subject to the following restrictions:                                *
13 *                                                                               *
14 * 1. The origin of this software must not be misrepresented; you must not claim *
15 *    that you wrote the original software. If you use this software in a        *
16 *    product, an acknowledgment in the product documentation would be           *
17 *    appreciated but is not required.                                           *
18 *                                                                               *
19 * 2. Altered source versions must be plainly marked as such, and must not be    *
20 *    misrepresented as being the original software.                             *
21 *                                                                               *
22 * 3. This notice may not be removed or altered from any source distribution.    *
23 *                                                                               *
24 ********************************************************************************/
25 
26 #ifndef REACTPHYSICS3D_CONFIGURATION_H
27 #define	REACTPHYSICS3D_CONFIGURATION_H
28 
29 // Libraries
30 #include <limits>
31 #include <cfloat>
32 #include <utility>
33 #include <sstream>
34 #include <string>
35 #include <reactphysics3d/decimal.h>
36 #include <reactphysics3d/containers/Pair.h>
37 
38 // Windows platform
39 #if defined(WIN32) ||defined(_WIN32) || defined(_WIN64) ||defined(__WIN32__) || defined(__WINDOWS__)
40     #define WINDOWS_OS
41 #elif defined(__APPLE__)     // Apple platform
42     #define APPLE_OS
43 #elif defined(__linux__) || defined(linux) || defined(__linux)    // Linux platform
44     #define LINUX_OS
45 #endif
46 
47 /// Namespace reactphysics3d
48 namespace reactphysics3d {
49 
50 // ------------------- Type definitions ------------------- //
51 
52 using uint = unsigned int;
53 using uchar = unsigned char;
54 using ushort = unsigned short;
55 using luint = long unsigned int;
56 
57 using int8 = std::int8_t;
58 using uint8 = std::uint8_t;
59 using int16 = std::int16_t;
60 using uint16 = std::uint16_t;
61 using int32 = std::int32_t;
62 using uint32 = std::uint32_t;
63 using int64 = std::int64_t;
64 using uint64 = std::uint64_t;
65 
66 struct Entity;
67 using bodypair = Pair<Entity, Entity>;
68 
69 // ------------------- Enumerations ------------------- //
70 
71 /// Position correction technique used in the constraint solver (for joints).
72 /// BAUMGARTE_JOINTS : Faster but can be innacurate in some situations.
73 /// NON_LINEAR_GAUSS_SEIDEL : Slower but more precise. This is the option used by default.
74 enum class JointsPositionCorrectionTechnique {BAUMGARTE_JOINTS, NON_LINEAR_GAUSS_SEIDEL};
75 
76 /// Position correction technique used in the contact solver (for contacts)
77 /// BAUMGARTE_CONTACTS : Faster but can be innacurate and can lead to unexpected bounciness
78 ///                      in some situations (due to error correction factor being added to
79 ///                      the bodies momentum).
80 /// SPLIT_IMPULSES : A bit slower but the error correction factor is not added to the
81 ///                 bodies momentum. This is the option used by default.
82 enum class ContactsPositionCorrectionTechnique {BAUMGARTE_CONTACTS, SPLIT_IMPULSES};
83 
84 // ------------------- Constants ------------------- //
85 
86 /// Smallest decimal value (negative)
87 const decimal DECIMAL_SMALLEST = - std::numeric_limits<decimal>::max();
88 
89 /// Maximum decimal value
90 const decimal DECIMAL_LARGEST = std::numeric_limits<decimal>::max();
91 
92 /// Machine epsilon
93 const decimal MACHINE_EPSILON = std::numeric_limits<decimal>::epsilon();
94 
95 /// Pi constant
96 constexpr decimal PI = decimal(3.14159265);
97 
98 /// 2*Pi constant
99 constexpr decimal PI_TIMES_2 = decimal(6.28318530);
100 
101 /// In the broad-phase collision detection (dynamic AABB tree), the AABBs are
102 /// inflated by a constant percentage of its size to allow the collision shape to move a little bit
103 /// without triggering a large modification of the tree each frame which can be costly
104 constexpr decimal DYNAMIC_TREE_FAT_AABB_INFLATE_PERCENTAGE = decimal(0.08);
105 
106 /// Current version of ReactPhysics3D
107 const std::string RP3D_VERSION = std::string("0.8.0");
108 
109 }
110 
111 #endif
112