Blender  V3.3
Classes | Macros | Typedefs | Functions | Variables
btScalar.h File Reference
#include <math.h>
#include <stdlib.h>
#include <float.h>
#include <assert.h>

Go to the source code of this file.

Classes

struct  btInfMaskConverter
 
struct  btTypedObject
 rudimentary class to provide type info More...
 

Macros

#define BT_BULLET_VERSION   289
 
#define BT_NOT_EMPTY_FILE
 
#define SIMD_FORCE_INLINE   inline
 
#define ATTRIBUTE_ALIGNED16(a)   a
 
#define ATTRIBUTE_ALIGNED64(a)   a
 
#define ATTRIBUTE_ALIGNED128(a)   a
 
#define btAssert(x)
 
#define btFullAssert(x)
 
#define btLikely(_c)   _c
 
#define btUnlikely(_c)   _c
 
#define BT_LARGE_FLOAT   1e18f
 
#define BT_INFINITY   (btInfinityMask.mask)
 
#define BT_DECLARE_ALIGNED_ALLOCATOR()
 
#define SIMD_PI   btScalar(3.1415926535897932384626433832795029)
 
#define SIMD_2_PI   (btScalar(2.0) * SIMD_PI)
 
#define SIMD_HALF_PI   (SIMD_PI * btScalar(0.5))
 
#define SIMD_RADS_PER_DEG   (SIMD_2_PI / btScalar(360.0))
 
#define SIMD_DEGS_PER_RAD   (btScalar(360.0) / SIMD_2_PI)
 
#define SIMDSQRT12   btScalar(0.7071067811865475244008443621048490)
 
#define btRecipSqrt(x)   ((btScalar)(btScalar(1.0) / btSqrt(btScalar(x)))) /* reciprocal square root */
 
#define btRecip(x)   (btScalar(1.0) / btScalar(x))
 
#define SIMD_EPSILON   FLT_EPSILON
 
#define SIMD_INFINITY   FLT_MAX
 
#define BT_ONE   1.0f
 
#define BT_ZERO   0.0f
 
#define BT_TWO   2.0f
 
#define BT_HALF   0.5f
 
#define BT_DECLARE_HANDLE(name)
 
#define btFsels(a, b, c)   (btScalar) btFsel(a, b, c)
 

Typedefs

typedef float btScalar
 The btScalar type abstracts floating point numbers, to easily switch between double and single floating point precision. More...
 

Functions

int btGetVersion ()
 
int btIsDoublePrecision ()
 
int btGetInfinityMask ()
 
SIMD_FORCE_INLINE btScalar btSqrt (btScalar y)
 
SIMD_FORCE_INLINE btScalar btFabs (btScalar x)
 
SIMD_FORCE_INLINE btScalar btCos (btScalar x)
 
SIMD_FORCE_INLINE btScalar btSin (btScalar x)
 
SIMD_FORCE_INLINE btScalar btTan (btScalar x)
 
SIMD_FORCE_INLINE btScalar btAcos (btScalar x)
 
SIMD_FORCE_INLINE btScalar btAsin (btScalar x)
 
SIMD_FORCE_INLINE btScalar btAtan (btScalar x)
 
SIMD_FORCE_INLINE btScalar btAtan2 (btScalar x, btScalar y)
 
SIMD_FORCE_INLINE btScalar btExp (btScalar x)
 
SIMD_FORCE_INLINE btScalar btLog (btScalar x)
 
SIMD_FORCE_INLINE btScalar btPow (btScalar x, btScalar y)
 
SIMD_FORCE_INLINE btScalar btFmod (btScalar x, btScalar y)
 
SIMD_FORCE_INLINE btScalar btAtan2Fast (btScalar y, btScalar x)
 
SIMD_FORCE_INLINE bool btFuzzyZero (btScalar x)
 
SIMD_FORCE_INLINE bool btEqual (btScalar a, btScalar eps)
 
SIMD_FORCE_INLINE bool btGreaterEqual (btScalar a, btScalar eps)
 
