move some files to shared folders

use b3Aabb for compound vs compound on host (for testing, towards BVH)
This commit is contained in:
erwin coumans
2013-08-14 17:48:12 -07:00
parent 678f634699
commit b32ae0c75c
36 changed files with 1633 additions and 835 deletions

View File

@@ -16,7 +16,7 @@ subject to the following restrictions:
#ifndef B3_OVERLAPPING_PAIR_H
#define B3_OVERLAPPING_PAIR_H
#include "Bullet3Common/b3Int4.h"
#include "Bullet3Common/shared/b3Int4.h"
#define B3_NEW_PAIR_MARKER -1
#define B3_REMOVED_PAIR_MARKER -2

View File

@@ -16,7 +16,7 @@ subject to the following restrictions:
#ifndef B3_OVERLAPPING_PAIR_CACHE_H
#define B3_OVERLAPPING_PAIR_CACHE_H
#include "Bullet3Common/b3Int2.h"
#include "Bullet3Common/shared/b3Int2.h"
#include "Bullet3Common/b3AlignedObjectArray.h"
class b3Dispatcher;

View File

@@ -18,20 +18,14 @@ subject to the following restrictions:
#include "Bullet3Common/b3Scalar.h"
#include "Bullet3Common/b3Matrix3x3.h"
#include "Bullet3Collision/NarrowPhaseCollision/Shared/b3RigidBodyData.h"
B3_ATTRIBUTE_ALIGNED16(struct) b3RigidBodyCL
B3_ATTRIBUTE_ALIGNED16(struct) b3RigidBodyCL : public b3RigidBodyData
{
B3_DECLARE_ALIGNED_ALLOCATOR();
b3Vector3 m_pos;
b3Quaternion m_quat;
b3Vector3 m_linVel;
b3Vector3 m_angVel;
int m_collidableIdx;
float m_invMass;
float m_restituitionCoeff;
float m_frictionCoeff;
float getInvMass() const
{

View File

@@ -2,8 +2,9 @@
#ifndef B3_COLLIDABLE_H
#define B3_COLLIDABLE_H
#include "Bullet3Common/b3Vector3.h"
#include "Bullet3Common/b3Quaternion.h"
#include "Bullet3Common/shared/b3Float4.h"
#include "Bullet3Common/shared/b3Quat.h"
enum b3ShapeTypes
{
@@ -23,22 +24,22 @@ struct b3Collidable
int m_numChildShapes;
int m_bvhIndex;
};
float m_radius;
union
{
float m_radius;
int m_compoundBvhIndex;
};
int m_shapeType;
int m_shapeIndex;
};
struct b3CollidableNew
{
short int m_shapeType;
short int m_numShapes;
int m_shapeIndex;
};
struct b3GpuChildShape
{
b3Vector3 m_childPosition;
b3Quaternion m_childOrientation;
b3Float4 m_childPosition;
b3Quat m_childOrientation;
int m_shapeIndex;
int m_unused0;
int m_unused1;

View File

@@ -0,0 +1,37 @@
#ifndef B3_CONVEX_POLYHEDRON_DATA_H
#define B3_CONVEX_POLYHEDRON_DATA_H
#include "Bullet3Common/shared/b3Float4.h"
#include "Bullet3Common/shared/b3Quat.h"
struct b3GpuFace
{
b3Float4 m_plane;
int m_indexOffset;
int m_numIndices;
int m_unusedPadding1;
int m_unusedPadding2;
};
B3_ATTRIBUTE_ALIGNED16(struct) b3ConvexPolyhedronData
{
b3Float4 m_localCenter;
b3Float4 m_extents;
b3Float4 mC;
b3Float4 mE;
float m_radius;
int m_faceOffset;
int m_numFaces;
int m_numVertices;
int m_vertexOffset;
int m_uniqueEdgesOffset;
int m_numUniqueEdges;
int m_unused;
};
#endif //B3_CONVEX_POLYHEDRON_DATA_H

View File

@@ -0,0 +1,21 @@
#ifndef B3_RIGIDBODY_DATA_H
#define B3_RIGIDBODY_DATA_H
#include "Bullet3Common/shared/b3Float4.h"
#include "Bullet3Common/shared/b3Quat.h"
struct b3RigidBodyData
{
b3Float4 m_pos;
b3Quat m_quat;
b3Float4 m_linVel;
b3Float4 m_angVel;
int m_collidableIdx;
float m_invMass;
float m_restituitionCoeff;
float m_frictionCoeff;
};
#endif //B3_RIGIDBODY_DATA_H

View File

@@ -832,6 +832,12 @@ b3Slerp(const b3Quaternion& q1, const b3Quaternion& q2, const b3Scalar& t)
return q1.slerp(q2, t);
}
B3_FORCE_INLINE b3Quaternion
b3QuatMul(const b3Quaternion& rot0, const b3Quaternion& rot1)
{
return rot0*rot1;
}
B3_FORCE_INLINE b3Vector3
b3QuatRotate(const b3Quaternion& rotation, const b3Vector3& v)
{

View File

@@ -4,8 +4,9 @@
#include "Bullet3Common/shared/b3PlatformDefinitions.h"
#ifdef __cplusplus
#include "Bullet3Common/b3Vector3.h"
#define b3Float4 b3Vector3
#else//bla
#else
typedef float4 b3Float4;
#endif

View File

@@ -6,4 +6,11 @@ struct MyTest
int bla;
};
#ifdef __cplusplus
#define b3AtomicInc(a) ((*a)++)
#else
#define b3AtomicInc atomic_inc
#endif
#endif

View File

@@ -0,0 +1,13 @@
#ifndef B3_QUAT_H
#define B3_QUAT_H
#include "Bullet3Common/shared/b3PlatformDefinitions.h"
#ifdef __cplusplus
#include "Bullet3Common/b3Quaternion.h"
#define b3Quat b3Quaternion
#else
typedef float4 b3Quat;
#endif
#endif //B3_QUAT_H

View File

@@ -16,7 +16,7 @@ subject to the following restrictions:
#ifndef B3_SOLVER_BODY_H
#define B3_SOLVER_BODY_H
class b3RigidBody;
struct b3RigidBody;
#include "Bullet3Common/b3Vector3.h"
#include "Bullet3Common/b3Matrix3x3.h"

View File

@@ -16,7 +16,7 @@ subject to the following restrictions:
#ifndef B3_SOLVER_CONSTRAINT_H
#define B3_SOLVER_CONSTRAINT_H
class b3RigidBody;
struct b3RigidBody;
#include "Bullet3Common/b3Vector3.h"
#include "Bullet3Common/b3Matrix3x3.h"
//#include "b3JacobianEntry.h"

View File

@@ -61,6 +61,7 @@ B3_ATTRIBUTE_ALIGNED16(struct) b3JointFeedback
b3Vector3 m_appliedTorqueBodyB;
};
struct b3RigidBodyCL;

