Just number the nodes with numbers below a certain threshold, in my example 65535, i.e. representable within 16bit. Then, inorder to group or characterize your nodes, you set cetain bits in the upper 2 bytes of the ID via bitwise OR
Code: Select all
// initial numbering
node->setID(192);
// several types of nodes in your app
enum E_MY_NODE_TYPES
{
E_BUILDING=1<<17,
E_NPC=1<<18,
E_VEGETATION=1<<19
};
// make node vegetation
node->setID(node->getID()|E_VEGETATION);
// or to be sure to have just one class, also when changing types later on
node->setID((node->getID()&0xffff)|E_BUILDING);
You can also mix several types and characterizations, e.g. add an 'unimportant' flag for things which you can avoid to render if on low-end platforms. Such values can then also be added to the ID via some more OR operators.
For bitmasks you can then choose, e.g. E_VEGETATION, as bitmask to search for all nodes belonging to that class.