[Bf-blender-cvs] [afb9393] master: Fix T38354: Excess memory allocation when projecting onto object with multires

Bastien Montagne noreply at git.blender.org
Sun Jan 26 17:00:07 CET 2014


Commit: afb9393ddad3c57e99a5df13a74969c192a023f5
Author: Bastien Montagne
Date:   Sun Jan 26 16:53:33 2014 +0100
https://developer.blender.org/rBafb9393ddad3c57e99a5df13a74969c192a023f5

Fix T38354: Excess memory allocation when projecting onto object with multires

Found three cases where created bvhtree was not freed...

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

M	source/blender/editors/transform/transform_snap.c
M	source/blender/makesrna/intern/rna_object_api.c

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

diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index f0762e1..7df5c5f 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -1570,6 +1570,7 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes
 							retval |= 1;
 						}
 					}
+					free_bvhtree_from_mesh(&treeData);
 					break;
 				}
 				case SCE_SNAP_MODE_VERTEX:
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c
index fc97a32..b4692f9 100644
--- a/source/blender/makesrna/intern/rna_object_api.c
+++ b/source/blender/makesrna/intern/rna_object_api.c
@@ -309,6 +309,7 @@ static void rna_Object_ray_cast(Object *ob, ReportList *reports, float ray_start
 				copy_v3_v3(r_location, hit.co);
 				copy_v3_v3(r_normal, hit.no);
 				*index = dm_tessface_to_poly_index(ob->derivedFinal, hit.index);
+				free_bvhtree_from_mesh(&treeData);
 				return;
 			}
 		}
@@ -317,6 +318,7 @@ static void rna_Object_ray_cast(Object *ob, ReportList *reports, float ray_start
 	zero_v3(r_location);
 	zero_v3(r_normal);
 	*index = -1;
+	free_bvhtree_from_mesh(&treeData);
 }
 
 static void rna_Object_closest_point_on_mesh(Object *ob, ReportList *reports, float point_co[3], float max_dist,
@@ -348,6 +350,7 @@ static void rna_Object_closest_point_on_mesh(Object *ob, ReportList *reports, fl
 			copy_v3_v3(n_location, nearest.co);
 			copy_v3_v3(n_normal, nearest.no);
 			*index = dm_tessface_to_poly_index(ob->derivedFinal, nearest.index);
+			free_bvhtree_from_mesh(&treeData);
 			return;
 		}
 	}
@@ -355,6 +358,7 @@ static void rna_Object_closest_point_on_mesh(Object *ob, ReportList *reports, fl
 	zero_v3(n_location);
 	zero_v3(n_normal);
 	*index = -1;
+	free_bvhtree_from_mesh(&treeData);
 }
 
 /* ObjectBase */




More information about the Bf-blender-cvs mailing list