Jump to content
XCOMUFO & Xenocide

Line Of Sight Algorithm?


Recommended Posts

Currently i'm doing some research howto implement the line of sight.

Current method is to shoot rays to a 90degree angle, and following the rays path,

and checking stopLOS for each tile.

But it is tricky, since each cell has 4 tiles (floor, westwall,northwall and content eg: a barrel).

Do how do you decide which tile gets hit first by the ray??

Also this algorithm is somewhat inefficient, since at the beginning the rays overlap,

and create a overhead -> maybe a minor performance issue?

Also these rays have to go from down to up, also 90degrees.

 

So if anybody has any suggestions, comments, u r welcome!

Link to comment
Share on other sites

Today performance in tiled based environment is a non issue unless you are implementing it in very small hardware, like cell phones... even there I doubt you would have problems with it. The best way to handle that is using a DDA (Diferential Digital Analyzer) that is basicly shooting rays in all directions. The directions can be found dividing the circle of minimmum probability in slices and shooting rays following the tiles are touched by the ray. Take a look at the Bresenham algorithm, same principle apply.

 

Then you can use a probabilitic approach (nearer gets higher random value) if random is in the interval, then you see it.

 

Greetings

Red Knight

Edited by red knight
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...