SIMD_FORCE_INLINE int btIsNegative (btScalar x)
 
SIMD_FORCE_INLINE btScalar btRadians (btScalar x)
 
SIMD_FORCE_INLINE btScalar btDegrees (btScalar x)
 
SIMD_FORCE_INLINE btScalar btFsel (btScalar a, btScalar b, btScalar c)
 
SIMD_FORCE_INLINE bool btMachineIsLittleEndian ()
 
SIMD_FORCE_INLINE unsigned btSelect (unsigned condition, unsigned valueIfConditionNonZero, unsigned valueIfConditionZero)
 
SIMD_FORCE_INLINE int btSelect (unsigned condition, int valueIfConditionNonZero, int valueIfConditionZero)
 
SIMD_FORCE_INLINE float btSelect (unsigned condition, float valueIfConditionNonZero, float valueIfConditionZero)
 
template<typename T >
SIMD_FORCE_INLINE void btSwap (T &a, T &b)
 
SIMD_FORCE_INLINE unsigned btSwapEndian (unsigned val)
 
SIMD_FORCE_INLINE unsigned short btSwapEndian (unsigned short val)
 
SIMD_FORCE_INLINE unsigned btSwapEndian (int val)
 
SIMD_FORCE_INLINE unsigned short btSwapEndian (short val)
 
SIMD_FORCE_INLINE unsigned int btSwapEndianFloat (float d)
 btSwapFloat uses using char pointers to swap the endianness More...
 
SIMD_FORCE_INLINE float btUnswapEndianFloat (unsigned int a)
 
SIMD_FORCE_INLINE void btSwapEndianDouble (double d, unsigned char *dst)
 
SIMD_FORCE_INLINE double btUnswapEndianDouble (const unsigned char *src)
 
template<typename T >
SIMD_FORCE_INLINE void btSetZero (T *a, int n)
 
SIMD_FORCE_INLINE btScalar btLargeDot (const btScalar *a, const btScalar *b, int n)
 
SIMD_FORCE_INLINE btScalar btNormalizeAngle (btScalar angleInRadians)
 
template<typename T >
TbtAlignPointer (T *unalignedPtr, size_t alignment)
 align a pointer to the provided alignment, upwards More...
 

Variables

static btInfMaskConverter btInfinityMask = 0x7F800000
 

Macro Definition Documentation

◆ ATTRIBUTE_ALIGNED128

#define ATTRIBUTE_ALIGNED128 (   a)    a

Definition at line 287 of file btScalar.h.

◆ ATTRIBUTE_ALIGNED16

#define ATTRIBUTE_ALIGNED16 (   a)    a
Todo:
: check out alignment methods for other platforms/compilers define ATTRIBUTE_ALIGNED16(a) a attribute ((aligned (16))) define ATTRIBUTE_ALIGNED64(a) a attribute ((aligned (64))) define ATTRIBUTE_ALIGNED128(a) a attribute ((aligned (128)))

Definition at line 285 of file btScalar.h.

◆ ATTRIBUTE_ALIGNED64

#define ATTRIBUTE_ALIGNED64 (   a)    a

Definition at line 286 of file btScalar.h.

◆ BT_BULLET_VERSION

#define BT_BULLET_VERSION   289

Definition at line 28 of file btScalar.h.

◆ BT_DECLARE_ALIGNED_ALLOCATOR

BT_DECLARE_ALIGNED_ALLOCATOR ( )
Value:
SIMD_FORCE_INLINE void *operator new(size_t sizeInBytes) { return btAlignedAlloc(sizeInBytes, 16); } \
SIMD_FORCE_INLINE void operator delete(void *ptr) { btAlignedFree(ptr); } \
SIMD_FORCE_INLINE void *operator new(size_t, void *ptr) { return ptr; } \
SIMD_FORCE_INLINE void operator delete(void *, void *) {} \
SIMD_FORCE_INLINE void *operator new[](size_t sizeInBytes) { return btAlignedAlloc(sizeInBytes, 16); } \
SIMD_FORCE_INLINE void operator delete[](void *ptr) { btAlignedFree(ptr); } \
SIMD_FORCE_INLINE void *operator new[](size_t, void *ptr) { return ptr; } \
SIMD_FORCE_INLINE void operator delete[](void *, void *) {}
#define btAlignedFree(ptr)
#define btAlignedAlloc(size, alignment)
#define SIMD_FORCE_INLINE
Definition: btScalar.h:280
PointerRNA * ptr
Definition: wm_files.c:3480

