hx3d  1
2D/3D Simple Game Framework
collision_matrix.hpp
1 /*
2  2D physics collision matrix.
3  Copyright (C) 2015 Denis BOURGE
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
18  USA
19 */
20 
21 #ifndef HX3D_PHYSICS_2D_COLLISIONMATRIX
22 #define HX3D_PHYSICS_2D_COLLISIONMATRIX
23 
24 #include <string>
25 #include <map>
26 
27 namespace hx3d {
28 namespace physics2d {
29 
34 public:
36 
42  void addCategory(std::string name);
43 
51  template <class... Categories>
52  void addMask(std::string name, std::string category, Categories... others);
53  template <class... Categories>
54  void addMask(std::string name, std::string category, typename std::enable_if<sizeof...(Categories) == 0>::type* test = nullptr);
55 
63  unsigned int getCategory(std::string category);
71  unsigned int getMask(std::string category);
72 
73 private:
75  std::map<std::string, unsigned int> _categories;
77  std::map<std::string, unsigned int> _masks;
78 
80  unsigned int _currentCategory;
81 
88  void addOneMask(std::string name, std::string category);
89 };
90 
91 #include "hx3d/physics/2d/_inline/collision_matrix.inl.hpp"
92 
93 } /* physics2d */
94 } /* hx3d */
95 
96 #endif
hx3d framework namespace
Definition: audio.hpp:26
void addMask(std::string name, std::string category, Categories...others)
Add a mask for a category from multiple categories.
unsigned int getCategory(std::string category)
Get a category bit from a name.
unsigned int getMask(std::string category)
Get a mask bit from a name.
Collision matrix with masks and category.
void addCategory(std::string name)
Add a category.