Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/physics/src/bullet/BulletMultiThreaded/SpuContactManifoldCollisionAlgorithm.h @ 1966

Last change on this file since 1966 was 1966, checked in by rgrieder, 16 years ago

Let's go for multithreaded physics!

  • Property svn:eol-style set to native
File size: 3.1 KB
Line 
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2007 Erwin Coumans  http://bulletphysics.com
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. 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.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. This notice may not be removed or altered from any source distribution.
14*/
15
16#ifndef SPU_CONTACTMANIFOLD_COLLISION_ALGORITHM_H
17#define SPU_CONTACTMANIFOLD_COLLISION_ALGORITHM_H
18
19#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
20#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
21#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h"
22#include "BulletCollision/BroadphaseCollision/btDispatcher.h"
23
24class btPersistentManifold;
25
26/// SpuContactManifoldCollisionAlgorithm  provides contact manifold and should be processed on SPU.
27ATTRIBUTE_ALIGNED16(class) SpuContactManifoldCollisionAlgorithm : public btCollisionAlgorithm
28{
29
30        btPersistentManifold*   m_manifoldPtr;
31        int             m_shapeType0;
32        int             m_shapeType1;
33        float   m_collisionMargin0;
34        float   m_collisionMargin1;
35
36       
37public:
38       
39        virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
40
41        virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
42
43        SpuContactManifoldCollisionAlgorithm();
44
45        SpuContactManifoldCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1);
46
47        virtual ~SpuContactManifoldCollisionAlgorithm();
48
49        virtual void    getAllContactManifolds(btManifoldArray& manifoldArray)
50        {
51                if (m_manifoldPtr)
52                        manifoldArray.push_back(m_manifoldPtr);
53        }
54
55        btPersistentManifold*   getContactManifoldPtr()
56        {
57                return m_manifoldPtr;
58        }
59
60        int             getShapeType0() const
61        {
62                return m_shapeType0;
63        }
64
65        int             getShapeType1() const
66        {
67                return m_shapeType1;
68        }
69        float   getCollisionMargin0() const
70        {
71                return m_collisionMargin0;
72        }
73        float   getCollisionMargin1() const
74        {
75                return m_collisionMargin1;
76        }
77
78        struct CreateFunc :public       btCollisionAlgorithmCreateFunc
79        {
80                virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
81                {
82                        void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(SpuContactManifoldCollisionAlgorithm));
83                        return new(mem) SpuContactManifoldCollisionAlgorithm(ci,body0,body1);
84                }
85        };
86
87};
88
89#endif //SPU_CONTACTMANIFOLD_COLLISION_ALGORITHM_H
Note: See TracBrowser for help on using the repository browser.