Spinning Topp Logo BlackTopp Studios
inc
collisiondispatcher.h.cpp
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 #ifndef _physicscollisiondispatcher_h_cpp
41 #define _physicscollisiondispatcher_h_cpp
42 
43 #include <btBulletDynamicsCommon.h>
44 #include <BulletMultiThreaded/SpuGatheringCollisionDispatcher.h>
45 
46 #include <list>
47 
48 namespace Mezzanine
49 {
50  namespace Physics
51  {
52  // internal forward declarations
54 
55  /// @brief Convenience datatype for a collection of Collision Algorithms.
56  typedef std::list<btCollisionAlgorithm*> AlgoList;
57 
58  ///////////////////////////////////////////////////////////////////////////////
59  /// @internal
60  /// @brief Used to provide better reporting of collisions.
61  /// @details
62  ///////////////////////////////////////
63  class CollisionDispatcher : public btCollisionDispatcher
64  {
65  protected:
66  /// @brief Physics Manager
68 
69  /// @internal
70  /// @brief A list of all the algorithms that have been created and need processing.
72  public:
73  /// @brief Class constructor.
74  /// @param CollisionConfig The collision configuration for the world being created.
75  CollisionDispatcher(PhysicsManager * PhysMan, btCollisionConfiguration* CollisionConfig);
76  /// @brief Class destructor.
77  virtual ~CollisionDispatcher();
78 
79  ///////////////////////////////////////////////////////////////////////////////
80  // New Implementation based on Algorithm creation
81 
82  /// @brief Allocates space for a new Collision Algorithm between two objects.
83  /// @note This usually means that a collision has started between two objects.
84  /// @param size The size needed for the new Collision Algorithm.
85  void* allocateCollisionAlgorithm(int size);
86  /// @brief Frees up the space belonging to a Collision Algorithm that is no longer needed.
87  /// @note This usually means that a collision has ended between two objects.
88  /// @param ptr A pointer to Collision Algorithim that is being removed.
89  void freeCollisionAlgorithm(void* ptr);
90  /// @brief Gets the list of algorithms that have been created and need processing.
91  /// @return Returns a reference to the list of algorithms that need processing.
92  AlgoList* GetAlgoCreationQueue();
93 
94  ///////////////////////////////////////////////////////////////////////////////
95  // Old Implementation based on Manifold creation
96 
97  /*btPersistentManifold* getNewManifold(void* b0, void* b1);
98  void releaseManifold(btPersistentManifold* manifold);
99  void releaseManifoldManual(btPersistentManifold* manifold);// */
100  };// CollisionDispatcher
101 
102  ///////////////////////////////////////////////////////////////////////////////
103  /// @internal
104  /// @brief Used to provide better reporting of collisions in a multithreaded environment.
105  /// @details
106  ///////////////////////////////////////
107  class ParallelCollisionDispatcher : public SpuGatheringCollisionDispatcher
108  {
109  protected:
110  /// @brief Physics Manager
112 
113  /// @internal
114  /// @brief A list of all the algorithms that have been created and need processing.
116  public:
117  /// @brief Class constructor.
118  /// @param CollisionConfig The collision configuration for the world being created.
119  ParallelCollisionDispatcher(PhysicsManager * PhysMan, btThreadSupportInterface* ThreadInterface, unsigned int MaxNumTasks, btCollisionConfiguration* CollisionConfig);
120  /// @brief Class destructor.
122 
123  ///////////////////////////////////////////////////////////////////////////////
124  // New Implementation based on Algorithm creation
125 
126  /// @brief Allocates space for a new Collision Algorithm between two objects.
127  /// @note This usually means that a collision has started between two objects.
128  /// @param size The size needed for the new Collision Algorithm.
129  void* allocateCollisionAlgorithm(int size);
130  /// @brief Frees up the space belonging to a Collision Algorithm that is no longer needed.
131  /// @note This usually means that a collision has ended between two objects.
132  /// @param ptr A pointer to Collision Algorithim that is being removed.
133  void freeCollisionAlgorithm(void* ptr);
134  /// @brief Gets the list of algorithms that have been created and need processing.
135  /// @return Returns a reference to the list of algorithms that need processing.
136  AlgoList* GetAlgoCreationQueue();
137 
138  ///////////////////////////////////////////////////////////////////////////////
139  // Old Implementation based on Manifold creation
140 
141  /*btPersistentManifold* getNewManifold(void* b0, void* b1);
142  void releaseManifold(btPersistentManifold* manifold);
143  void releaseManifoldManual(btPersistentManifold* manifold);// */
144  };// CollisionDispatcher
145  }//Physics
146 }//Mezzanine
147 
148 #endif
void freeCollisionAlgorithm(void *ptr)
Frees up the space belonging to a Collision Algorithm that is no longer needed.
void * allocateCollisionAlgorithm(int size)
Allocates space for a new Collision Algorithm between two objects.
AlgoList AlgoCreationQueue
A list of all the algorithms that have been created and need processing.
void freeCollisionAlgorithm(void *ptr)
Frees up the space belonging to a Collision Algorithm that is no longer needed.
AlgoList * GetAlgoCreationQueue()
Gets the list of algorithms that have been created and need processing.
ParallelCollisionDispatcher(PhysicsManager *PhysMan, btThreadSupportInterface *ThreadInterface, unsigned int MaxNumTasks, btCollisionConfiguration *CollisionConfig)
Class constructor.
Used to provide better reporting of collisions.
std::list< btCollisionAlgorithm * > AlgoList
Convenience datatype for a collection of Collision Algorithms.
Used to provide better reporting of collisions in a multithreaded environment.
This is simply a place for storing all the Physics Related functions.
PhysicsManager * PhysMan
Physics Manager.
AlgoList * GetAlgoCreationQueue()
Gets the list of algorithms that have been created and need processing.
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
AlgoList AlgoCreationQueue
A list of all the algorithms that have been created and need processing.
virtual ~CollisionDispatcher()
Class destructor.
void * allocateCollisionAlgorithm(int size)
Allocates space for a new Collision Algorithm between two objects.
CollisionDispatcher(PhysicsManager *PhysMan, btCollisionConfiguration *CollisionConfig)
Class constructor.