[Bf-blender-cvs] [decb724572c] blender2.8: Fix T55798: Crash when snapping objects with data recalculated by modifiers.
Germano
noreply at git.blender.org
Wed Jul 25 00:35:13 CEST 2018
Commit: decb724572c4700d2ed2b9fb9447a17c2b5b1626
Author: Germano
Date: Tue Jul 24 19:13:28 2018 -0300
Branches: blender2.8
https://developer.blender.org/rBdecb724572c4700d2ed2b9fb9447a17c2b5b1626
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.
===================================================================
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 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);
More information about the Bf-blender-cvs
mailing list