text: // MIT License
  
  // Copyright (c) 2019 Erin Catto
  
  // Permission is hereby granted, free of charge, to any person obtaining a copy
  // of this software and associated documentation files (the "Software"), to deal
  // in the Software without restriction, including without limitation the rights
  // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  // copies of the Software, and to permit persons to whom the Software is
  // furnished to do so, subject to the following conditions:
  
  // The above copyright notice and this permission notice shall be included in all
  // copies or substantial portions of the Software.
  
  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  // SOFTWARE.
  
  #ifndef B2_COMMON_H
  #define B2_COMMON_H
  
  #include "b2_settings.h"
  
  #include <stddef.h>
  #include <assert.h>
  #include <float.h>
  
  #if !defined(NDEBUG)
  	#define b2DEBUG
  #endif
  
  #define B2_NOT_USED(x) ((void)(x))
  #if DEBUG && !defined(NDEBUG)
  #define b2Assert(A) assert(A)
  #define B2_ASSERT_ENABLED 1
  #else
  #define b2Assert(A)
  #define B2_ASSERT_ENABLED 0
  #endif
  
  // Statement which is compiled out when DEBUG isn't defined.
  #if DEBUG
  #define B2_DEBUG_STATEMENT(A) A
  #else
  #define B2_DEBUG_STATEMENT(A)
  #endif  // DEBUG
  
  // Calculate the size of a static array.
  #define B2_ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
  
  #define	b2_maxFloat		FLT_MAX
  #define	b2_epsilon		FLT_EPSILON
  #define b2_pi			3.14159265359f
  
  #if !defined(b2Inline)
  #if defined(__GNUC__)
  #define b2Inline __attribute__((always_inline))
  #else
  #define b2Inline inline
  #endif // defined(__GNUC__)
  #endif // !defined(b2Inline)
  
  // We expand the API so that other languages (e.g. Java) can call into
  // our C++ more easily. Only set if when the flag is not externally defined.
  #if !defined(LIQUIDFUN_EXTERNAL_LANGUAGE_API)
  #if defined(SWIG) || defined(LIQUIDFUN_UNIT_TESTS)
  #define LIQUIDFUN_EXTERNAL_LANGUAGE_API 1
  #else
  #define LIQUIDFUN_EXTERNAL_LANGUAGE_API 0
  #endif
  #endif
  
  /// @file
  /// Global tuning constants based on meters-kilograms-seconds (MKS) units.
  ///
  
  // Collision
  
  /// The maximum number of contact points between two convex shapes. Do
  /// not change this value.
  #define b2_maxManifoldPoints	2
  
  /// This is used to fatten AABBs in the dynamic tree. This allows proxies
  /// to move by a small amount without triggering a tree adjustment.
  /// This is in meters.
  #define b2_aabbExtension		(0.1f * b2_lengthUnitsPerMeter)
  
  /// This is used to fatten AABBs in the dynamic tree. This is used to predict
  /// the future position based on the current displacement.
  /// This is a dimensionless multiplier.
  #define b2_aabbMultiplier		4.0f
  
  /// A small length used as a collision and constraint tolerance. Usually it is
  /// chosen to be numerically significant, but visually insignificant. In meters.
  #define b2_linearSlop			(0.005f * b2_lengthUnitsPerMeter)
  
  /// A small angle used as a collision and constraint tolerance. Usually it is
  /// chosen to be numerically significant, but visually insignificant.
  #define b2_angularSlop			(2.0f / 180.0f * b2_pi)
  
  /// The radius of the polygon/edge shape skin. This should not be modified. Making
  /// this smaller means polygons will have an insufficient buffer for continuous collision.
  /// Making it larger may create artifacts for vertex collision.
  #define b2_polygonRadius		(2.0f * b2_linearSlop)
  
  /// Maximum number of sub-steps per contact in continuous physics simulation.
  #define b2_maxSubSteps			8
  
  
  // Dynamics
  
  /// Maximum number of contacts to be handled to solve a TOI impact.
  #define b2_maxTOIContacts			32
  
  /// The maximum linear position correction used when solving constraints. This helps to
  /// prevent overshoot. Meters.
  #define b2_maxLinearCorrection		(0.2f * b2_lengthUnitsPerMeter)
  
  /// The maximum angular position correction used when solving constraints. This helps to
  /// prevent overshoot.
  #define b2_maxAngularCorrection		(8.0f / 180.0f * b2_pi)
  
  /// The maximum linear translation of a body per step. This limit is very large and is used
  /// to prevent numerical problems. You shouldn't need to adjust this. Meters.
  #define b2_maxTranslation			(2.0f * b2_lengthUnitsPerMeter)
  #define b2_maxTranslationSquared	(b2_maxTranslation * b2_maxTranslation)
  
  /// The maximum angular velocity of a body. This limit is very large and is used
  /// to prevent numerical problems. You shouldn't need to adjust this.
  #define b2_maxRotation				(0.5f * b2_pi)
  #define b2_maxRotationSquared		(b2_maxRotation * b2_maxRotation)
  
  /// This scale factor controls how fast overlap is resolved. Ideally this would be 1 so
  /// that overlap is removed in one time step. However using values close to 1 often lead
  /// to overshoot.
  #define b2_baumgarte				0.2f
  #define b2_toiBaumgarte				0.75f
  
  
  // Particle
  
  /// NEON SIMD requires 16-bit particle indices
  #if !defined(B2_USE_16_BIT_PARTICLE_INDICES) && defined(LIQUIDFUN_SIMD_NEON)
  #define B2_USE_16_BIT_PARTICLE_INDICES
  #endif
  
  /// A symbolic constant that stands for particle allocation error.
  #define b2_invalidParticleIndex		(-1)
  
  #ifdef B2_USE_16_BIT_PARTICLE_INDICES
  #define b2_maxParticleIndex			0x7FFF
  #else
  #define b2_maxParticleIndex			0x7FFFFFFF
  #endif
  
  /// The default distance between particles, multiplied by the particle diameter.
  #define b2_particleStride			0.75f
  
  /// The minimum particle weight that produces pressure.
  #define b2_minParticleWeight			1.0f
  
  /// The upper limit for particle pressure.
  #define b2_maxParticlePressure		0.25f
  
  /// The upper limit for force between particles.
  #define b2_maxParticleForce		0.5f
  
  /// The maximum distance between particles in a triad, multiplied by the
  /// particle diameter.
  #define b2_maxTriadDistance			2
  #define b2_maxTriadDistanceSquared		(b2_maxTriadDistance * b2_maxTriadDistance)
  
  /// The initial size of particle data buffers.
  #define b2_minParticleSystemBufferCapacity	256
  
  /// The time into the future that collisions against barrier particles will be detected.
  #define b2_barrierCollisionTime 2.5f
  
  // Sleep
  
  /// The time that a body must be still before it will go to sleep.
  #define b2_timeToSleep				0.5f
  
  /// A body cannot sleep if its linear velocity is above this tolerance.
  #define b2_linearSleepTolerance		(0.01f * b2_lengthUnitsPerMeter)
  
  /// A body cannot sleep if its angular velocity is above this tolerance.
  #define b2_angularSleepTolerance	(2.0f / 180.0f * b2_pi)
  
  /// Dump to a file. Only one dump file allowed at a time.
  void b2OpenDump(const char* fileName);
  void b2Dump(const char* string, ...);
  void b2CloseDump();
  
  /// Version numbering scheme.
  /// See http://en.wikipedia.org/wiki/Software_versioning
  struct b2Version
  {
  	int32 major;		///< significant changes
  	int32 minor;		///< incremental changes
  	int32 revision;		///< bug fixes
  };
  
  /// Current version.
  /// Version of Box2D, LiquidFun is based upon.
  extern B2_API b2Version b2_version;
  
  /// Global variable is used to identify the version of LiquidFun.
  extern const b2Version b2_liquidFunVersion;
  /// String which identifies the current version of LiquidFun.
  /// b2_liquidFunVersionString is used by Google developers to identify which
  /// applications uploaded to Google Play are using this library.  This allows
  /// the development team at Google to determine the popularity of the library.
  /// How it works: Applications that are uploaded to the Google Play Store are
  /// scanned for this version string.  We track which applications are using it
  /// to measure popularity.  You are free to remove it (of course) but we would
  /// appreciate if you left it in.
  extern const char *b2_liquidFunVersionString;
  
  #endif
  