Definition at line 425 of file btScalar.h.

◆ BT_DECLARE_HANDLE

#define BT_DECLARE_HANDLE (   name)
Value:
typedef struct name##__ \
{ \
int unused; \
} * name

Definition at line 591 of file btScalar.h.

◆ BT_HALF

#define BT_HALF   0.5f

Definition at line 548 of file btScalar.h.

◆ BT_INFINITY

#define BT_INFINITY   (btInfinityMask.mask)

Definition at line 405 of file btScalar.h.

◆ BT_LARGE_FLOAT

#define BT_LARGE_FLOAT   1e18f

Definition at line 316 of file btScalar.h.

◆ BT_NOT_EMPTY_FILE

#define BT_NOT_EMPTY_FILE

Definition at line 66 of file btScalar.h.

◆ BT_ONE

#define BT_ONE   1.0f

Definition at line 545 of file btScalar.h.

◆ BT_TWO

#define BT_TWO   2.0f

Definition at line 547 of file btScalar.h.

◆ BT_ZERO

#define BT_ZERO   0.0f

Definition at line 546 of file btScalar.h.

◆ btAssert

#define btAssert (   x)

Definition at line 295 of file btScalar.h.

◆ btFsels

#define btFsels (   a,
  b,
 
)    (btScalar) btFsel(a, b, c)

Definition at line 603 of file btScalar.h.

◆ btFullAssert

#define btFullAssert (   x)

Definition at line 299 of file btScalar.h.

◆ btLikely

#define btLikely (   _c)    _c

Definition at line 300 of file btScalar.h.

◆ btRecip

#define btRecip (   x)    (btScalar(1.0) / btScalar(x))

Definition at line 533 of file btScalar.h.

◆ btRecipSqrt

#define btRecipSqrt (   x)    ((btScalar)(btScalar(1.0) / btSqrt(btScalar(x)))) /* reciprocal square root */

Definition at line 532 of file btScalar.h.

◆ btUnlikely

#define btUnlikely (   _c)    _c

Definition at line 301 of file btScalar.h.

◆ SIMD_2_PI

#define SIMD_2_PI   (btScalar(2.0) * SIMD_PI)

Definition at line 527 of file btScalar.h.

◆ SIMD_DEGS_PER_RAD

#define SIMD_DEGS_PER_RAD   (btScalar(360.0) / SIMD_2_PI)

Definition at line 530 of file btScalar.h.

◆ SIMD_EPSILON

#define SIMD_EPSILON   FLT_EPSILON

Definition at line 543 of file btScalar.h.

◆ SIMD_FORCE_INLINE

#define SIMD_FORCE_INLINE   inline

Definition at line 280 of file btScalar.h.

◆ SIMD_HALF_PI

#define SIMD_HALF_PI   (SIMD_PI * btScalar(0.5))

Definition at line 528 of file btScalar.h.

◆ SIMD_INFINITY

#define SIMD_INFINITY   FLT_MAX

Definition at line 544 of file btScalar.h.

◆ SIMD_PI

#define SIMD_PI   btScalar(3.1415926535897932384626433832795029)

Definition at line 526 of file btScalar.h.

◆ SIMD_RADS_PER_DEG

#define SIMD_RADS_PER_DEG   (SIMD_2_PI / btScalar(360.0))

Definition at line 529 of file btScalar.h.

◆ SIMDSQRT12

#define SIMDSQRT12   btScalar(0.7071067811865475244008443621048490)

Definition at line 531 of file btScalar.h.

Typedef Documentation

◆ btScalar

typedef float btScalar

