Cell Decomposition

required:
  • cells are rectangles
  • each face is either wholly transparent or wholly opaque
  • cells are axis aligned
  • there are no junctions of this form:

Process:

Example:

Now consider the geometry of visible regions. They are made of triangles which have the focal point (fp) at one vertex.

The other vertices of these triangles are either (a) vertices of walls or (b) points on other walls where rays through vertices strike a wall.
If we can find these triangles efficiently, then we are basically done. Notice that it isn't good enough simply to cast rays through every vertex -- in a big maze, that would be hopelessly inefficient.

How do we construct triangles efficiently?
Use the cell deconposition.


Algorithm

while ( to-do list contains cells ) { }

"split" means to construct a ray through the focal point (fp) and the vertex, ending in the first opaque boundary (details to follow).
e.g.

Example:

to-do = a,b
notice the 2 rays cast, splitting cells
to-do = b,c
a third ray was cast
to-do = c,d
a fourth ray was cast
to-do = d,e
a fifth ray was cast
to-do = e,f,g,h
sixth and last ray was cast
Note that for f, g, and h, nothing new will happen.

Notice that the role of the cell structure is to find us vertices through which to cast rays.


Enumerating visibility triangles

The general idea is to proceed around the focalpoint (say counter-clockwise), moving out along a ray to an appropriate vertex. Then proceed along an edge, and back in along the next ray. The following example lists the visibility triangles which would be generated in one case.
fp,1,2
fp,2,3
fp,3,4
fp,8,5
fp,5,6
fp,6,7

Main Question: How can you tell to stop at 8 in triangle f,8,5 ?

Rule: rays can look like this:

Clearly, travelling counter-clockwise, going out:
(1) go to a
(2) stop at vertex b
(3) go to a
(4) stop at vertex b


Splitting Cells

Clearly, splitting rays are important. Here we list some of their properties.

Which sections of the following boundary are visible?

Hence changes come from intersections; the actual sense of visiblility must come from the following figure:

Notice that the constraints that rays stop at walls and that they do not affect visibility until their first vertex means that we will never see:

or similar nonsense.

Hence, in a ray you need to record:

In a cell, you need to record:

The Process of Intersecting Rays

We care only about edges here.
In particular, in the case shown, m > 0, and x_int > x_vert.

We can ignore:

and test only what remains in the quadrant. It is possible to do better by traversing the grid using Breserhaun's algorithm, but hardly worth it. In a maze there is clear benefit to using x,y closer to vertex first.