diff options
author | Reinier de Blois <rddeblois@gmail.com> | 2016-04-05 21:38:42 +0300 |
---|---|---|
committer | Porteries Tristan <republicthunderbolt9@gmail.com> | 2016-04-05 22:39:04 +0300 |
commit | c084520b0376c4ab92cb0193577a79cf23e5bb80 (patch) | |
tree | 645f35cdaa87464bb55e5c2b5657f86a142fedb2 /source/blender/editors | |
parent | 176538f61360fb54f0e4ce209fc7d7632bce1401 (diff) |
Expose new Recast partitioning methods for navmesh generation
This patch depends on D1747, which upgrades the Recast version. It exposes the new Recast partitioning methods in the navmesh generation.
Reviewers: campbellbarton, moguri
Reviewed By: moguri
Projects: #bf_blender
Differential Revision: https://developer.blender.org/D1748
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/mesh/mesh_navmesh.c | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/source/blender/editors/mesh/mesh_navmesh.c b/source/blender/editors/mesh/mesh_navmesh.c index 4d07d509616..b95921964eb 100644 --- a/source/blender/editors/mesh/mesh_navmesh.c +++ b/source/blender/editors/mesh/mesh_navmesh.c @@ -245,20 +245,41 @@ static bool buildNavMesh(const RecastData *recastParams, int nverts, float *vert return false; } - /* Prepare for region partitioning, by calculating distance field along the walkable surface */ - if (!recast_buildDistanceField(chf)) { - recast_destroyCompactHeightfield(chf); + if (recastParams->partitioning == RC_PARTITION_WATERSHED) { + /* Prepare for region partitioning, by calculating distance field along the walkable surface */ + if (!recast_buildDistanceField(chf)) { + recast_destroyCompactHeightfield(chf); - BKE_report(reports, RPT_ERROR, "Failed to build distance field"); - return false; - } + BKE_report(reports, RPT_ERROR, "Failed to build distance field"); + return false; + } - /* Partition the walkable surface into simple regions without holes */ - if (!recast_buildRegions(chf, 0, minRegionArea, mergeRegionArea)) { - recast_destroyCompactHeightfield(chf); + /* Partition the walkable surface into simple regions without holes */ + if (!recast_buildRegions(chf, 0, minRegionArea, mergeRegionArea)) { + recast_destroyCompactHeightfield(chf); - BKE_report(reports, RPT_ERROR, "Failed to build regions"); - return false; + BKE_report(reports, RPT_ERROR, "Failed to build watershed regions"); + return false; + } + } + else if (recastParams->partitioning == RC_PARTITION_MONOTONE) { + /* Partition the walkable surface into simple regions without holes */ + /* Monotone partitioning does not need distancefield. */ + if (!recast_buildRegionsMonotone(chf, 0, minRegionArea, mergeRegionArea)) { + recast_destroyCompactHeightfield(chf); + + BKE_report(reports, RPT_ERROR, "Failed to build monotone regions"); + return false; + } + } + else { /* RC_PARTITION_LAYERS */ + /* Partition the walkable surface into simple regions without holes */ + if (!recast_buildLayerRegions(chf, 0, minRegionArea)) { + recast_destroyCompactHeightfield(chf); + + BKE_report(reports, RPT_ERROR, "Failed to build layer regions"); + return false; + } } /* ** Step 5: Trace and simplify region contours ** */ |