Open leftiness opened 8 years ago
Pixel visibility is something which should be done aside from the hex_math library. I guess hex_render (or whatever I end up calling it) would handle that. It's one task to determine if a point is visible so that you know whether to show the player what's there. It's another task to draw shadows with pixels.
If I use the precomputed visibility tries (or something similar) then I should ofc precompute. Provide a function which provides the visiblity chains, and then require those as an argument in the fov function. Still not sure which lines I need to send a ray through in order to ensure that a ray touches every point in range...
Directional FOV is interesting. You wouldn't be able to see what's behind you, so you'd have to check. Checking would probably be free while it's your turn. Or almost free. I'd have to include something so you could hear bad guys behind you. There could be a visual cue to identify that a character heard a sound from some direction.
It would also drastically simplify these calculations...
Some devs apparently like FOV algorithms that are more permissive. For example, they want to see around corners slightly, as if you were "peaking."
I don't think I want that. Go stand on the point next to the corner. Then select the "peak" option, and select the point which is just around the corner. Now your FOV is drawn from that point. You use a minor action point (or something) for that. It also gives overwatched enemies a (reduced, affected by your agility, etc) chance to shoot you.
After all this research, I think I'll probably go with a shadow casting algorithm.
A big weakness of standard shadow casting is that it's asymmetric, so sometimes A can see B while B can't see A. At least, that's the case with square tiles. I should check to see how it works out on hex tiles.
The adammill.net resource has an altered algorithm that's symmetric at the cost of some extra comparisons and multiplications per loop. Probably still just fine since shadow casting is the more performant FOV algorithm in the first place. However, again, he's working with square tiles, so his algorithm might need tweaking.
TLDR
a: Point
, andb: HashSet<Point>
says which points block his vision, and he has a visible range ofc: i32
, whichd: HashSet<Point>
can he see?Notes
While I would first and foremost need a function to find which points are visible, it may also be useful to have a function for determining which pixels are visible. As the resources show, what you choose to show and hide can make for a neat graphical effect.
Resources