share more code between OpenCL kernels and C++ by moving kernel data structures/code to the 'shared' folders

This commit is contained in:
erwin coumans
2013-11-06 19:57:36 -08:00
parent 82a6855f9e
commit a9a758dd54
21 changed files with 549 additions and 364 deletions

View File

@@ -18,6 +18,9 @@ enum b3ShapeTypes
MAX_NUM_SHAPE_TYPES,
};
typedef struct b3Collidable b3Collidable_t;
struct b3Collidable
{
union {

View File

@@ -4,6 +4,9 @@
#include "Bullet3Common/shared/b3Float4.h"
#include "Bullet3Common/shared/b3Quat.h"
typedef struct b3RigidBodyData b3RigidBodyData_t;
struct b3RigidBodyData
{
b3Float4 m_pos;
@@ -17,5 +20,6 @@ struct b3RigidBodyData
float m_frictionCoeff;
};
#endif //B3_RIGIDBODY_DATA_H

View File

@@ -4,13 +4,15 @@
#include "Bullet3Collision/BroadPhaseCollision/shared/b3Aabb.h"
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3CollidableData.h"
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3Collidable.h"
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3RigidBodyData.h"
void b3ComputeWorldAabb( int bodyId, b3RigidBodyData* body, b3CollidableData* collidables, b3Aabb* localShapeAABB, b3Aabb* worldAabbs)
void b3ComputeWorldAabb( int bodyId, __global const b3RigidBodyData_t* bodies, __global const b3Collidable_t* collidables, __global const b3Aabb_t* localShapeAABB, __global b3Aabb_t* worldAabbs)
{
__global const b3RigidBodyData_t* body = &bodies[bodyId];
b3Float4 position = body->m_pos;
b3Quat orientation = body->m_quat;
@@ -20,10 +22,17 @@ void b3ComputeWorldAabb( int bodyId, b3RigidBodyData* body, b3CollidableData* c
if (shapeIndex>=0)
{
b3Aabb localAabb = localShapeAABB[shapeIndex];
b3Aabb worldAabb;
b3Aabb_t localAabb = localShapeAABB[collidableIndex];
b3Aabb_t worldAabb;
b3TransformAabb2(localAabb.m_minVec,localAabb.m_maxVec,margin,position,orientation,&worldAabb.m_minVec,&worldAabb.m_maxVec);
b3Float4 aabbAMinOut,aabbAMaxOut;
float margin = 0.f;
b3TransformAabb2(localAabb.m_minVec,localAabb.m_maxVec,margin,position,orientation,&aabbAMinOut,&aabbAMaxOut);
worldAabb.m_minVec =aabbAMinOut;
worldAabb.m_minIndices[3] = bodyId;
worldAabb.m_maxVec = aabbAMaxOut;
worldAabb.m_signedMaxIndices[3] = body[bodyId].m_invMass==0.f? 0 : 1;
worldAabbs[bodyId] = worldAabb;
}
}