The btScalar type abstracts floating point numbers, to easily switch between double and single floating point precision.

Definition at line 314 of file btScalar.h.

Function Documentation

◆ btAcos()

◆ btAlignPointer()

template<typename T >
T* btAlignPointer ( T unalignedPtr,
size_t  alignment 
)

align a pointer to the provided alignment, upwards

Definition at line 814 of file btScalar.h.

References ptr, and T.

Referenced by btAlignedAllocDefault(), and btDefaultSerializer::initDNA().

◆ btAsin()

◆ btAtan()

Definition at line 517 of file btScalar.h.

References atanf, and x.

◆ btAtan2()

SIMD_FORCE_INLINE btScalar btAtan2 ( btScalar  x,
btScalar  y 
)

◆ btAtan2Fast()

SIMD_FORCE_INLINE btScalar btAtan2Fast ( btScalar  y,
btScalar  x 
)

Definition at line 553 of file btScalar.h.

References angle(), btFabs(), r, SIMD_PI, x, and y.

Referenced by calcAngleInfo(), and GrahamScanConvexHull2D().

◆ btCos()

◆ btDegrees()

Definition at line 589 of file btScalar.h.

References SIMD_DEGS_PER_RAD, and x.

◆ btEqual()

SIMD_FORCE_INLINE bool btEqual ( btScalar  a,
btScalar  eps 
)

Definition at line 574 of file btScalar.h.

References Freestyle::a, and eps.

Referenced by btAngularLimit::fit().

◆ btExp()

Definition at line 519 of file btScalar.h.

References expf, and x.

◆ btFabs()

Definition at line 497 of file btScalar.h.

References fabsf, and x.

Referenced by absolute(), btVector4::absolute4(), btSoftBody::applyForces(), bt_line_plane_collision(), btAdjustAngleToLimits(), btAdjustInternalEdgeContacts(), btAtan2Fast(), btFuzzyZero(), btPlaneSpace1(), btShortestAngleUpdate(), btSolveDantzigLCP(), calc_absolute_matrix(), calcAngleInfo(), calculatePrincipalAxisTransform(), ccdEq(), ClusterMetric(), GIM_AABB::collide_ray(), collide_ray(), convertJoint(), cullPoints2(), dBoxBox2(), diagonalize(), btIDebugDraw::drawArc(), gjkepa2_impl::GJK::EncloseOrigin(), GJK< btConvexTemplate >::EncloseOrigin(), extractRotation(), btSoftBodyHelpers::extrapolateBarycentricWeights(), GIM_TRIANGLE::get_uv_parameters(), getEulerYPR(), getEulerZYX(), getInfo2NonVirtual(), btGeometryUtil::getVerticesFromPlaneEquations(), gridRaycast(), ImplicitSolve(), initialize2(), internalUpdateSprings(), IsAlmostZero(), IsAlmostZero1(), LINE_PLANE_COLLISION(), btContactArray::merge_contacts(), gim_contact_array::merge_contacts(), btKrylovSolver< MatrixX >::norm(), btVectorX< T >::nrm2(), gjkepa2_impl::GJK::projectorigin(), GJK< btConvexTemplate >::projectorigin(), btSoftBody::refine(), btSolve2LinearConstraint::resolveBilateralPairConstraint(), resolveConeFrictionConstraintRows(), resolveSingleBilateral(), btSolve2LinearConstraint::resolveUnilateralPairConstraint(), restitutionCurve(), setupMultiBodyContactConstraint(), btSoftBody::setVolumeDensity(), btSoftBody::setVolumeMass(), singularValueDecomposition(), btQuaternion::slerp(), solve33(), sort(), btEigen::system(), ThreePlaneIntersection(), topdown(), btSoftBody::updateArea(), btSoftBody::updateClusters(), wilkinsonShift(), and writeBackJoints().

◆ btFmod()

Definition at line 522 of file btScalar.h.

References fmodf, x, and y.

Referenced by btNormalizeAngle(), and btNormalizeAnglePositive().

◆ btFsel()

