b3UpdateAabbs.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #ifndef B3_UPDATE_AABBS_H
  2. #define B3_UPDATE_AABBS_H
  3. #include "Bullet3Collision/BroadPhaseCollision/shared/b3Aabb.h"
  4. #include "Bullet3Collision/NarrowPhaseCollision/shared/b3Collidable.h"
  5. #include "Bullet3Collision/NarrowPhaseCollision/shared/b3RigidBodyData.h"
  6. void b3ComputeWorldAabb(int bodyId, __global const b3RigidBodyData_t* bodies, __global const b3Collidable_t* collidables, __global const b3Aabb_t* localShapeAABB, __global b3Aabb_t* worldAabbs)
  7. {
  8. __global const b3RigidBodyData_t* body = &bodies[bodyId];
  9. b3Float4 position = body->m_pos;
  10. b3Quat orientation = body->m_quat;
  11. int collidableIndex = body->m_collidableIdx;
  12. int shapeIndex = collidables[collidableIndex].m_shapeIndex;
  13. if (shapeIndex >= 0)
  14. {
  15. b3Aabb_t localAabb = localShapeAABB[collidableIndex];
  16. b3Aabb_t worldAabb;
  17. b3Float4 aabbAMinOut, aabbAMaxOut;
  18. float margin = 0.f;
  19. b3TransformAabb2(localAabb.m_minVec, localAabb.m_maxVec, margin, position, orientation, &aabbAMinOut, &aabbAMaxOut);
  20. worldAabb.m_minVec = aabbAMinOut;
  21. worldAabb.m_minIndices[3] = bodyId;
  22. worldAabb.m_maxVec = aabbAMaxOut;
  23. worldAabb.m_signedMaxIndices[3] = body[bodyId].m_invMass == 0.f ? 0 : 1;
  24. worldAabbs[bodyId] = worldAabb;
  25. }
  26. }
  27. #endif //B3_UPDATE_AABBS_H