Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReinier de Blois <rddeblois@gmail.com>2016-04-05 21:38:42 +0300
committerPorteries Tristan <republicthunderbolt9@gmail.com>2016-04-05 22:39:04 +0300
commitc084520b0376c4ab92cb0193577a79cf23e5bb80 (patch)
tree645f35cdaa87464bb55e5c2b5657f86a142fedb2 /source/blender
parent176538f61360fb54f0e4ce209fc7d7632bce1401 (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')
-rw-r--r--source/blender/editors/mesh/mesh_navmesh.c43
-rw-r--r--source/blender/makesdna/DNA_scene_types.h8
-rw-r--r--source/blender/makesrna/intern/rna_scene.c14
3 files changed, 53 insertions, 12 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 ** */
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index fd37bde65ec..a8f78f6bb34 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -795,9 +795,15 @@ typedef struct RecastData {
int vertsperpoly;
float detailsampledist;
float detailsamplemaxerror;
- short pad1, pad2;
+ char partitioning;
+ char pad1;
+ short pad2;
} RecastData;
+#define RC_PARTITION_WATERSHED 0
+#define RC_PARTITION_MONOTONE 1
+#define RC_PARTITION_LAYERS 2
+
typedef struct GameData {
/* standalone player */
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 2af58a93305..94223f7f7da 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -3565,6 +3565,13 @@ static void rna_def_scene_game_recast_data(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
+ static EnumPropertyItem rna_enum_partitioning_items[] = {
+ {RC_PARTITION_WATERSHED, "WATERSHED", 0, "Watershed", "Classic Recast partitioning method generating the nicest tessellation"},
+ {RC_PARTITION_MONOTONE, "MONOTONE", 0, "Monotone", "Fastest navmesh generation method, may create long thin polygons"},
+ {RC_PARTITION_LAYERS, "LAYERS", 0, "Layers", "Reasonably fast method that produces better triangles than monotone partitioning"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
srna = RNA_def_struct(brna, "SceneGameRecastData", NULL);
RNA_def_struct_sdna(srna, "RecastData");
RNA_def_struct_nested(brna, srna, "Scene");
@@ -3627,6 +3634,13 @@ static void rna_def_scene_game_recast_data(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Merged Region Size", "Minimum regions size (smaller regions will be merged)");
RNA_def_property_update(prop, NC_SCENE, NULL);
+ prop = RNA_def_property(srna, "partitioning", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_bitflag_sdna(prop, NULL, "partitioning");
+ RNA_def_property_enum_items(prop, rna_enum_partitioning_items);
+ RNA_def_property_enum_default(prop, RC_PARTITION_WATERSHED);
+ RNA_def_property_ui_text(prop, "Partitioning", "Choose partitioning method");
+ RNA_def_property_update(prop, NC_SCENE, NULL);
+
prop = RNA_def_property(srna, "edge_max_len", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "edgemaxlen");
RNA_def_property_ui_range(prop, 0, 50, 1, 2);