SIMD_FORCE_INLINE btScalar btFsel ( btScalar  a,
btScalar  b,
btScalar  c 
)

Definition at line 598 of file btScalar.h.

References Freestyle::a, usdtokens::b(), and Freestyle::c.

Referenced by btSelect().

◆ btFuzzyZero()

SIMD_FORCE_INLINE bool btFuzzyZero ( btScalar  x)

◆ btGetInfinityMask()

int btGetInfinityMask ( )
inline

Definition at line 406 of file btScalar.h.

References btInfinityMask, and btInfMaskConverter::intmask.

◆ btGetVersion()

int btGetVersion ( )
inline

Definition at line 30 of file btScalar.h.

References BT_BULLET_VERSION.

◆ btGreaterEqual()

SIMD_FORCE_INLINE bool btGreaterEqual ( btScalar  a,
btScalar  eps 
)

Definition at line 578 of file btScalar.h.

References Freestyle::a, and eps.

◆ btIsDoublePrecision()

int btIsDoublePrecision ( )
inline

Definition at line 35 of file btScalar.h.

◆ btIsNegative()

SIMD_FORCE_INLINE int btIsNegative ( btScalar  x)

Definition at line 583 of file btScalar.h.

References x.

◆ btLargeDot()

SIMD_FORCE_INLINE btScalar btLargeDot ( const btScalar a,
const btScalar b,
int  n 
)

◆ btLog()

Definition at line 520 of file btScalar.h.

References logf, and x.

◆ btMachineIsLittleEndian()

SIMD_FORCE_INLINE bool btMachineIsLittleEndian ( )

Definition at line 605 of file btScalar.h.

◆ btNormalizeAngle()

SIMD_FORCE_INLINE btScalar btNormalizeAngle ( btScalar  angleInRadians)

◆ btPow()

Definition at line 521 of file btScalar.h.

References powf, x, and y.

Referenced by btRigidBody::applyDamping(), and btPolarDecomposition::decompose().

◆ btRadians()

Definition at line 588 of file btScalar.h.

References SIMD_RADS_PER_DEG, and x.

Referenced by btKinematicCharacterController().

◆ btSelect() [1/3]

SIMD_FORCE_INLINE float btSelect ( unsigned  condition,
float  valueIfConditionNonZero,
float  valueIfConditionZero 
)

Definition at line 633 of file btScalar.h.

References btFsel().

◆ btSelect() [2/3]

SIMD_FORCE_INLINE int btSelect ( unsigned  condition,
int  valueIfConditionNonZero,
int  valueIfConditionZero 
)

Definition at line 627 of file btScalar.h.

◆ btSelect() [3/3]

SIMD_FORCE_INLINE unsigned btSelect ( unsigned  condition,
unsigned  valueIfConditionNonZero,
unsigned  valueIfConditionZero 
)

btSelect avoids branches, which makes performance much better for consoles like Playstation 3 and XBox 360 Thanks Phil Knight. See also http://www.cellperformance.com/articles/2006/04/more_techniques_for_eliminatin_1.html

Definition at line 617 of file btScalar.h.

Referenced by testQuantizedAabbAgainstQuantizedAabb().

◆ btSetZero()

template<typename T >
SIMD_FORCE_INLINE void btSetZero ( T a,
int  n 
)

Definition at line 739 of file btScalar.h.

References Freestyle::a, and T.

Referenced by btLCP::btLCP(), btSolveDantzigLCP(), btVectorX< T >::setZero(), and btMatrixX< T >::setZero().

◆ btSin()

◆ btSqrt()

Definition at line 466 of file btScalar.h.

References sqrtf, x, y, and z.

