scenic.core.visibility

Implementations of Scenic’s visibility functions.

Summary of Module Members

Functions

canSee

Perform visibility checks on Points, OrientedPoints, or Objects, accounting for occlusion.

Member Details

canSee(position, orientation, visibleDistance, viewAngles, rayCount, rayDensity, distanceScaling, target, occludingObjects, debug=False)[source]

Perform visibility checks on Points, OrientedPoints, or Objects, accounting for occlusion.

For visibilty of Objects:

  1. Do several quick checks to see if the object is naively visible or not visible:

    • If the object contains its position and its position is visible, the object is visible.

    • If the viewer is inside the object, the object is visible.

    • If the closest distance from the object to the viewer is greater than the visible distance, the object is not visible.

  2. Check if the object crosses the back and/or front of the viewing object.

  3. Compute the spherical coordinates of all vertices in the mesh of the region we are trying to view, with the goal of using this to send rays only where they have a chance of hitting the region.

  4. Compute 2 ranges of angles (horizontal/vertical) in which rays have a chance of hitting the object, as follows:

    • If the object does not cross behind the viewer, take the min and max of the the spherical coordinate angles, while noting that this range is centered on the front of the viewer.

    • If the object crosses behind the viewer but not in front, transform the spherical angles so they are coming from the back of the object, while noting that this range is centered on the back of the object.

    • If it crosses both, we do not optimize the amount of rays sent.

  5. Compute the intersection of the optimizated range from step 4 and the viewAngles range, accounting for where the optimization range is centered. If it is empty, the object cannot be visible. If it is not empty, shoot rays at the desired density in the intersection region. Keep all rays that intersect the object (candidate rays).

  6. If there are no candidate rays, the object is not visible.

  7. For each occluding object in occludingObjects: check if any candidate rays intersect the occluding object at a distance less than the distance they intersected the target object. If they do, remove them from the candidate rays.

  8. If any candidate rays remain, the object is visible. If not, it is occluded and not visible.

For visibility of Points/OrientedPoints:

  1. Check if distance from the viewer to the point is greater than visibleDistance. If so, the point cannot be visible

  2. Create a single candidate ray, using the vector from the viewer to the target. If this ray is outside of the bounds of viewAngles, the point cannot be visible.

  3. For each occluding object in occludingObjets: check if the candidate ray hits the occluding object at a distance less than the distance from the viewer to the target point. If so, then the object is not visible. Otherwise, the object is visible.

Parameters:
  • position – Position of the viewer, accounting for any offsets.

  • orientation – Orientation of the viewer.

  • visibleDistance – The maximum distance the viewer can view objects from.

  • viewAngles – The horizontal and vertical view angles, in radians, of the viewer.

  • rayCount – The total number of rays in each dimension used in visibility calculations..

  • target – The target being viewed. Currently supports Point, OrientedPoint, and Object.

  • occludingObjects – An optional list of objects which can occlude the target.