Skip to main content
Tweeted twitter.com/#!/StackGameDev/status/539347859221794816

How to avoid checking the same triangle twice in collision detection with spatiakspatial hashing

Source Link
ThomYorkkke
  • 145
  • 1
  • 1
  • 3

How to avoid checking the same triangle twice in collision detection with spatiak hashing

I'm implementing a spatial hashing system to speed up my collision detection, but I've run into a problem. Since a triangle can be hashed into multiple buckets, how do I ensure that I don't check the same triangle multiple times?

I've though about having each struct Triangle have a list of pointers to each triangle it has been checked against, as well as a double lastTimeChecked. That way, if the lastTimeChecked was less than the current time, I would know all that data was invalid. This seems inefficient because I am guessing I would have to have this list be a std::vector since I won't know ahead of time how big the list should be.

Then, each time I want to check one triangle against another, I check each triangle's list of triangles it has been checked against to see if either has been checked against the other. Is this the most efficient way to do it?