Flatland
|
#include <collision_filter_registry.h>
Public Member Functions | |
CollisionFilterRegistry () | |
Constructor for the collision filter registry. | |
int | RegisterCollide () |
Get a new and unique collision group, +ve numbers. | |
int | RegisterNoCollide () |
Get a new and unique no collision group, -ve numbers. | |
bool | IsLayersFull () const |
Check if the number of layers maxed out. More... | |
int | RegisterLayer (std::string layer) |
Register a new layer. More... | |
int | LookUpLayerId (std::string name) const |
get layer ID More... | |
std::vector< std::string > | GetAllLayers () const |
Get all registered layers. More... | |
int | LayersCount () const |
Get number of layers. More... | |
uint16_t | GetCategoryBits (const std::vector< std::string > &layers, std::vector< std::string > *invalid_layers=nullptr) const |
: Get the Box2D category bits from a list of layers More... | |
Public Attributes | |
int | no_collide_group_cnt_ |
internal counter to keep track of no collides groups | |
int | collide_group_cnt_ |
internal counter to keep track of collide groups | |
std::map< std::string, int > | layer_id_table_ |
Layer name to ID LUT. | |
Static Public Attributes | |
static const int | LAYER_NOT_EXIST = -1 |
No such layer. | |
static const int | LAYER_ALREADY_EXIST = -2 |
Layer exists. | |
static const int | LAYERS_FULL = -3 |
Cannot add more layers. | |
static const int | MAX_LAYERS = 16 |
16 is the maximum as defined by Box2D | |
This class defines a collision filter registry. It allows layers to register for unique ID's, which are used for setting Box2D collision categories and mask bits. The footprints in the model will use this to put itself on the correct collision category. It also hands out unique collide (positive numbers) and no collide (negative numbers) Box2D collision groups.
std::vector< std::string > flatland_server::CollisionFilterRegistry::GetAllLayers | ( | ) | const |
Get all registered layers.
uint16_t flatland_server::CollisionFilterRegistry::GetCategoryBits | ( | const std::vector< std::string > & | layers, |
std::vector< std::string > * | invalid_layers = nullptr |
||
) | const |
: Get the Box2D category bits from a list of layers
[in] | layers | The layers for generating the category bits, if the input exactly equals to {"all"}, it returns all bits to 1 (0xFFFF) |
[out] | invalid_layers | if a given layer does not exist, it is pushed to this list, optional |
bool flatland_server::CollisionFilterRegistry::IsLayersFull | ( | ) | const |
Check if the number of layers maxed out.
int flatland_server::CollisionFilterRegistry::LayersCount | ( | ) | const |
Get number of layers.
int flatland_server::CollisionFilterRegistry::LookUpLayerId | ( | std::string | name | ) | const |
get layer ID
[in] | name | Name of the layer |
int flatland_server::CollisionFilterRegistry::RegisterLayer | ( | std::string | layer | ) |
Register a new layer.
[in] | layer | Name of the layer |