From c084520b0376c4ab92cb0193577a79cf23e5bb80 Mon Sep 17 00:00:00 2001 From: Reinier de Blois Date: Tue, 5 Apr 2016 20:38:42 +0200 Subject: 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 --- source/blender/editors/mesh/mesh_navmesh.c | 43 ++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 11 deletions(-) (limited to 'source/blender/editors/mesh') 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 ** */ -- cgit v1.2.3