[Bf-blender-cvs] [fe71c86888f] master: Fix T52478: Error report "Shrinkwrap: out of memory" on invisible target.

Bastien Montagne noreply at git.blender.org
Sat Aug 26 14:48:35 CEST 2017


Commit: fe71c86888fe4600573daec12eace59c0ed797ec
Author: Bastien Montagne
Date:   Sat Aug 26 14:46:59 2017 +0200
Branches: master
https://developer.blender.org/rBfe71c86888fe4600573daec12eace59c0ed797ec

Fix T52478: Error report "Shrinkwrap: out of memory" on invisible target.

Shrinkwrap must check it does have valid target data.

Safe for 2.79 release.

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

M	source/blender/blenkernel/intern/shrinkwrap.c

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

diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c
index 7094d5a3547..f9d1793d7cb 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -152,6 +152,9 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
 	BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh;
 	BVHTreeNearest nearest  = NULL_BVHTreeNearest;
 
+	if (calc->target != NULL && calc->target->getNumVerts(calc->target) == 0) {
+		return;
+	}
 
 	TIMEIT_BENCH(bvhtree_from_mesh_verts(&treeData, calc->target, 0.0, 2, 6), bvhtree_verts);
 	if (treeData.tree == NULL) {
@@ -376,6 +379,9 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, bool for
 	if ((calc->smd->shrinkOpts & (MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR | MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR)) == 0)
 		return;
 
+	if (calc->target != NULL && calc->target->getNumPolys(calc->target) == 0) {
+		return;
+	}
 
 	/* Prepare data to retrieve the direction in which we should project each vertex */
 	if (calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) {
@@ -432,7 +438,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, bool for
 	if (targ_tree) {
 		BVHTree *aux_tree = NULL;
 		void *aux_callback = NULL;
-		if (auxMesh != NULL) {
+		if (auxMesh != NULL && auxMesh->getNumPolys(auxMesh) != 0) {
 			/* use editmesh to avoid array allocation */
 			if (calc->smd->auxTarget && auxMesh->type == DM_TYPE_EDITBMESH) {
 				emaux = BKE_editmesh_from_object(calc->smd->auxTarget);
@@ -560,6 +566,10 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
 	BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh;
 	BVHTreeNearest nearest  = NULL_BVHTreeNearest;
 
+	if (calc->target->getNumPolys(calc->target) == 0) {
+		return;
+	}
+
 	/* Create a bvh-tree of the given target */
 	bvhtree_from_mesh_looptri(&treeData, calc->target, 0.0, 2, 6);
 	if (treeData.tree == NULL) {



More information about the Bf-blender-cvs mailing list