rename to b3 convention, to avoid naming conflicts when using in combination with Bullet 2.x
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org
|
||||
|
||||
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.
|
||||
@@ -15,9 +15,9 @@ subject to the following restrictions:
|
||||
|
||||
#include "b3AlignedAllocator.h"
|
||||
|
||||
int gNumAlignedAllocs = 0;
|
||||
int gNumAlignedFree = 0;
|
||||
int gTotalBytesAlignedAllocs = 0;//detect memory leaks
|
||||
int b3g_numAlignedAllocs = 0;
|
||||
int b3g_numAlignedFree = 0;
|
||||
int b3g_totalBytesAlignedAllocs = 0;//detect memory leaks
|
||||
|
||||
static void *b3AllocDefault(size_t size)
|
||||
{
|
||||
@@ -29,8 +29,8 @@ static void b3FreeDefault(void *ptr)
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
static b3AllocFunc *sAllocFunc = b3AllocDefault;
|
||||
static b3FreeFunc *sFreeFunc = b3FreeDefault;
|
||||
static b3AllocFunc* b3s_allocFunc = b3AllocDefault;
|
||||
static b3FreeFunc* b3s_freeFunc = b3FreeDefault;
|
||||
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ static inline void *b3AlignedAllocDefault(size_t size, int alignment)
|
||||
{
|
||||
void *ret;
|
||||
char *real;
|
||||
real = (char *)sAllocFunc(size + sizeof(void *) + (alignment-1));
|
||||
real = (char *)b3s_allocFunc(size + sizeof(void *) + (alignment-1));
|
||||
if (real) {
|
||||
ret = b3AlignPointer(real + sizeof(void *),alignment);
|
||||
*((void **)(ret)-1) = (void *)(real);
|
||||
@@ -83,25 +83,25 @@ static inline void b3AlignedFreeDefault(void *ptr)
|
||||
|
||||
if (ptr) {
|
||||
real = *((void **)(ptr)-1);
|
||||
sFreeFunc(real);
|
||||
b3s_freeFunc(real);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static b3AlignedAllocFunc *sAlignedAllocFunc = b3AlignedAllocDefault;
|
||||
static b3AlignedFreeFunc *sAlignedFreeFunc = b3AlignedFreeDefault;
|
||||
static b3AlignedAllocFunc* b3s_alignedAllocFunc = b3AlignedAllocDefault;
|
||||
static b3AlignedFreeFunc* b3s_alignedFreeFunc = b3AlignedFreeDefault;
|
||||
|
||||
void b3AlignedAllocSetCustomAligned(b3AlignedAllocFunc *allocFunc, b3AlignedFreeFunc *freeFunc)
|
||||
{
|
||||
sAlignedAllocFunc = allocFunc ? allocFunc : b3AlignedAllocDefault;
|
||||
sAlignedFreeFunc = freeFunc ? freeFunc : b3AlignedFreeDefault;
|
||||
b3s_alignedAllocFunc = allocFunc ? allocFunc : b3AlignedAllocDefault;
|
||||
b3s_alignedFreeFunc = freeFunc ? freeFunc : b3AlignedFreeDefault;
|
||||
}
|
||||
|
||||
void b3AlignedAllocSetCustom(b3AllocFunc *allocFunc, b3FreeFunc *freeFunc)
|
||||
{
|
||||
sAllocFunc = allocFunc ? allocFunc : b3AllocDefault;
|
||||
sFreeFunc = freeFunc ? freeFunc : b3FreeDefault;
|
||||
b3s_allocFunc = allocFunc ? allocFunc : b3AllocDefault;
|
||||
b3s_freeFunc = freeFunc ? freeFunc : b3FreeDefault;
|
||||
}
|
||||
|
||||
#ifdef B3_DEBUG_MEMORY_ALLOCATIONS
|
||||
@@ -113,11 +113,11 @@ void* b3AlignedAllocInternal (size_t size, int alignment,int line,char* filen
|
||||
void *ret;
|
||||
char *real;
|
||||
|
||||
gTotalBytesAlignedAllocs += size;
|
||||
gNumAlignedAllocs++;
|
||||
b3g_totalBytesAlignedAllocs += size;
|
||||
b3g_numAlignedAllocs++;
|
||||
|
||||
|
||||
real = (char *)sAllocFunc(size + 2*sizeof(void *) + (alignment-1));
|
||||
real = (char *)b3s_allocFunc(size + 2*sizeof(void *) + (alignment-1));
|
||||
if (real) {
|
||||
ret = (void*) b3AlignPointer(real + 2*sizeof(void *), alignment);
|
||||
*((void **)(ret)-1) = (void *)(real);
|
||||
@@ -127,7 +127,7 @@ void* b3AlignedAllocInternal (size_t size, int alignment,int line,char* filen
|
||||
ret = (void *)(real);//??
|
||||
}
|
||||
|
||||
printf("allocation#%d at address %x, from %s,line %d, size %d\n",gNumAlignedAllocs,real, filename,line,size);
|
||||
printf("allocation#%d at address %x, from %s,line %d, size %d\n",b3g_numAlignedAllocs,real, filename,line,size);
|
||||
|
||||
int* ptr = (int*)ret;
|
||||
*ptr = 12;
|
||||
@@ -138,16 +138,16 @@ void b3AlignedFreeInternal (void* ptr,int line,char* filename)
|
||||
{
|
||||
|
||||
void* real;
|
||||
gNumAlignedFree++;
|
||||
b3g_numAlignedFree++;
|
||||
|
||||
if (ptr) {
|
||||
real = *((void **)(ptr)-1);
|
||||
int size = *((int*)(ptr)-2);
|
||||
gTotalBytesAlignedAllocs -= size;
|
||||
b3g_totalBytesAlignedAllocs -= size;
|
||||
|
||||
printf("free #%d at address %x, from %s,line %d, size %d\n",gNumAlignedFree,real, filename,line,size);
|
||||
printf("free #%d at address %x, from %s,line %d, size %d\n",b3g_numAlignedFree,real, filename,line,size);
|
||||
|
||||
sFreeFunc(real);
|
||||
b3s_freeFunc(real);
|
||||
} else
|
||||
{
|
||||
printf("NULL ptr\n");
|
||||
@@ -158,9 +158,9 @@ void b3AlignedFreeInternal (void* ptr,int line,char* filename)
|
||||
|
||||
void* b3AlignedAllocInternal (size_t size, int alignment)
|
||||
{
|
||||
gNumAlignedAllocs++;
|
||||
b3g_numAlignedAllocs++;
|
||||
void* ptr;
|
||||
ptr = sAlignedAllocFunc(size, alignment);
|
||||
ptr = b3s_alignedAllocFunc(size, alignment);
|
||||
// printf("b3AlignedAllocInternal %d, %x\n",size,ptr);
|
||||
return ptr;
|
||||
}
|
||||
@@ -172,9 +172,9 @@ void b3AlignedFreeInternal (void* ptr)
|
||||
return;
|
||||
}
|
||||
|
||||
gNumAlignedFree++;
|
||||
b3g_numAlignedFree++;
|
||||
// printf("b3AlignedFreeInternal %x\n",ptr);
|
||||
sAlignedFreeFunc(ptr);
|
||||
b3s_alignedFreeFunc(ptr);
|
||||
}
|
||||
|
||||
#endif //B3_DEBUG_MEMORY_ALLOCATIONS
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org
|
||||
|
||||
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.
|
||||
@@ -42,7 +42,7 @@ void b3AlignedFreeInternal (void* ptr,int line,char* filename);
|
||||
#define b3AlignedFree(ptr) b3AlignedFreeInternal(ptr)
|
||||
|
||||
#endif
|
||||
typedef int size_type;
|
||||
typedef int btSizeType;
|
||||
|
||||
typedef void *(b3AlignedAllocFunc)(size_t size, int alignment);
|
||||
typedef void (b3AlignedFreeFunc)(void *memblock);
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
|
||||
pointer address ( reference ref ) const { return &ref; }
|
||||
const_pointer address ( const_reference ref ) const { return &ref; }
|
||||
pointer allocate ( size_type n , const_pointer * hint = 0 ) {
|
||||
pointer allocate ( btSizeType n , const_pointer * hint = 0 ) {
|
||||
(void)hint;
|
||||
return reinterpret_cast< pointer >(b3AlignedAlloc( sizeof(value_type) * n , Alignment ));
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org
|
||||
|
||||
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,
|
||||
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.
|
||||
@@ -17,7 +17,7 @@ subject to the following restrictions:
|
||||
#ifndef B3_OBJECT_ARRAY__
|
||||
#define B3_OBJECT_ARRAY__
|
||||
|
||||
#include "b3Scalar.h" // has definitions like SIMD_FORCE_INLINE
|
||||
#include "b3Scalar.h" // has definitions like B3_FORCE_INLINE
|
||||
#include "b3AlignedAllocator.h"
|
||||
|
||||
///If the platform doesn't support placement new, you can disable B3_USE_PLACEMENT_NEW
|
||||
@@ -56,22 +56,22 @@ class b3AlignedObjectArray
|
||||
|
||||
#ifdef B3_ALLOW_ARRAY_COPY_OPERATOR
|
||||
public:
|
||||
SIMD_FORCE_INLINE b3AlignedObjectArray<T>& operator=(const b3AlignedObjectArray<T> &other)
|
||||
B3_FORCE_INLINE b3AlignedObjectArray<T>& operator=(const b3AlignedObjectArray<T> &other)
|
||||
{
|
||||
copyFromArray(other);
|
||||
return *this;
|
||||
}
|
||||
#else//B3_ALLOW_ARRAY_COPY_OPERATOR
|
||||
private:
|
||||
SIMD_FORCE_INLINE b3AlignedObjectArray<T>& operator=(const b3AlignedObjectArray<T> &other);
|
||||
B3_FORCE_INLINE b3AlignedObjectArray<T>& operator=(const b3AlignedObjectArray<T> &other);
|
||||
#endif//B3_ALLOW_ARRAY_COPY_OPERATOR
|
||||
|
||||
protected:
|
||||
SIMD_FORCE_INLINE int allocSize(int size)
|
||||
B3_FORCE_INLINE int allocSize(int size)
|
||||
{
|
||||
return (size ? size*2 : 1);
|
||||
}
|
||||
SIMD_FORCE_INLINE void copy(int start,int end, T* dest) const
|
||||
B3_FORCE_INLINE void copy(int start,int end, T* dest) const
|
||||
{
|
||||
int i;
|
||||
for (i=start;i<end;++i)
|
||||
@@ -82,7 +82,7 @@ protected:
|
||||
#endif //B3_USE_PLACEMENT_NEW
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE void init()
|
||||
B3_FORCE_INLINE void init()
|
||||
{
|
||||
//PCK: added this line
|
||||
m_ownsMemory = true;
|
||||
@@ -90,7 +90,7 @@ protected:
|
||||
m_size = 0;
|
||||
m_capacity = 0;
|
||||
}
|
||||
SIMD_FORCE_INLINE void destroy(int first,int last)
|
||||
B3_FORCE_INLINE void destroy(int first,int last)
|
||||
{
|
||||
int i;
|
||||
for (i=first; i<last;i++)
|
||||
@@ -99,14 +99,14 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE void* allocate(int size)
|
||||
B3_FORCE_INLINE void* allocate(int size)
|
||||
{
|
||||
if (size)
|
||||
return m_allocator.allocate(size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE void deallocate()
|
||||
B3_FORCE_INLINE void deallocate()
|
||||
{
|
||||
if(m_data) {
|
||||
//PCK: enclosed the deallocation in this block
|
||||
@@ -146,33 +146,33 @@ protected:
|
||||
|
||||
|
||||
/// return the number of elements in the array
|
||||
SIMD_FORCE_INLINE int size() const
|
||||
B3_FORCE_INLINE int size() const
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE const T& at(int n) const
|
||||
B3_FORCE_INLINE const T& at(int n) const
|
||||
{
|
||||
b3Assert(n>=0);
|
||||
b3Assert(n<size());
|
||||
return m_data[n];
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE T& at(int n)
|
||||
B3_FORCE_INLINE T& at(int n)
|
||||
{
|
||||
b3Assert(n>=0);
|
||||
b3Assert(n<size());
|
||||
return m_data[n];
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE const T& operator[](int n) const
|
||||
B3_FORCE_INLINE const T& operator[](int n) const
|
||||
{
|
||||
b3Assert(n>=0);
|
||||
b3Assert(n<size());
|
||||
return m_data[n];
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE T& operator[](int n)
|
||||
B3_FORCE_INLINE T& operator[](int n)
|
||||
{
|
||||
b3Assert(n>=0);
|
||||
b3Assert(n<size());
|
||||
@@ -181,7 +181,7 @@ protected:
|
||||
|
||||
|
||||
///clear the array, deallocated memory. Generally it is better to use array.resize(0), to reduce performance overhead of run-time memory (de)allocations.
|
||||
SIMD_FORCE_INLINE void clear()
|
||||
B3_FORCE_INLINE void clear()
|
||||
{
|
||||
destroy(0,size());
|
||||
|
||||
@@ -190,7 +190,7 @@ protected:
|
||||
init();
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE void pop_back()
|
||||
B3_FORCE_INLINE void pop_back()
|
||||
{
|
||||
b3Assert(m_size>0);
|
||||
m_size--;
|
||||
@@ -200,7 +200,7 @@ protected:
|
||||
|
||||
///resize changes the number of elements in the array. If the new size is larger, the new elements will be constructed using the optional second argument.
|
||||
///when the new number of elements is smaller, the destructor will be called, but memory will not be freed, to reduce performance overhead of run-time memory (de)allocations.
|
||||
SIMD_FORCE_INLINE void resizeNoInitialize(int newsize)
|
||||
B3_FORCE_INLINE void resizeNoInitialize(int newsize)
|
||||
{
|
||||
int curSize = size();
|
||||
|
||||
@@ -217,7 +217,7 @@ protected:
|
||||
m_size = newsize;
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE void resize(int newsize, const T& fillData=T())
|
||||
B3_FORCE_INLINE void resize(int newsize, const T& fillData=T())
|
||||
{
|
||||
int curSize = size();
|
||||
|
||||
@@ -244,7 +244,7 @@ protected:
|
||||
|
||||
m_size = newsize;
|
||||
}
|
||||
SIMD_FORCE_INLINE T& expandNonInitializing( )
|
||||
B3_FORCE_INLINE T& expandNonInitializing( )
|
||||
{
|
||||
int sz = size();
|
||||
if( sz == capacity() )
|
||||
@@ -257,7 +257,7 @@ protected:
|
||||
}
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE T& expand( const T& fillValue=T())
|
||||
B3_FORCE_INLINE T& expand( const T& fillValue=T())
|
||||
{
|
||||
int sz = size();
|
||||
if( sz == capacity() )
|
||||
@@ -273,7 +273,7 @@ protected:
|
||||
}
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE void push_back(const T& _Val)
|
||||
B3_FORCE_INLINE void push_back(const T& _Val)
|
||||
{
|
||||
int sz = size();
|
||||
if( sz == capacity() )
|
||||
@@ -292,12 +292,12 @@ protected:
|
||||
|
||||
|
||||
/// return the pre-allocated (reserved) elements, this is at least as large as the total number of elements,see size() and reserve()
|
||||
SIMD_FORCE_INLINE int capacity() const
|
||||
B3_FORCE_INLINE int capacity() const
|
||||
{
|
||||
return m_capacity;
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE void reserve(int _Count)
|
||||
B3_FORCE_INLINE void reserve(int _Count)
|
||||
{ // determine new minimum length of allocated storage
|
||||
if (capacity() < _Count)
|
||||
{ // not enough room, reallocate
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
|
||||
Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org
|
||||
|
||||
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,
|
||||
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.
|
||||
@@ -25,7 +25,7 @@ struct b3HashString
|
||||
const char* m_string;
|
||||
unsigned int m_hash;
|
||||
|
||||
SIMD_FORCE_INLINE unsigned int getHash()const
|
||||
B3_FORCE_INLINE unsigned int getHash()const
|
||||
{
|
||||
return m_hash;
|
||||
}
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
return getUid1() == other.getUid1();
|
||||
}
|
||||
//to our success
|
||||
SIMD_FORCE_INLINE unsigned int getHash()const
|
||||
B3_FORCE_INLINE unsigned int getHash()const
|
||||
{
|
||||
int key = m_uid;
|
||||
// Thomas Wang's hash
|
||||
@@ -136,7 +136,7 @@ public:
|
||||
}
|
||||
|
||||
//to our success
|
||||
SIMD_FORCE_INLINE unsigned int getHash()const
|
||||
B3_FORCE_INLINE unsigned int getHash()const
|
||||
{
|
||||
const bool VOID_IS_8 = ((sizeof(void*)==8));
|
||||
|
||||
@@ -172,7 +172,7 @@ public:
|
||||
}
|
||||
|
||||
//to our success
|
||||
SIMD_FORCE_INLINE unsigned int getHash()const
|
||||
B3_FORCE_INLINE unsigned int getHash()const
|
||||
{
|
||||
int key = m_uid;
|
||||
// Thomas Wang's hash
|
||||
@@ -204,7 +204,7 @@ public:
|
||||
return getUid1() == other.getUid1();
|
||||
}
|
||||
//to our success
|
||||
SIMD_FORCE_INLINE unsigned int getHash()const
|
||||
B3_FORCE_INLINE unsigned int getHash()const
|
||||
{
|
||||
int key = m_uid;
|
||||
// Thomas Wang's hash
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef B3_INT2_H
|
||||
#define B3_INT2_H
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
Copyright (c) 2003-2013 Gino van den Bergen / Erwin Coumans http://bulletphysics.org
|
||||
|
||||
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.
|
||||
@@ -21,14 +21,14 @@ subject to the following restrictions:
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef B3_USE_SSE
|
||||
//const __m128 ATTRIBUTE_ALIGNED16(v2220) = {2.0f, 2.0f, 2.0f, 0.0f};
|
||||
const __m128 ATTRIBUTE_ALIGNED16(vMPPP) = {-0.0f, +0.0f, +0.0f, +0.0f};
|
||||
//const __m128 B3_ATTRIBUTE_ALIGNED16(v2220) = {2.0f, 2.0f, 2.0f, 0.0f};
|
||||
const __m128 B3_ATTRIBUTE_ALIGNED16(vMPPP) = {-0.0f, +0.0f, +0.0f, +0.0f};
|
||||
#endif
|
||||
|
||||
#if defined(B3_USE_SSE) || defined(B3_USE_NEON)
|
||||
const b3SimdFloat4 ATTRIBUTE_ALIGNED16(v1000) = {1.0f, 0.0f, 0.0f, 0.0f};
|
||||
const b3SimdFloat4 ATTRIBUTE_ALIGNED16(v0100) = {0.0f, 1.0f, 0.0f, 0.0f};
|
||||
const b3SimdFloat4 ATTRIBUTE_ALIGNED16(v0010) = {0.0f, 0.0f, 1.0f, 0.0f};
|
||||
const b3SimdFloat4 B3_ATTRIBUTE_ALIGNED16(v1000) = {1.0f, 0.0f, 0.0f, 0.0f};
|
||||
const b3SimdFloat4 B3_ATTRIBUTE_ALIGNED16(v0100) = {0.0f, 1.0f, 0.0f, 0.0f};
|
||||
const b3SimdFloat4 B3_ATTRIBUTE_ALIGNED16(v0010) = {0.0f, 0.0f, 1.0f, 0.0f};
|
||||
#endif
|
||||
|
||||
#ifdef B3_USE_DOUBLE_PRECISION
|
||||
@@ -40,7 +40,7 @@ const b3SimdFloat4 ATTRIBUTE_ALIGNED16(v0010) = {0.0f, 0.0f, 1.0f, 0.0f};
|
||||
|
||||
/**@brief The b3Matrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with b3Quaternion, b3Transform and b3Vector3.
|
||||
* Make sure to only include a pure orthogonal matrix without scaling. */
|
||||
ATTRIBUTE_ALIGNED16(class) b3Matrix3x3 {
|
||||
B3_ATTRIBUTE_ALIGNED16(class) b3Matrix3x3 {
|
||||
|
||||
///Data storage for the matrix, each vector is a row of the matrix
|
||||
b3Vector3 m_el[3];
|
||||
@@ -71,14 +71,14 @@ public:
|
||||
}
|
||||
|
||||
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))|| defined (B3_USE_NEON)
|
||||
SIMD_FORCE_INLINE b3Matrix3x3 (const b3SimdFloat4 v0, const b3SimdFloat4 v1, const b3SimdFloat4 v2 )
|
||||
B3_FORCE_INLINE b3Matrix3x3 (const b3SimdFloat4 v0, const b3SimdFloat4 v1, const b3SimdFloat4 v2 )
|
||||
{
|
||||
m_el[0].mVec128 = v0;
|
||||
m_el[1].mVec128 = v1;
|
||||
m_el[2].mVec128 = v2;
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE b3Matrix3x3 (const b3Vector3& v0, const b3Vector3& v1, const b3Vector3& v2 )
|
||||
B3_FORCE_INLINE b3Matrix3x3 (const b3Vector3& v0, const b3Vector3& v1, const b3Vector3& v2 )
|
||||
{
|
||||
m_el[0] = v0;
|
||||
m_el[1] = v1;
|
||||
@@ -86,7 +86,7 @@ public:
|
||||
}
|
||||
|
||||
// Copy constructor
|
||||
SIMD_FORCE_INLINE b3Matrix3x3(const b3Matrix3x3& rhs)
|
||||
B3_FORCE_INLINE b3Matrix3x3(const b3Matrix3x3& rhs)
|
||||
{
|
||||
m_el[0].mVec128 = rhs.m_el[0].mVec128;
|
||||
m_el[1].mVec128 = rhs.m_el[1].mVec128;
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
}
|
||||
|
||||
// Assignment Operator
|
||||
SIMD_FORCE_INLINE b3Matrix3x3& operator=(const b3Matrix3x3& m)
|
||||
B3_FORCE_INLINE b3Matrix3x3& operator=(const b3Matrix3x3& m)
|
||||
{
|
||||
m_el[0].mVec128 = m.m_el[0].mVec128;
|
||||
m_el[1].mVec128 = m.m_el[1].mVec128;
|
||||
@@ -106,7 +106,7 @@ public:
|
||||
#else
|
||||
|
||||
/** @brief Copy constructor */
|
||||
SIMD_FORCE_INLINE b3Matrix3x3 (const b3Matrix3x3& other)
|
||||
B3_FORCE_INLINE b3Matrix3x3 (const b3Matrix3x3& other)
|
||||
{
|
||||
m_el[0] = other.m_el[0];
|
||||
m_el[1] = other.m_el[1];
|
||||
@@ -114,7 +114,7 @@ public:
|
||||
}
|
||||
|
||||
/** @brief Assignment Operator */
|
||||
SIMD_FORCE_INLINE b3Matrix3x3& operator=(const b3Matrix3x3& other)
|
||||
B3_FORCE_INLINE b3Matrix3x3& operator=(const b3Matrix3x3& other)
|
||||
{
|
||||
m_el[0] = other.m_el[0];
|
||||
m_el[1] = other.m_el[1];
|
||||
@@ -126,7 +126,7 @@ public:
|
||||
|
||||
/** @brief Get a column of the matrix as a vector
|
||||
* @param i Column number 0 indexed */
|
||||
SIMD_FORCE_INLINE b3Vector3 getColumn(int i) const
|
||||
B3_FORCE_INLINE b3Vector3 getColumn(int i) const
|
||||
{
|
||||
return b3Vector3(m_el[0][i],m_el[1][i],m_el[2][i]);
|
||||
}
|
||||
@@ -134,7 +134,7 @@ public:
|
||||
|
||||
/** @brief Get a row of the matrix as a vector
|
||||
* @param i Row number 0 indexed */
|
||||
SIMD_FORCE_INLINE const b3Vector3& getRow(int i) const
|
||||
B3_FORCE_INLINE const b3Vector3& getRow(int i) const
|
||||
{
|
||||
b3FullAssert(0 <= i && i < 3);
|
||||
return m_el[i];
|
||||
@@ -142,7 +142,7 @@ public:
|
||||
|
||||
/** @brief Get a mutable reference to a row of the matrix as a vector
|
||||
* @param i Row number 0 indexed */
|
||||
SIMD_FORCE_INLINE b3Vector3& operator[](int i)
|
||||
B3_FORCE_INLINE b3Vector3& operator[](int i)
|
||||
{
|
||||
b3FullAssert(0 <= i && i < 3);
|
||||
return m_el[i];
|
||||
@@ -150,7 +150,7 @@ public:
|
||||
|
||||
/** @brief Get a const reference to a row of the matrix as a vector
|
||||
* @param i Row number 0 indexed */
|
||||
SIMD_FORCE_INLINE const b3Vector3& operator[](int i) const
|
||||
B3_FORCE_INLINE const b3Vector3& operator[](int i) const
|
||||
{
|
||||
b3FullAssert(0 <= i && i < 3);
|
||||
return m_el[i];
|
||||
@@ -493,17 +493,17 @@ public:
|
||||
roll = b3Scalar(b3Atan2(m_el[2].getY(), m_el[2].getZ()));
|
||||
|
||||
// on pitch = +/-HalfPI
|
||||
if (b3Fabs(pitch)==SIMD_HALF_PI)
|
||||
if (b3Fabs(pitch)==B3_HALF_PI)
|
||||
{
|
||||
if (yaw>0)
|
||||
yaw-=SIMD_PI;
|
||||
yaw-=B3_PI;
|
||||
else
|
||||
yaw+=SIMD_PI;
|
||||
yaw+=B3_PI;
|
||||
|
||||
if (roll>0)
|
||||
roll-=SIMD_PI;
|
||||
roll-=B3_PI;
|
||||
else
|
||||
roll+=SIMD_PI;
|
||||
roll+=B3_PI;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -536,15 +536,15 @@ public:
|
||||
b3Scalar delta = b3Atan2(m_el[0].getX(),m_el[0].getZ());
|
||||
if (m_el[2].getX() > 0) //gimbal locked up
|
||||
{
|
||||
euler_out.pitch = SIMD_PI / b3Scalar(2.0);
|
||||
euler_out2.pitch = SIMD_PI / b3Scalar(2.0);
|
||||
euler_out.pitch = B3_PI / b3Scalar(2.0);
|
||||
euler_out2.pitch = B3_PI / b3Scalar(2.0);
|
||||
euler_out.roll = euler_out.pitch + delta;
|
||||
euler_out2.roll = euler_out.pitch + delta;
|
||||
}
|
||||
else // gimbal locked down
|
||||
{
|
||||
euler_out.pitch = -SIMD_PI / b3Scalar(2.0);
|
||||
euler_out2.pitch = -SIMD_PI / b3Scalar(2.0);
|
||||
euler_out.pitch = -B3_PI / b3Scalar(2.0);
|
||||
euler_out2.pitch = -B3_PI / b3Scalar(2.0);
|
||||
euler_out.roll = -euler_out.pitch + delta;
|
||||
euler_out2.roll = -euler_out.pitch + delta;
|
||||
}
|
||||
@@ -552,7 +552,7 @@ public:
|
||||
else
|
||||
{
|
||||
euler_out.pitch = - b3Asin(m_el[2].getX());
|
||||
euler_out2.pitch = SIMD_PI - euler_out.pitch;
|
||||
euler_out2.pitch = B3_PI - euler_out.pitch;
|
||||
|
||||
euler_out.roll = b3Atan2(m_el[2].getY()/b3Cos(euler_out.pitch),
|
||||
m_el[2].getZ()/b3Cos(euler_out.pitch));
|
||||
@@ -608,15 +608,15 @@ public:
|
||||
b3Matrix3x3 transposeTimes(const b3Matrix3x3& m) const;
|
||||
b3Matrix3x3 timesTranspose(const b3Matrix3x3& m) const;
|
||||
|
||||
SIMD_FORCE_INLINE b3Scalar tdotx(const b3Vector3& v) const
|
||||
B3_FORCE_INLINE b3Scalar tdotx(const b3Vector3& v) const
|
||||
{
|
||||
return m_el[0].getX() * v.getX() + m_el[1].getX() * v.getY() + m_el[2].getX() * v.getZ();
|
||||
}
|
||||
SIMD_FORCE_INLINE b3Scalar tdoty(const b3Vector3& v) const
|
||||
B3_FORCE_INLINE b3Scalar tdoty(const b3Vector3& v) const
|
||||
{
|
||||
return m_el[0].getY() * v.getX() + m_el[1].getY() * v.getY() + m_el[2].getY() * v.getZ();
|
||||
}
|
||||
SIMD_FORCE_INLINE b3Scalar tdotz(const b3Vector3& v) const
|
||||
B3_FORCE_INLINE b3Scalar tdotz(const b3Vector3& v) const
|
||||
{
|
||||
return m_el[0].getZ() * v.getX() + m_el[1].getZ() * v.getY() + m_el[2].getZ() * v.getZ();
|
||||
}
|
||||
@@ -660,7 +660,7 @@ public:
|
||||
b3Scalar t = threshold * (b3Fabs(m_el[0][0]) + b3Fabs(m_el[1][1]) + b3Fabs(m_el[2][2]));
|
||||
if (max <= t)
|
||||
{
|
||||
if (max <= SIMD_EPSILON * t)
|
||||
if (max <= B3_EPSILON * t)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -673,7 +673,7 @@ public:
|
||||
b3Scalar theta2 = theta * theta;
|
||||
b3Scalar cos;
|
||||
b3Scalar sin;
|
||||
if (theta2 * theta2 < b3Scalar(10 / SIMD_EPSILON))
|
||||
if (theta2 * theta2 < b3Scalar(10 / B3_EPSILON))
|
||||
{
|
||||
t = (theta >= 0) ? 1 / (theta + b3Sqrt(1 + theta2))
|
||||
: 1 / (theta - b3Sqrt(1 + theta2));
|
||||
@@ -737,7 +737,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE b3Matrix3x3&
|
||||
B3_FORCE_INLINE b3Matrix3x3&
|
||||
b3Matrix3x3::operator*=(const b3Matrix3x3& m)
|
||||
{
|
||||
#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||
@@ -827,7 +827,7 @@ b3Matrix3x3::operator*=(const b3Matrix3x3& m)
|
||||
return *this;
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE b3Matrix3x3&
|
||||
B3_FORCE_INLINE b3Matrix3x3&
|
||||
b3Matrix3x3::operator+=(const b3Matrix3x3& m)
|
||||
{
|
||||
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))|| defined (B3_USE_NEON)
|
||||
@@ -849,7 +849,7 @@ b3Matrix3x3::operator+=(const b3Matrix3x3& m)
|
||||
return *this;
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE b3Matrix3x3
|
||||
B3_FORCE_INLINE b3Matrix3x3
|
||||
operator*(const b3Matrix3x3& m, const b3Scalar & k)
|
||||
{
|
||||
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))
|
||||
@@ -871,7 +871,7 @@ operator*(const b3Matrix3x3& m, const b3Scalar & k)
|
||||
#endif
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE b3Matrix3x3
|
||||
B3_FORCE_INLINE b3Matrix3x3
|
||||
operator+(const b3Matrix3x3& m1, const b3Matrix3x3& m2)
|
||||
{
|
||||
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))|| defined (B3_USE_NEON)
|
||||
@@ -895,7 +895,7 @@ operator+(const b3Matrix3x3& m1, const b3Matrix3x3& m2)
|
||||
#endif
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE b3Matrix3x3
|
||||
B3_FORCE_INLINE b3Matrix3x3
|
||||
operator-(const b3Matrix3x3& m1, const b3Matrix3x3& m2)
|
||||
{
|
||||
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))|| defined (B3_USE_NEON)
|
||||
@@ -920,7 +920,7 @@ operator-(const b3Matrix3x3& m1, const b3Matrix3x3& m2)
|
||||
}
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE b3Matrix3x3&
|
||||
B3_FORCE_INLINE b3Matrix3x3&
|
||||
b3Matrix3x3::operator-=(const b3Matrix3x3& m)
|
||||
{
|
||||
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))|| defined (B3_USE_NEON)
|
||||
@@ -943,14 +943,14 @@ b3Matrix3x3::operator-=(const b3Matrix3x3& m)
|
||||
}
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE b3Scalar
|
||||
B3_FORCE_INLINE b3Scalar
|
||||
b3Matrix3x3::determinant() const
|
||||
{
|
||||
return b3Triple((*this)[0], (*this)[1], (*this)[2]);
|
||||
}
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE b3Matrix3x3
|
||||
B3_FORCE_INLINE b3Matrix3x3
|
||||
b3Matrix3x3::absolute() const
|
||||
{
|
||||
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))
|
||||
@@ -971,7 +971,7 @@ b3Matrix3x3::absolute() const
|
||||
#endif
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE b3Matrix3x3
|
||||
B3_FORCE_INLINE b3Matrix3x3
|
||||
b3Matrix3x3::transpose() const
|
||||
{
|
||||
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))
|
||||
@@ -1008,7 +1008,7 @@ b3Matrix3x3::transpose() const
|
||||
#endif
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE b3Matrix3x3
|
||||
B3_FORCE_INLINE b3Matrix3x3
|
||||
b3Matrix3x3::adjoint() const
|
||||
{
|
||||
return b3Matrix3x3(cofac(1, 1, 2, 2), cofac(0, 2, 2, 1), cofac(0, 1, 1, 2),
|
||||
@@ -1016,7 +1016,7 @@ b3Matrix3x3::adjoint() const
|
||||
cofac(1, 0, 2, 1), cofac(0, 1, 2, 0), cofac(0, 0, 1, 1));
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE b3Matrix3x3
|
||||
B3_FORCE_INLINE b3Matrix3x3
|
||||
b3Matrix3x3::inverse() const
|
||||
{
|
||||
b3Vector3 co(cofac(1, 1, 2, 2), cofac(1, 2, 2, 0), cofac(1, 0, 2, 1));
|
||||
@@ -1028,7 +1028,7 @@ b3Matrix3x3::inverse() const
|
||||
co.getZ() * s, cofac(0, 1, 2, 0) * s, cofac(0, 0, 1, 1) * s);
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE b3Matrix3x3
|
||||
B3_FORCE_INLINE b3Matrix3x3
|
||||
b3Matrix3x3::transposeTimes(const b3Matrix3x3& m) const
|
||||
{
|
||||
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))
|
||||
@@ -1084,7 +1084,7 @@ b3Matrix3x3::transposeTimes(const b3Matrix3x3& m) const
|
||||
#endif
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE b3Matrix3x3
|
||||
B3_FORCE_INLINE b3Matrix3x3
|
||||
b3Matrix3x3::timesTranspose(const b3Matrix3x3& m) const
|
||||
{
|
||||
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))
|
||||
@@ -1137,7 +1137,7 @@ b3Matrix3x3::timesTranspose(const b3Matrix3x3& m) const
|
||||
#endif
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE b3Vector3
|
||||
B3_FORCE_INLINE b3Vector3
|
||||
operator*(const b3Matrix3x3& m, const b3Vector3& v)
|
||||
{
|
||||
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))|| defined (B3_USE_NEON)
|
||||
@@ -1148,7 +1148,7 @@ operator*(const b3Matrix3x3& m, const b3Vector3& v)
|
||||
}
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE b3Vector3
|
||||
B3_FORCE_INLINE b3Vector3
|
||||
operator*(const b3Vector3& v, const b3Matrix3x3& m)
|
||||
{
|
||||
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))
|
||||
@@ -1188,7 +1188,7 @@ operator*(const b3Vector3& v, const b3Matrix3x3& m)
|
||||
#endif
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE b3Matrix3x3
|
||||
B3_FORCE_INLINE b3Matrix3x3
|
||||
operator*(const b3Matrix3x3& m1, const b3Matrix3x3& m2)
|
||||
{
|
||||
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))
|
||||
@@ -1274,7 +1274,7 @@ operator*(const b3Matrix3x3& m1, const b3Matrix3x3& m2)
|
||||
}
|
||||
|
||||
/*
|
||||
SIMD_FORCE_INLINE b3Matrix3x3 b3MultTransposeLeft(const b3Matrix3x3& m1, const b3Matrix3x3& m2) {
|
||||
B3_FORCE_INLINE b3Matrix3x3 b3MultTransposeLeft(const b3Matrix3x3& m1, const b3Matrix3x3& m2) {
|
||||
return b3Matrix3x3(
|
||||
m1[0][0] * m2[0][0] + m1[1][0] * m2[1][0] + m1[2][0] * m2[2][0],
|
||||
m1[0][0] * m2[0][1] + m1[1][0] * m2[1][1] + m1[2][0] * m2[2][1],
|
||||
@@ -1290,7 +1290,7 @@ m1[0][2] * m2[0][2] + m1[1][2] * m2[1][2] + m1[2][2] * m2[2][2]);
|
||||
|
||||
/**@brief Equality operator between two matrices
|
||||
* It will test all elements are equal. */
|
||||
SIMD_FORCE_INLINE bool operator==(const b3Matrix3x3& m1, const b3Matrix3x3& m2)
|
||||
B3_FORCE_INLINE bool operator==(const b3Matrix3x3& m1, const b3Matrix3x3& m2)
|
||||
{
|
||||
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))
|
||||
|
||||
@@ -1327,32 +1327,32 @@ struct b3Matrix3x3DoubleData
|
||||
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE void b3Matrix3x3::serialize(struct b3Matrix3x3Data& dataOut) const
|
||||
B3_FORCE_INLINE void b3Matrix3x3::serialize(struct b3Matrix3x3Data& dataOut) const
|
||||
{
|
||||
for (int i=0;i<3;i++)
|
||||
m_el[i].serialize(dataOut.m_el[i]);
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE void b3Matrix3x3::serializeFloat(struct b3Matrix3x3FloatData& dataOut) const
|
||||
B3_FORCE_INLINE void b3Matrix3x3::serializeFloat(struct b3Matrix3x3FloatData& dataOut) const
|
||||
{
|
||||
for (int i=0;i<3;i++)
|
||||
m_el[i].serializeFloat(dataOut.m_el[i]);
|
||||
}
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE void b3Matrix3x3::deSerialize(const struct b3Matrix3x3Data& dataIn)
|
||||
B3_FORCE_INLINE void b3Matrix3x3::deSerialize(const struct b3Matrix3x3Data& dataIn)
|
||||
{
|
||||
for (int i=0;i<3;i++)
|
||||
m_el[i].deSerialize(dataIn.m_el[i]);
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE void b3Matrix3x3::deSerializeFloat(const struct b3Matrix3x3FloatData& dataIn)
|
||||
B3_FORCE_INLINE void b3Matrix3x3::deSerializeFloat(const struct b3Matrix3x3FloatData& dataIn)
|
||||
{
|
||||
for (int i=0;i<3;i++)
|
||||
m_el[i].deSerializeFloat(dataIn.m_el[i]);
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE void b3Matrix3x3::deSerializeDouble(const struct b3Matrix3x3DoubleData& dataIn)
|
||||
B3_FORCE_INLINE void b3Matrix3x3::deSerializeDouble(const struct b3Matrix3x3DoubleData& dataIn)
|
||||
{
|
||||
for (int i=0;i<3;i++)
|
||||
m_el[i].deSerializeDouble(dataIn.m_el[i]);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
Copyright (c) 2003-2013 Gino van den Bergen / Erwin Coumans http://bulletphysics.org
|
||||
|
||||
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.
|
||||
@@ -20,25 +20,25 @@ subject to the following restrictions:
|
||||
#include "b3Scalar.h"
|
||||
|
||||
template <class T>
|
||||
SIMD_FORCE_INLINE const T& b3Min(const T& a, const T& b)
|
||||
B3_FORCE_INLINE const T& b3Min(const T& a, const T& b)
|
||||
{
|
||||
return a < b ? a : b ;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
SIMD_FORCE_INLINE const T& b3Max(const T& a, const T& b)
|
||||
B3_FORCE_INLINE const T& b3Max(const T& a, const T& b)
|
||||
{
|
||||
return a > b ? a : b;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
SIMD_FORCE_INLINE const T& b3Clamped(const T& a, const T& lb, const T& ub)
|
||||
B3_FORCE_INLINE const T& b3Clamped(const T& a, const T& lb, const T& ub)
|
||||
{
|
||||
return a < lb ? lb : (ub < a ? ub : a);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
SIMD_FORCE_INLINE void b3SetMin(T& a, const T& b)
|
||||
B3_FORCE_INLINE void b3SetMin(T& a, const T& b)
|
||||
{
|
||||
if (b < a)
|
||||
{
|
||||
@@ -47,7 +47,7 @@ SIMD_FORCE_INLINE void b3SetMin(T& a, const T& b)
|
||||
}
|
||||
|
||||
template <class T>
|
||||
SIMD_FORCE_INLINE void b3SetMax(T& a, const T& b)
|
||||
B3_FORCE_INLINE void b3SetMax(T& a, const T& b)
|
||||
{
|
||||
if (a < b)
|
||||
{
|
||||
@@ -56,7 +56,7 @@ SIMD_FORCE_INLINE void b3SetMax(T& a, const T& b)
|
||||
}
|
||||
|
||||
template <class T>
|
||||
SIMD_FORCE_INLINE void b3Clamp(T& a, const T& lb, const T& ub)
|
||||
B3_FORCE_INLINE void b3Clamp(T& a, const T& lb, const T& ub)
|
||||
{
|
||||
if (a < lb)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
Copyright (c) 2003-2013 Gino van den Bergen / Erwin Coumans http://bulletphysics.org
|
||||
|
||||
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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
Copyright (c) 2003-2013 Gino van den Bergen / Erwin Coumans http://bulletphysics.org
|
||||
|
||||
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.
|
||||
@@ -31,7 +31,7 @@ subject to the following restrictions:
|
||||
* Some issues under PS3 Linux with IBM 2.1 SDK, gcc compiler prevent from using aligned quadword.
|
||||
*/
|
||||
#ifndef USE_LIBSPE2
|
||||
ATTRIBUTE_ALIGNED16(class) b3QuadWord
|
||||
B3_ATTRIBUTE_ALIGNED16(class) b3QuadWord
|
||||
#else
|
||||
class b3QuadWord
|
||||
#endif
|
||||
@@ -58,11 +58,11 @@ public:
|
||||
struct {b3Scalar x,y,z,w;};
|
||||
};
|
||||
public:
|
||||
SIMD_FORCE_INLINE b3SimdFloat4 get128() const
|
||||
B3_FORCE_INLINE b3SimdFloat4 get128() const
|
||||
{
|
||||
return mVec128;
|
||||
}
|
||||
SIMD_FORCE_INLINE void set128(b3SimdFloat4 v128)
|
||||
B3_FORCE_INLINE void set128(b3SimdFloat4 v128)
|
||||
{
|
||||
mVec128 = v128;
|
||||
}
|
||||
@@ -77,19 +77,19 @@ public:
|
||||
#if defined(B3_USE_SSE) || defined(B3_USE_NEON)
|
||||
|
||||
// Set Vector
|
||||
SIMD_FORCE_INLINE b3QuadWord(const b3SimdFloat4 vec)
|
||||
B3_FORCE_INLINE b3QuadWord(const b3SimdFloat4 vec)
|
||||
{
|
||||
mVec128 = vec;
|
||||
}
|
||||
|
||||
// Copy constructor
|
||||
SIMD_FORCE_INLINE b3QuadWord(const b3QuadWord& rhs)
|
||||
B3_FORCE_INLINE b3QuadWord(const b3QuadWord& rhs)
|
||||
{
|
||||
mVec128 = rhs.mVec128;
|
||||
}
|
||||
|
||||
// Assignment Operator
|
||||
SIMD_FORCE_INLINE b3QuadWord&
|
||||
B3_FORCE_INLINE b3QuadWord&
|
||||
operator=(const b3QuadWord& v)
|
||||
{
|
||||
mVec128 = v.mVec128;
|
||||
@@ -100,29 +100,29 @@ public:
|
||||
#endif
|
||||
|
||||
/**@brief Return the x value */
|
||||
SIMD_FORCE_INLINE const b3Scalar& getX() const { return m_floats[0]; }
|
||||
B3_FORCE_INLINE const b3Scalar& getX() const { return m_floats[0]; }
|
||||
/**@brief Return the y value */
|
||||
SIMD_FORCE_INLINE const b3Scalar& getY() const { return m_floats[1]; }
|
||||
B3_FORCE_INLINE const b3Scalar& getY() const { return m_floats[1]; }
|
||||
/**@brief Return the z value */
|
||||
SIMD_FORCE_INLINE const b3Scalar& getZ() const { return m_floats[2]; }
|
||||
B3_FORCE_INLINE const b3Scalar& getZ() const { return m_floats[2]; }
|
||||
/**@brief Set the x value */
|
||||
SIMD_FORCE_INLINE void setX(b3Scalar _x) { m_floats[0] = _x;};
|
||||
B3_FORCE_INLINE void setX(b3Scalar _x) { m_floats[0] = _x;};
|
||||
/**@brief Set the y value */
|
||||
SIMD_FORCE_INLINE void setY(b3Scalar _y) { m_floats[1] = _y;};
|
||||
B3_FORCE_INLINE void setY(b3Scalar _y) { m_floats[1] = _y;};
|
||||
/**@brief Set the z value */
|
||||
SIMD_FORCE_INLINE void setZ(b3Scalar _z) { m_floats[2] = _z;};
|
||||
B3_FORCE_INLINE void setZ(b3Scalar _z) { m_floats[2] = _z;};
|
||||
/**@brief Set the w value */
|
||||
SIMD_FORCE_INLINE void setW(b3Scalar _w) { m_floats[3] = _w;};
|
||||
B3_FORCE_INLINE void setW(b3Scalar _w) { m_floats[3] = _w;};
|
||||
/**@brief Return the x value */
|
||||
|
||||
|
||||
//SIMD_FORCE_INLINE b3Scalar& operator[](int i) { return (&m_floats[0])[i]; }
|
||||
//SIMD_FORCE_INLINE const b3Scalar& operator[](int i) const { return (&m_floats[0])[i]; }
|
||||
//B3_FORCE_INLINE b3Scalar& operator[](int i) { return (&m_floats[0])[i]; }
|
||||
//B3_FORCE_INLINE const b3Scalar& operator[](int i) const { return (&m_floats[0])[i]; }
|
||||
///operator b3Scalar*() replaces operator[], using implicit conversion. We added operator != and operator == to avoid pointer comparisons.
|
||||
SIMD_FORCE_INLINE operator b3Scalar *() { return &m_floats[0]; }
|
||||
SIMD_FORCE_INLINE operator const b3Scalar *() const { return &m_floats[0]; }
|
||||
B3_FORCE_INLINE operator b3Scalar *() { return &m_floats[0]; }
|
||||
B3_FORCE_INLINE operator const b3Scalar *() const { return &m_floats[0]; }
|
||||
|
||||
SIMD_FORCE_INLINE bool operator==(const b3QuadWord& other) const
|
||||
B3_FORCE_INLINE bool operator==(const b3QuadWord& other) const
|
||||
{
|
||||
#ifdef B3_USE_SSE
|
||||
return (0xf == _mm_movemask_ps((__m128)_mm_cmpeq_ps(mVec128, other.mVec128)));
|
||||
@@ -134,7 +134,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE bool operator!=(const b3QuadWord& other) const
|
||||
B3_FORCE_INLINE bool operator!=(const b3QuadWord& other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
@@ -144,7 +144,7 @@ public:
|
||||
* @param y Value of y
|
||||
* @param z Value of z
|
||||
*/
|
||||
SIMD_FORCE_INLINE void setValue(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z)
|
||||
B3_FORCE_INLINE void setValue(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z)
|
||||
{
|
||||
m_floats[0]=_x;
|
||||
m_floats[1]=_y;
|
||||
@@ -165,7 +165,7 @@ public:
|
||||
* @param z Value of z
|
||||
* @param w Value of w
|
||||
*/
|
||||
SIMD_FORCE_INLINE void setValue(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z,const b3Scalar& _w)
|
||||
B3_FORCE_INLINE void setValue(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z,const b3Scalar& _w)
|
||||
{
|
||||
m_floats[0]=_x;
|
||||
m_floats[1]=_y;
|
||||
@@ -173,7 +173,7 @@ public:
|
||||
m_floats[3]=_w;
|
||||
}
|
||||
/**@brief No initialization constructor */
|
||||
SIMD_FORCE_INLINE b3QuadWord()
|
||||
B3_FORCE_INLINE b3QuadWord()
|
||||
// :m_floats[0](b3Scalar(0.)),m_floats[1](b3Scalar(0.)),m_floats[2](b3Scalar(0.)),m_floats[3](b3Scalar(0.))
|
||||
{
|
||||
}
|
||||
@@ -183,7 +183,7 @@ public:
|
||||
* @param y Value of y
|
||||
* @param z Value of z
|
||||
*/
|
||||
SIMD_FORCE_INLINE b3QuadWord(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z)
|
||||
B3_FORCE_INLINE b3QuadWord(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z)
|
||||
{
|
||||
m_floats[0] = _x, m_floats[1] = _y, m_floats[2] = _z, m_floats[3] = 0.0f;
|
||||
}
|
||||
@@ -194,7 +194,7 @@ public:
|
||||
* @param z Value of z
|
||||
* @param w Value of w
|
||||
*/
|
||||
SIMD_FORCE_INLINE b3QuadWord(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z,const b3Scalar& _w)
|
||||
B3_FORCE_INLINE b3QuadWord(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z,const b3Scalar& _w)
|
||||
{
|
||||
m_floats[0] = _x, m_floats[1] = _y, m_floats[2] = _z, m_floats[3] = _w;
|
||||
}
|
||||
@@ -202,7 +202,7 @@ public:
|
||||
/**@brief Set each element to the max of the current values and the values of another b3QuadWord
|
||||
* @param other The other b3QuadWord to compare with
|
||||
*/
|
||||
SIMD_FORCE_INLINE void setMax(const b3QuadWord& other)
|
||||
B3_FORCE_INLINE void setMax(const b3QuadWord& other)
|
||||
{
|
||||
#ifdef B3_USE_SSE
|
||||
mVec128 = _mm_max_ps(mVec128, other.mVec128);
|
||||
@@ -218,7 +218,7 @@ public:
|
||||
/**@brief Set each element to the min of the current values and the values of another b3QuadWord
|
||||
* @param other The other b3QuadWord to compare with
|
||||
*/
|
||||
SIMD_FORCE_INLINE void setMin(const b3QuadWord& other)
|
||||
B3_FORCE_INLINE void setMin(const b3QuadWord& other)
|
||||
{
|
||||
#ifdef B3_USE_SSE
|
||||
mVec128 = _mm_min_ps(mVec128, other.mVec128);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
Copyright (c) 2003-2013 Gino van den Bergen / Erwin Coumans http://bulletphysics.org
|
||||
|
||||
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.
|
||||
@@ -27,14 +27,14 @@ subject to the following restrictions:
|
||||
|
||||
#ifdef B3_USE_SSE
|
||||
|
||||
const __m128 ATTRIBUTE_ALIGNED16(vOnes) = {1.0f, 1.0f, 1.0f, 1.0f};
|
||||
const __m128 B3_ATTRIBUTE_ALIGNED16(vOnes) = {1.0f, 1.0f, 1.0f, 1.0f};
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(B3_USE_SSE) || defined(B3_USE_NEON)
|
||||
|
||||
const b3SimdFloat4 ATTRIBUTE_ALIGNED16(vQInv) = {-0.0f, -0.0f, -0.0f, +0.0f};
|
||||
const b3SimdFloat4 ATTRIBUTE_ALIGNED16(vPPPM) = {+0.0f, +0.0f, +0.0f, -0.0f};
|
||||
const b3SimdFloat4 B3_ATTRIBUTE_ALIGNED16(vQInv) = {-0.0f, -0.0f, -0.0f, +0.0f};
|
||||
const b3SimdFloat4 B3_ATTRIBUTE_ALIGNED16(vPPPM) = {+0.0f, +0.0f, +0.0f, -0.0f};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -46,19 +46,19 @@ public:
|
||||
|
||||
#if (defined(B3_USE_SSE_IN_API) && defined(B3_USE_SSE))|| defined(B3_USE_NEON)
|
||||
// Set Vector
|
||||
SIMD_FORCE_INLINE b3Quaternion(const b3SimdFloat4 vec)
|
||||
B3_FORCE_INLINE b3Quaternion(const b3SimdFloat4 vec)
|
||||
{
|
||||
mVec128 = vec;
|
||||
}
|
||||
|
||||
// Copy constructor
|
||||
SIMD_FORCE_INLINE b3Quaternion(const b3Quaternion& rhs)
|
||||
B3_FORCE_INLINE b3Quaternion(const b3Quaternion& rhs)
|
||||
{
|
||||
mVec128 = rhs.mVec128;
|
||||
}
|
||||
|
||||
// Assignment Operator
|
||||
SIMD_FORCE_INLINE b3Quaternion&
|
||||
B3_FORCE_INLINE b3Quaternion&
|
||||
operator=(const b3Quaternion& v)
|
||||
{
|
||||
mVec128 = v.mVec128;
|
||||
@@ -148,7 +148,7 @@ public:
|
||||
}
|
||||
/**@brief Add two quaternions
|
||||
* @param q The quaternion to add to this one */
|
||||
SIMD_FORCE_INLINE b3Quaternion& operator+=(const b3Quaternion& q)
|
||||
B3_FORCE_INLINE b3Quaternion& operator+=(const b3Quaternion& q)
|
||||
{
|
||||
#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||
mVec128 = _mm_add_ps(mVec128, q.mVec128);
|
||||
@@ -350,7 +350,7 @@ public:
|
||||
|
||||
/**@brief Return a scaled version of this quaternion
|
||||
* @param s The scale factor */
|
||||
SIMD_FORCE_INLINE b3Quaternion
|
||||
B3_FORCE_INLINE b3Quaternion
|
||||
operator*(const b3Scalar& s) const
|
||||
{
|
||||
#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||
@@ -406,7 +406,7 @@ public:
|
||||
{
|
||||
b3Scalar s_squared = 1.f-m_floats[3]*m_floats[3];
|
||||
|
||||
if (s_squared < b3Scalar(10.) * SIMD_EPSILON) //Check for divide by zero
|
||||
if (s_squared < b3Scalar(10.) * B3_EPSILON) //Check for divide by zero
|
||||
return b3Vector3(1.0, 0.0, 0.0); // Arbitrary
|
||||
b3Scalar s = 1.f/b3Sqrt(s_squared);
|
||||
return b3Vector3(m_floats[0] * s, m_floats[1] * s, m_floats[2] * s);
|
||||
@@ -426,7 +426,7 @@ public:
|
||||
|
||||
/**@brief Return the sum of this quaternion and the other
|
||||
* @param q2 The other quaternion */
|
||||
SIMD_FORCE_INLINE b3Quaternion
|
||||
B3_FORCE_INLINE b3Quaternion
|
||||
operator+(const b3Quaternion& q2) const
|
||||
{
|
||||
#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||
@@ -441,7 +441,7 @@ public:
|
||||
|
||||
/**@brief Return the difference between this quaternion and the other
|
||||
* @param q2 The other quaternion */
|
||||
SIMD_FORCE_INLINE b3Quaternion
|
||||
B3_FORCE_INLINE b3Quaternion
|
||||
operator-(const b3Quaternion& q2) const
|
||||
{
|
||||
#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||
@@ -456,7 +456,7 @@ public:
|
||||
|
||||
/**@brief Return the negative of this quaternion
|
||||
* This simply negates each element */
|
||||
SIMD_FORCE_INLINE b3Quaternion operator-() const
|
||||
B3_FORCE_INLINE b3Quaternion operator-() const
|
||||
{
|
||||
#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||
return b3Quaternion(_mm_xor_ps(mVec128, b3vMzeroMask));
|
||||
@@ -468,7 +468,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
/**@todo document this and it's use */
|
||||
SIMD_FORCE_INLINE b3Quaternion farthest( const b3Quaternion& qd) const
|
||||
B3_FORCE_INLINE b3Quaternion farthest( const b3Quaternion& qd) const
|
||||
{
|
||||
b3Quaternion diff,sum;
|
||||
diff = *this - qd;
|
||||
@@ -479,7 +479,7 @@ public:
|
||||
}
|
||||
|
||||
/**@todo document this and it's use */
|
||||
SIMD_FORCE_INLINE b3Quaternion nearest( const b3Quaternion& qd) const
|
||||
B3_FORCE_INLINE b3Quaternion nearest( const b3Quaternion& qd) const
|
||||
{
|
||||
b3Quaternion diff,sum;
|
||||
diff = *this - qd;
|
||||
@@ -528,7 +528,7 @@ public:
|
||||
return identityQuat;
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE const b3Scalar& getW() const { return m_floats[3]; }
|
||||
B3_FORCE_INLINE const b3Scalar& getW() const { return m_floats[3]; }
|
||||
|
||||
|
||||
};
|
||||
@@ -538,7 +538,7 @@ public:
|
||||
|
||||
|
||||
/**@brief Return the product of two quaternions */
|
||||
SIMD_FORCE_INLINE b3Quaternion
|
||||
B3_FORCE_INLINE b3Quaternion
|
||||
operator*(const b3Quaternion& q1, const b3Quaternion& q2)
|
||||
{
|
||||
#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||
@@ -626,7 +626,7 @@ operator*(const b3Quaternion& q1, const b3Quaternion& q2)
|
||||
#endif
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE b3Quaternion
|
||||
B3_FORCE_INLINE b3Quaternion
|
||||
operator*(const b3Quaternion& q, const b3Vector3& w)
|
||||
{
|
||||
#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||
@@ -709,7 +709,7 @@ operator*(const b3Quaternion& q, const b3Vector3& w)
|
||||
#endif
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE b3Quaternion
|
||||
B3_FORCE_INLINE b3Quaternion
|
||||
operator*(const b3Vector3& w, const b3Quaternion& q)
|
||||
{
|
||||
#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||
@@ -793,30 +793,30 @@ operator*(const b3Vector3& w, const b3Quaternion& q)
|
||||
}
|
||||
|
||||
/**@brief Calculate the dot product between two quaternions */
|
||||
SIMD_FORCE_INLINE b3Scalar
|
||||
dot(const b3Quaternion& q1, const b3Quaternion& q2)
|
||||
B3_FORCE_INLINE b3Scalar
|
||||
b3Dot(const b3Quaternion& q1, const b3Quaternion& q2)
|
||||
{
|
||||
return q1.dot(q2);
|
||||
}
|
||||
|
||||
|
||||
/**@brief Return the length of a quaternion */
|
||||
SIMD_FORCE_INLINE b3Scalar
|
||||
length(const b3Quaternion& q)
|
||||
B3_FORCE_INLINE b3Scalar
|
||||
b3Length(const b3Quaternion& q)
|
||||
{
|
||||
return q.length();
|
||||
}
|
||||
|
||||
/**@brief Return the angle between two quaternions*/
|
||||
SIMD_FORCE_INLINE b3Scalar
|
||||
B3_FORCE_INLINE b3Scalar
|
||||
b3Angle(const b3Quaternion& q1, const b3Quaternion& q2)
|
||||
{
|
||||
return q1.angle(q2);
|
||||
}
|
||||
|
||||
/**@brief Return the inverse of a quaternion*/
|
||||
SIMD_FORCE_INLINE b3Quaternion
|
||||
inverse(const b3Quaternion& q)
|
||||
B3_FORCE_INLINE b3Quaternion
|
||||
b3Inverse(const b3Quaternion& q)
|
||||
{
|
||||
return q.inverse();
|
||||
}
|
||||
@@ -826,14 +826,14 @@ inverse(const b3Quaternion& q)
|
||||
* @param q2 The second quaternion
|
||||
* @param t The ration between q1 and q2. t = 0 return q1, t=1 returns q2
|
||||
* Slerp assumes constant velocity between positions. */
|
||||
SIMD_FORCE_INLINE b3Quaternion
|
||||
slerp(const b3Quaternion& q1, const b3Quaternion& q2, const b3Scalar& t)
|
||||
B3_FORCE_INLINE b3Quaternion
|
||||
b3Slerp(const b3Quaternion& q1, const b3Quaternion& q2, const b3Scalar& t)
|
||||
{
|
||||
return q1.slerp(q2, t);
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE b3Vector3
|
||||
quatRotate(const b3Quaternion& rotation, const b3Vector3& v)
|
||||
B3_FORCE_INLINE b3Vector3
|
||||
b3QuatRotate(const b3Quaternion& rotation, const b3Vector3& v)
|
||||
{
|
||||
b3Quaternion q = rotation * v;
|
||||
q *= rotation.inverse();
|
||||
@@ -846,13 +846,13 @@ quatRotate(const b3Quaternion& rotation, const b3Vector3& v)
|
||||
#endif
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE b3Quaternion
|
||||
shortestArcQuat(const b3Vector3& v0, const b3Vector3& v1) // Game Programming Gems 2.10. make sure v0,v1 are normalized
|
||||
B3_FORCE_INLINE b3Quaternion
|
||||
b3ShortestArcQuat(const b3Vector3& v0, const b3Vector3& v1) // Game Programming Gems 2.10. make sure v0,v1 are normalized
|
||||
{
|
||||
b3Vector3 c = v0.cross(v1);
|
||||
b3Scalar d = v0.dot(v1);
|
||||
|
||||
if (d < -1.0 + SIMD_EPSILON)
|
||||
if (d < -1.0 + B3_EPSILON)
|
||||
{
|
||||
b3Vector3 n,unused;
|
||||
b3PlaneSpace1(v0,n,unused);
|
||||
@@ -865,12 +865,12 @@ shortestArcQuat(const b3Vector3& v0, const b3Vector3& v1) // Game Programming Ge
|
||||
return b3Quaternion(c.getX()*rs,c.getY()*rs,c.getZ()*rs,s * 0.5f);
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE b3Quaternion
|
||||
shortestArcQuatNormalize2(b3Vector3& v0,b3Vector3& v1)
|
||||
B3_FORCE_INLINE b3Quaternion
|
||||
b3ShortestArcQuatNormalize2(b3Vector3& v0,b3Vector3& v1)
|
||||
{
|
||||
v0.normalize();
|
||||
v1.normalize();
|
||||
return shortestArcQuat(v0,v1);
|
||||
return b3ShortestArcQuat(v0,v1);
|
||||
}
|
||||
|
||||
#endif //B3_SIMD__QUATERNION_H_
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
/*
|
||||
Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
***************************************************************************************************
|
||||
@@ -14,11 +28,12 @@
|
||||
// Ogre (www.ogre3d.org).
|
||||
|
||||
#include "b3Quickprof.h"
|
||||
#include "b3MinMax.h"
|
||||
|
||||
#ifndef B3_NO_PROFILE
|
||||
|
||||
|
||||
static b3Clock gProfileClock;
|
||||
static b3Clock b3s_profileClock;
|
||||
|
||||
|
||||
#ifdef __CELLOS_LV2__
|
||||
@@ -52,7 +67,7 @@ static b3Clock gProfileClock;
|
||||
#include <sys/time.h>
|
||||
#endif //_WIN32
|
||||
|
||||
#define mymin(a,b) (a > b ? a : b)
|
||||
|
||||
|
||||
struct b3ClockData
|
||||
{
|
||||
@@ -141,7 +156,7 @@ unsigned long int b3Clock::getTimeMilliseconds()
|
||||
if (msecOff < -100 || msecOff > 100)
|
||||
{
|
||||
// Adjust the starting time forwards.
|
||||
LONGLONG msecAdjustment = mymin(msecOff *
|
||||
LONGLONG msecAdjustment = b3Min(msecOff *
|
||||
m_data->mClockFrequency.QuadPart / 1000, elapsedTime -
|
||||
m_data->mPrevElapsedTime);
|
||||
m_data->mStartTime.QuadPart += msecAdjustment;
|
||||
@@ -199,7 +214,7 @@ unsigned long int b3Clock::getTimeMicroseconds()
|
||||
if (msecOff < -100 || msecOff > 100)
|
||||
{
|
||||
// Adjust the starting time forwards.
|
||||
LONGLONG msecAdjustment = mymin(msecOff *
|
||||
LONGLONG msecAdjustment = b3Min(msecOff *
|
||||
m_data->mClockFrequency.QuadPart / 1000, elapsedTime -
|
||||
m_data->mPrevElapsedTime);
|
||||
m_data->mStartTime.QuadPart += msecAdjustment;
|
||||
@@ -239,12 +254,12 @@ unsigned long int b3Clock::getTimeMicroseconds()
|
||||
|
||||
|
||||
|
||||
inline void Profile_Get_Ticks(unsigned long int * ticks)
|
||||
inline void b3Profile_Get_Ticks(unsigned long int * ticks)
|
||||
{
|
||||
*ticks = gProfileClock.getTimeMicroseconds();
|
||||
*ticks = b3s_profileClock.getTimeMicroseconds();
|
||||
}
|
||||
|
||||
inline float Profile_Get_Tick_Rate(void)
|
||||
inline float b3Profile_Get_Tick_Rate(void)
|
||||
{
|
||||
// return 1000000.f;
|
||||
return 1000.f;
|
||||
@@ -255,7 +270,7 @@ inline float Profile_Get_Tick_Rate(void)
|
||||
|
||||
/***************************************************************************************************
|
||||
**
|
||||
** CProfileNode
|
||||
** b3ProfileNode
|
||||
**
|
||||
***************************************************************************************************/
|
||||
|
||||
@@ -268,7 +283,7 @@ inline float Profile_Get_Tick_Rate(void)
|
||||
* The name is assumed to be a static pointer, only the pointer is stored and compared for *
|
||||
* efficiency reasons. *
|
||||
*=============================================================================================*/
|
||||
CProfileNode::CProfileNode( const char * name, CProfileNode * parent ) :
|
||||
b3ProfileNode::b3ProfileNode( const char * name, b3ProfileNode * parent ) :
|
||||
Name( name ),
|
||||
TotalCalls( 0 ),
|
||||
TotalTime( 0 ),
|
||||
@@ -283,7 +298,7 @@ CProfileNode::CProfileNode( const char * name, CProfileNode * parent ) :
|
||||
}
|
||||
|
||||
|
||||
void CProfileNode::CleanupMemory()
|
||||
void b3ProfileNode::CleanupMemory()
|
||||
{
|
||||
delete ( Child);
|
||||
Child = NULL;
|
||||
@@ -291,7 +306,7 @@ void CProfileNode::CleanupMemory()
|
||||
Sibling = NULL;
|
||||
}
|
||||
|
||||
CProfileNode::~CProfileNode( void )
|
||||
b3ProfileNode::~b3ProfileNode( void )
|
||||
{
|
||||
delete ( Child);
|
||||
delete ( Sibling);
|
||||
@@ -306,10 +321,10 @@ CProfileNode::~CProfileNode( void )
|
||||
* All profile names are assumed to be static strings so this function uses pointer compares *
|
||||
* to find the named node. *
|
||||
*=============================================================================================*/
|
||||
CProfileNode * CProfileNode::Get_Sub_Node( const char * name )
|
||||
b3ProfileNode * b3ProfileNode::Get_Sub_Node( const char * name )
|
||||
{
|
||||
// Try to find this sub node
|
||||
CProfileNode * child = Child;
|
||||
b3ProfileNode * child = Child;
|
||||
while ( child ) {
|
||||
if ( child->Name == name ) {
|
||||
return child;
|
||||
@@ -319,14 +334,14 @@ CProfileNode * CProfileNode::Get_Sub_Node( const char * name )
|
||||
|
||||
// We didn't find it, so add it
|
||||
|
||||
CProfileNode * node = new CProfileNode( name, this );
|
||||
b3ProfileNode * node = new b3ProfileNode( name, this );
|
||||
node->Sibling = Child;
|
||||
Child = node;
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
void CProfileNode::Reset( void )
|
||||
void b3ProfileNode::Reset( void )
|
||||
{
|
||||
TotalCalls = 0;
|
||||
TotalTime = 0.0f;
|
||||
@@ -341,22 +356,22 @@ void CProfileNode::Reset( void )
|
||||
}
|
||||
|
||||
|
||||
void CProfileNode::Call( void )
|
||||
void b3ProfileNode::Call( void )
|
||||
{
|
||||
TotalCalls++;
|
||||
if (RecursionCounter++ == 0) {
|
||||
Profile_Get_Ticks(&StartTime);
|
||||
b3Profile_Get_Ticks(&StartTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CProfileNode::Return( void )
|
||||
bool b3ProfileNode::Return( void )
|
||||
{
|
||||
if ( --RecursionCounter == 0 && TotalCalls != 0 ) {
|
||||
unsigned long int time;
|
||||
Profile_Get_Ticks(&time);
|
||||
b3Profile_Get_Ticks(&time);
|
||||
time-=StartTime;
|
||||
TotalTime += (float)time / Profile_Get_Tick_Rate();
|
||||
TotalTime += (float)time / b3Profile_Get_Tick_Rate();
|
||||
}
|
||||
return ( RecursionCounter == 0 );
|
||||
}
|
||||
@@ -364,35 +379,35 @@ bool CProfileNode::Return( void )
|
||||
|
||||
/***************************************************************************************************
|
||||
**
|
||||
** CProfileIterator
|
||||
** b3ProfileIterator
|
||||
**
|
||||
***************************************************************************************************/
|
||||
CProfileIterator::CProfileIterator( CProfileNode * start )
|
||||
b3ProfileIterator::b3ProfileIterator( b3ProfileNode * start )
|
||||
{
|
||||
CurrentParent = start;
|
||||
CurrentChild = CurrentParent->Get_Child();
|
||||
}
|
||||
|
||||
|
||||
void CProfileIterator::First(void)
|
||||
void b3ProfileIterator::First(void)
|
||||
{
|
||||
CurrentChild = CurrentParent->Get_Child();
|
||||
}
|
||||
|
||||
|
||||
void CProfileIterator::Next(void)
|
||||
void b3ProfileIterator::Next(void)
|
||||
{
|
||||
CurrentChild = CurrentChild->Get_Sibling();
|
||||
}
|
||||
|
||||
|
||||
bool CProfileIterator::Is_Done(void)
|
||||
bool b3ProfileIterator::Is_Done(void)
|
||||
{
|
||||
return CurrentChild == NULL;
|
||||
}
|
||||
|
||||
|
||||
void CProfileIterator::Enter_Child( int index )
|
||||
void b3ProfileIterator::Enter_Child( int index )
|
||||
{
|
||||
CurrentChild = CurrentParent->Get_Child();
|
||||
while ( (CurrentChild != NULL) && (index != 0) ) {
|
||||
@@ -407,7 +422,7 @@ void CProfileIterator::Enter_Child( int index )
|
||||
}
|
||||
|
||||
|
||||
void CProfileIterator::Enter_Parent( void )
|
||||
void b3ProfileIterator::Enter_Parent( void )
|
||||
{
|
||||
if ( CurrentParent->Get_Parent() != NULL ) {
|
||||
CurrentParent = CurrentParent->Get_Parent();
|
||||
@@ -418,18 +433,18 @@ void CProfileIterator::Enter_Parent( void )
|
||||
|
||||
/***************************************************************************************************
|
||||
**
|
||||
** CProfileManager
|
||||
** b3ProfileManager
|
||||
**
|
||||
***************************************************************************************************/
|
||||
|
||||
CProfileNode CProfileManager::Root( "Root", NULL );
|
||||
CProfileNode * CProfileManager::CurrentNode = &CProfileManager::Root;
|
||||
int CProfileManager::FrameCounter = 0;
|
||||
unsigned long int CProfileManager::ResetTime = 0;
|
||||
b3ProfileNode b3ProfileManager::Root( "Root", NULL );
|
||||
b3ProfileNode * b3ProfileManager::CurrentNode = &b3ProfileManager::Root;
|
||||
int b3ProfileManager::FrameCounter = 0;
|
||||
unsigned long int b3ProfileManager::ResetTime = 0;
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* CProfileManager::Start_Profile -- Begin a named profile *
|
||||
* b3ProfileManager::Start_Profile -- Begin a named profile *
|
||||
* *
|
||||
* Steps one level deeper into the tree, if a child already exists with the specified name *
|
||||
* then it accumulates the profiling; otherwise a new child node is added to the profile tree. *
|
||||
@@ -441,7 +456,7 @@ unsigned long int CProfileManager::ResetTime = 0;
|
||||
* The string used is assumed to be a static string; pointer compares are used throughout *
|
||||
* the profiling code for efficiency. *
|
||||
*=============================================================================================*/
|
||||
void CProfileManager::Start_Profile( const char * name )
|
||||
void b3ProfileManager::Start_Profile( const char * name )
|
||||
{
|
||||
if (name != CurrentNode->Get_Name()) {
|
||||
CurrentNode = CurrentNode->Get_Sub_Node( name );
|
||||
@@ -452,9 +467,9 @@ void CProfileManager::Start_Profile( const char * name )
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* CProfileManager::Stop_Profile -- Stop timing and record the results. *
|
||||
* b3ProfileManager::Stop_Profile -- Stop timing and record the results. *
|
||||
*=============================================================================================*/
|
||||
void CProfileManager::Stop_Profile( void )
|
||||
void b3ProfileManager::Stop_Profile( void )
|
||||
{
|
||||
// Return will indicate whether we should back up to our parent (we may
|
||||
// be profiling a recursive function)
|
||||
@@ -465,51 +480,51 @@ void CProfileManager::Stop_Profile( void )
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* CProfileManager::Reset -- Reset the contents of the profiling system *
|
||||
* b3ProfileManager::Reset -- Reset the contents of the profiling system *
|
||||
* *
|
||||
* This resets everything except for the tree structure. All of the timing data is reset. *
|
||||
*=============================================================================================*/
|
||||
void CProfileManager::Reset( void )
|
||||
void b3ProfileManager::Reset( void )
|
||||
{
|
||||
gProfileClock.reset();
|
||||
b3s_profileClock.reset();
|
||||
Root.Reset();
|
||||
Root.Call();
|
||||
FrameCounter = 0;
|
||||
Profile_Get_Ticks(&ResetTime);
|
||||
b3Profile_Get_Ticks(&ResetTime);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* CProfileManager::Increment_Frame_Counter -- Increment the frame counter *
|
||||
* b3ProfileManager::Increment_Frame_Counter -- Increment the frame counter *
|
||||
*=============================================================================================*/
|
||||
void CProfileManager::Increment_Frame_Counter( void )
|
||||
void b3ProfileManager::Increment_Frame_Counter( void )
|
||||
{
|
||||
FrameCounter++;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* CProfileManager::Get_Time_Since_Reset -- returns the elapsed time since last reset *
|
||||
* b3ProfileManager::Get_Time_Since_Reset -- returns the elapsed time since last reset *
|
||||
*=============================================================================================*/
|
||||
float CProfileManager::Get_Time_Since_Reset( void )
|
||||
float b3ProfileManager::Get_Time_Since_Reset( void )
|
||||
{
|
||||
unsigned long int time;
|
||||
Profile_Get_Ticks(&time);
|
||||
b3Profile_Get_Ticks(&time);
|
||||
time -= ResetTime;
|
||||
return (float)time / Profile_Get_Tick_Rate();
|
||||
return (float)time / b3Profile_Get_Tick_Rate();
|
||||
}
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
void CProfileManager::dumpRecursive(CProfileIterator* profileIterator, int spacing)
|
||||
void b3ProfileManager::dumpRecursive(b3ProfileIterator* profileIterator, int spacing)
|
||||
{
|
||||
profileIterator->First();
|
||||
if (profileIterator->Is_Done())
|
||||
return;
|
||||
|
||||
float accumulated_time=0,parent_time = profileIterator->Is_Root() ? CProfileManager::Get_Time_Since_Reset() : profileIterator->Get_Current_Parent_Total_Time();
|
||||
float accumulated_time=0,parent_time = profileIterator->Is_Root() ? b3ProfileManager::Get_Time_Since_Reset() : profileIterator->Get_Current_Parent_Total_Time();
|
||||
int i;
|
||||
int frames_since_reset = CProfileManager::Get_Frame_Count_Since_Reset();
|
||||
int frames_since_reset = b3ProfileManager::Get_Frame_Count_Since_Reset();
|
||||
for (i=0;i<spacing;i++) printf(".");
|
||||
printf("----------------------------------\n");
|
||||
for (i=0;i<spacing;i++) printf(".");
|
||||
@@ -524,7 +539,7 @@ void CProfileManager::dumpRecursive(CProfileIterator* profileIterator, int spaci
|
||||
numChildren++;
|
||||
float current_total_time = profileIterator->Get_Current_Total_Time();
|
||||
accumulated_time += current_total_time;
|
||||
float fraction = parent_time > SIMD_EPSILON ? (current_total_time / parent_time) * 100 : 0.f;
|
||||
float fraction = parent_time > B3_EPSILON ? (current_total_time / parent_time) * 100 : 0.f;
|
||||
{
|
||||
int i; for (i=0;i<spacing;i++) printf(".");
|
||||
}
|
||||
@@ -538,7 +553,7 @@ void CProfileManager::dumpRecursive(CProfileIterator* profileIterator, int spaci
|
||||
printf("what's wrong\n");
|
||||
}
|
||||
for (i=0;i<spacing;i++) printf(".");
|
||||
printf("%s (%.3f %%) :: %.3f ms\n", "Unaccounted:",parent_time > SIMD_EPSILON ? ((parent_time - accumulated_time) / parent_time) * 100 : 0.f, parent_time - accumulated_time);
|
||||
printf("%s (%.3f %%) :: %.3f ms\n", "Unaccounted:",parent_time > B3_EPSILON ? ((parent_time - accumulated_time) / parent_time) * 100 : 0.f, parent_time - accumulated_time);
|
||||
|
||||
for (i=0;i<numChildren;i++)
|
||||
{
|
||||
@@ -550,14 +565,14 @@ void CProfileManager::dumpRecursive(CProfileIterator* profileIterator, int spaci
|
||||
|
||||
|
||||
|
||||
void CProfileManager::dumpAll()
|
||||
void b3ProfileManager::dumpAll()
|
||||
{
|
||||
CProfileIterator* profileIterator = 0;
|
||||
profileIterator = CProfileManager::Get_Iterator();
|
||||
b3ProfileIterator* profileIterator = 0;
|
||||
profileIterator = b3ProfileManager::Get_Iterator();
|
||||
|
||||
dumpRecursive(profileIterator,0);
|
||||
|
||||
CProfileManager::Release_Iterator(profileIterator);
|
||||
b3ProfileManager::Release_Iterator(profileIterator);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
/*
|
||||
Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
/***************************************************************************************************
|
||||
**
|
||||
@@ -27,9 +40,9 @@
|
||||
|
||||
|
||||
|
||||
#define USE_BT_CLOCK 1
|
||||
#define B3_USE_CLOCK 1
|
||||
|
||||
#ifdef USE_BT_CLOCK
|
||||
#ifdef B3_USE_CLOCK
|
||||
|
||||
///The b3Clock is a portable basic clock that measures accurate time in seconds, use for profiling.
|
||||
class b3Clock
|
||||
@@ -56,23 +69,23 @@ private:
|
||||
struct b3ClockData* m_data;
|
||||
};
|
||||
|
||||
#endif //USE_BT_CLOCK
|
||||
#endif //B3_USE_CLOCK
|
||||
|
||||
|
||||
|
||||
|
||||
///A node in the Profile Hierarchy Tree
|
||||
class CProfileNode {
|
||||
class b3ProfileNode {
|
||||
|
||||
public:
|
||||
CProfileNode( const char * name, CProfileNode * parent );
|
||||
~CProfileNode( void );
|
||||
b3ProfileNode( const char * name, b3ProfileNode * parent );
|
||||
~b3ProfileNode( void );
|
||||
|
||||
CProfileNode * Get_Sub_Node( const char * name );
|
||||
b3ProfileNode * Get_Sub_Node( const char * name );
|
||||
|
||||
CProfileNode * Get_Parent( void ) { return Parent; }
|
||||
CProfileNode * Get_Sibling( void ) { return Sibling; }
|
||||
CProfileNode * Get_Child( void ) { return Child; }
|
||||
b3ProfileNode * Get_Parent( void ) { return Parent; }
|
||||
b3ProfileNode * Get_Sibling( void ) { return Sibling; }
|
||||
b3ProfileNode * Get_Child( void ) { return Child; }
|
||||
|
||||
void CleanupMemory();
|
||||
void Reset( void );
|
||||
@@ -92,14 +105,14 @@ protected:
|
||||
unsigned long int StartTime;
|
||||
int RecursionCounter;
|
||||
|
||||
CProfileNode * Parent;
|
||||
CProfileNode * Child;
|
||||
CProfileNode * Sibling;
|
||||
b3ProfileNode * Parent;
|
||||
b3ProfileNode * Child;
|
||||
b3ProfileNode * Sibling;
|
||||
void* m_userPtr;
|
||||
};
|
||||
|
||||
///An iterator to navigate through the tree
|
||||
class CProfileIterator
|
||||
class b3ProfileIterator
|
||||
{
|
||||
public:
|
||||
// Access all the children of the current parent
|
||||
@@ -128,17 +141,17 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
CProfileNode * CurrentParent;
|
||||
CProfileNode * CurrentChild;
|
||||
b3ProfileNode * CurrentParent;
|
||||
b3ProfileNode * CurrentChild;
|
||||
|
||||
|
||||
CProfileIterator( CProfileNode * start );
|
||||
friend class CProfileManager;
|
||||
b3ProfileIterator( b3ProfileNode * start );
|
||||
friend class b3ProfileManager;
|
||||
};
|
||||
|
||||
|
||||
///The Manager for the Profile system
|
||||
class CProfileManager {
|
||||
class b3ProfileManager {
|
||||
public:
|
||||
static void Start_Profile( const char * name );
|
||||
static void Stop_Profile( void );
|
||||
@@ -153,20 +166,20 @@ public:
|
||||
static int Get_Frame_Count_Since_Reset( void ) { return FrameCounter; }
|
||||
static float Get_Time_Since_Reset( void );
|
||||
|
||||
static CProfileIterator * Get_Iterator( void )
|
||||
static b3ProfileIterator * Get_Iterator( void )
|
||||
{
|
||||
|
||||
return new CProfileIterator( &Root );
|
||||
return new b3ProfileIterator( &Root );
|
||||
}
|
||||
static void Release_Iterator( CProfileIterator * iterator ) { delete ( iterator); }
|
||||
static void Release_Iterator( b3ProfileIterator * iterator ) { delete ( iterator); }
|
||||
|
||||
static void dumpRecursive(CProfileIterator* profileIterator, int spacing);
|
||||
static void dumpRecursive(b3ProfileIterator* profileIterator, int spacing);
|
||||
|
||||
static void dumpAll();
|
||||
|
||||
private:
|
||||
static CProfileNode Root;
|
||||
static CProfileNode * CurrentNode;
|
||||
static b3ProfileNode Root;
|
||||
static b3ProfileNode * CurrentNode;
|
||||
static int FrameCounter;
|
||||
static unsigned long int ResetTime;
|
||||
};
|
||||
@@ -174,21 +187,21 @@ private:
|
||||
|
||||
///ProfileSampleClass is a simple way to profile a function's scope
|
||||
///Use the B3_PROFILE macro at the start of scope to time
|
||||
class CProfileSample {
|
||||
class b3ProfileSample {
|
||||
public:
|
||||
CProfileSample( const char * name )
|
||||
b3ProfileSample( const char * name )
|
||||
{
|
||||
CProfileManager::Start_Profile( name );
|
||||
b3ProfileManager::Start_Profile( name );
|
||||
}
|
||||
|
||||
~CProfileSample( void )
|
||||
~b3ProfileSample( void )
|
||||
{
|
||||
CProfileManager::Stop_Profile();
|
||||
b3ProfileManager::Stop_Profile();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#define B3_PROFILE( name ) CProfileSample __profile( name )
|
||||
#define B3_PROFILE( name ) b3ProfileSample __profile( name )
|
||||
|
||||
#else
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
Copyright (c) 2003-2013 Gino van den Bergen / Erwin Coumans http://bulletphysics.org
|
||||
|
||||
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.
|
||||
@@ -22,19 +22,19 @@ subject to the following restrictions:
|
||||
#include <limits.h>
|
||||
#include <mt19937.h>
|
||||
|
||||
#define GEN_RAND_MAX UINT_MAX
|
||||
#define B3_RAND_MAX UINT_MAX
|
||||
|
||||
SIMD_FORCE_INLINE void GEN_srand(unsigned int seed) { init_genrand(seed); }
|
||||
SIMD_FORCE_INLINE unsigned int GEN_rand() { return genrand_int32(); }
|
||||
B3_FORCE_INLINE void b3Srand(unsigned int seed) { init_genrand(seed); }
|
||||
B3_FORCE_INLINE unsigned int b3rand() { return genrand_int32(); }
|
||||
|
||||
#else
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define GEN_RAND_MAX RAND_MAX
|
||||
#define B3_RAND_MAX RAND_MAX
|
||||
|
||||
SIMD_FORCE_INLINE void GEN_srand(unsigned int seed) { srand(seed); }
|
||||
SIMD_FORCE_INLINE unsigned int GEN_rand() { return rand(); }
|
||||
B3_FORCE_INLINE void b3Srand(unsigned int seed) { srand(seed); }
|
||||
B3_FORCE_INLINE unsigned int b3rand() { return rand(); }
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2003-2009 Erwin Coumans http://bullet.googlecode.com
|
||||
Copyright (c) 2003-2013 Gino van den Bergen / Erwin Coumans http://bulletphysics.org
|
||||
|
||||
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.
|
||||
@@ -44,10 +44,10 @@ inline int b3GetVersion()
|
||||
|
||||
#if defined(__MINGW32__) || defined(__CYGWIN__) || (defined (_MSC_VER) && _MSC_VER < 1300)
|
||||
|
||||
#define SIMD_FORCE_INLINE inline
|
||||
#define ATTRIBUTE_ALIGNED16(a) a
|
||||
#define ATTRIBUTE_ALIGNED64(a) a
|
||||
#define ATTRIBUTE_ALIGNED128(a) a
|
||||
#define B3_FORCE_INLINE inline
|
||||
#define B3_ATTRIBUTE_ALIGNED16(a) a
|
||||
#define B3_ATTRIBUTE_ALIGNED64(a) a
|
||||
#define B3_ATTRIBUTE_ALIGNED128(a) a
|
||||
#else
|
||||
//#define B3_HAS_ALIGNED_ALLOCATOR
|
||||
#pragma warning(disable : 4324) // disable padding warning
|
||||
@@ -55,10 +55,10 @@ inline int b3GetVersion()
|
||||
// #pragma warning(disable:4996) //Turn off warnings about deprecated C routines
|
||||
// #pragma warning(disable:4786) // Disable the "debug name too long" warning
|
||||
|
||||
#define SIMD_FORCE_INLINE __forceinline
|
||||
#define ATTRIBUTE_ALIGNED16(a) __declspec(align(16)) a
|
||||
#define ATTRIBUTE_ALIGNED64(a) __declspec(align(64)) a
|
||||
#define ATTRIBUTE_ALIGNED128(a) __declspec (align(128)) a
|
||||
#define B3_FORCE_INLINE __forceinline
|
||||
#define B3_ATTRIBUTE_ALIGNED16(a) __declspec(align(16)) a
|
||||
#define B3_ATTRIBUTE_ALIGNED64(a) __declspec(align(64)) a
|
||||
#define B3_ATTRIBUTE_ALIGNED128(a) __declspec (align(128)) a
|
||||
#ifdef _XBOX
|
||||
#define B3_USE_VMX128
|
||||
|
||||
@@ -105,10 +105,10 @@ inline int b3GetVersion()
|
||||
#else
|
||||
|
||||
#if defined (__CELLOS_LV2__)
|
||||
#define SIMD_FORCE_INLINE inline __attribute__((always_inline))
|
||||
#define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))
|
||||
#define ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64)))
|
||||
#define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128)))
|
||||
#define B3_FORCE_INLINE inline __attribute__((always_inline))
|
||||
#define B3_ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))
|
||||
#define B3_ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64)))
|
||||
#define B3_ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128)))
|
||||
#ifndef assert
|
||||
#include <assert.h>
|
||||
#endif
|
||||
@@ -134,10 +134,10 @@ inline int b3GetVersion()
|
||||
|
||||
#ifdef USE_LIBSPE2
|
||||
|
||||
#define SIMD_FORCE_INLINE __inline
|
||||
#define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))
|
||||
#define ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64)))
|
||||
#define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128)))
|
||||
#define B3_FORCE_INLINE __inline
|
||||
#define B3_ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))
|
||||
#define B3_ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64)))
|
||||
#define B3_ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128)))
|
||||
#ifndef assert
|
||||
#include <assert.h>
|
||||
#endif
|
||||
@@ -185,11 +185,11 @@ inline int b3GetVersion()
|
||||
#endif //__clang__
|
||||
#endif//__arm__
|
||||
|
||||
#define SIMD_FORCE_INLINE inline __attribute__ ((always_inline))
|
||||
#define B3_FORCE_INLINE inline __attribute__ ((always_inline))
|
||||
///@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)))
|
||||
#define B3_ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))
|
||||
#define B3_ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64)))
|
||||
#define B3_ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128)))
|
||||
#ifndef assert
|
||||
#include <assert.h>
|
||||
#endif
|
||||
@@ -219,14 +219,14 @@ inline int b3GetVersion()
|
||||
|
||||
#else
|
||||
|
||||
#define SIMD_FORCE_INLINE inline
|
||||
#define B3_FORCE_INLINE inline
|
||||
///@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)))
|
||||
#define ATTRIBUTE_ALIGNED16(a) a
|
||||
#define ATTRIBUTE_ALIGNED64(a) a
|
||||
#define ATTRIBUTE_ALIGNED128(a) a
|
||||
///#define B3_ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))
|
||||
///#define B3_ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64)))
|
||||
///#define B3_ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128)))
|
||||
#define B3_ATTRIBUTE_ALIGNED16(a) a
|
||||
#define B3_ATTRIBUTE_ALIGNED64(a) a
|
||||
#define B3_ATTRIBUTE_ALIGNED128(a) a
|
||||
#ifndef assert
|
||||
#include <assert.h>
|
||||
#endif
|
||||
@@ -326,36 +326,36 @@ typedef float32x4_t b3SimdFloat4;
|
||||
|
||||
|
||||
#define B3_DECLARE_ALIGNED_ALLOCATOR() \
|
||||
SIMD_FORCE_INLINE void* operator new(size_t sizeInBytes) { return b3AlignedAlloc(sizeInBytes,16); } \
|
||||
SIMD_FORCE_INLINE void operator delete(void* ptr) { b3AlignedFree(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 b3AlignedAlloc(sizeInBytes,16); } \
|
||||
SIMD_FORCE_INLINE void operator delete[](void* ptr) { b3AlignedFree(ptr); } \
|
||||
SIMD_FORCE_INLINE void* operator new[](size_t, void* ptr) { return ptr; } \
|
||||
SIMD_FORCE_INLINE void operator delete[](void*, void*) { } \
|
||||
B3_FORCE_INLINE void* operator new(size_t sizeInBytes) { return b3AlignedAlloc(sizeInBytes,16); } \
|
||||
B3_FORCE_INLINE void operator delete(void* ptr) { b3AlignedFree(ptr); } \
|
||||
B3_FORCE_INLINE void* operator new(size_t, void* ptr) { return ptr; } \
|
||||
B3_FORCE_INLINE void operator delete(void*, void*) { } \
|
||||
B3_FORCE_INLINE void* operator new[](size_t sizeInBytes) { return b3AlignedAlloc(sizeInBytes,16); } \
|
||||
B3_FORCE_INLINE void operator delete[](void* ptr) { b3AlignedFree(ptr); } \
|
||||
B3_FORCE_INLINE void* operator new[](size_t, void* ptr) { return ptr; } \
|
||||
B3_FORCE_INLINE void operator delete[](void*, void*) { } \
|
||||
|
||||
|
||||
|
||||
#if defined(B3_USE_DOUBLE_PRECISION) || defined(B3_FORCE_DOUBLE_FUNCTIONS)
|
||||
|
||||
SIMD_FORCE_INLINE b3Scalar b3Sqrt(b3Scalar x) { return sqrt(x); }
|
||||
SIMD_FORCE_INLINE b3Scalar b3Fabs(b3Scalar x) { return fabs(x); }
|
||||
SIMD_FORCE_INLINE b3Scalar b3Cos(b3Scalar x) { return cos(x); }
|
||||
SIMD_FORCE_INLINE b3Scalar b3Sin(b3Scalar x) { return sin(x); }
|
||||
SIMD_FORCE_INLINE b3Scalar b3Tan(b3Scalar x) { return tan(x); }
|
||||
SIMD_FORCE_INLINE b3Scalar b3Acos(b3Scalar x) { if (x<b3Scalar(-1)) x=b3Scalar(-1); if (x>b3Scalar(1)) x=b3Scalar(1); return acos(x); }
|
||||
SIMD_FORCE_INLINE b3Scalar b3Asin(b3Scalar x) { if (x<b3Scalar(-1)) x=b3Scalar(-1); if (x>b3Scalar(1)) x=b3Scalar(1); return asin(x); }
|
||||
SIMD_FORCE_INLINE b3Scalar b3Atan(b3Scalar x) { return atan(x); }
|
||||
SIMD_FORCE_INLINE b3Scalar b3Atan2(b3Scalar x, b3Scalar y) { return atan2(x, y); }
|
||||
SIMD_FORCE_INLINE b3Scalar b3Exp(b3Scalar x) { return exp(x); }
|
||||
SIMD_FORCE_INLINE b3Scalar b3Log(b3Scalar x) { return log(x); }
|
||||
SIMD_FORCE_INLINE b3Scalar b3Pow(b3Scalar x,b3Scalar y) { return pow(x,y); }
|
||||
SIMD_FORCE_INLINE b3Scalar b3Fmod(b3Scalar x,b3Scalar y) { return fmod(x,y); }
|
||||
B3_FORCE_INLINE b3Scalar b3Sqrt(b3Scalar x) { return sqrt(x); }
|
||||
B3_FORCE_INLINE b3Scalar b3Fabs(b3Scalar x) { return fabs(x); }
|
||||
B3_FORCE_INLINE b3Scalar b3Cos(b3Scalar x) { return cos(x); }
|
||||
B3_FORCE_INLINE b3Scalar b3Sin(b3Scalar x) { return sin(x); }
|
||||
B3_FORCE_INLINE b3Scalar b3Tan(b3Scalar x) { return tan(x); }
|
||||
B3_FORCE_INLINE b3Scalar b3Acos(b3Scalar x) { if (x<b3Scalar(-1)) x=b3Scalar(-1); if (x>b3Scalar(1)) x=b3Scalar(1); return acos(x); }
|
||||
B3_FORCE_INLINE b3Scalar b3Asin(b3Scalar x) { if (x<b3Scalar(-1)) x=b3Scalar(-1); if (x>b3Scalar(1)) x=b3Scalar(1); return asin(x); }
|
||||
B3_FORCE_INLINE b3Scalar b3Atan(b3Scalar x) { return atan(x); }
|
||||
B3_FORCE_INLINE b3Scalar b3Atan2(b3Scalar x, b3Scalar y) { return atan2(x, y); }
|
||||
B3_FORCE_INLINE b3Scalar b3Exp(b3Scalar x) { return exp(x); }
|
||||
B3_FORCE_INLINE b3Scalar b3Log(b3Scalar x) { return log(x); }
|
||||
B3_FORCE_INLINE b3Scalar b3Pow(b3Scalar x,b3Scalar y) { return pow(x,y); }
|
||||
B3_FORCE_INLINE b3Scalar b3Fmod(b3Scalar x,b3Scalar y) { return fmod(x,y); }
|
||||
|
||||
#else
|
||||
|
||||
SIMD_FORCE_INLINE b3Scalar b3Sqrt(b3Scalar y)
|
||||
B3_FORCE_INLINE b3Scalar b3Sqrt(b3Scalar y)
|
||||
{
|
||||
#ifdef USE_APPROXIMATION
|
||||
double x, z, tempf;
|
||||
@@ -375,54 +375,54 @@ SIMD_FORCE_INLINE b3Scalar b3Sqrt(b3Scalar y)
|
||||
return sqrtf(y);
|
||||
#endif
|
||||
}
|
||||
SIMD_FORCE_INLINE b3Scalar b3Fabs(b3Scalar x) { return fabsf(x); }
|
||||
SIMD_FORCE_INLINE b3Scalar b3Cos(b3Scalar x) { return cosf(x); }
|
||||
SIMD_FORCE_INLINE b3Scalar b3Sin(b3Scalar x) { return sinf(x); }
|
||||
SIMD_FORCE_INLINE b3Scalar b3Tan(b3Scalar x) { return tanf(x); }
|
||||
SIMD_FORCE_INLINE b3Scalar b3Acos(b3Scalar x) {
|
||||
B3_FORCE_INLINE b3Scalar b3Fabs(b3Scalar x) { return fabsf(x); }
|
||||
B3_FORCE_INLINE b3Scalar b3Cos(b3Scalar x) { return cosf(x); }
|
||||
B3_FORCE_INLINE b3Scalar b3Sin(b3Scalar x) { return sinf(x); }
|
||||
B3_FORCE_INLINE b3Scalar b3Tan(b3Scalar x) { return tanf(x); }
|
||||
B3_FORCE_INLINE b3Scalar b3Acos(b3Scalar x) {
|
||||
if (x<b3Scalar(-1))
|
||||
x=b3Scalar(-1);
|
||||
if (x>b3Scalar(1))
|
||||
x=b3Scalar(1);
|
||||
return acosf(x);
|
||||
}
|
||||
SIMD_FORCE_INLINE b3Scalar b3Asin(b3Scalar x) {
|
||||
B3_FORCE_INLINE b3Scalar b3Asin(b3Scalar x) {
|
||||
if (x<b3Scalar(-1))
|
||||
x=b3Scalar(-1);
|
||||
if (x>b3Scalar(1))
|
||||
x=b3Scalar(1);
|
||||
return asinf(x);
|
||||
}
|
||||
SIMD_FORCE_INLINE b3Scalar b3Atan(b3Scalar x) { return atanf(x); }
|
||||
SIMD_FORCE_INLINE b3Scalar b3Atan2(b3Scalar x, b3Scalar y) { return atan2f(x, y); }
|
||||
SIMD_FORCE_INLINE b3Scalar b3Exp(b3Scalar x) { return expf(x); }
|
||||
SIMD_FORCE_INLINE b3Scalar b3Log(b3Scalar x) { return logf(x); }
|
||||
SIMD_FORCE_INLINE b3Scalar b3Pow(b3Scalar x,b3Scalar y) { return powf(x,y); }
|
||||
SIMD_FORCE_INLINE b3Scalar b3Fmod(b3Scalar x,b3Scalar y) { return fmodf(x,y); }
|
||||
B3_FORCE_INLINE b3Scalar b3Atan(b3Scalar x) { return atanf(x); }
|
||||
B3_FORCE_INLINE b3Scalar b3Atan2(b3Scalar x, b3Scalar y) { return atan2f(x, y); }
|
||||
B3_FORCE_INLINE b3Scalar b3Exp(b3Scalar x) { return expf(x); }
|
||||
B3_FORCE_INLINE b3Scalar b3Log(b3Scalar x) { return logf(x); }
|
||||
B3_FORCE_INLINE b3Scalar b3Pow(b3Scalar x,b3Scalar y) { return powf(x,y); }
|
||||
B3_FORCE_INLINE b3Scalar b3Fmod(b3Scalar x,b3Scalar y) { return fmodf(x,y); }
|
||||
|
||||
#endif
|
||||
|
||||
#define SIMD_2_PI b3Scalar(6.283185307179586232)
|
||||
#define SIMD_PI (SIMD_2_PI * b3Scalar(0.5))
|
||||
#define SIMD_HALF_PI (SIMD_2_PI * b3Scalar(0.25))
|
||||
#define SIMD_RADS_PER_DEG (SIMD_2_PI / b3Scalar(360.0))
|
||||
#define SIMD_DEGS_PER_RAD (b3Scalar(360.0) / SIMD_2_PI)
|
||||
#define SIMDSQRT12 b3Scalar(0.7071067811865475244008443621048490)
|
||||
#define B3_2_PI b3Scalar(6.283185307179586232)
|
||||
#define B3_PI (B3_2_PI * b3Scalar(0.5))
|
||||
#define B3_HALF_PI (B3_2_PI * b3Scalar(0.25))
|
||||
#define B3_RADS_PER_DEG (B3_2_PI / b3Scalar(360.0))
|
||||
#define B3_DEGS_PER_RAD (b3Scalar(360.0) / B3_2_PI)
|
||||
#define B3_SQRT12 b3Scalar(0.7071067811865475244008443621048490)
|
||||
|
||||
#define b3RecipSqrt(x) ((b3Scalar)(b3Scalar(1.0)/b3Sqrt(b3Scalar(x)))) /* reciprocal square root */
|
||||
|
||||
|
||||
#ifdef B3_USE_DOUBLE_PRECISION
|
||||
#define SIMD_EPSILON DBL_EPSILON
|
||||
#define SIMD_INFINITY DBL_MAX
|
||||
#define B3_EPSILON DBL_EPSILON
|
||||
#define B3_INFINITY DBL_MAX
|
||||
#else
|
||||
#define SIMD_EPSILON FLT_EPSILON
|
||||
#define SIMD_INFINITY FLT_MAX
|
||||
#define B3_EPSILON FLT_EPSILON
|
||||
#define B3_INFINITY FLT_MAX
|
||||
#endif
|
||||
|
||||
SIMD_FORCE_INLINE b3Scalar b3Atan2Fast(b3Scalar y, b3Scalar x)
|
||||
B3_FORCE_INLINE b3Scalar b3Atan2Fast(b3Scalar y, b3Scalar x)
|
||||
{
|
||||
b3Scalar coeff_1 = SIMD_PI / 4.0f;
|
||||
b3Scalar coeff_1 = B3_PI / 4.0f;
|
||||
b3Scalar coeff_2 = 3.0f * coeff_1;
|
||||
b3Scalar abs_y = b3Fabs(y);
|
||||
b3Scalar angle;
|
||||
@@ -436,27 +436,27 @@ SIMD_FORCE_INLINE b3Scalar b3Atan2Fast(b3Scalar y, b3Scalar x)
|
||||
return (y < 0.0f) ? -angle : angle;
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE bool b3FuzzyZero(b3Scalar x) { return b3Fabs(x) < SIMD_EPSILON; }
|
||||
B3_FORCE_INLINE bool b3FuzzyZero(b3Scalar x) { return b3Fabs(x) < B3_EPSILON; }
|
||||
|
||||
SIMD_FORCE_INLINE bool b3Equal(b3Scalar a, b3Scalar eps) {
|
||||
B3_FORCE_INLINE bool b3Equal(b3Scalar a, b3Scalar eps) {
|
||||
return (((a) <= eps) && !((a) < -eps));
|
||||
}
|
||||
SIMD_FORCE_INLINE bool b3GreaterEqual (b3Scalar a, b3Scalar eps) {
|
||||
B3_FORCE_INLINE bool b3GreaterEqual (b3Scalar a, b3Scalar eps) {
|
||||
return (!((a) <= eps));
|
||||
}
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE int b3IsNegative(b3Scalar x) {
|
||||
B3_FORCE_INLINE int b3IsNegative(b3Scalar x) {
|
||||
return x < b3Scalar(0.0) ? 1 : 0;
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE b3Scalar b3Radians(b3Scalar x) { return x * SIMD_RADS_PER_DEG; }
|
||||
SIMD_FORCE_INLINE b3Scalar b3Degrees(b3Scalar x) { return x * SIMD_DEGS_PER_RAD; }
|
||||
B3_FORCE_INLINE b3Scalar b3Radians(b3Scalar x) { return x * B3_RADS_PER_DEG; }
|
||||
B3_FORCE_INLINE b3Scalar b3Degrees(b3Scalar x) { return x * B3_DEGS_PER_RAD; }
|
||||
|
||||
#define B3_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name
|
||||
|
||||
#ifndef b3Fsel
|
||||
SIMD_FORCE_INLINE b3Scalar b3Fsel(b3Scalar a, b3Scalar b, b3Scalar c)
|
||||
B3_FORCE_INLINE b3Scalar b3Fsel(b3Scalar a, b3Scalar b, b3Scalar c)
|
||||
{
|
||||
return a >= 0 ? b : c;
|
||||
}
|
||||
@@ -464,7 +464,7 @@ SIMD_FORCE_INLINE b3Scalar b3Fsel(b3Scalar a, b3Scalar b, b3Scalar c)
|
||||
#define b3Fsels(a,b,c) (b3Scalar)b3Fsel(a,b,c)
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE bool b3MachineIsLittleEndian()
|
||||
B3_FORCE_INLINE bool b3MachineIsLittleEndian()
|
||||
{
|
||||
long int i = 1;
|
||||
const char *p = (const char *) &i;
|
||||
@@ -478,7 +478,7 @@ SIMD_FORCE_INLINE bool b3MachineIsLittleEndian()
|
||||
|
||||
///b3Select 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
|
||||
SIMD_FORCE_INLINE unsigned b3Select(unsigned condition, unsigned valueIfConditionNonZero, unsigned valueIfConditionZero)
|
||||
B3_FORCE_INLINE unsigned b3Select(unsigned condition, unsigned valueIfConditionNonZero, unsigned valueIfConditionZero)
|
||||
{
|
||||
// Set testNz to 0xFFFFFFFF if condition is nonzero, 0x00000000 if condition is zero
|
||||
// Rely on positive value or'ed with its negative having sign bit on
|
||||
@@ -488,13 +488,13 @@ SIMD_FORCE_INLINE unsigned b3Select(unsigned condition, unsigned valueIfConditio
|
||||
unsigned testEqz = ~testNz;
|
||||
return ((valueIfConditionNonZero & testNz) | (valueIfConditionZero & testEqz));
|
||||
}
|
||||
SIMD_FORCE_INLINE int b3Select(unsigned condition, int valueIfConditionNonZero, int valueIfConditionZero)
|
||||
B3_FORCE_INLINE int b3Select(unsigned condition, int valueIfConditionNonZero, int valueIfConditionZero)
|
||||
{
|
||||
unsigned testNz = (unsigned)(((int)condition | -(int)condition) >> 31);
|
||||
unsigned testEqz = ~testNz;
|
||||
return static_cast<int>((valueIfConditionNonZero & testNz) | (valueIfConditionZero & testEqz));
|
||||
}
|
||||
SIMD_FORCE_INLINE float b3Select(unsigned condition, float valueIfConditionNonZero, float valueIfConditionZero)
|
||||
B3_FORCE_INLINE float b3Select(unsigned condition, float valueIfConditionNonZero, float valueIfConditionZero)
|
||||
{
|
||||
#ifdef B3_HAVE_NATIVE_FSEL
|
||||
return (float)b3Fsel((b3Scalar)condition - b3Scalar(1.0f), valueIfConditionNonZero, valueIfConditionZero);
|
||||
@@ -503,7 +503,7 @@ SIMD_FORCE_INLINE float b3Select(unsigned condition, float valueIfConditionNonZe
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T> SIMD_FORCE_INLINE void b3Swap(T& a, T& b)
|
||||
template<typename T> B3_FORCE_INLINE void b3Swap(T& a, T& b)
|
||||
{
|
||||
T tmp = a;
|
||||
a = b;
|
||||
@@ -512,22 +512,22 @@ template<typename T> SIMD_FORCE_INLINE void b3Swap(T& a, T& b)
|
||||
|
||||
|
||||
//PCK: endian swapping functions
|
||||
SIMD_FORCE_INLINE unsigned b3SwapEndian(unsigned val)
|
||||
B3_FORCE_INLINE unsigned b3SwapEndian(unsigned val)
|
||||
{
|
||||
return (((val & 0xff000000) >> 24) | ((val & 0x00ff0000) >> 8) | ((val & 0x0000ff00) << 8) | ((val & 0x000000ff) << 24));
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE unsigned short b3SwapEndian(unsigned short val)
|
||||
B3_FORCE_INLINE unsigned short b3SwapEndian(unsigned short val)
|
||||
{
|
||||
return static_cast<unsigned short>(((val & 0xff00) >> 8) | ((val & 0x00ff) << 8));
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE unsigned b3SwapEndian(int val)
|
||||
B3_FORCE_INLINE unsigned b3SwapEndian(int val)
|
||||
{
|
||||
return b3SwapEndian((unsigned)val);
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE unsigned short b3SwapEndian(short val)
|
||||
B3_FORCE_INLINE unsigned short b3SwapEndian(short val)
|
||||
{
|
||||
return b3SwapEndian((unsigned short) val);
|
||||
}
|
||||
@@ -538,7 +538,7 @@ SIMD_FORCE_INLINE unsigned short b3SwapEndian(short val)
|
||||
///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
|
||||
SIMD_FORCE_INLINE unsigned int b3SwapEndianFloat(float d)
|
||||
B3_FORCE_INLINE unsigned int b3SwapEndianFloat(float d)
|
||||
{
|
||||
unsigned int a = 0;
|
||||
unsigned char *dst = (unsigned char *)&a;
|
||||
@@ -552,7 +552,7 @@ SIMD_FORCE_INLINE unsigned int b3SwapEndianFloat(float d)
|
||||
}
|
||||
|
||||
// unswap using char pointers
|
||||
SIMD_FORCE_INLINE float b3UnswapEndianFloat(unsigned int a)
|
||||
B3_FORCE_INLINE float b3UnswapEndianFloat(unsigned int a)
|
||||
{
|
||||
float d = 0.0f;
|
||||
unsigned char *src = (unsigned char *)&a;
|
||||
@@ -568,7 +568,7 @@ SIMD_FORCE_INLINE float b3UnswapEndianFloat(unsigned int a)
|
||||
|
||||
|
||||
// swap using char pointers
|
||||
SIMD_FORCE_INLINE void b3SwapEndianDouble(double d, unsigned char* dst)
|
||||
B3_FORCE_INLINE void b3SwapEndianDouble(double d, unsigned char* dst)
|
||||
{
|
||||
unsigned char *src = (unsigned char *)&d;
|
||||
|
||||
@@ -584,7 +584,7 @@ SIMD_FORCE_INLINE void b3SwapEndianDouble(double d, unsigned char* dst)
|
||||
}
|
||||
|
||||
// unswap using char pointers
|
||||
SIMD_FORCE_INLINE double b3UnswapEndianDouble(const unsigned char *src)
|
||||
B3_FORCE_INLINE double b3UnswapEndianDouble(const unsigned char *src)
|
||||
{
|
||||
double d = 0.0;
|
||||
unsigned char *dst = (unsigned char *)&d;
|
||||
@@ -601,17 +601,17 @@ SIMD_FORCE_INLINE double b3UnswapEndianDouble(const unsigned char *src)
|
||||
return d;
|
||||
}
|
||||
|
||||
// returns normalized value in range [-SIMD_PI, SIMD_PI]
|
||||
SIMD_FORCE_INLINE b3Scalar b3NormalizeAngle(b3Scalar angleInRadians)
|
||||
// returns normalized value in range [-B3_PI, B3_PI]
|
||||
B3_FORCE_INLINE b3Scalar b3NormalizeAngle(b3Scalar angleInRadians)
|
||||
{
|
||||
angleInRadians = b3Fmod(angleInRadians, SIMD_2_PI);
|
||||
if(angleInRadians < -SIMD_PI)
|
||||
angleInRadians = b3Fmod(angleInRadians, B3_2_PI);
|
||||
if(angleInRadians < -B3_PI)
|
||||
{
|
||||
return angleInRadians + SIMD_2_PI;
|
||||
return angleInRadians + B3_2_PI;
|
||||
}
|
||||
else if(angleInRadians > SIMD_PI)
|
||||
else if(angleInRadians > B3_PI)
|
||||
{
|
||||
return angleInRadians - SIMD_2_PI;
|
||||
return angleInRadians - B3_2_PI;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
Copyright (c) 2003-2013 Gino van den Bergen / Erwin Coumans http://bulletphysics.org
|
||||
|
||||
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.
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
|
||||
return(0);
|
||||
}
|
||||
SIMD_FORCE_INLINE b3Block* beginBlock()
|
||||
B3_FORCE_INLINE b3Block* beginBlock()
|
||||
{
|
||||
b3Block* pb = (b3Block*)allocate(sizeof(b3Block));
|
||||
pb->previous = current;
|
||||
@@ -86,7 +86,7 @@ public:
|
||||
current = pb;
|
||||
return(pb);
|
||||
}
|
||||
SIMD_FORCE_INLINE void endBlock(b3Block* block)
|
||||
B3_FORCE_INLINE void endBlock(b3Block* block)
|
||||
{
|
||||
b3Assert(block==current);
|
||||
//Raise(L"Unmatched blocks");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
Copyright (c) 2003-2013 Gino van den Bergen / Erwin Coumans http://bulletphysics.org
|
||||
|
||||
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.
|
||||
@@ -13,7 +13,6 @@ subject to the following restrictions:
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef B3_TRANSFORM_H
|
||||
#define B3_TRANSFORM_H
|
||||
|
||||
@@ -31,7 +30,7 @@ subject to the following restrictions:
|
||||
|
||||
/**@brief The b3Transform class supports rigid transforms with only translation and rotation and no scaling/shear.
|
||||
*It can be used in combination with b3Vector3, b3Quaternion and b3Matrix3x3 linear algebra classes. */
|
||||
ATTRIBUTE_ALIGNED16(class) b3Transform {
|
||||
B3_ATTRIBUTE_ALIGNED16(class) b3Transform {
|
||||
|
||||
///Storage for the rotation
|
||||
b3Matrix3x3 m_basis;
|
||||
@@ -45,7 +44,7 @@ public:
|
||||
/**@brief Constructor from b3Quaternion (optional b3Vector3 )
|
||||
* @param q Rotation from quaternion
|
||||
* @param c Translation from Vector (default 0,0,0) */
|
||||
explicit SIMD_FORCE_INLINE b3Transform(const b3Quaternion& q,
|
||||
explicit B3_FORCE_INLINE b3Transform(const b3Quaternion& q,
|
||||
const b3Vector3& c = b3Vector3(b3Scalar(0), b3Scalar(0), b3Scalar(0)))
|
||||
: m_basis(q),
|
||||
m_origin(c)
|
||||
@@ -54,19 +53,19 @@ public:
|
||||
/**@brief Constructor from b3Matrix3x3 (optional b3Vector3)
|
||||
* @param b Rotation from Matrix
|
||||
* @param c Translation from Vector default (0,0,0)*/
|
||||
explicit SIMD_FORCE_INLINE b3Transform(const b3Matrix3x3& b,
|
||||
explicit B3_FORCE_INLINE b3Transform(const b3Matrix3x3& b,
|
||||
const b3Vector3& c = b3Vector3(b3Scalar(0), b3Scalar(0), b3Scalar(0)))
|
||||
: m_basis(b),
|
||||
m_origin(c)
|
||||
{}
|
||||
/**@brief Copy constructor */
|
||||
SIMD_FORCE_INLINE b3Transform (const b3Transform& other)
|
||||
B3_FORCE_INLINE b3Transform (const b3Transform& other)
|
||||
: m_basis(other.m_basis),
|
||||
m_origin(other.m_origin)
|
||||
{
|
||||
}
|
||||
/**@brief Assignment Operator */
|
||||
SIMD_FORCE_INLINE b3Transform& operator=(const b3Transform& other)
|
||||
B3_FORCE_INLINE b3Transform& operator=(const b3Transform& other)
|
||||
{
|
||||
m_basis = other.m_basis;
|
||||
m_origin = other.m_origin;
|
||||
@@ -78,7 +77,7 @@ public:
|
||||
* @param t1 Transform 1
|
||||
* @param t2 Transform 2
|
||||
* This = Transform1 * Transform2 */
|
||||
SIMD_FORCE_INLINE void mult(const b3Transform& t1, const b3Transform& t2) {
|
||||
B3_FORCE_INLINE void mult(const b3Transform& t1, const b3Transform& t2) {
|
||||
m_basis = t1.m_basis * t2.m_basis;
|
||||
m_origin = t1(t2.m_origin);
|
||||
}
|
||||
@@ -91,32 +90,32 @@ public:
|
||||
*/
|
||||
|
||||
/**@brief Return the transform of the vector */
|
||||
SIMD_FORCE_INLINE b3Vector3 operator()(const b3Vector3& x) const
|
||||
B3_FORCE_INLINE b3Vector3 operator()(const b3Vector3& x) const
|
||||
{
|
||||
return x.dot3(m_basis[0], m_basis[1], m_basis[2]) + m_origin;
|
||||
}
|
||||
|
||||
/**@brief Return the transform of the vector */
|
||||
SIMD_FORCE_INLINE b3Vector3 operator*(const b3Vector3& x) const
|
||||
B3_FORCE_INLINE b3Vector3 operator*(const b3Vector3& x) const
|
||||
{
|
||||
return (*this)(x);
|
||||
}
|
||||
|
||||
/**@brief Return the transform of the b3Quaternion */
|
||||
SIMD_FORCE_INLINE b3Quaternion operator*(const b3Quaternion& q) const
|
||||
B3_FORCE_INLINE b3Quaternion operator*(const b3Quaternion& q) const
|
||||
{
|
||||
return getRotation() * q;
|
||||
}
|
||||
|
||||
/**@brief Return the basis matrix for the rotation */
|
||||
SIMD_FORCE_INLINE b3Matrix3x3& getBasis() { return m_basis; }
|
||||
B3_FORCE_INLINE b3Matrix3x3& getBasis() { return m_basis; }
|
||||
/**@brief Return the basis matrix for the rotation */
|
||||
SIMD_FORCE_INLINE const b3Matrix3x3& getBasis() const { return m_basis; }
|
||||
B3_FORCE_INLINE const b3Matrix3x3& getBasis() const { return m_basis; }
|
||||
|
||||
/**@brief Return the origin vector translation */
|
||||
SIMD_FORCE_INLINE b3Vector3& getOrigin() { return m_origin; }
|
||||
B3_FORCE_INLINE b3Vector3& getOrigin() { return m_origin; }
|
||||
/**@brief Return the origin vector translation */
|
||||
SIMD_FORCE_INLINE const b3Vector3& getOrigin() const { return m_origin; }
|
||||
B3_FORCE_INLINE const b3Vector3& getOrigin() const { return m_origin; }
|
||||
|
||||
/**@brief Return a quaternion representing the rotation */
|
||||
b3Quaternion getRotation() const {
|
||||
@@ -147,22 +146,22 @@ public:
|
||||
|
||||
/**@brief Set the translational element
|
||||
* @param origin The vector to set the translation to */
|
||||
SIMD_FORCE_INLINE void setOrigin(const b3Vector3& origin)
|
||||
B3_FORCE_INLINE void setOrigin(const b3Vector3& origin)
|
||||
{
|
||||
m_origin = origin;
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE b3Vector3 invXform(const b3Vector3& inVec) const;
|
||||
B3_FORCE_INLINE b3Vector3 invXform(const b3Vector3& inVec) const;
|
||||
|
||||
|
||||
/**@brief Set the rotational element by b3Matrix3x3 */
|
||||
SIMD_FORCE_INLINE void setBasis(const b3Matrix3x3& basis)
|
||||
B3_FORCE_INLINE void setBasis(const b3Matrix3x3& basis)
|
||||
{
|
||||
m_basis = basis;
|
||||
}
|
||||
|
||||
/**@brief Set the rotational element by b3Quaternion */
|
||||
SIMD_FORCE_INLINE void setRotation(const b3Quaternion& q)
|
||||
B3_FORCE_INLINE void setRotation(const b3Quaternion& q)
|
||||
{
|
||||
m_basis.setRotation(q);
|
||||
}
|
||||
@@ -219,14 +218,14 @@ public:
|
||||
};
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE b3Vector3
|
||||
B3_FORCE_INLINE b3Vector3
|
||||
b3Transform::invXform(const b3Vector3& inVec) const
|
||||
{
|
||||
b3Vector3 v = inVec - m_origin;
|
||||
return (m_basis.transpose() * v);
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE b3Transform
|
||||
B3_FORCE_INLINE b3Transform
|
||||
b3Transform::inverseTimes(const b3Transform& t) const
|
||||
{
|
||||
b3Vector3 v = t.getOrigin() - m_origin;
|
||||
@@ -234,7 +233,7 @@ b3Transform::inverseTimes(const b3Transform& t) const
|
||||
v * m_basis);
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE b3Transform
|
||||
B3_FORCE_INLINE b3Transform
|
||||
b3Transform::operator*(const b3Transform& t) const
|
||||
{
|
||||
return b3Transform(m_basis * t.m_basis,
|
||||
@@ -242,7 +241,7 @@ b3Transform::operator*(const b3Transform& t) const
|
||||
}
|
||||
|
||||
/**@brief Test if two transforms have all elements equal */
|
||||
SIMD_FORCE_INLINE bool operator==(const b3Transform& t1, const b3Transform& t2)
|
||||
B3_FORCE_INLINE bool operator==(const b3Transform& t1, const b3Transform& t2)
|
||||
{
|
||||
return ( t1.getBasis() == t2.getBasis() &&
|
||||
t1.getOrigin() == t2.getOrigin() );
|
||||
@@ -264,32 +263,32 @@ struct b3TransformDoubleData
|
||||
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE void b3Transform::serialize(b3TransformData& dataOut) const
|
||||
B3_FORCE_INLINE void b3Transform::serialize(b3TransformData& dataOut) const
|
||||
{
|
||||
m_basis.serialize(dataOut.m_basis);
|
||||
m_origin.serialize(dataOut.m_origin);
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE void b3Transform::serializeFloat(b3TransformFloatData& dataOut) const
|
||||
B3_FORCE_INLINE void b3Transform::serializeFloat(b3TransformFloatData& dataOut) const
|
||||
{
|
||||
m_basis.serializeFloat(dataOut.m_basis);
|
||||
m_origin.serializeFloat(dataOut.m_origin);
|
||||
}
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE void b3Transform::deSerialize(const b3TransformData& dataIn)
|
||||
B3_FORCE_INLINE void b3Transform::deSerialize(const b3TransformData& dataIn)
|
||||
{
|
||||
m_basis.deSerialize(dataIn.m_basis);
|
||||
m_origin.deSerialize(dataIn.m_origin);
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE void b3Transform::deSerializeFloat(const b3TransformFloatData& dataIn)
|
||||
B3_FORCE_INLINE void b3Transform::deSerializeFloat(const b3TransformFloatData& dataIn)
|
||||
{
|
||||
m_basis.deSerializeFloat(dataIn.m_basis);
|
||||
m_origin.deSerializeFloat(dataIn.m_origin);
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE void b3Transform::deSerializeDouble(const b3TransformDoubleData& dataIn)
|
||||
B3_FORCE_INLINE void b3Transform::deSerializeDouble(const b3TransformDoubleData& dataIn)
|
||||
{
|
||||
m_basis.deSerializeDouble(dataIn.m_basis);
|
||||
m_origin.deSerializeDouble(dataIn.m_origin);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
Copyright (c) 2003-2013 Gino van den Bergen / Erwin Coumans http://bulletphysics.org
|
||||
|
||||
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.
|
||||
@@ -17,12 +17,12 @@ subject to the following restrictions:
|
||||
#define B3_TRANSFORM_UTIL_H
|
||||
|
||||
#include "b3Transform.h"
|
||||
#define ANGULAR_MOTION_THRESHOLD b3Scalar(0.5)*SIMD_HALF_PI
|
||||
#define B3_ANGULAR_MOTION_THRESHOLD b3Scalar(0.5)*B3_HALF_PI
|
||||
|
||||
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE b3Vector3 b3AabbSupport(const b3Vector3& halfExtents,const b3Vector3& supportDir)
|
||||
B3_FORCE_INLINE b3Vector3 b3AabbSupport(const b3Vector3& halfExtents,const b3Vector3& supportDir)
|
||||
{
|
||||
return b3Vector3(supportDir.getX() < b3Scalar(0.0) ? -halfExtents.getX() : halfExtents.getX(),
|
||||
supportDir.getY() < b3Scalar(0.0) ? -halfExtents.getY() : halfExtents.getY(),
|
||||
@@ -55,9 +55,9 @@ public:
|
||||
b3Vector3 axis;
|
||||
b3Scalar fAngle = angvel.length();
|
||||
//limit the angular motion
|
||||
if (fAngle*timeStep > ANGULAR_MOTION_THRESHOLD)
|
||||
if (fAngle*timeStep > B3_ANGULAR_MOTION_THRESHOLD)
|
||||
{
|
||||
fAngle = ANGULAR_MOTION_THRESHOLD / timeStep;
|
||||
fAngle = B3_ANGULAR_MOTION_THRESHOLD / timeStep;
|
||||
}
|
||||
|
||||
if ( fAngle < b3Scalar(0.001) )
|
||||
@@ -103,7 +103,7 @@ public:
|
||||
axis[3] = b3Scalar(0.);
|
||||
//check for axis length
|
||||
b3Scalar len = axis.length2();
|
||||
if (len < SIMD_EPSILON*SIMD_EPSILON)
|
||||
if (len < B3_EPSILON*B3_EPSILON)
|
||||
axis = b3Vector3(b3Scalar(1.),b3Scalar(0.),b3Scalar(0.));
|
||||
else
|
||||
axis /= b3Sqrt(len);
|
||||
@@ -132,7 +132,7 @@ public:
|
||||
axis[3] = b3Scalar(0.);
|
||||
//check for axis length
|
||||
b3Scalar len = axis.length2();
|
||||
if (len < SIMD_EPSILON*SIMD_EPSILON)
|
||||
if (len < B3_EPSILON*B3_EPSILON)
|
||||
axis = b3Vector3(b3Scalar(1.),b3Scalar(0.),b3Scalar(0.));
|
||||
else
|
||||
axis /= b3Sqrt(len);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2011 Apple Inc.
|
||||
http://continuousphysics.com/Bullet/
|
||||
Copyright (c) 2011-213 Apple Inc. http://bulletphysics.org
|
||||
|
||||
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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
Copyright (c) 2003-2013 Gino van den Bergen / Erwin Coumans http://bulletphysics.org
|
||||
|
||||
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.
|
||||
@@ -55,19 +55,19 @@ subject to the following restrictions:
|
||||
|
||||
|
||||
|
||||
const __m128 ATTRIBUTE_ALIGNED16(b3vMzeroMask) = {-0.0f, -0.0f, -0.0f, -0.0f};
|
||||
const __m128 ATTRIBUTE_ALIGNED16(v1110) = {1.0f, 1.0f, 1.0f, 0.0f};
|
||||
const __m128 ATTRIBUTE_ALIGNED16(vHalf) = {0.5f, 0.5f, 0.5f, 0.5f};
|
||||
const __m128 ATTRIBUTE_ALIGNED16(v1_5) = {1.5f, 1.5f, 1.5f, 1.5f};
|
||||
const __m128 B3_ATTRIBUTE_ALIGNED16(b3vMzeroMask) = {-0.0f, -0.0f, -0.0f, -0.0f};
|
||||
const __m128 B3_ATTRIBUTE_ALIGNED16(v1110) = {1.0f, 1.0f, 1.0f, 0.0f};
|
||||
const __m128 B3_ATTRIBUTE_ALIGNED16(vHalf) = {0.5f, 0.5f, 0.5f, 0.5f};
|
||||
const __m128 B3_ATTRIBUTE_ALIGNED16(v1_5) = {1.5f, 1.5f, 1.5f, 1.5f};
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef B3_USE_NEON
|
||||
|
||||
const float32x4_t ATTRIBUTE_ALIGNED16(b3vMzeroMask) = (float32x4_t){-0.0f, -0.0f, -0.0f, -0.0f};
|
||||
const int32x4_t ATTRIBUTE_ALIGNED16(b3vFFF0Mask) = (int32x4_t){0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0};
|
||||
const int32x4_t ATTRIBUTE_ALIGNED16(b3vAbsMask) = (int32x4_t){0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF};
|
||||
const int32x4_t ATTRIBUTE_ALIGNED16(b3v3AbsMask) = (int32x4_t){0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x0};
|
||||
const float32x4_t B3_ATTRIBUTE_ALIGNED16(b3vMzeroMask) = (float32x4_t){-0.0f, -0.0f, -0.0f, -0.0f};
|
||||
const int32x4_t B3_ATTRIBUTE_ALIGNED16(b3vFFF0Mask) = (int32x4_t){0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0};
|
||||
const int32x4_t B3_ATTRIBUTE_ALIGNED16(b3vAbsMask) = (int32x4_t){0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF};
|
||||
const int32x4_t B3_ATTRIBUTE_ALIGNED16(b3v3AbsMask) = (int32x4_t){0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x0};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -75,7 +75,7 @@ const int32x4_t ATTRIBUTE_ALIGNED16(b3v3AbsMask) = (int32x4_t){0x7FFFFFFF, 0x7FF
|
||||
* It has an un-used w component to suit 16-byte alignment when b3Vector3 is stored in containers. This extra component can be used by derived classes (Quaternion?) or by user
|
||||
* Ideally, this class should be replaced by a platform optimized SIMD version that keeps the data in registers
|
||||
*/
|
||||
ATTRIBUTE_ALIGNED16(class) b3Vector3
|
||||
B3_ATTRIBUTE_ALIGNED16(class) b3Vector3
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
#if defined (__SPU__) && defined (__CELLOS_LV2__)
|
||||
b3Scalar m_floats[4];
|
||||
public:
|
||||
SIMD_FORCE_INLINE const vec_float4& get128() const
|
||||
B3_FORCE_INLINE const vec_float4& get128() const
|
||||
{
|
||||
return *((const vec_float4*)&m_floats[0]);
|
||||
}
|
||||
@@ -97,11 +97,11 @@ public:
|
||||
struct {b3Scalar x,y,z,w;};
|
||||
|
||||
};
|
||||
SIMD_FORCE_INLINE b3SimdFloat4 get128() const
|
||||
B3_FORCE_INLINE b3SimdFloat4 get128() const
|
||||
{
|
||||
return mVec128;
|
||||
}
|
||||
SIMD_FORCE_INLINE void set128(b3SimdFloat4 v128)
|
||||
B3_FORCE_INLINE void set128(b3SimdFloat4 v128)
|
||||
{
|
||||
mVec128 = v128;
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public:
|
||||
public:
|
||||
|
||||
/**@brief No initialization constructor */
|
||||
SIMD_FORCE_INLINE b3Vector3()
|
||||
B3_FORCE_INLINE b3Vector3()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -125,7 +125,7 @@ public:
|
||||
* @param y Y value
|
||||
* @param z Z value
|
||||
*/
|
||||
SIMD_FORCE_INLINE b3Vector3(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z)
|
||||
B3_FORCE_INLINE b3Vector3(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z)
|
||||
{
|
||||
m_floats[0] = _x;
|
||||
m_floats[1] = _y;
|
||||
@@ -135,19 +135,19 @@ public:
|
||||
|
||||
#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) )|| defined (B3_USE_NEON)
|
||||
// Set Vector
|
||||
SIMD_FORCE_INLINE b3Vector3( b3SimdFloat4 v)
|
||||
B3_FORCE_INLINE b3Vector3( b3SimdFloat4 v)
|
||||
{
|
||||
mVec128 = v;
|
||||
}
|
||||
|
||||
// Copy constructor
|
||||
SIMD_FORCE_INLINE b3Vector3(const b3Vector3& rhs)
|
||||
B3_FORCE_INLINE b3Vector3(const b3Vector3& rhs)
|
||||
{
|
||||
mVec128 = rhs.mVec128;
|
||||
}
|
||||
|
||||
// Assignment Operator
|
||||
SIMD_FORCE_INLINE b3Vector3&
|
||||
B3_FORCE_INLINE b3Vector3&
|
||||
operator=(const b3Vector3& v)
|
||||
{
|
||||
mVec128 = v.mVec128;
|
||||
@@ -158,7 +158,7 @@ public:
|
||||
|
||||
/**@brief Add a vector to this one
|
||||
* @param The vector to add to this one */
|
||||
SIMD_FORCE_INLINE b3Vector3& operator+=(const b3Vector3& v)
|
||||
B3_FORCE_INLINE b3Vector3& operator+=(const b3Vector3& v)
|
||||
{
|
||||
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||
mVec128 = _mm_add_ps(mVec128, v.mVec128);
|
||||
@@ -175,7 +175,7 @@ public:
|
||||
|
||||
/**@brief Subtract a vector from this one
|
||||
* @param The vector to subtract */
|
||||
SIMD_FORCE_INLINE b3Vector3& operator-=(const b3Vector3& v)
|
||||
B3_FORCE_INLINE b3Vector3& operator-=(const b3Vector3& v)
|
||||
{
|
||||
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||
mVec128 = _mm_sub_ps(mVec128, v.mVec128);
|
||||
@@ -191,7 +191,7 @@ public:
|
||||
|
||||
/**@brief Scale the vector
|
||||
* @param s Scale factor */
|
||||
SIMD_FORCE_INLINE b3Vector3& operator*=(const b3Scalar& s)
|
||||
B3_FORCE_INLINE b3Vector3& operator*=(const b3Scalar& s)
|
||||
{
|
||||
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||
__m128 vs = _mm_load_ss(&s); // (S 0 0 0)
|
||||
@@ -209,7 +209,7 @@ public:
|
||||
|
||||
/**@brief Inversely scale the vector
|
||||
* @param s Scale factor to divide by */
|
||||
SIMD_FORCE_INLINE b3Vector3& operator/=(const b3Scalar& s)
|
||||
B3_FORCE_INLINE b3Vector3& operator/=(const b3Scalar& s)
|
||||
{
|
||||
b3FullAssert(s != b3Scalar(0.0));
|
||||
|
||||
@@ -229,7 +229,7 @@ public:
|
||||
|
||||
/**@brief Return the dot product
|
||||
* @param v The other vector in the dot product */
|
||||
SIMD_FORCE_INLINE b3Scalar dot(const b3Vector3& v) const
|
||||
B3_FORCE_INLINE b3Scalar dot(const b3Vector3& v) const
|
||||
{
|
||||
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||
__m128 vd = _mm_mul_ps(mVec128, v.mVec128);
|
||||
@@ -251,26 +251,26 @@ public:
|
||||
}
|
||||
|
||||
/**@brief Return the length of the vector squared */
|
||||
SIMD_FORCE_INLINE b3Scalar length2() const
|
||||
B3_FORCE_INLINE b3Scalar length2() const
|
||||
{
|
||||
return dot(*this);
|
||||
}
|
||||
|
||||
/**@brief Return the length of the vector */
|
||||
SIMD_FORCE_INLINE b3Scalar length() const
|
||||
B3_FORCE_INLINE b3Scalar length() const
|
||||
{
|
||||
return b3Sqrt(length2());
|
||||
}
|
||||
|
||||
/**@brief Return the distance squared between the ends of this and another vector
|
||||
* This is symantically treating the vector like a point */
|
||||
SIMD_FORCE_INLINE b3Scalar distance2(const b3Vector3& v) const;
|
||||
B3_FORCE_INLINE b3Scalar distance2(const b3Vector3& v) const;
|
||||
|
||||
/**@brief Return the distance between the ends of this and another vector
|
||||
* This is symantically treating the vector like a point */
|
||||
SIMD_FORCE_INLINE b3Scalar distance(const b3Vector3& v) const;
|
||||
B3_FORCE_INLINE b3Scalar distance(const b3Vector3& v) const;
|
||||
|
||||
SIMD_FORCE_INLINE b3Vector3& safeNormalize()
|
||||
B3_FORCE_INLINE b3Vector3& safeNormalize()
|
||||
{
|
||||
b3Vector3 absVec = this->absolute();
|
||||
int maxIndex = absVec.maxAxis();
|
||||
@@ -285,7 +285,7 @@ public:
|
||||
|
||||
/**@brief Normalize this vector
|
||||
* x^2 + y^2 + z^2 = 1 */
|
||||
SIMD_FORCE_INLINE b3Vector3& normalize()
|
||||
B3_FORCE_INLINE b3Vector3& normalize()
|
||||
{
|
||||
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||
// dot product first
|
||||
@@ -328,16 +328,16 @@ public:
|
||||
}
|
||||
|
||||
/**@brief Return a normalized version of this vector */
|
||||
SIMD_FORCE_INLINE b3Vector3 normalized() const;
|
||||
B3_FORCE_INLINE b3Vector3 normalized() const;
|
||||
|
||||
/**@brief Return a rotated version of this vector
|
||||
* @param wAxis The axis to rotate about
|
||||
* @param angle The angle to rotate by */
|
||||
SIMD_FORCE_INLINE b3Vector3 rotate( const b3Vector3& wAxis, const b3Scalar angle ) const;
|
||||
B3_FORCE_INLINE b3Vector3 rotate( const b3Vector3& wAxis, const b3Scalar angle ) const;
|
||||
|
||||
/**@brief Return the angle between this and another vector
|
||||
* @param v The other vector */
|
||||
SIMD_FORCE_INLINE b3Scalar angle(const b3Vector3& v) const
|
||||
B3_FORCE_INLINE b3Scalar angle(const b3Vector3& v) const
|
||||
{
|
||||
b3Scalar s = b3Sqrt(length2() * v.length2());
|
||||
b3FullAssert(s != b3Scalar(0.0));
|
||||
@@ -345,7 +345,7 @@ public:
|
||||
}
|
||||
|
||||
/**@brief Return a vector will the absolute values of each element */
|
||||
SIMD_FORCE_INLINE b3Vector3 absolute() const
|
||||
B3_FORCE_INLINE b3Vector3 absolute() const
|
||||
{
|
||||
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||
return b3Vector3(_mm_and_ps(mVec128, b3v3AbsfMask));
|
||||
@@ -361,7 +361,7 @@ public:
|
||||
|
||||
/**@brief Return the cross product between this and another vector
|
||||
* @param v The other vector */
|
||||
SIMD_FORCE_INLINE b3Vector3 cross(const b3Vector3& v) const
|
||||
B3_FORCE_INLINE b3Vector3 cross(const b3Vector3& v) const
|
||||
{
|
||||
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||
__m128 T, V;
|
||||
@@ -400,7 +400,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE b3Scalar triple(const b3Vector3& v1, const b3Vector3& v2) const
|
||||
B3_FORCE_INLINE b3Scalar triple(const b3Vector3& v1, const b3Vector3& v2) const
|
||||
{
|
||||
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||
// cross:
|
||||
@@ -452,30 +452,30 @@ public:
|
||||
|
||||
/**@brief Return the axis with the smallest value
|
||||
* Note return values are 0,1,2 for x, y, or z */
|
||||
SIMD_FORCE_INLINE int minAxis() const
|
||||
B3_FORCE_INLINE int minAxis() const
|
||||
{
|
||||
return m_floats[0] < m_floats[1] ? (m_floats[0] <m_floats[2] ? 0 : 2) : (m_floats[1] <m_floats[2] ? 1 : 2);
|
||||
}
|
||||
|
||||
/**@brief Return the axis with the largest value
|
||||
* Note return values are 0,1,2 for x, y, or z */
|
||||
SIMD_FORCE_INLINE int maxAxis() const
|
||||
B3_FORCE_INLINE int maxAxis() const
|
||||
{
|
||||
return m_floats[0] < m_floats[1] ? (m_floats[1] <m_floats[2] ? 2 : 1) : (m_floats[0] <m_floats[2] ? 2 : 0);
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE int furthestAxis() const
|
||||
B3_FORCE_INLINE int furthestAxis() const
|
||||
{
|
||||
return absolute().minAxis();
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE int closestAxis() const
|
||||
B3_FORCE_INLINE int closestAxis() const
|
||||
{
|
||||
return absolute().maxAxis();
|
||||
}
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE void setInterpolate3(const b3Vector3& v0, const b3Vector3& v1, b3Scalar rt)
|
||||
B3_FORCE_INLINE void setInterpolate3(const b3Vector3& v0, const b3Vector3& v1, b3Scalar rt)
|
||||
{
|
||||
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||
__m128 vrt = _mm_load_ss(&rt); // (rt 0 0 0)
|
||||
@@ -504,7 +504,7 @@ public:
|
||||
/**@brief Return the linear interpolation between this and another vector
|
||||
* @param v The other vector
|
||||
* @param t The ration of this to v (t = 0 => return this, t=1 => return other) */
|
||||
SIMD_FORCE_INLINE b3Vector3 lerp(const b3Vector3& v, const b3Scalar& t) const
|
||||
B3_FORCE_INLINE b3Vector3 lerp(const b3Vector3& v, const b3Scalar& t) const
|
||||
{
|
||||
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||
__m128 vt = _mm_load_ss(&t); // (t 0 0 0)
|
||||
@@ -530,7 +530,7 @@ public:
|
||||
|
||||
/**@brief Elementwise multiply this vector by the other
|
||||
* @param v The other vector */
|
||||
SIMD_FORCE_INLINE b3Vector3& operator*=(const b3Vector3& v)
|
||||
B3_FORCE_INLINE b3Vector3& operator*=(const b3Vector3& v)
|
||||
{
|
||||
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||
mVec128 = _mm_mul_ps(mVec128, v.mVec128);
|
||||
@@ -545,30 +545,30 @@ public:
|
||||
}
|
||||
|
||||
/**@brief Return the x value */
|
||||
SIMD_FORCE_INLINE const b3Scalar& getX() const { return m_floats[0]; }
|
||||
B3_FORCE_INLINE const b3Scalar& getX() const { return m_floats[0]; }
|
||||
/**@brief Return the y value */
|
||||
SIMD_FORCE_INLINE const b3Scalar& getY() const { return m_floats[1]; }
|
||||
B3_FORCE_INLINE const b3Scalar& getY() const { return m_floats[1]; }
|
||||
/**@brief Return the z value */
|
||||
SIMD_FORCE_INLINE const b3Scalar& getZ() const { return m_floats[2]; }
|
||||
B3_FORCE_INLINE const b3Scalar& getZ() const { return m_floats[2]; }
|
||||
/**@brief Return the w value */
|
||||
SIMD_FORCE_INLINE const b3Scalar& getW() const { return m_floats[3]; }
|
||||
B3_FORCE_INLINE const b3Scalar& getW() const { return m_floats[3]; }
|
||||
|
||||
/**@brief Set the x value */
|
||||
SIMD_FORCE_INLINE void setX(b3Scalar _x) { m_floats[0] = _x;};
|
||||
B3_FORCE_INLINE void setX(b3Scalar _x) { m_floats[0] = _x;};
|
||||
/**@brief Set the y value */
|
||||
SIMD_FORCE_INLINE void setY(b3Scalar _y) { m_floats[1] = _y;};
|
||||
B3_FORCE_INLINE void setY(b3Scalar _y) { m_floats[1] = _y;};
|
||||
/**@brief Set the z value */
|
||||
SIMD_FORCE_INLINE void setZ(b3Scalar _z) { m_floats[2] = _z;};
|
||||
B3_FORCE_INLINE void setZ(b3Scalar _z) { m_floats[2] = _z;};
|
||||
/**@brief Set the w value */
|
||||
SIMD_FORCE_INLINE void setW(b3Scalar _w) { m_floats[3] = _w;};
|
||||
B3_FORCE_INLINE void setW(b3Scalar _w) { m_floats[3] = _w;};
|
||||
|
||||
//SIMD_FORCE_INLINE b3Scalar& operator[](int i) { return (&m_floats[0])[i]; }
|
||||
//SIMD_FORCE_INLINE const b3Scalar& operator[](int i) const { return (&m_floats[0])[i]; }
|
||||
//B3_FORCE_INLINE b3Scalar& operator[](int i) { return (&m_floats[0])[i]; }
|
||||
//B3_FORCE_INLINE const b3Scalar& operator[](int i) const { return (&m_floats[0])[i]; }
|
||||
///operator b3Scalar*() replaces operator[], using implicit conversion. We added operator != and operator == to avoid pointer comparisons.
|
||||
SIMD_FORCE_INLINE operator b3Scalar *() { return &m_floats[0]; }
|
||||
SIMD_FORCE_INLINE operator const b3Scalar *() const { return &m_floats[0]; }
|
||||
B3_FORCE_INLINE operator b3Scalar *() { return &m_floats[0]; }
|
||||
B3_FORCE_INLINE operator const b3Scalar *() const { return &m_floats[0]; }
|
||||
|
||||
SIMD_FORCE_INLINE bool operator==(const b3Vector3& other) const
|
||||
B3_FORCE_INLINE bool operator==(const b3Vector3& other) const
|
||||
{
|
||||
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||
return (0xf == _mm_movemask_ps((__m128)_mm_cmpeq_ps(mVec128, other.mVec128)));
|
||||
@@ -580,7 +580,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE bool operator!=(const b3Vector3& other) const
|
||||
B3_FORCE_INLINE bool operator!=(const b3Vector3& other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
@@ -588,7 +588,7 @@ public:
|
||||
/**@brief Set each element to the max of the current values and the values of another b3Vector3
|
||||
* @param other The other b3Vector3 to compare with
|
||||
*/
|
||||
SIMD_FORCE_INLINE void setMax(const b3Vector3& other)
|
||||
B3_FORCE_INLINE void setMax(const b3Vector3& other)
|
||||
{
|
||||
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||
mVec128 = _mm_max_ps(mVec128, other.mVec128);
|
||||
@@ -605,7 +605,7 @@ public:
|
||||
/**@brief Set each element to the min of the current values and the values of another b3Vector3
|
||||
* @param other The other b3Vector3 to compare with
|
||||
*/
|
||||
SIMD_FORCE_INLINE void setMin(const b3Vector3& other)
|
||||
B3_FORCE_INLINE void setMin(const b3Vector3& other)
|
||||
{
|
||||
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||
mVec128 = _mm_min_ps(mVec128, other.mVec128);
|
||||
@@ -619,7 +619,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE void setValue(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z)
|
||||
B3_FORCE_INLINE void setValue(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z)
|
||||
{
|
||||
m_floats[0]=_x;
|
||||
m_floats[1]=_y;
|
||||
@@ -662,42 +662,42 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE bool isZero() const
|
||||
B3_FORCE_INLINE bool isZero() const
|
||||
{
|
||||
return m_floats[0] == b3Scalar(0) && m_floats[1] == b3Scalar(0) && m_floats[2] == b3Scalar(0);
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE bool fuzzyZero() const
|
||||
B3_FORCE_INLINE bool fuzzyZero() const
|
||||
{
|
||||
return length2() < SIMD_EPSILON;
|
||||
return length2() < B3_EPSILON;
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE void serialize(struct b3Vector3Data& dataOut) const;
|
||||
B3_FORCE_INLINE void serialize(struct b3Vector3Data& dataOut) const;
|
||||
|
||||
SIMD_FORCE_INLINE void deSerialize(const struct b3Vector3Data& dataIn);
|
||||
B3_FORCE_INLINE void deSerialize(const struct b3Vector3Data& dataIn);
|
||||
|
||||
SIMD_FORCE_INLINE void serializeFloat(struct b3Vector3FloatData& dataOut) const;
|
||||
B3_FORCE_INLINE void serializeFloat(struct b3Vector3FloatData& dataOut) const;
|
||||
|
||||
SIMD_FORCE_INLINE void deSerializeFloat(const struct b3Vector3FloatData& dataIn);
|
||||
B3_FORCE_INLINE void deSerializeFloat(const struct b3Vector3FloatData& dataIn);
|
||||
|
||||
SIMD_FORCE_INLINE void serializeDouble(struct b3Vector3DoubleData& dataOut) const;
|
||||
B3_FORCE_INLINE void serializeDouble(struct b3Vector3DoubleData& dataOut) const;
|
||||
|
||||
SIMD_FORCE_INLINE void deSerializeDouble(const struct b3Vector3DoubleData& dataIn);
|
||||
B3_FORCE_INLINE void deSerializeDouble(const struct b3Vector3DoubleData& dataIn);
|
||||
|
||||
/**@brief returns index of maximum dot product between this and vectors in array[]
|
||||
* @param array The other vectors
|
||||
* @param array_count The number of other vectors
|
||||
* @param dotOut The maximum dot product */
|
||||
SIMD_FORCE_INLINE long maxDot( const b3Vector3 *array, long array_count, b3Scalar &dotOut ) const;
|
||||
B3_FORCE_INLINE long maxDot( const b3Vector3 *array, long array_count, b3Scalar &dotOut ) const;
|
||||
|
||||
/**@brief returns index of minimum dot product between this and vectors in array[]
|
||||
* @param array The other vectors
|
||||
* @param array_count The number of other vectors
|
||||
* @param dotOut The minimum dot product */
|
||||
SIMD_FORCE_INLINE long minDot( const b3Vector3 *array, long array_count, b3Scalar &dotOut ) const;
|
||||
B3_FORCE_INLINE long minDot( const b3Vector3 *array, long array_count, b3Scalar &dotOut ) const;
|
||||
|
||||
/* create a vector as b3Vector3( this->dot( b3Vector3 v0 ), this->dot( b3Vector3 v1), this->dot( b3Vector3 v2 )) */
|
||||
SIMD_FORCE_INLINE b3Vector3 dot3( const b3Vector3 &v0, const b3Vector3 &v1, const b3Vector3 &v2 ) const
|
||||
B3_FORCE_INLINE b3Vector3 dot3( const b3Vector3 &v0, const b3Vector3 &v1, const b3Vector3 &v2 ) const
|
||||
{
|
||||
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||
|
||||
@@ -730,7 +730,7 @@ public:
|
||||
};
|
||||
|
||||
/**@brief Return the sum of two vectors (Point symantics)*/
|
||||
SIMD_FORCE_INLINE b3Vector3
|
||||
B3_FORCE_INLINE b3Vector3
|
||||
operator+(const b3Vector3& v1, const b3Vector3& v2)
|
||||
{
|
||||
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||
@@ -746,7 +746,7 @@ operator+(const b3Vector3& v1, const b3Vector3& v2)
|
||||
}
|
||||
|
||||
/**@brief Return the elementwise product of two vectors */
|
||||
SIMD_FORCE_INLINE b3Vector3
|
||||
B3_FORCE_INLINE b3Vector3
|
||||
operator*(const b3Vector3& v1, const b3Vector3& v2)
|
||||
{
|
||||
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||
@@ -762,7 +762,7 @@ operator*(const b3Vector3& v1, const b3Vector3& v2)
|
||||
}
|
||||
|
||||
/**@brief Return the difference between two vectors */
|
||||
SIMD_FORCE_INLINE b3Vector3
|
||||
B3_FORCE_INLINE b3Vector3
|
||||
operator-(const b3Vector3& v1, const b3Vector3& v2)
|
||||
{
|
||||
#if (defined(B3_USE_SSE_IN_API) && defined(B3_USE_SSE))
|
||||
@@ -782,7 +782,7 @@ operator-(const b3Vector3& v1, const b3Vector3& v2)
|
||||
}
|
||||
|
||||
/**@brief Return the negative of the vector */
|
||||
SIMD_FORCE_INLINE b3Vector3
|
||||
B3_FORCE_INLINE b3Vector3
|
||||
operator-(const b3Vector3& v)
|
||||
{
|
||||
#if (defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE))
|
||||
@@ -796,7 +796,7 @@ operator-(const b3Vector3& v)
|
||||
}
|
||||
|
||||
/**@brief Return the vector scaled by s */
|
||||
SIMD_FORCE_INLINE b3Vector3
|
||||
B3_FORCE_INLINE b3Vector3
|
||||
operator*(const b3Vector3& v, const b3Scalar& s)
|
||||
{
|
||||
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||
@@ -812,14 +812,14 @@ operator*(const b3Vector3& v, const b3Scalar& s)
|
||||
}
|
||||
|
||||
/**@brief Return the vector scaled by s */
|
||||
SIMD_FORCE_INLINE b3Vector3
|
||||
B3_FORCE_INLINE b3Vector3
|
||||
operator*(const b3Scalar& s, const b3Vector3& v)
|
||||
{
|
||||
return v * s;
|
||||
}
|
||||
|
||||
/**@brief Return the vector inversely scaled by s */
|
||||
SIMD_FORCE_INLINE b3Vector3
|
||||
B3_FORCE_INLINE b3Vector3
|
||||
operator/(const b3Vector3& v, const b3Scalar& s)
|
||||
{
|
||||
b3FullAssert(s != b3Scalar(0.0));
|
||||
@@ -836,7 +836,7 @@ operator/(const b3Vector3& v, const b3Scalar& s)
|
||||
}
|
||||
|
||||
/**@brief Return the vector inversely scaled by s */
|
||||
SIMD_FORCE_INLINE b3Vector3
|
||||
B3_FORCE_INLINE b3Vector3
|
||||
operator/(const b3Vector3& v1, const b3Vector3& v2)
|
||||
{
|
||||
#if (defined(B3_USE_SSE_IN_API)&& defined (B3_USE_SSE))
|
||||
@@ -866,7 +866,7 @@ operator/(const b3Vector3& v1, const b3Vector3& v2)
|
||||
}
|
||||
|
||||
/**@brief Return the dot product between two vectors */
|
||||
SIMD_FORCE_INLINE b3Scalar
|
||||
B3_FORCE_INLINE b3Scalar
|
||||
b3Dot(const b3Vector3& v1, const b3Vector3& v2)
|
||||
{
|
||||
return v1.dot(v2);
|
||||
@@ -874,7 +874,7 @@ b3Dot(const b3Vector3& v1, const b3Vector3& v2)
|
||||
|
||||
|
||||
/**@brief Return the distance squared between two vectors */
|
||||
SIMD_FORCE_INLINE b3Scalar
|
||||
B3_FORCE_INLINE b3Scalar
|
||||
b3Distance2(const b3Vector3& v1, const b3Vector3& v2)
|
||||
{
|
||||
return v1.distance2(v2);
|
||||
@@ -882,27 +882,27 @@ b3Distance2(const b3Vector3& v1, const b3Vector3& v2)
|
||||
|
||||
|
||||
/**@brief Return the distance between two vectors */
|
||||
SIMD_FORCE_INLINE b3Scalar
|
||||
B3_FORCE_INLINE b3Scalar
|
||||
b3Distance(const b3Vector3& v1, const b3Vector3& v2)
|
||||
{
|
||||
return v1.distance(v2);
|
||||
}
|
||||
|
||||
/**@brief Return the angle between two vectors */
|
||||
SIMD_FORCE_INLINE b3Scalar
|
||||
B3_FORCE_INLINE b3Scalar
|
||||
b3Angle(const b3Vector3& v1, const b3Vector3& v2)
|
||||
{
|
||||
return v1.angle(v2);
|
||||
}
|
||||
|
||||
/**@brief Return the cross product of two vectors */
|
||||
SIMD_FORCE_INLINE b3Vector3
|
||||
B3_FORCE_INLINE b3Vector3
|
||||
b3Cross(const b3Vector3& v1, const b3Vector3& v2)
|
||||
{
|
||||
return v1.cross(v2);
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE b3Scalar
|
||||
B3_FORCE_INLINE b3Scalar
|
||||
b3Triple(const b3Vector3& v1, const b3Vector3& v2, const b3Vector3& v3)
|
||||
{
|
||||
return v1.triple(v2, v3);
|
||||
@@ -912,25 +912,25 @@ b3Triple(const b3Vector3& v1, const b3Vector3& v2, const b3Vector3& v3)
|
||||
* @param v1 One vector
|
||||
* @param v2 The other vector
|
||||
* @param t The ration of this to v (t = 0 => return v1, t=1 => return v2) */
|
||||
SIMD_FORCE_INLINE b3Vector3
|
||||
lerp(const b3Vector3& v1, const b3Vector3& v2, const b3Scalar& t)
|
||||
B3_FORCE_INLINE b3Vector3
|
||||
b3Lerp(const b3Vector3& v1, const b3Vector3& v2, const b3Scalar& t)
|
||||
{
|
||||
return v1.lerp(v2, t);
|
||||
}
|
||||
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE b3Scalar b3Vector3::distance2(const b3Vector3& v) const
|
||||
B3_FORCE_INLINE b3Scalar b3Vector3::distance2(const b3Vector3& v) const
|
||||
{
|
||||
return (v - *this).length2();
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE b3Scalar b3Vector3::distance(const b3Vector3& v) const
|
||||
B3_FORCE_INLINE b3Scalar b3Vector3::distance(const b3Vector3& v) const
|
||||
{
|
||||
return (v - *this).length();
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE b3Vector3 b3Vector3::normalized() const
|
||||
B3_FORCE_INLINE b3Vector3 b3Vector3::normalized() const
|
||||
{
|
||||
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||
b3Vector3 norm = *this;
|
||||
@@ -941,7 +941,7 @@ SIMD_FORCE_INLINE b3Vector3 b3Vector3::normalized() const
|
||||
#endif
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE b3Vector3 b3Vector3::rotate( const b3Vector3& wAxis, const b3Scalar _angle ) const
|
||||
B3_FORCE_INLINE b3Vector3 b3Vector3::rotate( const b3Vector3& wAxis, const b3Scalar _angle ) const
|
||||
{
|
||||
// wAxis must be a unit lenght vector
|
||||
|
||||
@@ -983,7 +983,7 @@ SIMD_FORCE_INLINE b3Vector3 b3Vector3::rotate( const b3Vector3& wAxis, const b3S
|
||||
#endif
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE long b3Vector3::maxDot( const b3Vector3 *array, long array_count, b3Scalar &dotOut ) const
|
||||
B3_FORCE_INLINE long b3Vector3::maxDot( const b3Vector3 *array, long array_count, b3Scalar &dotOut ) const
|
||||
{
|
||||
#if defined (B3_USE_SSE) || defined (B3_USE_NEON)
|
||||
#if defined _WIN32 || defined (B3_USE_SSE)
|
||||
@@ -998,7 +998,7 @@ SIMD_FORCE_INLINE long b3Vector3::maxDot( const b3Vector3 *array, long arra
|
||||
|
||||
#endif//B3_USE_SSE || B3_USE_NEON
|
||||
{
|
||||
b3Scalar maxDot = -SIMD_INFINITY;
|
||||
b3Scalar maxDot = -B3_INFINITY;
|
||||
int i = 0;
|
||||
int ptIndex = -1;
|
||||
for( i = 0; i < array_count; i++ )
|
||||
@@ -1020,7 +1020,7 @@ SIMD_FORCE_INLINE long b3Vector3::maxDot( const b3Vector3 *array, long arra
|
||||
#endif
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE long b3Vector3::minDot( const b3Vector3 *array, long array_count, b3Scalar &dotOut ) const
|
||||
B3_FORCE_INLINE long b3Vector3::minDot( const b3Vector3 *array, long array_count, b3Scalar &dotOut ) const
|
||||
{
|
||||
#if defined (B3_USE_SSE) || defined (B3_USE_NEON)
|
||||
#if defined B3_USE_SSE
|
||||
@@ -1036,7 +1036,7 @@ SIMD_FORCE_INLINE long b3Vector3::minDot( const b3Vector3 *array, long arra
|
||||
if( array_count < scalar_cutoff )
|
||||
#endif//B3_USE_SSE || B3_USE_NEON
|
||||
{
|
||||
b3Scalar minDot = SIMD_INFINITY;
|
||||
b3Scalar minDot = B3_INFINITY;
|
||||
int i = 0;
|
||||
int ptIndex = -1;
|
||||
|
||||
@@ -1065,27 +1065,27 @@ class b3Vector4 : public b3Vector3
|
||||
{
|
||||
public:
|
||||
|
||||
SIMD_FORCE_INLINE b3Vector4() {}
|
||||
B3_FORCE_INLINE b3Vector4() {}
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE b3Vector4(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z,const b3Scalar& _w)
|
||||
B3_FORCE_INLINE b3Vector4(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z,const b3Scalar& _w)
|
||||
: b3Vector3(_x,_y,_z)
|
||||
{
|
||||
m_floats[3] = _w;
|
||||
}
|
||||
|
||||
#if (defined (B3_USE_SSE_IN_API)&& defined (B3_USE_SSE)) || defined (B3_USE_NEON)
|
||||
SIMD_FORCE_INLINE b3Vector4(const b3SimdFloat4 vec)
|
||||
B3_FORCE_INLINE b3Vector4(const b3SimdFloat4 vec)
|
||||
{
|
||||
mVec128 = vec;
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE b3Vector4(const b3Vector3& rhs)
|
||||
B3_FORCE_INLINE b3Vector4(const b3Vector3& rhs)
|
||||
{
|
||||
mVec128 = rhs.mVec128;
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE b3Vector4&
|
||||
B3_FORCE_INLINE b3Vector4&
|
||||
operator=(const b3Vector4& v)
|
||||
{
|
||||
mVec128 = v.mVec128;
|
||||
@@ -1093,7 +1093,7 @@ public:
|
||||
}
|
||||
#endif // #if defined (B3_USE_SSE_IN_API) || defined (B3_USE_NEON)
|
||||
|
||||
SIMD_FORCE_INLINE b3Vector4 absolute4() const
|
||||
B3_FORCE_INLINE b3Vector4 absolute4() const
|
||||
{
|
||||
#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)
|
||||
return b3Vector4(_mm_and_ps(mVec128, b3vAbsfMask));
|
||||
@@ -1112,7 +1112,7 @@ public:
|
||||
b3Scalar getW() const { return m_floats[3];}
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE int maxAxis4() const
|
||||
B3_FORCE_INLINE int maxAxis4() const
|
||||
{
|
||||
int maxIndex = -1;
|
||||
b3Scalar maxVal = b3Scalar(-B3_LARGE_FLOAT);
|
||||
@@ -1141,7 +1141,7 @@ public:
|
||||
}
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE int minAxis4() const
|
||||
B3_FORCE_INLINE int minAxis4() const
|
||||
{
|
||||
int minIndex = -1;
|
||||
b3Scalar minVal = b3Scalar(B3_LARGE_FLOAT);
|
||||
@@ -1170,7 +1170,7 @@ public:
|
||||
}
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE int closestAxis4() const
|
||||
B3_FORCE_INLINE int closestAxis4() const
|
||||
{
|
||||
return absolute4().maxAxis4();
|
||||
}
|
||||
@@ -1198,7 +1198,7 @@ public:
|
||||
* @param z Value of z
|
||||
* @param w Value of w
|
||||
*/
|
||||
SIMD_FORCE_INLINE void setValue(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z,const b3Scalar& _w)
|
||||
B3_FORCE_INLINE void setValue(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z,const b3Scalar& _w)
|
||||
{
|
||||
m_floats[0]=_x;
|
||||
m_floats[1]=_y;
|
||||
@@ -1211,7 +1211,7 @@ public:
|
||||
|
||||
|
||||
///b3SwapVector3Endian swaps vector endianness, useful for network and cross-platform serialization
|
||||
SIMD_FORCE_INLINE void b3SwapScalarEndian(const b3Scalar& sourceVal, b3Scalar& destVal)
|
||||
B3_FORCE_INLINE void b3SwapScalarEndian(const b3Scalar& sourceVal, b3Scalar& destVal)
|
||||
{
|
||||
#ifdef B3_USE_DOUBLE_PRECISION
|
||||
unsigned char* dest = (unsigned char*) &destVal;
|
||||
@@ -1234,7 +1234,7 @@ SIMD_FORCE_INLINE void b3SwapScalarEndian(const b3Scalar& sourceVal, b3Scalar& d
|
||||
#endif //B3_USE_DOUBLE_PRECISION
|
||||
}
|
||||
///b3SwapVector3Endian swaps vector endianness, useful for network and cross-platform serialization
|
||||
SIMD_FORCE_INLINE void b3SwapVector3Endian(const b3Vector3& sourceVec, b3Vector3& destVec)
|
||||
B3_FORCE_INLINE void b3SwapVector3Endian(const b3Vector3& sourceVec, b3Vector3& destVec)
|
||||
{
|
||||
for (int i=0;i<4;i++)
|
||||
{
|
||||
@@ -1244,7 +1244,7 @@ SIMD_FORCE_INLINE void b3SwapVector3Endian(const b3Vector3& sourceVec, b3Vector3
|
||||
}
|
||||
|
||||
///b3UnSwapVector3Endian swaps vector endianness, useful for network and cross-platform serialization
|
||||
SIMD_FORCE_INLINE void b3UnSwapVector3Endian(b3Vector3& vector)
|
||||
B3_FORCE_INLINE void b3UnSwapVector3Endian(b3Vector3& vector)
|
||||
{
|
||||
|
||||
b3Vector3 swappedVec;
|
||||
@@ -1256,9 +1256,9 @@ SIMD_FORCE_INLINE void b3UnSwapVector3Endian(b3Vector3& vector)
|
||||
}
|
||||
|
||||
template <class T>
|
||||
SIMD_FORCE_INLINE void b3PlaneSpace1 (const T& n, T& p, T& q)
|
||||
B3_FORCE_INLINE void b3PlaneSpace1 (const T& n, T& p, T& q)
|
||||
{
|
||||
if (b3Fabs(n[2]) > SIMDSQRT12) {
|
||||
if (b3Fabs(n[2]) > B3_SQRT12) {
|
||||
// choose p in y-z plane
|
||||
b3Scalar a = n[1]*n[1] + n[2]*n[2];
|
||||
b3Scalar k = b3RecipSqrt (a);
|
||||
@@ -1296,42 +1296,42 @@ struct b3Vector3DoubleData
|
||||
|
||||
};
|
||||
|
||||
SIMD_FORCE_INLINE void b3Vector3::serializeFloat(struct b3Vector3FloatData& dataOut) const
|
||||
B3_FORCE_INLINE void b3Vector3::serializeFloat(struct b3Vector3FloatData& dataOut) const
|
||||
{
|
||||
///could also do a memcpy, check if it is worth it
|
||||
for (int i=0;i<4;i++)
|
||||
dataOut.m_floats[i] = float(m_floats[i]);
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE void b3Vector3::deSerializeFloat(const struct b3Vector3FloatData& dataIn)
|
||||
B3_FORCE_INLINE void b3Vector3::deSerializeFloat(const struct b3Vector3FloatData& dataIn)
|
||||
{
|
||||
for (int i=0;i<4;i++)
|
||||
m_floats[i] = b3Scalar(dataIn.m_floats[i]);
|
||||
}
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE void b3Vector3::serializeDouble(struct b3Vector3DoubleData& dataOut) const
|
||||
B3_FORCE_INLINE void b3Vector3::serializeDouble(struct b3Vector3DoubleData& dataOut) const
|
||||
{
|
||||
///could also do a memcpy, check if it is worth it
|
||||
for (int i=0;i<4;i++)
|
||||
dataOut.m_floats[i] = double(m_floats[i]);
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE void b3Vector3::deSerializeDouble(const struct b3Vector3DoubleData& dataIn)
|
||||
B3_FORCE_INLINE void b3Vector3::deSerializeDouble(const struct b3Vector3DoubleData& dataIn)
|
||||
{
|
||||
for (int i=0;i<4;i++)
|
||||
m_floats[i] = b3Scalar(dataIn.m_floats[i]);
|
||||
}
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE void b3Vector3::serialize(struct b3Vector3Data& dataOut) const
|
||||
B3_FORCE_INLINE void b3Vector3::serialize(struct b3Vector3Data& dataOut) const
|
||||
{
|
||||
///could also do a memcpy, check if it is worth it
|
||||
for (int i=0;i<4;i++)
|
||||
dataOut.m_floats[i] = m_floats[i];
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE void b3Vector3::deSerialize(const struct b3Vector3Data& dataIn)
|
||||
B3_FORCE_INLINE void b3Vector3::deSerialize(const struct b3Vector3Data& dataIn)
|
||||
{
|
||||
for (int i=0;i<4;i++)
|
||||
m_floats[i] = dataIn.m_floats[i];
|
||||
|
||||
Reference in New Issue
Block a user