How do B3D collisions work, internally?
Blitz3D Forums/Blitz3D Programming/How do B3D collisions work, internally?
| ||
I'm just wondering how Blitz3D collisions work, internally. I mean, you can PositionEntity and the collision detection will detect any collision that occured during the entity's move from it's old position to it's new position. Anyone know/guess how this is achieved? |
| ||
It possibly does a "thick" raycast from the old position to the new position, and then detects if the ray intersects a polygon/box/sphere. There may be another check before this one to see if the new position is inside the bounding box of the static object. |
| ||
Yeah, I guess it must be along those lines. Just wondering how the 'thick raycast' is achieved. Maybe it's simply a case of doing a progressive sphere collision check along the old-to-new position vector. Would kinda explain why blitz collisions are always sphere-to-something, as sphere checks are relatively fast. This seems to be how line picking works, as the longer the pick length, the slower it is. I actually only need this for 2D space, so that eliminates some complexity. Hmm. I'll have to think through this some more... |
| ||
Sphere to something is basically the same as EntityDistance but with a collision. I imagine that internally, collisions find the positions of all the verticies in the program (or verticies nearby to save time) and, using some intersection code, see if they are ever within a certain distance (the entity's radius) from the specified entity. I think thats how sphere to polygon collisions work. EntityDistance can be found with a simple system using Pythagorean theorem. |