[Bf-blender-cvs] [a976fe42ef7] master: Revert "Transform Snap: Clear 'SnapObjectData' after changes in the geometry"

Germano Cavalcante noreply at git.blender.org
Tue Mar 3 02:12:52 CET 2020


Commit: a976fe42ef74e77744f571578bf52998af491cb9
Author: Germano Cavalcante
Date:   Mon Mar 2 22:12:46 2020 -0300
Branches: master
https://developer.blender.org/rBa976fe42ef74e77744f571578bf52998af491cb9

Revert "Transform Snap: Clear 'SnapObjectData' after changes in the geometry"

This reverts commit fe7c4fb4a2d5d48555ebb9178fd5e7a8c1ace1ee.

It does not work because `mesh_eval_cage` and `mesh_eval_final` always is `NULL` in this case.

===================================================================

M	source/blender/editors/transform/transform_snap_object.c

===================================================================

diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c
index 7d046c4bb11..ecd267d6f2a 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -218,23 +218,14 @@ static SnapObjectData *snap_object_data_lookup(SnapObjectContext *sctx, Object *
 
 static SnapObjectData *snap_object_data_mesh_get(SnapObjectContext *sctx, Object *ob)
 {
-  SnapObjectData *sod;
   void **sod_p;
-  bool init = false;
-
   if (BLI_ghash_ensure_p(sctx->cache.object_map, ob, &sod_p)) {
-    sod = *sod_p;
-    if (sod->type != SNAP_MESH) {
-      snap_object_data_clear(sod);
-      init = true;
-    }
+    BLI_assert(((SnapObjectData *)*sod_p)->type == SNAP_MESH);
   }
   else {
-    sod = *sod_p = BLI_memarena_calloc(sctx->cache.mem_arena, sizeof(*sod));
-    init = true;
-  }
+    SnapObjectData *sod = *sod_p = BLI_memarena_calloc(sctx->cache.mem_arena, sizeof(*sod));
 
-  if (init) {
+    /* Init. */
     sod->type = SNAP_MESH;
     /* start assuming that it has each of these element types */
     sod->has_looptris = true;
@@ -242,16 +233,14 @@ static SnapObjectData *snap_object_data_mesh_get(SnapObjectContext *sctx, Object
     sod->has_loose_vert = true;
   }
 
-  return sod;
+  return *sod_p;
 }
 
 static SnapObjectData *snap_object_data_editmesh_get(SnapObjectContext *sctx,
                                                      Object *ob,
                                                      BMEditMesh *em)
 {
-  SnapObjectData *sod;
   void **sod_p;
-  bool init = false;
 
   {
     /* Use object-data as the key in ghash since the editmesh
@@ -269,24 +258,18 @@ static SnapObjectData *snap_object_data_editmesh_get(SnapObjectContext *sctx,
   }
 
   if (BLI_ghash_ensure_p(sctx->cache.object_map, ob, &sod_p)) {
-    sod = *sod_p;
-    if (sod->type != SNAP_EDIT_MESH) {
-      snap_object_data_clear(sod);
-      init = true;
-    }
+    BLI_assert(((SnapObjectData *)*sod_p)->type == SNAP_EDIT_MESH);
   }
   else {
-    sod = *sod_p = BLI_memarena_calloc(sctx->cache.mem_arena, sizeof(*sod));
-    init = true;
-  }
+    SnapObjectData *sod = *sod_p = BLI_memarena_calloc(sctx->cache.mem_arena, sizeof(*sod));
 
-  if (init) {
+    /* Init. */
     sod->type = SNAP_EDIT_MESH;
     sod->treedata_editmesh.em = em;
     bm_mesh_minmax(em->bm, sod->min, sod->max);
   }
 
-  return sod;
+  return *sod_p;
 }
 
 /** \} */
@@ -2464,16 +2447,7 @@ static short snapEditMesh(SnapObjectContext *sctx,
     return 0;
   }
 
-  BVHCache **em_bvh_cache;
-  if (em->mesh_eval_final) {
-    em_bvh_cache = &em->mesh_eval_final->runtime.bvh_cache;
-  }
-  else if (em->mesh_eval_cage) {
-    em_bvh_cache = &em->mesh_eval_cage->runtime.bvh_cache;
-  }
-  else {
-    em_bvh_cache = &((Mesh *)ob->data)->runtime.bvh_cache;
-  }
+  BVHCache **em_bvh_cache = &((Mesh *)ob->data)->runtime.bvh_cache;
 
   if (snapdata->snap_to_flag & SCE_SNAP_MODE_VERTEX) {
     BVHTreeFromEditMesh treedata = {.tree = sod->bvhtree[0]};



More information about the Bf-blender-cvs mailing list