Generating rcContourSet from polygons with holes #767
-
|
I'm using Recast to generate a polymesh/navmesh, starting not with a heightfield but some 2D vector shapes preprocessed and inset into polyline contours by clipper2. Clipper outputs a set of counterclockwise polygons which may contain clockwise holes. It's simple enough to flip the orientation of the outermost polygons when feeding them into Recast, but the innermost polygons (eg, representing pillars in a room) aren't interpreted as holes regardless of their orientation. If wound clockwise they produce an additional navigation area overlapping the main one, and if wound counterclockwise they produce a nonsensical inverted mesh. Internally, I can see that recast supports hole polygons via a data structure called rcContourRegion, which is used in the process of rendering heightmaps to an rcContourSet. But this functionality seems to be hidden away in an implementation file. Is there any way to use it, or will I need to rig up a separate tessellator? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Resolving polygon holes of 2.5D data, like a navmesh on a surface, is super tricky to do as the polygons can fold over each other. For that reason, recast partitions the polygons when things are still represented as voxels. A region is partition of the voxelized walkable space that does not have holes. After that the regions are turned into contours, then polygons, etc. If your data is strictly 2D, you can connect a corner of the hole polygon to the outer polygon, so that there's just one continuous contour (but overlapping edge which connects the polygons). Alternatively you can paint the shapes on the voxels, in which case you will loose some accuracy, bit it will be easier to handle. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the quick reply! I was under the impression the voxelization pass occurred while converting contours to a polymesh, but it sounds like I'm By the way... an easy way to make |
Beta Was this translation helpful? Give feedback.
Resolving polygon holes of 2.5D data, like a navmesh on a surface, is super tricky to do as the polygons can fold over each other. For that reason, recast partitions the polygons when things are still represented as voxels. A region is partition of the voxelized walkable space that does not have holes. After that the regions are turned into contours, then polygons, etc.
If your data is strictly 2D, you can connect a corner of the hole polygon to the outer polygon, so that there's just one continuous contour (but overlapping edge which connects the polygons).
Alternatively you can paint the shapes on the voxels, in which case you will loose some accuracy, bit it will be easier to handle.