2017-08-01 12:30:58 +00:00
|
|
|
#ifndef B3_UPDATE_AABBS_H
|
|
|
|
#define B3_UPDATE_AABBS_H
|
|
|
|
|
|
|
|
#include "Bullet3Collision/BroadPhaseCollision/shared/b3Aabb.h"
|
|
|
|
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3Collidable.h"
|
|
|
|
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3RigidBodyData.h"
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
void b3ComputeWorldAabb(int bodyId, __global const b3RigidBodyData_t* bodies, __global const b3Collidable_t* collidables, __global const b3Aabb_t* localShapeAABB, __global b3Aabb_t* worldAabbs)
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
|
|
|
__global const b3RigidBodyData_t* body = &bodies[bodyId];
|
|
|
|
|
|
|
|
b3Float4 position = body->m_pos;
|
2019-01-03 13:26:51 +00:00
|
|
|
b3Quat orientation = body->m_quat;
|
|
|
|
|
2017-08-01 12:30:58 +00:00
|
|
|
int collidableIndex = body->m_collidableIdx;
|
|
|
|
int shapeIndex = collidables[collidableIndex].m_shapeIndex;
|
2019-01-03 13:26:51 +00:00
|
|
|
|
|
|
|
if (shapeIndex >= 0)
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
|
|
|
b3Aabb_t localAabb = localShapeAABB[collidableIndex];
|
|
|
|
b3Aabb_t worldAabb;
|
2019-01-03 13:26:51 +00:00
|
|
|
|
|
|
|
b3Float4 aabbAMinOut, aabbAMaxOut;
|
2017-08-01 12:30:58 +00:00
|
|
|
float margin = 0.f;
|
2019-01-03 13:26:51 +00:00
|
|
|
b3TransformAabb2(localAabb.m_minVec, localAabb.m_maxVec, margin, position, orientation, &aabbAMinOut, &aabbAMaxOut);
|
|
|
|
|
|
|
|
worldAabb.m_minVec = aabbAMinOut;
|
2017-08-01 12:30:58 +00:00
|
|
|
worldAabb.m_minIndices[3] = bodyId;
|
|
|
|
worldAabb.m_maxVec = aabbAMaxOut;
|
2019-01-03 13:26:51 +00:00
|
|
|
worldAabb.m_signedMaxIndices[3] = body[bodyId].m_invMass == 0.f ? 0 : 1;
|
2017-08-01 12:30:58 +00:00
|
|
|
worldAabbs[bodyId] = worldAabb;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
#endif //B3_UPDATE_AABBS_H
|