[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 | |
---|
| 20 | btConvexInternalShape::btConvexInternalShape() |
---|
| 21 | : btConvexShape (), m_localScaling(btScalar(1.),btScalar(1.),btScalar(1.)), |
---|
| 22 | m_collisionMargin(CONVEX_DISTANCE_MARGIN) |
---|
| 23 | { |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | |
---|
| 27 | void btConvexInternalShape::setLocalScaling(const btVector3& scaling) |
---|
| 28 | { |
---|
| 29 | m_localScaling = scaling.absolute(); |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | |
---|
| 33 | |
---|
| 34 | void btConvexInternalShape::getAabbSlow(const btTransform& trans,btVector3&minAabb,btVector3&maxAabb) const |
---|
| 35 | { |
---|
| 36 | |
---|
| 37 | btScalar margin = getMargin(); |
---|
| 38 | for (int i=0;i<3;i++) |
---|
| 39 | { |
---|
| 40 | btVector3 vec(btScalar(0.),btScalar(0.),btScalar(0.)); |
---|
| 41 | vec[i] = btScalar(1.); |
---|
| 42 | |
---|
| 43 | btVector3 sv = localGetSupportingVertex(vec*trans.getBasis()); |
---|
| 44 | |
---|
| 45 | btVector3 tmp = trans(sv); |
---|
| 46 | maxAabb[i] = tmp[i]+margin; |
---|
| 47 | vec[i] = btScalar(-1.); |
---|
| 48 | tmp = trans(localGetSupportingVertex(vec*trans.getBasis())); |
---|
| 49 | minAabb[i] = tmp[i]-margin; |
---|
| 50 | } |
---|
| 51 | }; |
---|
| 52 | |
---|
| 53 | |
---|
| 54 | btVector3 btConvexInternalShape::localGetSupportingVertex(const btVector3& vec)const |
---|
| 55 | { |
---|
| 56 | #ifndef __SPU__ |
---|
| 57 | |
---|
| 58 | btVector3 supVertex = localGetSupportingVertexWithoutMargin(vec); |
---|
| 59 | |
---|
| 60 | if ( getMargin()!=btScalar(0.) ) |
---|
| 61 | { |
---|
| 62 | btVector3 vecnorm = vec; |
---|
| 63 | if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON)) |
---|
| 64 | { |
---|
| 65 | vecnorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.)); |
---|
| 66 | } |
---|
| 67 | vecnorm.normalize(); |
---|
| 68 | supVertex+= getMargin() * vecnorm; |
---|
| 69 | } |
---|
| 70 | return supVertex; |
---|
| 71 | |
---|
| 72 | #else |
---|
| 73 | return btVector3(0,0,0); |
---|
| 74 | #endif //__SPU__ |
---|
| 75 | |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | |
---|