| [1963] | 1 | /* | 
|---|
|  | 2 | Bullet Continuous Collision Detection and Physics Library | 
|---|
|  | 3 | Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/ | 
|---|
|  | 4 |  | 
|---|
|  | 5 | This software is provided 'as-is', without any express or implied warranty. | 
|---|
|  | 6 | In no event will the authors be held liable for any damages arising from the use of this software. | 
|---|
|  | 7 | Permission is granted to anyone to use this software for any purpose, | 
|---|
|  | 8 | including commercial applications, and to alter it and redistribute it freely, | 
|---|
|  | 9 | subject to the following restrictions: | 
|---|
|  | 10 |  | 
|---|
|  | 11 | 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. | 
|---|
|  | 12 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. | 
|---|
|  | 13 | 3. This notice may not be removed or altered from any source distribution. | 
|---|
|  | 14 | */ | 
|---|
|  | 15 |  | 
|---|
|  | 16 |  | 
|---|
|  | 17 | #include "btConvexInternalShape.h" | 
|---|
|  | 18 |  | 
|---|
|  | 19 |  | 
|---|
| [2430] | 20 |  | 
|---|
| [1963] | 21 | btConvexInternalShape::btConvexInternalShape() | 
|---|
| [2430] | 22 | : m_localScaling(btScalar(1.),btScalar(1.),btScalar(1.)), | 
|---|
| [1963] | 23 | m_collisionMargin(CONVEX_DISTANCE_MARGIN) | 
|---|
|  | 24 | { | 
|---|
|  | 25 | } | 
|---|
|  | 26 |  | 
|---|
|  | 27 |  | 
|---|
|  | 28 | void    btConvexInternalShape::setLocalScaling(const btVector3& scaling) | 
|---|
|  | 29 | { | 
|---|
|  | 30 | m_localScaling = scaling.absolute(); | 
|---|
|  | 31 | } | 
|---|
|  | 32 |  | 
|---|
|  | 33 |  | 
|---|
|  | 34 |  | 
|---|
|  | 35 | void    btConvexInternalShape::getAabbSlow(const btTransform& trans,btVector3&minAabb,btVector3&maxAabb) const | 
|---|
|  | 36 | { | 
|---|
|  | 37 |  | 
|---|
|  | 38 | btScalar margin = getMargin(); | 
|---|
|  | 39 | for (int i=0;i<3;i++) | 
|---|
|  | 40 | { | 
|---|
|  | 41 | btVector3 vec(btScalar(0.),btScalar(0.),btScalar(0.)); | 
|---|
|  | 42 | vec[i] = btScalar(1.); | 
|---|
|  | 43 |  | 
|---|
|  | 44 | btVector3 sv = localGetSupportingVertex(vec*trans.getBasis()); | 
|---|
|  | 45 |  | 
|---|
|  | 46 | btVector3 tmp = trans(sv); | 
|---|
|  | 47 | maxAabb[i] = tmp[i]+margin; | 
|---|
|  | 48 | vec[i] = btScalar(-1.); | 
|---|
|  | 49 | tmp = trans(localGetSupportingVertex(vec*trans.getBasis())); | 
|---|
|  | 50 | minAabb[i] = tmp[i]-margin; | 
|---|
|  | 51 | } | 
|---|
| [2430] | 52 | } | 
|---|
| [1963] | 53 |  | 
|---|
|  | 54 |  | 
|---|
| [2430] | 55 |  | 
|---|
| [1963] | 56 | btVector3       btConvexInternalShape::localGetSupportingVertex(const btVector3& vec)const | 
|---|
|  | 57 | { | 
|---|
|  | 58 | #ifndef __SPU__ | 
|---|
|  | 59 |  | 
|---|
|  | 60 | btVector3      supVertex = localGetSupportingVertexWithoutMargin(vec); | 
|---|
|  | 61 |  | 
|---|
|  | 62 | if ( getMargin()!=btScalar(0.) ) | 
|---|
|  | 63 | { | 
|---|
|  | 64 | btVector3 vecnorm = vec; | 
|---|
|  | 65 | if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON)) | 
|---|
|  | 66 | { | 
|---|
|  | 67 | vecnorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.)); | 
|---|
|  | 68 | } | 
|---|
|  | 69 | vecnorm.normalize(); | 
|---|
|  | 70 | supVertex+= getMargin() * vecnorm; | 
|---|
|  | 71 | } | 
|---|
|  | 72 | return supVertex; | 
|---|
|  | 73 |  | 
|---|
|  | 74 | #else | 
|---|
| [2430] | 75 | btAssert(0); | 
|---|
| [1963] | 76 | return btVector3(0,0,0); | 
|---|
|  | 77 | #endif //__SPU__ | 
|---|
|  | 78 |  | 
|---|
|  | 79 | } | 
|---|
|  | 80 |  | 
|---|
|  | 81 |  | 
|---|