Referenced by btSoftBody::addAeroForceToFace(), btSoftBody::addAeroForceToNode(), btQuaternion::angle(), angle(), btQuaternion::angleShortestPath(), btDeformableFaceRigidContactConstraint::applyImpulse(), btComputeGjkEpaPenetration(), btConeShape(), btEpsRoot(), btTransformUtil::calculateDiffAxisAngle(), btTransformUtil::calculateDiffAxisAngleQuaternion(), Clamp(), SphereTriangleDetector::collide(), GivensRotation::compute(), btRigidBody::computeGyroscopicForceExplicit(), GivensRotation::computeUnconventional(), coneLocalSupport(), convertContact(), btSoftBodyHelpers::CreateEllipsoid(), CylinderLocalSupportX(), CylinderLocalSupportY(), CylinderLocalSupportZ(), diagonalize(), btPolyhedralContactClipping::findSeparatingAxis(), get_limit_motor_info2(), btQuaternion::getAxis(), btGjkPairDetector::getClosestPointsNonVirtual(), gjkepa2_impl::EPA::getedgedist(), EPA< btConvexTemplate >::getedgedist(), getInfo2InternalUsingFrameOffset(), getInfo2NonVirtual(), getRotation(), gridRaycast(), btTransformUtil::integrateTransform(), internalSetupContactConstraints(), GIM_CONTACT::interpolate_normals(), btQuaternion::length(), length(), localGetSupportVertexWithoutMarginNonVirtual(), polarDecomposition(), btSoftColliders::CollideVF_SS::Process(), gjkepa2_impl::GJK::projectorigin(), GJK< btConvexTemplate >::projectorigin(), ProjectOrigin(), safeNorm(), safeNormalize(), shortestArcQuat(), singularValueDecomposition(), btQuaternion::slerp(), btEigen::system(), btDeformableLagrangianForce::testHessian(), btRaycastVehicle::updateFriction(), and wilkinsonShift().

◆ btSwap()

template<typename T >
SIMD_FORCE_INLINE void btSwap ( T a,
T b 
)

◆ btSwapEndian() [1/4]

SIMD_FORCE_INLINE unsigned btSwapEndian ( int  val)

Definition at line 661 of file btScalar.h.

References btSwapEndian().

◆ btSwapEndian() [2/4]

SIMD_FORCE_INLINE unsigned short btSwapEndian ( short  val)

Definition at line 666 of file btScalar.h.

References btSwapEndian().

◆ btSwapEndian() [3/4]

SIMD_FORCE_INLINE unsigned short btSwapEndian ( unsigned short  val)

Definition at line 656 of file btScalar.h.

◆ btSwapEndian() [4/4]

SIMD_FORCE_INLINE unsigned btSwapEndian ( unsigned  val)

Definition at line 651 of file btScalar.h.

Referenced by btSwapEndian(), and btDefaultSerializer::initDNA().

◆ btSwapEndianDouble()

SIMD_FORCE_INLINE void btSwapEndianDouble ( double  d,
unsigned char *  dst 
)

Definition at line 706 of file btScalar.h.

References src.

◆ btSwapEndianFloat()

SIMD_FORCE_INLINE unsigned int btSwapEndianFloat ( float  d)

btSwapFloat uses using char pointers to swap the endianness

btSwapFloat/btSwapDouble will NOT return a float, because the machine might 'correct' invalid floating point values Not all values of sign/exponent/mantissa are valid floating point numbers according to IEEE 754. When a floating point unit is faced with an invalid value, it may actually change the value, or worse, throw an exception. In most systems, running user mode code, you wouldn't get an exception, but instead the hardware/os/runtime will 'fix' the number for you. so instead of returning a float/double, we return integer/long long integer

Definition at line 677 of file btScalar.h.

References Freestyle::a, and src.

◆ btTan()

Definition at line 500 of file btScalar.h.

References tanf, and x.

◆ btUnswapEndianDouble()

SIMD_FORCE_INLINE double btUnswapEndianDouble ( const unsigned char *  src)

Definition at line 721 of file btScalar.h.

References src.

◆ btUnswapEndianFloat()

SIMD_FORCE_INLINE float btUnswapEndianFloat ( unsigned int  a)

Definition at line 691 of file btScalar.h.

References Freestyle::a, and src.

Variable Documentation

◆ btInfinityMask

btInfMaskConverter btInfinityMask = 0x7F800000
static

Definition at line 404 of file btScalar.h.

Referenced by btGetInfinityMask().