16#if defined(_WIN32) || defined(__i386__)
17#define BT_USE_SSE_IN_API
30#if defined(__CELLOS_LV2__) && defined(__SPU__)
31#include <spu_intrinsics.h>
32static inline vec_float4 vec_dot3(vec_float4 vec0, vec_float4 vec1)
35 result = spu_mul(vec0, vec1);
36 result = spu_madd(spu_rlqwbyte(vec0, 4), spu_rlqwbyte(vec1, 4), result);
37 return spu_madd(spu_rlqwbyte(vec0, 8), spu_rlqwbyte(vec1, 8), result);
72 btVector3 vec = localDirOrg * localScaling;
74#if defined(__CELLOS_LV2__) && defined(__SPU__)
78 vec_float4 v_distMax = {-FLT_MAX, 0, 0, 0};
79 vec_int4 v_idxMax = {-999, 0, 0, 0};
81 int numverts = numPoints;
83 for (; v < (int)numverts - 4; v += 4)
85 vec_float4 p0 = vec_dot3(points[v].get128(), localDir.get128());
86 vec_float4 p1 = vec_dot3(points[v + 1].get128(), localDir.get128());
87 vec_float4 p2 = vec_dot3(points[v + 2].get128(), localDir.get128());
88 vec_float4 p3 = vec_dot3(points[v + 3].get128(), localDir.get128());
89 const vec_int4 i0 = {v, 0, 0, 0};
90 const vec_int4 i1 = {v + 1, 0, 0, 0};
91 const vec_int4 i2 = {v + 2, 0, 0, 0};
92 const vec_int4 i3 = {v + 3, 0, 0, 0};
93 vec_uint4 retGt01 = spu_cmpgt(p0, p1);
94 vec_float4 pmax01 = spu_sel(p1, p0, retGt01);
95 vec_int4 imax01 = spu_sel(i1, i0, retGt01);
96 vec_uint4 retGt23 = spu_cmpgt(p2, p3);
97 vec_float4 pmax23 = spu_sel(p3, p2, retGt23);
98 vec_int4 imax23 = spu_sel(i3, i2, retGt23);
99 vec_uint4 retGt0123 = spu_cmpgt(pmax01, pmax23);
100 vec_float4 pmax0123 = spu_sel(pmax23, pmax01, retGt0123);
101 vec_int4 imax0123 = spu_sel(imax23, imax01, retGt0123);
102 vec_uint4 retGtMax = spu_cmpgt(v_distMax, pmax0123);
103 v_distMax = spu_sel(pmax0123, v_distMax, retGtMax);
104 v_idxMax = spu_sel(imax0123, v_idxMax, retGtMax);
106 for (; v < (int)numverts; v++)
108 vec_float4 p = vec_dot3(points[v].get128(), localDir.get128());
109 const vec_int4 i = {v, 0, 0, 0};
110 vec_uint4 retGtMax = spu_cmpgt(v_distMax, p);
111 v_distMax = spu_sel(p, v_distMax, retGtMax);
112 v_idxMax = spu_sel(i, v_idxMax, retGtMax);
114 int ptIndex = spu_extract(v_idxMax, 0);
115 const btVector3& supVec = points[ptIndex] * localScaling;
120 long ptIndex = vec.
maxDot(points, numPoints, maxDot);
126 btVector3 supVec = points[ptIndex] * localScaling;
144#if defined(__APPLE__) && (defined(BT_USE_SSE) || defined(BT_USE_NEON))
145#if defined(BT_USE_SSE)
146 return btVector3(_mm_xor_ps(_mm_and_ps(localDir.mVec128, (__m128){-0.0f, -0.0f, -0.0f, -0.0f}), halfExtents.mVec128));
147#elif defined(BT_USE_NEON)
148 return btVector3((float32x4_t)(((uint32x4_t)localDir.mVec128 & (uint32x4_t){0x80000000, 0x80000000, 0x80000000, 0x80000000}) ^ (uint32x4_t)halfExtents.mVec128));
150#error unknown vector arch
154 btFsels(localDir.
y(), halfExtents.
y(), -halfExtents.
y()),
155 btFsels(localDir.
z(), halfExtents.
z(), -halfExtents.
z()));
163 btVector3 dots = dir.
dot3(vertices[0], vertices[1], vertices[2]);
174 int cylinderUpAxis = cylShape->
getUpAxis();
175 int XX(1), YY(0), ZZ(2);
177 switch (cylinderUpAxis)
206 btScalar halfHeight = halfExtents[cylinderUpAxis];
216 tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight;
223 tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight;
234 int capsuleUpAxis = capsuleShape->
getUpAxis();
255 pos[capsuleUpAxis] = halfHeight;
258 newDot = vec.
dot(vtx);
268 pos[capsuleUpAxis] = -halfHeight;
271 newDot = vec.
dot(vtx);
384 btVector3 extent(margin, margin, margin);
385 aabbMin = center - extent;
386 aabbMax = center + extent;
396 halfExtents +=
btVector3(margin, margin, margin);
399 btVector3 extent = halfExtents.
dot3(abs_b[0], abs_b[1], abs_b[2]);
401 aabbMin = center - extent;
402 aabbMax = center + extent;
409 for (
int i = 0; i < 3; i++)
417 aabbMax[i] = tmp[i] + margin;
420 aabbMin[i] = tmp[i] - margin;
428 int m_upAxis = capsuleShape->
getUpAxis();
432 btVector3 extent = halfExtents.
dot3(abs_b[0], abs_b[1], abs_b[2]);
433 aabbMin = center - extent;
434 aabbMax = center + extent;
447 this->
getAabb(t, aabbMin, aabbMax);
@ CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE
@ TRIANGLE_SHAPE_PROXYTYPE
@ CYLINDER_SHAPE_PROXYTYPE
@ CAPSULE_SHAPE_PROXYTYPE
@ CONVEX_HULL_SHAPE_PROXYTYPE
static btVector3 convexHullSupport(const btVector3 &localDirOrg, const btVector3 *points, int numPoints, const btVector3 &localScaling)
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
btScalar btSqrt(btScalar y)
The btBoxShape is a box primitive around the origin, its sides axis aligned with length specified by ...
The btCapsuleShape represents a capsule around the Y axis, there is also the btCapsuleShapeX aligned ...
btScalar getRadius() const
btScalar getHalfHeight() const
The btConeShape implements a cone shape primitive, centered around the origin and aligned with the Y ...
The btConvexHullShape implements an implicit convex hull of an array of vertices.
btVector3 * getUnscaledPoints()
const btVector3 & getLocalScalingNV() const
const btVector3 & getImplicitShapeDimensions() const
btScalar getMarginNV() const
The btConvexPointCloudShape implements an implicit convex hull of an array of vertices.
btVector3 * getUnscaledPoints()
btScalar getMarginNonVirtual() const
btConvexShape()
not supported on IBM SDK, until we fix the alignment of btVector3
virtual void project(const btTransform &trans, const btVector3 &dir, btScalar &minProj, btScalar &maxProj, btVector3 &witnesPtMin, btVector3 &witnesPtMax) const
virtual btVector3 localGetSupportingVertex(const btVector3 &vec) const =0
btVector3 localGetSupportVertexNonVirtual(const btVector3 &vec) const
virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3 &vec) const =0
void getAabbNonVirtual(const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
virtual btScalar getMargin() const =0
void getAabb(const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const =0
getAabb's default implementation is brute force, expected derived classes to implement a fast dedicat...
btVector3 localGetSupportVertexWithoutMarginNonVirtual(const btVector3 &vec) const
The btCylinderShape class implements a cylinder shape primitive, centered around the origin....
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
btMatrix3x3 absolute() const
Return the matrix with all values non negative.
The btPolyhedralConvexAabbCachingShape adds aabb caching to the btPolyhedralConvexShape.
void getNonvirtualAabb(const btTransform &trans, btVector3 &aabbMin, btVector3 &aabbMax, btScalar margin) const
The btPolyhedralConvexShape is an internal interface class for polyhedral convex shapes.
The btSphereShape implements an implicit sphere, centered around a local origin with radius.
btScalar getRadius() const
btVector3 can be used to represent 3D points and vectors.
const btScalar & getZ() const
Return the z value.
const btScalar & z() const
Return the z value.
btScalar dot(const btVector3 &v) const
Return the dot product.
btVector3 dot3(const btVector3 &v0, const btVector3 &v1, const btVector3 &v2) const
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
long maxDot(const btVector3 *array, long array_count, btScalar &dotOut) const
returns index of maximum dot product between this and vectors in array[]
btScalar length2() const
Return the length of the vector squared.
const btScalar & getY() const
Return the y value.
const btScalar & x() const
Return the x value.
int maxAxis() const
Return the axis with the largest value Note return values are 0,1,2 for x, y, or z.
btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
const btScalar & getX() const
Return the x value.
const btScalar & y() const
Return the y value.