Operations with obstacles
Regardless of the obstacle processing mode, the processing procedure consists of several stages:
- Collecting information about the geometry of the obstacle for each Nav3DObstacle.
At this stage, a list of all geometries that form an obstacle is obtained, then they are combined (clustered).
Let’s say there are several children in the transform hierarchy of the obstacle, each of which has a MeshFilter with a Mesh assigned. Accordingly, in this case, several lists of triangles that make up the meshes will be obtained. Next, for each list of triangles, the enclosing volume will be defined in the form of Bounds. Those lists whose Bounds intersect will be merged. We will call each such individual list an “obstacle volume.” The result is one or more obstacle volumes. This will be done for every Nav3DObstacle processed in the scene.
- Clustering with already processed obstacles.
It is checked whether the volumes of the newly procсessing obstacle intersect with the volumes of obstacles already in the storage. If yes, then clustering occurs with obstacles already added. The result is a new list of obstacle volumes.
- Removing obsolete volumes of stored obstacles from storage.
Those volumes that intersected with the volumes of the newly processing obstacle and that were included in the new (clustered) volumes are considered obsolete.
- Next, navigation graphs are constructed for new volumes.
These volumes are then added to the obstacle storage.
Removing an obstacle from a storage consists of the following steps:
- From the storage, a list of all volumes containing triangles of the obstacle being removed is obtained (each volume can contain triangles of several obstacles).
- For each volume, the triangles of the obstacle to be removed are removed from the resulting list.
- Further, only volumes in which triangles still remain after removal are considered. For these volumes, the embracing Bounds are recalculated.
- All volumes from the original list are removed from the obstacle storage.
- All remaining volumes with recalculated Bounds are clustered and added back to the obstacle storage.