2011-12-11 00:40:04 +00:00
|
|
|
/********************************************************************************
|
|
|
|
* ReactPhysics3D physics library, http://code.google.com/p/reactphysics3d/ *
|
2013-03-02 15:26:18 +00:00
|
|
|
* Copyright (c) 2010-2013 Daniel Chappuis *
|
2011-12-11 00:40:04 +00:00
|
|
|
*********************************************************************************
|
|
|
|
* *
|
|
|
|
* This software is provided 'as-is', without any express or implied warranty. *
|
|
|
|
* In no event will the authors be held liable for any damages arising from the *
|
|
|
|
* use of this software. *
|
|
|
|
* *
|
|
|
|
* Permission is granted to anyone to use this software for any purpose, *
|
|
|
|
* including commercial applications, and to alter it and redistribute it *
|
|
|
|
* freely, subject to the following restrictions: *
|
|
|
|
* *
|
|
|
|
* 1. The origin of this software must not be misrepresented; you must not claim *
|
|
|
|
* that you wrote the original software. If you use this software in a *
|
|
|
|
* product, an acknowledgment in the product documentation would be *
|
|
|
|
* appreciated but is not required. *
|
|
|
|
* *
|
|
|
|
* 2. Altered source versions must be plainly marked as such, and must not be *
|
|
|
|
* misrepresented as being the original software. *
|
|
|
|
* *
|
|
|
|
* 3. This notice may not be removed or altered from any source distribution. *
|
|
|
|
* *
|
|
|
|
********************************************************************************/
|
|
|
|
|
2013-04-18 20:54:36 +00:00
|
|
|
#ifndef REACTPHYSICS3D_CONFIGURATION_H
|
|
|
|
#define REACTPHYSICS3D_CONFIGURATION_H
|
2011-12-11 00:40:04 +00:00
|
|
|
|
2012-01-18 23:06:33 +00:00
|
|
|
// Libraries
|
|
|
|
#include <limits>
|
|
|
|
#include <cfloat>
|
2012-09-26 21:07:40 +00:00
|
|
|
#include <utility>
|
2012-01-18 23:06:33 +00:00
|
|
|
#include "decimal.h"
|
|
|
|
|
2011-12-11 00:40:04 +00:00
|
|
|
// Windows platform
|
2012-10-09 20:21:02 +00:00
|
|
|
#if defined(WIN32) ||defined(_WIN32) || defined(_WIN64) ||defined(__WIN32__) || defined(__WINDOWS__)
|
2011-12-11 00:40:04 +00:00
|
|
|
#define WINDOWS_OS
|
|
|
|
#elif defined(__APPLE__) // Apple platform
|
|
|
|
#define APPLE_OS
|
|
|
|
#elif defined(__linux__) || defined(linux) || defined(__linux) // Linux platform
|
|
|
|
#define LINUX_OS
|
|
|
|
#endif
|
|
|
|
|
2013-03-05 22:09:50 +00:00
|
|
|
/// Namespace reactphysics3d
|
2012-08-02 21:33:56 +00:00
|
|
|
namespace reactphysics3d {
|
|
|
|
|
2012-10-09 20:21:02 +00:00
|
|
|
// ------------------- Type definitions ------------------- //
|
|
|
|
|
2012-01-18 23:06:33 +00:00
|
|
|
typedef unsigned int uint;
|
|
|
|
typedef long unsigned int luint;
|
2013-03-17 16:07:09 +00:00
|
|
|
typedef luint bodyindex;
|
2012-09-26 21:07:40 +00:00
|
|
|
typedef std::pair<bodyindex, bodyindex> bodyindexpair;
|
2012-01-18 23:06:33 +00:00
|
|
|
|
2013-05-08 21:33:04 +00:00
|
|
|
// ------------------- Enumerations ------------------- //
|
|
|
|
|
|
|
|
/// Position correction technique used in the constraint solver (for joints).
|
2013-06-26 20:28:31 +00:00
|
|
|
/// BAUMGARTE_JOINTS : Faster but can be innacurate in some situations.
|
|
|
|
/// NON_LINEAR_GAUSS_SEIDEL : Slower but more precise. This is the option used by default.
|
2013-05-08 21:33:04 +00:00
|
|
|
enum JointsPositionCorrectionTechnique {BAUMGARTE_JOINTS, NON_LINEAR_GAUSS_SEIDEL};
|
|
|
|
|
|
|
|
/// Position correction technique used in the contact solver (for contacts)
|
2013-06-26 20:28:31 +00:00
|
|
|
/// BAUMGARTE_CONTACTS : Faster but can be innacurate and can lead to unexpected bounciness
|
|
|
|
/// in some situations (due to error correction factor being added to
|
|
|
|
/// the bodies momentum).
|
2013-05-08 21:33:04 +00:00
|
|
|
/// SPLIT_IMPULSES : A bit slower but the error correction factor is not added to the
|
|
|
|
/// bodies momentum. This is the option used by default.
|
|
|
|
enum ContactsPositionCorrectionTechnique {BAUMGARTE_CONTACTS, SPLIT_IMPULSES};
|
|
|
|
|
2012-10-09 20:21:02 +00:00
|
|
|
// ------------------- Constants ------------------- //
|
|
|
|
|
2013-03-05 22:09:50 +00:00
|
|
|
/// Smallest decimal value (negative)
|
2013-02-19 22:16:20 +00:00
|
|
|
const decimal DECIMAL_SMALLEST = - std::numeric_limits<decimal>::max();
|
2012-10-09 20:21:02 +00:00
|
|
|
|
2013-03-05 22:09:50 +00:00
|
|
|
/// Maximum decimal value
|
2013-02-19 22:16:20 +00:00
|
|
|
const decimal DECIMAL_LARGEST = std::numeric_limits<decimal>::max();
|
2012-10-09 20:21:02 +00:00
|
|
|
|
2013-03-05 22:09:50 +00:00
|
|
|
/// Machine epsilon
|
2013-02-19 22:16:20 +00:00
|
|
|
const decimal MACHINE_EPSILON = std::numeric_limits<decimal>::epsilon();
|
2012-10-09 20:21:02 +00:00
|
|
|
|
2013-03-05 22:09:50 +00:00
|
|
|
/// Pi constant
|
2013-02-19 22:16:20 +00:00
|
|
|
const decimal PI = decimal(3.14159265);
|
2012-10-09 20:21:02 +00:00
|
|
|
|
2013-06-09 14:31:01 +00:00
|
|
|
/// 2*Pi constant
|
|
|
|
const decimal PI_TIMES_2 = decimal(6.28318530);
|
|
|
|
|
2013-03-05 22:09:50 +00:00
|
|
|
/// Default internal constant timestep in seconds
|
2013-02-19 22:16:20 +00:00
|
|
|
const decimal DEFAULT_TIMESTEP = decimal(1.0 / 60.0);
|
|
|
|
|
2013-03-05 22:09:50 +00:00
|
|
|
/// Default friction coefficient for a rigid body
|
2013-02-19 22:16:20 +00:00
|
|
|
const decimal DEFAULT_FRICTION_COEFFICIENT = decimal(0.3);
|
2012-10-09 20:21:02 +00:00
|
|
|
|
2013-07-09 22:17:14 +00:00
|
|
|
/// Default bounciness factor for a rigid body
|
|
|
|
const decimal DEFAULT_BOUNCINESS = decimal(0.5);
|
|
|
|
|
2013-09-03 17:30:43 +00:00
|
|
|
/// True if the spleeping technique is enabled
|
2013-08-26 19:28:48 +00:00
|
|
|
const bool SPLEEPING_ENABLED = true;
|
2012-10-09 20:21:02 +00:00
|
|
|
|
2013-07-03 20:50:00 +00:00
|
|
|
/// Object margin for collision detection in meters (for the GJK-EPA Algorithm)
|
2013-02-19 22:16:20 +00:00
|
|
|
const decimal OBJECT_MARGIN = decimal(0.04);
|
2012-10-09 20:21:02 +00:00
|
|
|
|
2013-03-05 22:09:50 +00:00
|
|
|
/// Distance threshold for two contact points for a valid persistent contact (in meters)
|
2013-02-19 22:16:20 +00:00
|
|
|
const decimal PERSISTENT_CONTACT_DIST_THRESHOLD = decimal(0.03);
|
2012-10-09 20:21:02 +00:00
|
|
|
|
2013-03-05 22:09:50 +00:00
|
|
|
/// Velocity threshold for contact velocity restitution
|
2013-02-26 21:43:45 +00:00
|
|
|
const decimal RESTITUTION_VELOCITY_THRESHOLD = decimal(1.0);
|
|
|
|
|
2013-05-08 21:33:04 +00:00
|
|
|
/// Number of iterations when solving the velocity constraints of the Sequential Impulse technique
|
2013-09-27 16:43:45 +00:00
|
|
|
const uint DEFAULT_VELOCITY_SOLVER_NB_ITERATIONS = 10;
|
2013-05-08 21:33:04 +00:00
|
|
|
|
|
|
|
/// Number of iterations when solving the position constraints of the Sequential Impulse technique
|
2013-06-26 20:28:31 +00:00
|
|
|
const uint DEFAULT_POSITION_SOLVER_NB_ITERATIONS = 5;
|
2012-10-09 20:21:02 +00:00
|
|
|
|
2013-09-03 17:30:43 +00:00
|
|
|
/// Time (in seconds) that a body must stay still to be considered sleeping
|
|
|
|
const float DEFAULT_TIME_BEFORE_SLEEP = 1.0f;
|
|
|
|
|
|
|
|
/// A body with a linear velocity smaller than the sleep linear velocity (in m/s)
|
|
|
|
/// might enter sleeping mode.
|
|
|
|
const decimal DEFAULT_SLEEP_LINEAR_VELOCITY = decimal(0.02);
|
|
|
|
|
|
|
|
/// A body with angular velocity smaller than the sleep angular velocity (in rad/s)
|
|
|
|
/// might enter sleeping mode
|
|
|
|
const decimal DEFAULT_SLEEP_ANGULAR_VELOCITY = decimal(3.0 * (PI / 180.0));
|
|
|
|
|
2014-03-16 19:59:10 +00:00
|
|
|
/// In the broad-phase collision detection (dynamic AABB tree), the AABBs are
|
2014-07-02 22:13:30 +00:00
|
|
|
/// inflated with a constant gap to allow the collision shape to move a little bit
|
|
|
|
/// without triggering a large modification of the tree which can be costly
|
2014-03-16 19:59:10 +00:00
|
|
|
const decimal DYNAMIC_TREE_AABB_GAP = decimal(0.1);
|
2014-07-02 22:13:30 +00:00
|
|
|
|
|
|
|
/// In the broad-phase collision detection (dynamic AABB tree), the AABBs are
|
|
|
|
/// also inflated in direction of the linear motion of the body by mutliplying the
|
|
|
|
/// followin constant with the linear velocity and the elapsed time between two frames.
|
2014-07-09 21:45:19 +00:00
|
|
|
const decimal DYNAMIC_TREE_AABB_LIN_GAP_MULTIPLIER = decimal(1.7);
|
2014-07-02 22:13:30 +00:00
|
|
|
|
2012-08-02 21:33:56 +00:00
|
|
|
}
|
2012-01-18 23:06:33 +00:00
|
|
|
|
2011-12-11 00:40:04 +00:00
|
|
|
#endif
|