[Bf-blender-cvs] [d95a490] soc-2013-sketch_mesh: Changed the names of some variables. The modifier print on screnn an alert when the user change the vertices, edges, or vertex group.

Alexander Pinzon Fernandez noreply at git.blender.org
Thu Nov 21 21:18:19 CET 2013


Commit: d95a4903f1b71e83dbae92dbe659f8de29f6d612
Author: Alexander Pinzon Fernandez
Date:   Thu Nov 21 13:50:19 2013 -0500
http://developer.blender.org/rBd95a4903f1b71e83dbae92dbe659f8de29f6d612

Changed the names of some variables.
The modifier print on screnn an alert when the user change the vertices, edges, or vertex group.

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

M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	source/blender/editors/object/object_modifier.c
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/modifiers/intern/MOD_laplaciandeform.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 63c7fc6..2a86b92 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -380,7 +380,6 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         row.active = not md.is_bind
         row = layout.row()
         row.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
-        row.active = not md.is_bind
         row.enabled = not md.is_bind
         layout.separator()
         row = layout.row()
@@ -388,7 +387,6 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
             row.operator("object.laplaciandeform_bind", text="Unbind")
         else:
             row.operator("object.laplaciandeform_bind", text="Bind")
-        row.active = bool(md.vertex_group)
         row.enabled = bool(md.vertex_group)
 
     def LAPLACIANSMOOTH(self, layout, ob, md):
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 22f7a44..1357eb0 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -2220,15 +2220,15 @@ static int laplaciandeform_bind_exec(bContext *C, wmOperator *op)
 {
 	Scene *scene = CTX_data_scene(C);
 	Object *ob = ED_object_active_context(C);
-	LaplacianDeformModifierData *mmd = (LaplacianDeformModifierData *)edit_modifier_property_get(op, ob, eModifierType_LaplacianDeform);
+	LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)edit_modifier_property_get(op, ob, eModifierType_LaplacianDeform);
 	
-	if (!mmd)
+	if (!lmd)
 		return OPERATOR_CANCELLED;
-	if (mmd->bind) {
-		mmd->bind = 0;
+	if (lmd->flag & MOD_LAPLACIANDEFORM_BIND) {
+		lmd->flag &= ~MOD_LAPLACIANDEFORM_BIND;
 	}
 	else {
-		mmd->bind = 1;
+		lmd->flag |= MOD_LAPLACIANDEFORM_BIND;
 	}
 	DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
 	WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 76f80da..59ce965 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1300,7 +1300,7 @@ typedef struct LaplacianDeformModifierData {
 	int total_verts, repeat;
 	float *vertexco;
 	void *cacheSystem;
-	short bind, pad[3];
+	short flag, pad[3];
 	
 } LaplacianDeformModifierData;
 
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index ec86860..6c22a5c 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -797,7 +797,8 @@ static void rna_LaplacianDeformModifier_vgroup_set(PointerRNA *ptr, const char *
 
 static int rna_LaplacianDeformModifier_is_bind_get(PointerRNA *ptr)
 {
-	return (((LaplacianDeformModifierData *)ptr->data)->bind == 1);
+	LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)ptr->data;
+	return ((lmd->flag & MOD_LAPLACIANDEFORM_BIND) && (lmd->cacheSystem != NULL));
 }
 
 #else
diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c
index b08f1b4..196f8c0 100644
--- a/source/blender/modifiers/intern/MOD_laplaciandeform.c
+++ b/source/blender/modifiers/intern/MOD_laplaciandeform.c
@@ -52,6 +52,9 @@
 #define LAPDEFORM_SYSTEM_ONLY_CHANGE_ANCHORS 2
 #define LAPDEFORM_SYSTEM_ONLY_CHANGE_GROUP 3
 #define LAPDEFORM_SYSTEM_ONLY_CHANGE_MESH 4
+#define LAPDEFORM_SYSTEM_CHANGE_VERTEXES 5
+#define LAPDEFORM_SYSTEM_CHANGE_EDGES 6
+#define LAPDEFORM_SYSTEM_CHANGE_NOT_VALID_GROUP 7
 
 typedef struct LaplacianSystem {
 	bool is_matrix_computed;
@@ -583,17 +586,17 @@ static void laplacianDeformPreview(LaplacianSystem *sys, float (*vertexCos)[3])
 	}
 }
 
