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:
authorGermano Cavalcante <germano.costa@ig.com.br>2020-03-03 02:59:11 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2020-03-03 02:59:11 +0300
commitfe7c4fb4a2d5d48555ebb9178fd5e7a8c1ace1ee (patch)
treee92976eed3d125ade68ec2468cd63db9a60ec325 /source/blender/editors/transform/transform_snap_object.c
parent5a77748e470df308cd325311bab9bf21beb6f77e (diff)
Transform Snap: Clear 'SnapObjectData' after changes in the geometry
Differential Revision: https://developer.blender.org/D6927
Diffstat (limited to 'source/blender/editors/transform/transform_snap_object.c')
-rw-r--r--source/blender/editors/transform/transform_snap_object.c44
1 files changed, 35 insertions, 9 deletions
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c
index ecd267d6f2a..7d046c4bb11 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -218,14 +218,23 @@ 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)) {
- BLI_assert(((SnapObjectData *)*sod_p)->type == SNAP_MESH);
+ sod = *sod_p;
+ if (sod->type != SNAP_MESH) {
+ snap_object_data_clear(sod);
+ init = true;
+ }
}
else {
- SnapObjectData *sod = *sod_p = BLI_memarena_calloc(sctx->cache.mem_arena, sizeof(*sod));
+ sod = *sod_p = BLI_memarena_calloc(sctx->cache.mem_arena, sizeof(*sod));
+ init = true;
+ }
- /* Init. */
+ if (init) {
sod->type = SNAP_MESH;
/* start assuming that it has each of these element types */
sod->has_looptris = true;
@@ -233,14 +242,16 @@ static SnapObjectData *snap_object_data_mesh_get(SnapObjectContext *sctx, Object
sod->has_loose_vert = true;
}
- return *sod_p;
+ return sod;
}
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
@@ -258,18 +269,24 @@ static SnapObjectData *snap_object_data_editmesh_get(SnapObjectContext *sctx,
}
if (BLI_ghash_ensure_p(sctx->cache.object_map, ob, &sod_p)) {
- BLI_assert(((SnapObjectData *)*sod_p)->type == SNAP_EDIT_MESH);
+ sod = *sod_p;
+ if (sod->type != SNAP_EDIT_MESH) {
+ snap_object_data_clear(sod);
+ init = true;
+ }
}
else {
- SnapObjectData *sod = *sod_p = BLI_memarena_calloc(sctx->cache.mem_arena, sizeof(*sod));
+ sod = *sod_p = BLI_memarena_calloc(sctx->cache.mem_arena, sizeof(*sod));
+ init = true;
+ }
- /* Init. */
+ if (init) {
sod->type = SNAP_EDIT_MESH;
sod->treedata_editmesh.em = em;
bm_mesh_minmax(em->bm, sod->min, sod->max);
}
- return *sod_p;
+ return sod;
}
/** \} */
@@ -2447,7 +2464,16 @@ static short snapEditMesh(SnapObjectContext *sctx,
return 0;
}
- BVHCache **em_bvh_cache = &((Mesh *)ob->data)->runtime.bvh_cache;
+ 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;
+ }
if (snapdata->snap_to_flag & SCE_SNAP_MODE_VERTEX) {
BVHTreeFromEditMesh treedata = {.tree = sod->bvhtree[0]};