File indexing completed on 2024-05-19 14:56:23
0001 /* 0002 * Copyright (c) 2006-2009 Erin Catto http://www.box2d.org 0003 * 0004 * This software is provided 'as-is', without any express or implied 0005 * warranty. In no event will the authors be held liable for any damages 0006 * arising from the use of this software. 0007 * Permission is granted to anyone to use this software for any purpose, 0008 * including commercial applications, and to alter it and redistribute it 0009 * freely, subject to the following restrictions: 0010 * 1. The origin of this software must not be misrepresented; you must not 0011 * claim that you wrote the original software. If you use this software 0012 * in a product, an acknowledgment in the product documentation would be 0013 * appreciated but is not required. 0014 * 2. Altered source versions must be plainly marked as such, and must not be 0015 * misrepresented as being the original software. 0016 * 3. This notice may not be removed or altered from any source distribution. 0017 */ 0018 0019 #ifndef B2_SETTINGS_H 0020 #define B2_SETTINGS_H 0021 0022 #include <stddef.h> 0023 #include <assert.h> 0024 #include <float.h> 0025 0026 #define B2_NOT_USED(x) ((void)(x)) 0027 #define b2Assert(A) assert(A) 0028 0029 typedef signed char int8; 0030 typedef signed short int16; 0031 typedef signed int int32; 0032 typedef unsigned char uint8; 0033 typedef unsigned short uint16; 0034 typedef unsigned int uint32; 0035 typedef float float32; 0036 typedef double float64; 0037 0038 #define b2_maxFloat FLT_MAX 0039 #define b2_epsilon FLT_EPSILON 0040 #define b2_pi 3.14159265359f 0041 0042 /// @file 0043 /// Global tuning constants based on meters-kilograms-seconds (MKS) units. 0044 /// 0045 0046 // Collision 0047 0048 /// The maximum number of contact points between two convex shapes. Do 0049 /// not change this value. 0050 #define b2_maxManifoldPoints 2 0051 0052 /// The maximum number of vertices on a convex polygon. You cannot increase 0053 /// this too much because b2BlockAllocator has a maximum object size. 0054 #define b2_maxPolygonVertices 8 0055 0056 /// This is used to fatten AABBs in the dynamic tree. This allows proxies 0057 /// to move by a small amount without triggering a tree adjustment. 0058 /// This is in meters. 0059 #define b2_aabbExtension 0.1f 0060 0061 /// This is used to fatten AABBs in the dynamic tree. This is used to predict 0062 /// the future position based on the current displacement. 0063 /// This is a dimensionless multiplier. 0064 #define b2_aabbMultiplier 2.0f 0065 0066 /// A small length used as a collision and constraint tolerance. Usually it is 0067 /// chosen to be numerically significant, but visually insignificant. 0068 #define b2_linearSlop 0.005f 0069 0070 /// A small angle used as a collision and constraint tolerance. Usually it is 0071 /// chosen to be numerically significant, but visually insignificant. 0072 #define b2_angularSlop (2.0f / 180.0f * b2_pi) 0073 0074 /// The radius of the polygon/edge shape skin. This should not be modified. Making 0075 /// this smaller means polygons will have an insufficient buffer for continuous collision. 0076 /// Making it larger may create artifacts for vertex collision. 0077 #define b2_polygonRadius (2.0f * b2_linearSlop) 0078 0079 /// Maximum number of sub-steps per contact in continuous physics simulation. 0080 #define b2_maxSubSteps 8 0081 0082 0083 // Dynamics 0084 0085 /// Maximum number of contacts to be handled to solve a TOI impact. 0086 #define b2_maxTOIContacts 32 0087 0088 /// A velocity threshold for elastic collisions. Any collision with a relative linear 0089 /// velocity below this threshold will be treated as inelastic. 0090 #define b2_velocityThreshold 1.0f 0091 0092 /// The maximum linear position correction used when solving constraints. This helps to 0093 /// prevent overshoot. 0094 #define b2_maxLinearCorrection 0.2f 0095 0096 /// The maximum angular position correction used when solving constraints. This helps to 0097 /// prevent overshoot. 0098 #define b2_maxAngularCorrection (8.0f / 180.0f * b2_pi) 0099 0100 /// The maximum linear velocity of a body. This limit is very large and is used 0101 /// to prevent numerical problems. You shouldn't need to adjust this. 0102 #define b2_maxTranslation 2.0f 0103 #define b2_maxTranslationSquared (b2_maxTranslation * b2_maxTranslation) 0104 0105 /// The maximum angular velocity of a body. This limit is very large and is used 0106 /// to prevent numerical problems. You shouldn't need to adjust this. 0107 #define b2_maxRotation (0.5f * b2_pi) 0108 #define b2_maxRotationSquared (b2_maxRotation * b2_maxRotation) 0109 0110 /// This scale factor controls how fast overlap is resolved. Ideally this would be 1 so 0111 /// that overlap is removed in one time step. However using values close to 1 often lead 0112 /// to overshoot. 0113 #define b2_baumgarte 0.2f 0114 #define b2_toiBaugarte 0.75f 0115 0116 0117 // Sleep 0118 0119 /// The time that a body must be still before it will go to sleep. 0120 #define b2_timeToSleep 0.5f 0121 0122 /// A body cannot sleep if its linear velocity is above this tolerance. 0123 #define b2_linearSleepTolerance 0.01f 0124 0125 /// A body cannot sleep if its angular velocity is above this tolerance. 0126 #define b2_angularSleepTolerance (2.0f / 180.0f * b2_pi) 0127 0128 // Memory Allocation 0129 0130 /// Implement this function to use your own memory allocator. 0131 void* b2Alloc(int32 size); 0132 0133 /// If you implement b2Alloc, you should also implement this function. 0134 void b2Free(void* mem); 0135 0136 /// Logging function. 0137 void b2Log(const char* string, ...); 0138 0139 /// Version numbering scheme. 0140 /// See http://en.wikipedia.org/wiki/Software_versioning 0141 struct b2Version 0142 { 0143 int32 major; ///< significant changes 0144 int32 minor; ///< incremental changes 0145 int32 revision; ///< bug fixes 0146 }; 0147 0148 /// Current version. 0149 extern b2Version b2_version; 0150 0151 #endif