summaryrefslogtreecommitdiff
path: root/thirdparty/bullet/src/Bullet3Common/shared/b3Float4.h
diff options
context:
space:
mode:
authorAndreaCatania <info@andreacatania.com>2017-08-01 14:30:58 +0200
committerAndreaCatania <info@andreacatania.com>2017-11-04 20:08:26 +0100
commited047261f06f814eeb88a1f6ee2dd8abd7a14034 (patch)
tree3addbdbfa8ca5068226a644a0dbbbee0ed691303 /thirdparty/bullet/src/Bullet3Common/shared/b3Float4.h
parent3cbcf5c2ddadf1cd630137d6bd438634b8517b00 (diff)
Vendor thirdparty Bullet source for upcoming physics server backend
Diffstat (limited to 'thirdparty/bullet/src/Bullet3Common/shared/b3Float4.h')
-rw-r--r--thirdparty/bullet/src/Bullet3Common/shared/b3Float4.h97
1 files changed, 97 insertions, 0 deletions
diff --git a/thirdparty/bullet/src/Bullet3Common/shared/b3Float4.h b/thirdparty/bullet/src/Bullet3Common/shared/b3Float4.h
new file mode 100644
index 0000000000..5e4b95bcee
--- /dev/null
+++ b/thirdparty/bullet/src/Bullet3Common/shared/b3Float4.h
@@ -0,0 +1,97 @@
+#ifndef B3_FLOAT4_H
+#define B3_FLOAT4_H
+
+#include "Bullet3Common/shared/b3PlatformDefinitions.h"
+
+#ifdef __cplusplus
+ #include "Bullet3Common/b3Vector3.h"
+ #define b3Float4 b3Vector3
+ #define b3Float4ConstArg const b3Vector3&
+ #define b3Dot3F4 b3Dot
+ #define b3Cross3 b3Cross
+ #define b3MakeFloat4 b3MakeVector3
+ inline b3Vector3 b3Normalized(const b3Vector3& vec)
+ {
+ return vec.normalized();
+ }
+
+ inline b3Float4 b3FastNormalized3(b3Float4ConstArg v)
+ {
+ return v.normalized();
+ }
+
+ inline b3Float4 b3MaxFloat4 (const b3Float4& a, const b3Float4& b)
+ {
+ b3Float4 tmp = a;
+ tmp.setMax(b);
+ return tmp;
+ }
+ inline b3Float4 b3MinFloat4 (const b3Float4& a, const b3Float4& b)
+ {
+ b3Float4 tmp = a;
+ tmp.setMin(b);
+ return tmp;
+ }
+
+
+
+#else
+ typedef float4 b3Float4;
+ #define b3Float4ConstArg const b3Float4
+ #define b3MakeFloat4 (float4)
+ float b3Dot3F4(b3Float4ConstArg v0,b3Float4ConstArg v1)
+ {
+ float4 a1 = b3MakeFloat4(v0.xyz,0.f);
+ float4 b1 = b3MakeFloat4(v1.xyz,0.f);
+ return dot(a1, b1);
+ }
+ b3Float4 b3Cross3(b3Float4ConstArg v0,b3Float4ConstArg v1)
+ {
+ float4 a1 = b3MakeFloat4(v0.xyz,0.f);
+ float4 b1 = b3MakeFloat4(v1.xyz,0.f);
+ return cross(a1, b1);
+ }
+ #define b3MinFloat4 min
+ #define b3MaxFloat4 max
+
+ #define b3Normalized(a) normalize(a)
+
+#endif
+
+
+
+inline bool b3IsAlmostZero(b3Float4ConstArg v)
+{
+ if(b3Fabs(v.x)>1e-6 || b3Fabs(v.y)>1e-6 || b3Fabs(v.z)>1e-6)
+ return false;
+ return true;
+}
+
+
+inline int b3MaxDot( b3Float4ConstArg vec, __global const b3Float4* vecArray, int vecLen, float* dotOut )
+{
+ float maxDot = -B3_INFINITY;
+ int i = 0;
+ int ptIndex = -1;
+ for( i = 0; i < vecLen; i++ )
+ {
+ float dot = b3Dot3F4(vecArray[i],vec);
+
+ if( dot > maxDot )
+ {
+ maxDot = dot;
+ ptIndex = i;
+ }
+ }
+ b3Assert(ptIndex>=0);
+ if (ptIndex<0)
+ {
+ ptIndex = 0;
+ }
+ *dotOut = maxDot;
+ return ptIndex;
+}
+
+
+
+#endif //B3_FLOAT4_H