Jump to content


Photo

Line Of Sight Algorithm?


  • Please log in to reply
2 replies to this topic

#1 mrnikosia

mrnikosia

    Squaddie

  • Forum Members
  • PipPip
  • 8 posts

Posted 24 May 2007 - 02:38 PM

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!

#2 red knight

red knight

    Xenocide Project Leader

  • Xenocide Inactive
  • 3,310 posts

Posted 24 May 2007 - 04:23 PM

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, 24 May 2007 - 04:24 PM.

Sourceforge Nick: flois - Federico Andres Lois
Visit my blog at: flois.blogspot.com

Posted Image

Pookie cover me, I am going in.

#3 mrnikosia

mrnikosia

    Squaddie

  • Forum Members
  • PipPip
  • 8 posts

Posted 24 May 2007 - 05:10 PM

Great!
You give me inspiration =b

Cheers m8!