support compound versus compound collision shape acceleration on GPU, using aabb tree versus aabb tree.

Remove constructor from b3Vector3,  to make it a POD type, so it can go into a union (and more compatible with OpenCL float4)
Use b3MakeVector3 instead of constructor
Share some code between C++ and GPU in a shared file: see b3TransformAabb2 in src/Bullet3Collision/BroadPhaseCollision/shared/b3Aabb.h
Improve PairBench a bit, show timings and #overlapping pairs.
Increase shadowmap default size to 8192x8192 (hope the GPU supports it)
This commit is contained in:
erwincoumans
2013-08-20 03:19:59 -07:00
parent 41ba48b10d
commit 677722bba3
62 changed files with 1827 additions and 564 deletions

View File

@@ -6,8 +6,26 @@
#ifdef __cplusplus
#include "Bullet3Common/b3Vector3.h"
#define b3Float4 b3Vector3
#define b3Float4ConstArg const b3Vector3&
#define b3Dot3F4 b3Dot
#define b3Cross3 b3Cross
#define b3MakeFloat4 b3MakeVector3
#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);
}
#endif
#endif //B3_FLOAT4_H

View File

@@ -16,6 +16,8 @@ subject to the following restrictions:
#ifndef B3_INT2_H
#define B3_INT2_H
#ifdef __cplusplus
struct b3UnsignedInt2
{
union
@@ -52,5 +54,11 @@ inline b3Int2 b3MakeInt2(int x, int y)
v.s[0] = x; v.s[1] = y;
return v;
}
#else
#define b3UnsignedInt2 uint2
#define b3Int2 int2
#define b3MakeInt2 (int2)
#endif //__cplusplus
#endif

View File

@@ -0,0 +1,75 @@
#ifndef B3_MAT3x3_H
#define B3_MAT3x3_H
#include "Bullet3Common/shared/b3Quat.h"
#ifdef __cplusplus
#include "Bullet3Common/b3Matrix3x3.h"
#define b3Mat3x3 b3Matrix3x3
#define b3Mat3x3ConstArg const b3Matrix3x3&
inline b3Mat3x3 b3QuatGetRotationMatrix(b3QuatConstArg quat)
{
return b3Mat3x3(quat);
}
inline b3Mat3x3 b3AbsoluteMat3x3(b3Mat3x3ConstArg mat)
{
return mat.absolute();
}
#define b3GetRow(m,row) m.getRow(row)
#else
typedef struct
{
float4 m_row[3];
}b3Mat3x3;
#define b3Mat3x3ConstArg const b3Mat3x3
#define b3GetRow(m,row) (m.m_row[row])
inline b3Mat3x3 b3QuatGetRotationMatrix(b3Quat quat)
{
float4 quat2 = (float4)(quat.x*quat.x, quat.y*quat.y, quat.z*quat.z, 0.f);
b3Mat3x3 out;
out.m_row[0].x=1-2*quat2.y-2*quat2.z;
out.m_row[0].y=2*quat.x*quat.y-2*quat.w*quat.z;
out.m_row[0].z=2*quat.x*quat.z+2*quat.w*quat.y;
out.m_row[0].w = 0.f;
out.m_row[1].x=2*quat.x*quat.y+2*quat.w*quat.z;
out.m_row[1].y=1-2*quat2.x-2*quat2.z;
out.m_row[1].z=2*quat.y*quat.z-2*quat.w*quat.x;
out.m_row[1].w = 0.f;
out.m_row[2].x=2*quat.x*quat.z-2*quat.w*quat.y;
out.m_row[2].y=2*quat.y*quat.z+2*quat.w*quat.x;
out.m_row[2].z=1-2*quat2.x-2*quat2.y;
out.m_row[2].w = 0.f;
return out;
}
inline b3Mat3x3 b3AbsoluteMat3x3(b3Mat3x3ConstArg matIn)
{
b3Mat3x3 out;
out.m_row[0] = fabs(matIn.m_row[0]);
out.m_row[1] = fabs(matIn.m_row[1]);
out.m_row[2] = fabs(matIn.m_row[2]);
return out;
}
#endif
#endif //B3_MAT3x3_H

View File

@@ -2,12 +2,76 @@
#define B3_QUAT_H
#include "Bullet3Common/shared/b3PlatformDefinitions.h"
#include "Bullet3Common/shared/b3Float4.h"
#ifdef __cplusplus
#include "Bullet3Common/b3Quaternion.h"
#include "Bullet3Common/b3Transform.h"
#define b3Quat b3Quaternion
#define b3QuatConstArg const b3Quaternion&
inline b3Float4 b3TransformPoint(b3Float4ConstArg point, b3Float4ConstArg translation, b3QuatConstArg orientation)
{
b3Transform tr;
tr.setOrigin(translation);
tr.setRotation(orientation);
return tr(point);
}
#else
typedef float4 b3Quat;
#define b3QuatConstArg const b3Quat
inline float4 b3FastNormalize4(float4 v)
{
v = (float4)(v.xyz,0.f);
return fast_normalize(v);
}
inline b3Quat b3QuatMul(b3Quat a, b3Quat b);
inline b3Quat b3QuatNormalize(b3QuatConstArg in);
inline b3Quat b3QuatRotate(b3QuatConstArg q, b3QuatConstArg vec);
inline b3Quat b3QuatInvert(b3QuatConstArg q);
inline b3Quat b3QuatMul(b3QuatConstArg a, b3QuatConstArg b)
{
b3Quat ans;
ans = b3Cross3( a, b );
ans += a.w*b+b.w*a;
// ans.w = a.w*b.w - (a.x*b.x+a.y*b.y+a.z*b.z);
ans.w = a.w*b.w - b3Dot3F4(a, b);
return ans;
}
inline b3Quat b3QuatNormalize(b3QuatConstArg in)
{
return b3FastNormalize4(in);
}
inline float4 b3QuatRotate(b3QuatConstArg q, b3QuatConstArg vec)
{
b3Quat qInv = b3QuatInvert( q );
float4 vcpy = vec;
vcpy.w = 0.f;
float4 out = b3QuatMul(b3QuatMul(q,vcpy),qInv);
return out;
}
inline b3Quat b3QuatInvert(b3QuatConstArg q)
{
return (b3Quat)(-q.xyz, q.w);
}
inline float4 b3QuatInvRotate(b3QuatConstArg q, b3QuatConstArg vec)
{
return b3QuatRotate( b3QuatInvert( q ), vec );
}
inline b3Float4 b3TransformPoint(b3Float4ConstArg point, b3Float4ConstArg translation, b3QuatConstArg orientation)
{
return b3QuatRotate( orientation, point ) + (translation);
}
#endif
#endif //B3_QUAT_H