SpuContactResult.h

Go to the documentation of this file.
00001 /*
00002 Bullet Continuous Collision Detection and Physics Library
00003 Copyright (c) 2003-2006 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_CONTACT_RESULT2_H
00017 #define SPU_CONTACT_RESULT2_H
00018 
00019 
00020 #ifndef _WIN32
00021 #include <stdint.h>
00022 #endif
00023 
00024 
00025 
00026 #include "../SpuDoubleBuffer.h"
00027 
00028 
00029 #include "LinearMath/btTransform.h"
00030 
00031 
00032 #include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
00033 #include "BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h"
00034 
00035 class btCollisionShape;
00036 
00037 
00038 struct SpuCollisionPairInput
00039 {
00040         ppu_address_t m_collisionShapes[2];
00041         btCollisionShape*       m_spuCollisionShapes[2];
00042 
00043         ppu_address_t m_persistentManifoldPtr;
00044         btVector3       m_primitiveDimensions0;
00045         btVector3       m_primitiveDimensions1;
00046         int             m_shapeType0;
00047         int             m_shapeType1;   
00048         float   m_collisionMargin0;
00049         float   m_collisionMargin1;
00050 
00051         btTransform     m_worldTransform0;
00052         btTransform m_worldTransform1;
00053         
00054         bool    m_isSwapped;
00055         bool    m_useEpa;
00056 };
00057 
00058 
00059 struct SpuClosestPointInput : public btDiscreteCollisionDetectorInterface::ClosestPointInput
00060 {
00061         struct SpuConvexPolyhedronVertexData* m_convexVertexData[2];
00062 };
00063 
00066 class SpuContactResult : public btDiscreteCollisionDetectorInterface::Result
00067 {
00068     btTransform         m_rootWorldTransform0;
00069         btTransform             m_rootWorldTransform1;
00070         ppu_address_t   m_manifoldAddress;
00071 
00072     btPersistentManifold* m_spuManifold;
00073         bool m_RequiresWriteBack;
00074         btScalar        m_combinedFriction;
00075         btScalar        m_combinedRestitution;
00076         
00077         bool m_isSwapped;
00078 
00079         DoubleBuffer<btPersistentManifold, 1> g_manifoldDmaExport;
00080 
00081         public:
00082                 SpuContactResult();
00083                 virtual ~SpuContactResult();
00084 
00085                 btPersistentManifold*   GetSpuManifold() const
00086                 {
00087                         return m_spuManifold;
00088                 }
00089 
00090                 virtual void setShapeIdentifiersA(int partId0,int index0);
00091                 virtual void setShapeIdentifiersB(int partId1,int index1);
00092 
00093                 void    setContactInfo(btPersistentManifold* spuManifold, ppu_address_t manifoldAddress,const btTransform& worldTrans0,const btTransform& worldTrans1, btScalar restitution0,btScalar restitution1, btScalar friction0,btScalar friction01, bool isSwapped);
00094 
00095 
00096         void writeDoubleBufferedManifold(btPersistentManifold* lsManifold, btPersistentManifold* mmManifold);
00097 
00098         virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth);
00099 
00100                 void flush();
00101 };
00102 
00103 
00104 
00105 #endif //SPU_CONTACT_RESULT2_H
00106