Box2D: Box2D/Box2D/Common/b2Settings.h Source File

- Main Page
- Classes
- Files

- File List
- File Members

# Box2D/Box2D/Common/b2Settings.h

Go to the documentation of this file.

    00001 /*
    00002 * Copyright (c) 2006-2009 Erin Catto http://www.gphysics.com
    00003 *
    00004 * This software is provided 'as-is', without any express or implied
    00005 * warranty.  In no event will the authors be held liable for any damages
    00006 * arising from the use of this software.
    00007 * Permission is granted to anyone to use this software for any purpose,
    00008 * including commercial applications, and to alter it and redistribute it
    00009 * freely, subject to the following restrictions:
    00010 * 1. The origin of this software must not be misrepresented; you must not
    00011 * claim that you wrote the original software. If you use this software
    00012 * in a product, an acknowledgment in the product documentation would be
    00013 * appreciated but is not required.
    00014 * 2. Altered source versions must be plainly marked as such, and must not be
    00015 * misrepresented as being the original software.
    00016 * 3. This notice may not be removed or altered from any source distribution.
    00017 */
    00018
    00019 #ifndef B2_SETTINGS_H
    00020 #define B2_SETTINGS_H
    00021
    00022 #include <cassert>
    00023 #include <cmath>
    00024
    00025 #define B2_NOT_USED(x) ((void)(x))
    00026 #define b2Assert(A) assert(A)
    00027
    00028 typedef signed char     int8;
    00029 typedef signed short int16;
    00030 typedef signed int int32;
    00031 typedef unsigned char uint8;
    00032 typedef unsigned short uint16;
    00033 typedef unsigned int uint32;
    00034 typedef float float32;
    00035
    00036 #define b2_maxFloat             FLT_MAX
    00037 #define b2_epsilon              FLT_EPSILON
    00038 #define b2_pi                   3.14159265359f
    00039
    00043
    00044 // Collision
    00045
    00047 #define b2_maxManifoldPoints    2
    00048
    00050 #define b2_maxPolygonVertices   8
    00051
    00055 #define b2_aabbExtension                0.1f
    00056
    00060 #define b2_aabbMultiplier               2.0f
    00061
    00064 #define b2_linearSlop                   0.005f
    00065
    00068 #define b2_angularSlop                  (2.0f / 180.0f * b2_pi)
    00069
    00073 #define b2_polygonRadius                (2.0f * b2_linearSlop)
    00074
    00075
    00076 // Dynamics
    00077
    00079 #define b2_maxTOIContacts                       32
    00080
    00083 #define b2_velocityThreshold            1.0f
    00084
    00087 #define b2_maxLinearCorrection          0.2f
    00088
    00091 #define b2_maxAngularCorrection         (8.0f / 180.0f * b2_pi)
    00092
    00095 #define b2_maxTranslation                       2.0f
    00096 #define b2_maxTranslationSquared        (b2_maxTranslation * b2_maxTranslation)
    00097
    00100 #define b2_maxRotation                          (0.5f * b2_pi)
    00101 #define b2_maxRotationSquared           (b2_maxRotation * b2_maxRotation)
    00102
    00106 #define b2_contactBaumgarte                     0.2f
    00107
    00108 // Sleep
    00109
    00111 #define b2_timeToSleep                          0.5f
    00112
    00114 #define b2_linearSleepTolerance         0.01f
    00115
    00117 #define b2_angularSleepTolerance        (2.0f / 180.0f * b2_pi)
    00118
    00119 // Memory Allocation
    00120
    00122 void* b2Alloc(int32 size);
    00123
    00125 void b2Free(void* mem);
    00126
    00129 struct b2Version
    00130 {
    00131         int32 major;
    00132         int32 minor;
    00133         int32 revision;
    00134 };
    00135
    00137 extern b2Version b2_version;
    00138
    00140 inline float32 b2MixFriction(float32 friction1, float32 friction2)
    00141 {
    00142         return sqrtf(friction1 * friction2);
    00143 }
    00144
    00146 inline float32 b2MixRestitution(float32 restitution1, float32 restitution2)
    00147 {
    00148         return restitution1 > restitution2 ? restitution1 : restitution2;
    00149 }
    00150
    00151 #endif