-static bool isValidVertexGroup(LaplacianDeformModifierData *smd, Object *ob, DerivedMesh *dm)
+static bool isValidVertexGroup(LaplacianDeformModifierData *lmd, Object *ob, DerivedMesh *dm)
 {
 	int defgrp_index;
 	MDeformVert *dvert = NULL;
 
-	modifier_get_vgroup(ob, dm, smd->anchor_grp_name, &dvert, &defgrp_index);
+	modifier_get_vgroup(ob, dm, lmd->anchor_grp_name, &dvert, &defgrp_index);
 
 	return  (dvert != NULL);
 }
 
-static void initSystem(LaplacianDeformModifierData *smd, Object *ob, DerivedMesh *dm,
+static void initSystem(LaplacianDeformModifierData *lmd, Object *ob, DerivedMesh *dm,
                        float (*vertexCos)[3], int numVerts)
 {
 	int i;
@@ -603,13 +606,13 @@ static void initSystem(LaplacianDeformModifierData *smd, Object *ob, DerivedMesh
 	MDeformVert *dvert = NULL;
 	MDeformVert *dv = NULL;
 	LaplacianSystem *sys;
-	if (isValidVertexGroup(smd, ob, dm)) {
+	if (isValidVertexGroup(lmd, ob, dm)) {
 		int *index_anchors = MEM_mallocN(sizeof(int) * numVerts, __func__);  /* over-alloc */
 		MFace *tessface;
 		STACK_DECLARE(index_anchors);
 		STACK_INIT(index_anchors);
 
-		modifier_get_vgroup(ob, dm, smd->anchor_grp_name, &dvert, &defgrp_index);
+		modifier_get_vgroup(ob, dm, lmd->anchor_grp_name, &dvert, &defgrp_index);
 		BLI_assert(dvert != NULL);
 		dv = dvert;
 		for (i = 0; i < numVerts; i++) {
@@ -621,16 +624,16 @@ static void initSystem(LaplacianDeformModifierData *smd, Object *ob, DerivedMesh
 		}
 		DM_ensure_tessface(dm);
 		total_anchors = STACK_SIZE(index_anchors);
-		smd->cacheSystem = initLaplacianSystem(numVerts, dm->getNumEdges(dm), dm->getNumTessFaces(dm),
-		                                       total_anchors, smd->anchor_grp_name, smd->repeat);
-		sys = (LaplacianSystem *)smd->cacheSystem;
+		lmd->cacheSystem = initLaplacianSystem(numVerts, dm->getNumEdges(dm), dm->getNumTessFaces(dm),
+		                                       total_anchors, lmd->anchor_grp_name, lmd->repeat);
+		sys = (LaplacianSystem *)lmd->cacheSystem;
 		memcpy(sys->index_anchors, index_anchors, sizeof(int) * total_anchors);
 		memcpy(sys->co, vertexCos, sizeof(float[3]) * numVerts);
 		MEM_freeN(index_anchors);
 		STACK_FREE(index_anchors);
-		smd->vertexco = MEM_mallocN(sizeof(float[3]) * numVerts, "ModDeformCoordinates");
-		memcpy(smd->vertexco, vertexCos, sizeof(float[3]) * numVerts);
-		smd->total_verts = numVerts;
+		lmd->vertexco = MEM_mallocN(sizeof(float[3]) * numVerts, "ModDeformCoordinates");
+		memcpy(lmd->vertexco, vertexCos, sizeof(float[3]) * numVerts);
+		lmd->total_verts = numVerts;
 
 		createFaceRingMap(
 		            dm->getNumVerts(dm), dm->getTessFaceArray(dm), dm->getNumTessFaces(dm),
@@ -648,7 +651,7 @@ static void initSystem(LaplacianDeformModifierData *smd, Object *ob, DerivedMesh
 	}
 }
 
-static int isSystemDifferent(LaplacianDeformModifierData *smd, Object *ob, DerivedMesh *dm, int numVerts)
+static int isSystemDifferent(LaplacianDeformModifierData *lmd, Object *ob, DerivedMesh *dm, int numVerts)
 {
 	int i;
 	int defgrp_index;
@@ -656,20 +659,20 @@ static int isSystemDifferent(LaplacianDeformModifierData *smd, Object *ob, Deriv
 	float wpaint;
 	MDeformVert *dvert = NULL;
 	MDeformVert *dv = NULL;
-	LaplacianSystem *sys = (LaplacianSystem *)smd->cacheSystem;
+	LaplacianSystem *sys = (LaplacianSystem *)lmd->cacheSystem;
 
 	if (sys->total_verts != numVerts) {
-		return LAPDEFORM_SYSTEM_IS_DIFFERENT;
+		return LAPDEFORM_SYSTEM_CHANGE_VERTEXES;
 	}
 	if (sys->total_edges != dm->getNumEdges(dm)) {
-		return LAPDEFORM_SYSTEM_IS_DIFFERENT;
+		return LAPDEFORM_SYSTEM_CHANGE_EDGES;
 	}
-	if (!STREQ(smd->anchor_grp_name, sys->anchor_grp_name)) {
+	if (!STREQ(lmd->anchor_grp_name, sys->anchor_grp_name)) {
 		return LAPDEFORM_SYSTEM_ONLY_CHANGE_GROUP; 
 	}
-	modifier_get_vgroup(ob, dm, smd->anchor_grp_name, &dvert, &defgrp_index);
+	modifier_get_vgroup(ob, dm, lmd->anchor_grp_name, &dvert, &defgrp_index);
 	if (!dvert) {
-		return LAPDEFORM_SYSTEM_IS_DIFFERENT;
+		return LAPDEFORM_SYSTEM_CHANGE_NOT_VALID_GROUP;
 	}
 	dv = dvert;
 	for (i = 0; i < numVerts; i++) {
@@ -687,69 +690,72 @@ static int isSystemDifferent(LaplacianDeformModifierData *smd, Object *ob, Deriv
 }
 
 static void LaplacianDeformModifier_do(
-        LaplacianDeformModifierData *smd, Object *ob, DerivedMesh *dm,
+        LaplacianDeformModifierData *lmd, Object *ob, DerivedMesh *dm,
         float (*vertexCos)[3], int numVerts)
 {
 	float (*filevertexCos)[3];
 	int sysdif;
 	LaplacianSystem *sys = NULL;
 	filevertexCos = NULL;
-	if (!smd->bind) {
-		if (smd->cacheSystem) {
-			sys = smd->cacheSystem;
+	if (!(lmd->flag & MOD_LAPLACIANDEFORM_BIND)) {
+		if (lmd->cacheSystem) {
+			sys = lmd->cacheSystem;
 			deleteLaplacianSystem(sys);
-			smd->cacheSystem = NULL;
-			smd->total_verts = 0;
-			MEM_SAFE_FREE(smd->vertexco);
+			lmd->cacheSystem = NULL;
+			lmd->total_verts = 0;
+			MEM_SAFE_FREE(lmd->vertexco);
 		}
 		return;
 	}
-	if (smd->cacheSystem) {
-		sysdif = isSystemDifferent(smd, ob, dm, numVerts);
-		sys = smd->cacheSystem;
+	if (lmd->cacheSystem) {
+		sysdif = isSystemDifferent(lmd, ob, dm, numVerts);
+		sys = lmd->cacheSystem;
 		if (sysdif) {
 			if (sysdif == LAPDEFORM_SYSTEM_ONLY_CHANGE_ANCHORS || sysdif == LAPDEFORM_SYSTEM_ONLY_CHANGE_GROUP) {
 				filevertexCos = MEM_mallocN(sizeof(float[3]) * numVerts, "TempModDeformCoordinates");
-				memcpy(filevertexCos, smd->vertexco, sizeof(float[3]) * numVerts);
-				MEM_SAFE_FREE(smd->vertexco);
-				smd->total_verts = 0;
+				memcpy(filevertexCos, lmd->vertexco, sizeof(float[3]) * numVerts);
+				MEM_SAFE_FREE(lmd->vertexco);
+				lmd->total_verts = 0;
 				deleteLaplacianSystem(sys);
-				initSystem(smd, ob, dm, filevertexCos, numVerts);
-				sys = smd->cacheSystem; /* may have been reallocated */
+				initSystem(lmd, ob, dm, filevertexCos, numVerts);
+				sys = lmd->cacheSystem; /* may have been reallocated */
 				MEM_SAFE_FREE(filevertexCos);
 				laplacianDeformPreview(sys, vertexCos);
 			}
 			else {
-				deleteLaplacianSystem(sys);
-				MEM_SAFE_FREE(smd->vertexco);
-				smd->total_verts = 0;
-				initSystem(smd, ob, dm, vertexCos, numVerts);
-				sys = smd->cacheSystem; /* may have been reallocated */
-				laplacianDeformPreview(sys, vertexCos);
+				if (sysdif == LAPDEFORM_SYSTEM_CHANGE_VERTEXES) {
+					modifier_setError(lmd, "Verts changed

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list