diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-04-16 17:53:30 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-04-16 17:53:30 +0400 |
commit | caafc8184bb63f38eeac13f9acf7f7410cddc440 (patch) | |
tree | 86966d1685a793f206eaac2e07ac7ca453378876 /source/blender/blenkernel/intern/DerivedMesh.c | |
parent | f4498e62a78e80e0db0a6d398f8b956827dddca5 (diff) |
Fix #30720: Creating Navmesh crashes blender
In fact there were several issues fixed (all of them regressions since bmesh merge):
- Creating navmesh crashed because creating new faces for mesh was trying to set
default values for all customdata layers in this face. This requires memory
pool created for this datablock.
Usually this pool is creating on creating datablock if there're some elements
to be stored in this block. In cases of regular primitive creating it wasn't
an issue because they doesn't create customdata layers, they only creates
geometry.
Navigation mesh creates geometry and customdata layers (CD_RECAST layer)
which used to confuse a bit custom data functions. Solved by ensuring there's
memory pool created for polygons datablock after adding new custom data layer.
Most probably it's better to be resolved on CD level (like smarter track on
changed amount of stored data and so) but prefer not to make such global changes
so close to the release.
- Toggling edit mode lead to loosing recast datalayer. Solved by adding recast
layer to bmesh mask so it'll be copied to/from edit mesh.
- Some part of code assumed raycast layer is in face datablock, some that it's in
polygon datablock. Made it to be in polygons datablock.
Kind of temporary solution to make navmesh working, probably it'll fail if one
will want to edit navmesh by hand after it was generated.
Proper way would be to ensure the whole navmesh things are using ngons.
Diffstat (limited to 'source/blender/blenkernel/intern/DerivedMesh.c')
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index e6fb506620c..3330a6596a7 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1753,18 +1753,6 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos add_orco_dm(ob, NULL, *deform_r, NULL, CD_ORCO); } -#ifdef WITH_GAMEENGINE - /* NavMesh - this is a hack but saves having a NavMesh modifier */ - if ((ob->gameflag & OB_NAVMESH) && (finaldm->type == DM_TYPE_CDDM)) { - DerivedMesh *tdm; - tdm= navmesh_dm_createNavMeshForVisualization(finaldm); - if (finaldm != tdm) { - finaldm->release(finaldm); - finaldm= tdm; - } - } -#endif /* WITH_GAMEENGINE */ - { /* calculating normals can re-calculate tessfaces in some cases */ #if 0 @@ -1820,6 +1808,18 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos } } +#ifdef WITH_GAMEENGINE + /* NavMesh - this is a hack but saves having a NavMesh modifier */ + if ((ob->gameflag & OB_NAVMESH) && (finaldm->type == DM_TYPE_CDDM)) { + DerivedMesh *tdm; + tdm= navmesh_dm_createNavMeshForVisualization(finaldm); + if (finaldm != tdm) { + finaldm->release(finaldm); + finaldm= tdm; + } + } +#endif /* WITH_GAMEENGINE */ + *final_r = finaldm; if (orcodm) @@ -2898,7 +2898,7 @@ static void navmesh_drawColored(DerivedMesh *dm) int a, glmode; MVert *mvert = (MVert *)CustomData_get_layer(&dm->vertData, CD_MVERT); MFace *mface = (MFace *)CustomData_get_layer(&dm->faceData, CD_MFACE); - int *polygonIdx = (int *)CustomData_get_layer(&dm->faceData, CD_RECAST); + int *polygonIdx = (int *)CustomData_get_layer(&dm->polyData, CD_RECAST); float col[3]; if (!polygonIdx) @@ -2980,14 +2980,14 @@ static DerivedMesh *navmesh_dm_createNavMeshForVisualization(DerivedMesh *dm) int res; result = CDDM_copy(dm); - if (!CustomData_has_layer(&result->faceData, CD_RECAST)) { - int *sourceRecastData = (int*)CustomData_get_layer(&dm->faceData, CD_RECAST); + if (!CustomData_has_layer(&result->polyData, CD_RECAST)) { + int *sourceRecastData = (int*)CustomData_get_layer(&dm->polyData, CD_RECAST); if (sourceRecastData) { - CustomData_add_layer_named(&result->faceData, CD_RECAST, CD_DUPLICATE, + CustomData_add_layer_named(&result->polyData, CD_RECAST, CD_DUPLICATE, sourceRecastData, maxFaces, "recastData"); } } - recastData = (int*)CustomData_get_layer(&result->faceData, CD_RECAST); + recastData = (int*)CustomData_get_layer(&result->polyData, CD_RECAST); /* note: This is not good design! - really should not be doing this */ result->drawFacesTex = navmesh_DM_drawFacesTex; |