[Bf-blender-cvs] [9cedd1d68b] uv_unwrapping_slim_and_ceres: Category: UV Unwrapping SLIM Algorithm Integration
Aurel Gruber
noreply at git.blender.org
Mon Feb 27 11:27:24 CET 2017
Commit: 9cedd1d68bfced2f630c7c3018589130f254ed5f
Author: Aurel Gruber
Date: Fri Feb 10 17:13:03 2017 +0100
Branches: uv_unwrapping_slim_and_ceres
https://developer.blender.org/rB9cedd1d68bfced2f630c7c3018589130f254ed5f
Category: UV Unwrapping SLIM Algorithm Integration
taking care of memory leaks
===================================================================
M intern/SLIM
M source/blender/editors/uvedit/uvedit_parametrizer.c
M source/blender/editors/uvedit/uvedit_parametrizer.h
M source/blender/editors/uvedit/uvedit_unwrap_ops.c
===================================================================
diff --git a/intern/SLIM b/intern/SLIM
index 8c6ee9dbdc..8686b499ce 160000
--- a/intern/SLIM
+++ b/intern/SLIM
@@ -1 +1 @@
-Subproject commit 8c6ee9dbdc60a9e2c3543eec38e71f9ca4fcd971
+Subproject commit 8686b499ce3f23d537e1e56ab91412bc0b2aefb3
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index 1459f9d45c..472e293d8a 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -4428,6 +4428,7 @@ void param_slim_end(ParamHandle *handle) {
PHandle *phandle = (PHandle *) handle;
matrix_transfer *mt = phandle->mt;
set_uv_param_slim(handle, mt);
+ free_matrix_transfer(mt);
}
@@ -4874,6 +4875,8 @@ void convert_blender_slim(ParamHandle *handle, bool selectionOnly, int weightMap
mt->Pmatrices[chartNr] = MEM_reallocN_id(mt->Pmatrices[chartNr], mt->nPinnedVertices[chartNr] * sizeof(**mt->Pmatrices), " Pinned-Vertex Matrix");
mt->Bvectors[chartNr] = MEM_reallocN_id(mt->Bvectors[chartNr], mt->nBoundaryVertices[chartNr] * sizeof(**mt->Bvectors), " boundary-Vertex Matrix");
mt->Ematrices[chartNr] = MEM_reallocN_id(mt->Ematrices[chartNr], (mt->nEdges[chartNr] + mt->nBoundaryVertices[chartNr]) * 2 * sizeof(**mt->Ematrices), " boundarys-Vertex Matrix");
+
+ MEM_freeN(tempW);
}
if (mt->nPinnedVertices > 0){
@@ -5164,17 +5167,31 @@ void free_matrix_transfer(matrix_transfer *mt){
MEM_freeN(mt->Vmatrices[chartNr]);
MEM_freeN(mt->UVmatrices[chartNr]);
MEM_freeN(mt->Fmatrices[chartNr]);
-
+ MEM_freeN(mt->PPmatrices[chartNr]);
+ MEM_freeN(mt->ELvectors[chartNr]);
+ MEM_freeN(mt->Wvectors[chartNr]);
+ MEM_freeN(mt->Pmatrices[chartNr]);
+ MEM_freeN(mt->Ematrices[chartNr]);
+ MEM_freeN(mt->Bvectors[chartNr]);
}
- MEM_freeN(mt->nVerts);
- MEM_freeN(mt->nFaces);
- MEM_freeN(mt->nPinnedVertices);
+
MEM_freeN(mt->Vmatrices);
MEM_freeN(mt->UVmatrices);
MEM_freeN(mt->Fmatrices);
- MEM_freeN(mt->Pmatrices);
MEM_freeN(mt->PPmatrices);
+ MEM_freeN(mt->ELvectors);
+ MEM_freeN(mt->Wvectors);
+ MEM_freeN(mt->Pmatrices);
+ MEM_freeN(mt->Ematrices);
+ MEM_freeN(mt->Bvectors);
+
+ MEM_freeN(mt->nVerts);
+ MEM_freeN(mt->nFaces);
+ MEM_freeN(mt->nPinnedVertices);
+ MEM_freeN(mt->nBoundaryVertices);
+ MEM_freeN(mt->nEdges);
+
MEM_freeN(mt);
}
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.h b/source/blender/editors/uvedit/uvedit_parametrizer.h
index ed5b10a594..2a3abaa35c 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.h
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.h
@@ -175,7 +175,9 @@ void convert_blender_slim(ParamHandle *handle, bool selectionOnly, int weightMap
void set_uv_param_slim(ParamHandle *handle, matrix_transfer *mt);
bool transformIslands(ParamHandle *handle);
bool mark_pins(ParamHandle *paramHandle);
-
+void add_index_to_vertices(BMEditMesh *em);
+void free_matrix_transfer(matrix_transfer *mt);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index 5920ecfecd..ccce5ca230 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -787,9 +787,6 @@ typedef struct {
bool noPins;
} MinStretchSlim;
-void add_index_to_vertices(BMEditMesh *em);
-void free_matrix_transfer(matrix_transfer *mt);
-
/* AUREL THESIS
Initialises SLIM and transfars data matrices
*/
@@ -865,6 +862,12 @@ static void minimize_stretch_SLIM_iteration(bContext *C, wmOperator *op, bool in
WM_event_add_notifier(C, NC_GEOM | ND_DATA, mss->obedit->data);
}
+void free_slimPtrs(void **slimPtrs, int nCharts){
+ for (int i = 0; i<nCharts; i++){
+ free_slim_data_C(slimPtrs[i]);
+ }
+}
+
/* AUREL THESIS
Exit interactive parametrisation. Clean up memory.
*/
@@ -897,6 +900,7 @@ static void minimize_stretch_SLIM_exit(bContext *C, wmOperator *op, bool cancel)
param_delete(mss->handle);
free_matrix_transfer(mss->mt);
+ free_slimPtrs(mss->slimPtrs, mss->mt->nCharts);
MEM_freeN(mss->slimPtrs);
MEM_freeN(mss);
op->customdata = NULL;
@@ -1472,7 +1476,7 @@ void ED_unwrap_lscm(Scene *scene, Object *obedit, const short sel)
handle = construct_param_handle(scene, obedit, em->bm, false, fill_holes, sel, correct_aspect);
if (use_slim_method){
- matrix_transfer *mt = MEM_mallocN(sizeof(matrix_transfer), "matrix transfer data");
+ matrix_transfer *mt = MEM_callocN(sizeof(matrix_transfer), "matrix transfer data");
enrich_handle_slim(scene, obedit, em, handle, mt);
}
More information about the Bf-blender-cvs
mailing list