Reputation: 41
Imagine there are 20 types of objects.
What fast methods exist to detect which objects collide now in Box2d?
A scan with switch/if is not fast enough.
Upvotes: 0
Views: 329
Reputation: 8262
The best way to keep an updated list of which objects are currently colliding with each other is to use the BeginContact/EndContact events to update the list - typically each object would store such a list so it can access whatever it's touching efficiently. If you really think it's a problem to check the tags of the other objects in this list, you could have more than one list, eg. you could keep all touching objects of kTag1 in a list by themselves.
Upvotes: 2