[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47077] branches/meshdata_transfer/source/ blender/editors/object/object_vgroup.c: GUI added, but crashes becasuse: ob_act / ob_src ->DerivedDeform == 0x0

Ove Murberg Henriksen sorayasilvermoon at hotmail.com
Sun May 27 16:17:02 CEST 2012


Revision: 47077
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47077
Author:   cyborgmuppet
Date:     2012-05-27 14:17:01 +0000 (Sun, 27 May 2012)
Log Message:
-----------
GUI added, but crashes becasuse: ob_act / ob_src ->DerivedDeform == 0x0

Modified Paths:
--------------
    branches/meshdata_transfer/source/blender/editors/object/object_vgroup.c

Modified: branches/meshdata_transfer/source/blender/editors/object/object_vgroup.c
===================================================================
--- branches/meshdata_transfer/source/blender/editors/object/object_vgroup.c	2012-05-27 13:44:21 UTC (rev 47076)
+++ branches/meshdata_transfer/source/blender/editors/object/object_vgroup.c	2012-05-27 14:17:01 UTC (rev 47077)
@@ -395,6 +395,27 @@
 	REPLACE_SELECTED_WEIGHTS = 3
 } ReplaceOption;
 
+static EnumPropertyItem vertex_group_option_item[] = {
+	{REPLACE_SINGLE_VERTEX_GROUP, "REPLACE_SINGLE_VERTEX_GROUP", 1, "Single", "Transfer single vertex group."},
+	{REPLACE_ALL_VERTEX_GROUPS, "REPLACE_ALL_VERTEX_GROUPS", 1, "All", "Transfer all vertex groups."},
+	{0, NULL, 0, NULL, NULL}
+};
+
+static EnumPropertyItem method_option_item[] = {
+	{BY_INDEX, "BY_INDEX", 1, "Vertex index", "Copy for identical meshes."},
+	{BY_NEAREST_VERTEX, "BY_NEAREST_VERTEX", 1, "Nearest vertex", "Copy weight from closest vertex."},
+	{BY_NEAREST_FACE, "BY_NEAREST_FACE", 1, "Nearest face", "Barycentric interpolation from nearest face."},
+	{BY_NEAREST_VERTEX_IN_FACE, "BY_NEAREST_VERTEX_IN_FACE", 1, "Nearest vertex in face", "Copy weight from closest vertex in nearest face."},
+	{0, NULL, 0, NULL, NULL}
+};
+
+static EnumPropertyItem replace_option_item[] = {
+	{REPLACE_ALL_WEIGHTS, "REPLACE_ALL_WEIGHTS", 1, "All", "Overwrites all weights."},
+	{REPLACE_EMPTY_WEIGHTS, "REPLACE_EMPTY_WEIGHTS", 1, "Empty", "Adds weights to vertices with no weight."},
+	{REPLACE_SELECTED_WEIGHTS, "REPLACE_SELECTED_WEIGHTS", 1, "Selected", "Replace selected weights."},
+	{0, NULL, 0, NULL, NULL}
+};
+
 /*copy weight*/
 void vgroup_transfer_weight(MVert *mv_dst, float *weight_dst, float weight_src, ReplaceOption replace_option)
 {
@@ -608,6 +629,12 @@
 			free_bvhtree_from_mesh(&tree_mesh_faces_src);
 			break;
 	}
+
+	/*free memory*/
+	if (mface_src) MEM_freeN(mface_src);
+	if (dv_array_src) MEM_freeN(dv_array_src);
+	if (dv_array_dst) MEM_freeN(dv_array_dst);
+
 	return 1;
 }
 
@@ -3002,14 +3029,10 @@
 	int fail = 0;
 	bDeformGroup *dg_src;
 
-	/* TODO: get these parameters from gui.
-	 * For now 1,3,1 is default because GUI doesnt contain more than one button yet:
-	 * Replace all weights in single vertexgroup based on interpolation of nearest face*/
+	VertexGroupOption vertex_group_option = RNA_enum_get(op->ptr, "VertexGroupOption");
+	MethodOption method_option = RNA_enum_get(op->ptr, "MethodOption");
+	ReplaceOption replace_option = RNA_enum_get(op->ptr, "ReplaceOption");
 
-	VertexGroupOption vertex_group_option = 1;
-	MethodOption method_option = 3;
-	ReplaceOption replace_option = 1;
-
 	/*Macro to loop through selected objects and perform operation depending on function, option and method*/
 	CTX_DATA_BEGIN(C, Object *, ob_slc, selected_editable_objects)
 	{
@@ -3063,6 +3086,11 @@
 
 	/* flags */
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+	/* properties */
+	ot->prop = RNA_def_enum(ot->srna, "VertexGroupOption", vertex_group_option_item, 1, "Group", "What groups to transfer.");
+	ot->prop = RNA_def_enum(ot->srna, "MethodOption", method_option_item, 3, "Method", "How to calculate weight.");
+	ot->prop = RNA_def_enum(ot->srna, "ReplaceOption", replace_option_item, 1, "Replace", "What weights to overwrite");
 }
 
 static EnumPropertyItem vgroup_items[] = {




More information about the Bf-blender-cvs mailing list