SpuPreferredPenetrationDirections.h

Go to the documentation of this file.
00001 /*
00002 Bullet Continuous Collision Detection and Physics Library
00003 Copyright (c) 2003-2007 Erwin Coumans  http://continuousphysics.com/Bullet/
00004 
00005 This software is provided 'as-is', without any express or implied warranty.
00006 In no event will the authors be held liable for any damages arising from the use of this software.
00007 Permission is granted to anyone to use this software for any purpose, 
00008 including commercial applications, and to alter it and redistribute it freely, 
00009 subject to the following restrictions:
00010 
00011 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.
00012 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
00013 3. This notice may not be removed or altered from any source distribution.
00014 */
00015 
00016 #ifndef _SPU_PREFERRED_PENETRATION_DIRECTIONS_H
00017 #define _SPU_PREFERRED_PENETRATION_DIRECTIONS_H
00018 
00019 
00020 #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
00021 
00022 int             spuGetNumPreferredPenetrationDirections(int shapeType, void* shape)
00023 {
00024         switch (shapeType)
00025     {
00026                 case TRIANGLE_SHAPE_PROXYTYPE:
00027                 {
00028                         return 2;
00029                         //spu_printf("2\n");
00030                         break;
00031                 }
00032                 default:
00033                         {
00034 #if __ASSERT
00035         spu_printf("spuGetNumPreferredPenetrationDirections() - Unsupported bound type: %d.\n", shapeType);
00036 #endif // __ASSERT
00037                         }
00038         }
00039 
00040         return 0;       
00041 }       
00042 
00043 void    spuGetPreferredPenetrationDirection(int shapeType, void* shape, int index, btVector3& penetrationVector)
00044 {
00045 
00046 
00047         switch (shapeType)
00048     {
00049                 case TRIANGLE_SHAPE_PROXYTYPE:
00050                 {
00051                         btVector3* vertices = (btVector3*)shape;
00053                         penetrationVector = (vertices[1]-vertices[0]).cross(vertices[2]-vertices[0]);
00054                         penetrationVector.normalize();
00055                         if (index)
00056                                 penetrationVector *= btScalar(-1.);
00057                         break;
00058                 }
00059                 default:
00060                         {
00061                                         
00062 #if __ASSERT
00063         spu_printf("spuGetNumPreferredPenetrationDirections() - Unsupported bound type: %d.\n", shapeType);
00064 #endif // __ASSERT
00065                         }
00066         }
00067                 
00068 }
00069 
00070 #endif //_SPU_PREFERRED_PENETRATION_DIRECTIONS_H