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 <germano.costa@ig.com.br>2018-07-25 01:13:28 +0300
committerGermano <germano.costa@ig.com.br>2018-07-25 01:13:28 +0300
commitdecb724572c4700d2ed2b9fb9447a17c2b5b1626 (patch)
treeb594381a1e020b9330925120be54f4d756b84164 /source/blender
parenta76198cb238bef5c08e83b7777c977daa7316c1f (diff)
Fix T55798: Crash when snapping objects with data recalculated by modifiers.
Although the default behavior is for these objects to be ignored during the snap operation, this should not crash.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/transform/transform_snap_object.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c
index b826e72acaf..dd4fc5025d9 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -172,6 +172,26 @@ static void min_max_from_bmesh(
}
}
+static SnapObjectData_Mesh *snap_object_data_mesh_create(SnapObjectContext *sctx)
+{
+ SnapObjectData_Mesh *sod = BLI_memarena_calloc(sctx->cache.mem_arena, sizeof(*sod));
+ sod->sd.type = SNAP_MESH;
+ /* start assuming that it has each of these element types */
+ sod->has_looptris = true;
+ sod->has_loose_edge = true;
+ sod->has_loose_vert = true;
+
+ return sod;
+}
+
+static SnapObjectData_EditMesh *snap_object_data_editmesh_create(SnapObjectContext *sctx, BMesh *bm)
+{
+ SnapObjectData_EditMesh *sod = BLI_memarena_calloc(sctx->cache.mem_arena, sizeof(*sod));
+ sod->sd.type = SNAP_EDIT_MESH;
+ min_max_from_bmesh(bm, sod->min, sod->max);
+
+ return sod;
+}
/**
* Walks through all objects in the scene to create the list of objets to snap.
@@ -386,8 +406,7 @@ static bool raycastMesh(
sod = *sod_p;
}
else {
- sod = *sod_p = BLI_memarena_calloc(sctx->cache.mem_arena, sizeof(*sod));
- sod->sd.type = SNAP_MESH;
+ sod = *sod_p = snap_object_data_mesh_create(sctx);
}
BVHTreeFromMesh *treedata = &sod->treedata;
@@ -525,9 +544,7 @@ static bool raycastEditMesh(
sod = *sod_p;
}
else {
- sod = *sod_p = BLI_memarena_calloc(sctx->cache.mem_arena, sizeof(*sod));
- sod->sd.type = SNAP_EDIT_MESH;
- min_max_from_bmesh(em->bm, sod->min, sod->max);
+ sod = *sod_p = snap_object_data_editmesh_create(sctx, em->bm);
}
{
@@ -1838,12 +1855,7 @@ static short snapMesh(
sod = *sod_p;
}
else {
- sod = *sod_p = BLI_memarena_calloc(sctx->cache.mem_arena, sizeof(*sod));
- sod->sd.type = SNAP_MESH;
- /* start assuming that it has each of these element types */
- sod->has_looptris = true;
- sod->has_loose_edge = true;
- sod->has_loose_vert = true;
+ sod = *sod_p = snap_object_data_mesh_create(sctx);
}
BVHTreeFromMesh *treedata, dummy_treedata;
@@ -2050,9 +2062,7 @@ static short snapEditMesh(
sod = *sod_p;
}
else {
- sod = *sod_p = BLI_memarena_calloc(sctx->cache.mem_arena, sizeof(*sod));
- sod->sd.type = SNAP_EDIT_MESH;
- min_max_from_bmesh(em->bm, sod->min, sod->max);
+ sod = *sod_p = snap_object_data_mesh_create(sctx, em->bm);
}
float dist_px_sq = SQUARE(*dist_px);