printz
CRAZY DUMB ZEALOT

Posts: 8144
Registered: 06-06 |
This is pretty easy. Assuming you have access to the level data:
- for a given point (x, y), find the closest linedef to it.
- if that linedef is not facing the point, and if it has no second sidedef, then (x, y) is in the void.
Facing the point:
(x y): the point to test
(x1 y1): coordinates of linedef vertex 1
(x2 y2): those of linedef vertex 2
Check if (x - x1)*(y2 - y1) < (y - y1) * (x2 - x1)
If true, then it's not facing the first side, it's facing the second side, and might be in the void.
If they're equal, then the point is resting on the line.
How to calculate distance to linedef: I think you can just calculate the distance to one of its vertices. Or the minimum between the distance to vertex 1, to vertex 2, or to the projection (x0, y0) of (x, y) on the linedef line.
__________________
Available for download: Automatic Wolfenstein - Wolfenstein 3D bot
MBF configuration for WHackEd2
Last edited by printz on 11-30-12 at 17:08
|