View File

@@ -7,7 +7,7 @@ class b3Vector3;
#include "Bullet3OpenCL/ParallelPrimitives/b3RadixSort32CL.h"
#include "b3SapAabb.h"
#include "Bullet3Common/b3Int2.h"
#include "Bullet3Common/shared/b3Int2.h"
class b3GpuSapBroadphase

View File

@@ -2,19 +2,13 @@
#define B3_SAP_AABB_H
#include "Bullet3Common/b3Scalar.h"
#include "Bullet3Collision/BroadPhaseCollision/shared/b3Aabb.h"
B3_ATTRIBUTE_ALIGNED16(struct) b3SapAabb
///just make sure that the b3Aabb is 16-byte aligned
B3_ATTRIBUTE_ALIGNED16(struct) b3SapAabb : public b3Aabb
{
union
{
float m_min[4];
int m_minIndices[4];
};
union
{
float m_max[4];
int m_signedMaxIndices[4];
};
};
#endif //B3_SAP_AABB_H

File diff suppressed because it is too large Load Diff

View File

@@ -7,30 +7,18 @@
#include "Bullet3Common/b3AlignedObjectArray.h"
#include "b3ConvexUtility.h"
#include "b3ConvexPolyhedronCL.h"
#include "b3Collidable.h"
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3Collidable.h"
#include "Bullet3Collision/NarrowPhaseCollision/b3Contact4.h"
#include "Bullet3Common/b3Int2.h"
#include "Bullet3Common/b3Int4.h"
#include "Bullet3Common/shared/b3Int2.h"
#include "Bullet3Common/shared/b3Int4.h"
#include "b3OptimizedBvh.h"
#include "b3BvhInfo.h"
#include "Bullet3Collision/BroadPhaseCollision/shared/b3Aabb.h"
//#include "../../dynamics/basic_demo/Stubs/ChNarrowPhase.h"
struct b3YetAnotherAabb
{
union
{
float m_min[4];
int m_minIndices[4];
};
union
{
float m_max[4];
//int m_signedMaxIndices[4];
//unsigned int m_unsignedMaxIndices[4];
};
};
struct GpuSatCollision
{
@@ -89,7 +77,9 @@ struct GpuSatCollision
const b3OpenCLArray<b3Collidable>& gpuCollidables,
const b3OpenCLArray<b3GpuChildShape>& gpuChildShapes,
const b3OpenCLArray<b3YetAnotherAabb>& clAabbs,
const b3OpenCLArray<b3Aabb>& clAabbsWorldSpace,
const b3OpenCLArray<b3Aabb>& clAabbsLocalSpace,
b3OpenCLArray<b3Vector3>& worldVertsB1GPU,
b3OpenCLArray<b3Int4>& clippingFacesOutGPU,
b3OpenCLArray<b3Vector3>& worldNormalsAGPU,

View File

@@ -2,34 +2,12 @@
#define CONVEX_POLYHEDRON_CL
#include "Bullet3Common/b3Transform.h"
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3ConvexPolyhedronData.h"
struct b3GpuFace
B3_ATTRIBUTE_ALIGNED16(struct) b3ConvexPolyhedronCL : public b3ConvexPolyhedronData
{
b3Vector4 m_plane;
int m_indexOffset;
int m_numIndices;
int m_unusedPadding1;
int m_unusedPadding2;
};
B3_ATTRIBUTE_ALIGNED16(struct) b3ConvexPolyhedronCL
{
b3Vector3 m_localCenter;
b3Vector3 m_extents;
b3Vector3 mC;
b3Vector3 mE;
b3Scalar m_radius;
int m_faceOffset;
int m_numFaces;
int m_numVertices;
int m_vertexOffset;
int m_uniqueEdgesOffset;
int m_numUniqueEdges;
int m_unused;
inline void project(const b3Transform& trans, const b3Vector3& dir, const b3AlignedObjectArray<b3Vector3>& vertices, b3Scalar& min, b3Scalar& max) const
{

View File

@@ -10,9 +10,13 @@ static const char* primitiveContactsKernelsCL= \
"{\n"
" int bla;\n"
"};\n"
"#ifdef __cplusplus\n"
"#else\n"
"#define b3AtomicInc atomic_inc\n"
"#endif\n"
"#endif\n"
"#ifdef __cplusplus\n"
"#else//bla\n"
"#else\n"
" typedef float4 b3Float4;\n"
"#endif \n"
"#endif //B3_FLOAT4_H\n"

View File

@@ -42,9 +42,13 @@ static const char* satClipKernelsCL= \
"{\n"
" int bla;\n"
"};\n"
"#ifdef __cplusplus\n"
"#else\n"
"#define b3AtomicInc atomic_inc\n"
"#endif\n"
"#endif\n"
"#ifdef __cplusplus\n"
"#else//bla\n"
"#else\n"
" typedef float4 b3Float4;\n"
"#endif \n"
"#endif //B3_FLOAT4_H\n"

View File

@@ -4,8 +4,8 @@
#include "b3OpenCLArray.h"
#include "Bullet3Common/b3Scalar.h"
#include "Bullet3Common/b3Int2.h"
#include "Bullet3Common/b3Int4.h"
#include "Bullet3Common/shared/b3Int2.h"
#include "Bullet3Common/shared/b3Int4.h"
class b3FillCL

View File

@@ -1,6 +1,6 @@
#include "b3GpuRaycast.h"
#include "Bullet3OpenCL/NarrowphaseCollision/b3Collidable.h"
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3Collidable.h"
#include "Bullet3Collision/NarrowPhaseCollision/b3RigidBodyCL.h"
#include "Bullet3OpenCL/RigidBody/b3GpuNarrowPhaseInternalData.h"

View File

@@ -698,7 +698,7 @@ const struct b3Collidable* b3GpuNarrowPhase::getCollidablesCpu() const
}
cl_mem b3GpuNarrowPhase::getAabbBufferGpu()
cl_mem b3GpuNarrowPhase::getAabbLocalSpaceBufferGpu()
{
return m_data->m_localShapeAABBGPU->getBufferCL();
}
@@ -726,8 +726,11 @@ const b3Contact4* b3GpuNarrowPhase::getContactsCPU() const
return &m_data->m_pBufContactOutCPU->at(0);
}
void b3GpuNarrowPhase::computeContacts(cl_mem broadphasePairs, int numBroadphasePairs, cl_mem aabbsWS, int numObjects)
void b3GpuNarrowPhase::computeContacts(cl_mem broadphasePairs, int numBroadphasePairs, cl_mem aabbsWorldSpace, int numObjects)
{
cl_mem aabbsLocalSpace = m_data->m_localShapeAABBGPU->getBufferCL();
int nContactOut = 0;
//swap buffer
@@ -744,8 +747,11 @@ void b3GpuNarrowPhase::computeContacts(cl_mem broadphasePairs, int numBroadphase
b3OpenCLArray<b3YetAnotherAabb> clAabbArray(this->m_context,this->m_queue);
clAabbArray.setFromOpenCLBuffer(aabbsWS,numObjects);
b3OpenCLArray<b3Aabb> clAabbArrayWorldSpace(this->m_context,this->m_queue);
clAabbArrayWorldSpace.setFromOpenCLBuffer(aabbsWorldSpace,numObjects);
b3OpenCLArray<b3Aabb> clAabbArrayLocalSpace(this->m_context,this->m_queue);
clAabbArrayLocalSpace.setFromOpenCLBuffer(aabbsLocalSpace,numObjects);
m_data->m_gpuSatCollision->computeConvexConvexContactsGPUSAT(
&broadphasePairsGPU, numBroadphasePairs,
@@ -762,7 +768,8 @@ void b3GpuNarrowPhase::computeContacts(cl_mem broadphasePairs, int numBroadphase
*m_data->m_convexIndicesGPU,
*m_data->m_collidablesGPU,
*m_data->m_gpuChildShapes,
clAabbArray,
clAabbArrayWorldSpace,
clAabbArrayLocalSpace,
*m_data->m_worldVertsB1GPU,
*m_data->m_clippingFacesOutGPU,
*m_data->m_worldNormalsAGPU,

View File

@@ -1,7 +1,7 @@
#ifndef B3_GPU_NARROWPHASE_H
#define B3_GPU_NARROWPHASE_H
#include "Bullet3OpenCL/NarrowphaseCollision/b3Collidable.h"
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3Collidable.h"
#include "Bullet3OpenCL/Initialize/b3OpenCLInclude.h"
#include "Bullet3Common/b3AlignedObjectArray.h"
#include "Bullet3Common/b3Vector3.h"
@@ -56,7 +56,7 @@ public:
void setObjectVelocityCpu(float* linVel, float* angVel, int bodyIndex);
virtual void computeContacts(cl_mem broadphasePairs, int numBroadphasePairs, cl_mem aabbs, int numObjects);
virtual void computeContacts(cl_mem broadphasePairs, int numBroadphasePairs, cl_mem aabbsWorldSpace, int numObjects);
cl_mem getBodiesGpu();
@@ -78,7 +78,7 @@ public:
cl_mem getContactsGpu();
int getNumContactsGpu() const;
cl_mem getAabbBufferGpu();
cl_mem getAabbLocalSpaceBufferGpu();
int getNumRigidBodies() const;

View File

@@ -5,7 +5,8 @@
#include "Bullet3OpenCL/ParallelPrimitives/b3OpenCLArray.h"
#include "Bullet3OpenCL/NarrowphaseCollision/b3ConvexPolyhedronCL.h"
#include "b3Config.h"
#include "Bullet3OpenCL/NarrowphaseCollision/b3Collidable.h"
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3Collidable.h"
#include "Bullet3OpenCL/Initialize/b3OpenCLInclude.h"
#include "Bullet3Common/b3AlignedObjectArray.h"
#include "Bullet3Common/b3Vector3.h"
@@ -16,8 +17,8 @@
#include "Bullet3OpenCL/NarrowphaseCollision/b3QuantizedBvh.h"
#include "Bullet3OpenCL/NarrowphaseCollision/b3BvhInfo.h"
#include "Bullet3Common/b3Int4.h"
#include "Bullet3Common/b3Int2.h"
#include "Bullet3Common/shared/b3Int4.h"
#include "Bullet3Common/shared/b3Int2.h"
class b3ConvexUtility;

View File

@@ -450,7 +450,7 @@ void b3GpuRigidBodyPipeline::setupGpuAabbsFull()
launcher.setBuffer(bodies);
cl_mem collidables = m_data->m_narrowphase->getCollidablesGpu();
launcher.setBuffer(collidables);
cl_mem localAabbs = m_data->m_narrowphase->getAabbBufferGpu();
cl_mem localAabbs = m_data->m_narrowphase->getAabbLocalSpaceBufferGpu();
launcher.setBuffer(localAabbs);
cl_mem worldAabbs =0;

View File

@@ -20,7 +20,8 @@ subject to the following restrictions:
#include "Bullet3Common/b3AlignedObjectArray.h"
#include "Bullet3OpenCL/ParallelPrimitives/b3OpenCLArray.h"
#include "Bullet3OpenCL/NarrowphaseCollision/b3Collidable.h"
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3Collidable.h"
#include "Bullet3OpenCL/BroadphaseCollision/b3SapAabb.h"
#include "Bullet3Dynamics/ConstraintSolver/b3TypedConstraint.h"

View File

@@ -22,9 +22,13 @@ static const char* batchingKernelsCL= \
"{\n"
" int bla;\n"
"};\n"
"#ifdef __cplusplus\n"
"#else\n"
"#define b3AtomicInc atomic_inc\n"
"#endif\n"
"#endif\n"
"#ifdef __cplusplus\n"
"#else//bla\n"
"#else\n"
" typedef float4 b3Float4;\n"
"#endif \n"
"#endif //B3_FLOAT4_H\n"

View File

@@ -22,9 +22,13 @@ static const char* batchingKernelsNewCL= \
"{\n"
" int bla;\n"
"};\n"
"#ifdef __cplusplus\n"
"#else\n"
"#define b3AtomicInc atomic_inc\n"
"#endif\n"
"#endif\n"
"#ifdef __cplusplus\n"
"#else//bla\n"
"#else\n"
" typedef float4 b3Float4;\n"
"#endif \n"
"#endif //B3_FLOAT4_H\n"

View File

@@ -22,9 +22,13 @@ static const char* solverSetupCL= \
"{\n"
" int bla;\n"
"};\n"
"#ifdef __cplusplus\n"
"#else\n"
"#define b3AtomicInc atomic_inc\n"
"#endif\n"
"#endif\n"
"#ifdef __cplusplus\n"
"#else//bla\n"
"#else\n"
" typedef float4 b3Float4;\n"
"#endif \n"
"#endif //B3_FLOAT4_H\n"

View File

@@ -22,9 +22,13 @@ static const char* solverSetup2CL= \
"{\n"
" int bla;\n"
"};\n"
"#ifdef __cplusplus\n"
"#else\n"
"#define b3AtomicInc atomic_inc\n"
"#endif\n"
"#endif\n"
"#ifdef __cplusplus\n"
"#else//bla\n"
"#else\n"
" typedef float4 b3Float4;\n"
"#endif \n"
"#endif //B3_FLOAT4_H\n"

View File

@@ -22,9 +22,13 @@ static const char* solverUtilsCL= \
"{\n"
" int bla;\n"
"};\n"
"#ifdef __cplusplus\n"
"#else\n"
"#define b3AtomicInc atomic_inc\n"
"#endif\n"
"#endif\n"
"#ifdef __cplusplus\n"
"#else//bla\n"
"#else\n"
" typedef float4 b3Float4;\n"
"#endif \n"
"#endif //B3_FLOAT4_H\n"

View File

@@ -17,7 +17,7 @@ subject to the following restrictions:
#include "Bullet3OpenCL/Initialize/b3OpenCLUtils.h"
#include "Bullet3OpenCL/ParallelPrimitives/b3OpenCLArray.h"
#include "Bullet3Common/b3Int2.h"
#include "Bullet3Common/shared/b3Int2.h"
#include "../btgui/Timing/b3Clock.h"
#include "b3BitonicSort.h"