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>
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__)
81 int numverts = numPoints;
83 for(;v<(int)numverts-4;v+=4) {
84 vec_float4 p0 = vec_dot3(points[v ].get128(),localDir.get128());
85 vec_float4 p1 = vec_dot3(points[v+1].get128(),localDir.get128());
86 vec_float4 p2 = vec_dot3(points[v+2].get128(),localDir.get128());
87 vec_float4 p3 = vec_dot3(points[v+3].get128(),localDir.get128());
94 vec_int4 imax01 = spu_sel(i1,i0,retGt01);
97 vec_int4 imax23 = spu_sel(i3,i2,retGt23);
98 vec_uint4 retGt0123 = spu_cmpgt(pmax01,pmax23);
99 vec_float4 pmax0123 = spu_sel(pmax23,pmax01,retGt0123);
100 vec_int4 imax0123 = spu_sel(imax23,imax01,retGt0123);
101 vec_uint4 retGtMax = spu_cmpgt(v_distMax,pmax0123);
102 v_distMax = spu_sel(pmax0123,v_distMax,retGtMax);
103 v_idxMax = spu_sel(imax0123,v_idxMax,retGtMax);
105 for(;v<(int)numverts;v++) {
106 vec_float4 p = vec_dot3(points[v].get128(),localDir.get128());
108 vec_uint4 retGtMax = spu_cmpgt(v_distMax,p);
109 v_distMax = spu_sel(p,v_distMax,retGtMax);
110 v_idxMax = spu_sel(i,v_idxMax,retGtMax);
112 int ptIndex = spu_extract(v_idxMax,0);
113 const btVector3& supVec= points[ptIndex] * localScaling;
118 long ptIndex = vec.
maxDot( points, numPoints, maxDot);
120 btVector3 supVec = points[ptIndex] * localScaling;
138 #if defined( __APPLE__ ) && (defined( BT_USE_SSE )||defined( BT_USE_NEON ))
139 #if defined( BT_USE_SSE )
140 return btVector3( _mm_xor_ps( _mm_and_ps( localDir.mVec128, (__m128){-0.0f, -0.0f, -0.0f, -0.0f }), halfExtents.mVec128 ));
141 #elif defined( BT_USE_NEON )
142 return btVector3( (float32x4_t) (((uint32x4_t) localDir.mVec128 & (uint32x4_t){ 0x80000000, 0x80000000, 0x80000000, 0x80000000}) ^ (uint32x4_t) halfExtents.mVec128 ));
144 #error unknown vector arch
148 btFsels(localDir.
y(), halfExtents.y(), -halfExtents.y()),
149 btFsels(localDir.
z(), halfExtents.z(), -halfExtents.z()));
155 btVector3 dir(localDir.getX(),localDir.getY(),localDir.getZ());
157 btVector3 dots = dir.
dot3(vertices[0], vertices[1], vertices[2]);
167 btVector3 v(localDir.getX(),localDir.getY(),localDir.getZ());
168 int cylinderUpAxis = cylShape->
getUpAxis();
169 int XX(1),YY(0),ZZ(2);
171 switch (cylinderUpAxis)
201 btScalar halfHeight = halfExtents[cylinderUpAxis];
211 tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight;
216 tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight;
223 btVector3 vec0(localDir.getX(),localDir.getY(),localDir.getZ());
227 int capsuleUpAxis = capsuleShape->getUpAxis();
229 btScalar radius = capsuleShape->getRadius();
248 pos[capsuleUpAxis] = halfHeight;
251 vtx = pos +vec*(radius) - vec * capsuleShape->getMarginNV();
252 newDot = vec.
dot(vtx);
263 pos[capsuleUpAxis] = -halfHeight;
266 vtx = pos +vec*(radius) - vec * capsuleShape->getMarginNV();
267 newDot = vec.
dot(vtx);
274 return btVector3(supVec.getX(),supVec.getY(),supVec.getZ());
292 return this->localGetSupportingVertexWithoutMargin (localDir);
381 aabbMin = center - extent;
382 aabbMax = center + extent;
392 halfExtents +=
btVector3(margin,margin,margin);
395 btVector3 extent = halfExtents.
dot3(abs_b[0], abs_b[1], abs_b[2]);
397 aabbMin = center - extent;
398 aabbMax = center + extent;
405 for (
int i=0;i<3;i++)
413 aabbMax[i] = tmp[i]+margin;
416 aabbMin[i] = tmp[i]-margin;
424 int m_upAxis = capsuleShape->
getUpAxis();
429 btVector3 extent = halfExtents.
dot3(abs_b[0], abs_b[1], abs_b[2]);
430 aabbMin = center - extent;
431 aabbMax = center + extent;
444 this->
getAabb (t, aabbMin, aabbMax);
const btVector3 & getLocalScalingNV() const
virtual btVector3 localGetSupportingVertex(const btVector3 &vec) const =0
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
void getNonvirtualAabb(const btTransform &trans, btVector3 &aabbMin, btVector3 &aabbMax, btScalar margin) const
static btVector3 convexHullSupport(const btVector3 &localDirOrg, const btVector3 *points, int numPoints, const btVector3 &localScaling)
The btCapsuleShape represents a capsule around the Y axis, there is also the btCapsuleShapeX aligned ...
btScalar btSqrt(btScalar y)
long maxDot(const btVector3 *array, long array_count, btScalar &dotOut) const
returns index of maximum dot product between this and vectors in array[]
btVector3 localGetSupportVertexWithoutMarginNonVirtual(const btVector3 &vec) const
The btSphereShape implements an implicit sphere, centered around a local origin with radius...
btScalar getRadius() const
btScalar getMarginNonVirtual() const
btScalar dot(const btVector3 &v) const
Return the dot product.
btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
const btScalar & x() const
Return the x value.
const btScalar & getZ() const
Return the z value.
virtual void project(const btTransform &trans, const btVector3 &dir, btScalar &min, btScalar &max) const
btVector3 * getUnscaledPoints()
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...
btMatrix3x3 absolute() const
Return the matrix with all values non negative.
The btConeShape implements a cone shape primitive, centered around the origin and aligned with the Y ...
static float max(float a, float b)
void getAabbNonVirtual(const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
const btScalar & getY() const
Return the y value.
const btScalar & getX() const
Return the x value.
The btPolyhedralConvexShape is an internal interface class for polyhedral convex shapes.
btVector3 localGetSupportVertexNonVirtual(const btVector3 &vec) const
virtual btScalar getMargin() const =0
const btScalar & y() const
Return the y value.
static float min(float a, float b)
The btBoxShape is a box primitive around the origin, its sides axis aligned with length specified by ...
btVector3 can be used to represent 3D points and vectors.
btScalar length2() const
Return the length of the vector squared.
btScalar getMarginNV() const
The btPolyhedralConvexAabbCachingShape adds aabb caching to the btPolyhedralConvexShape.
const btVector3 & getImplicitShapeDimensions() const
The btCylinderShape class implements a cylinder shape primitive, centered around the origin...
btVector3 * getUnscaledPoints()
btVector3 dot3(const btVector3 &v0, const btVector3 &v1, const btVector3 &v2) const
btScalar getRadius() const
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
The btConvexHullShape implements an implicit convex hull of an array of vertices. ...
The btConvexPointCloudShape implements an implicit convex hull of an array of vertices.
btScalar getHalfHeight() const
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
btConvexShape()
not supported on IBM SDK, until we fix the alignment of btVector3
int maxAxis() const
Return the axis with the largest value Note return values are 0,1,2 for x, y, or z.
const btScalar & z() const
Return the z value.