summaryrefslogtreecommitdiff
path: root/thirdparty/bullet/Bullet3Collision/NarrowPhaseCollision/shared/b3UpdateAabbs.h
blob: 8d40d19a036ed183d3cdaf807f449baca83c0106 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#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"



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;
	
	int collidableIndex = body->m_collidableIdx;
	int shapeIndex = collidables[collidableIndex].m_shapeIndex;
		
	if (shapeIndex>=0)
	{
				
		b3Aabb_t localAabb = localShapeAABB[collidableIndex];
		b3Aabb_t worldAabb;
		
		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;
	}
}

#endif //B3_UPDATE_AABBS_H