[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40201] branches/soc-2011-radish/source/ blender/editors: another cleanup pass, quiet all warnings for GCC

Campbell Barton ideasman42 at gmail.com
Wed Sep 14 07:25:43 CEST 2011


Revision: 40201
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40201
Author:   campbellbarton
Date:     2011-09-14 05:25:43 +0000 (Wed, 14 Sep 2011)
Log Message:
-----------
another cleanup pass, quiet all warnings for GCC
- comment unused funcs/vars.
- replace some allocs with stack variables.
- use BLI_math functions to replace in-line vector math.

Modified Paths:
--------------
    branches/soc-2011-radish/source/blender/editors/object/object_vgroup.c
    branches/soc-2011-radish/source/blender/editors/sculpt_paint/paint_vertex.c
    branches/soc-2011-radish/source/blender/editors/space_view3d/drawobject.c
    branches/soc-2011-radish/source/blender/editors/space_view3d/view3d_select.c

Modified: branches/soc-2011-radish/source/blender/editors/object/object_vgroup.c
===================================================================
--- branches/soc-2011-radish/source/blender/editors/object/object_vgroup.c	2011-09-14 02:45:44 UTC (rev 40200)
+++ branches/soc-2011-radish/source/blender/editors/object/object_vgroup.c	2011-09-14 05:25:43 UTC (rev 40201)
@@ -49,6 +49,7 @@
 #include "DNA_scene_types.h"
 #include "DNA_particle_types.h"
 
+#include "BLI_math.h"
 #include "BLI_blenlib.h"
 #include "BLI_editVert.h"
 #include "BLI_utildefines.h"
@@ -866,20 +867,17 @@
 /* coord is a point on the plane */
 /* point is the point that you want the nearest of */
 /* norm is the plane's normal, and d is the last number in the plane equation 0 = ax + by + cz + d */
-static void getNearestPointOnPlane(float *norm, float d, float *coord, float *point, float *dst) {
-	float *temp = MEM_callocN(sizeof(float)*3, "temp");
-	int i;
-	float dotprod = 0;
-	for(i = 0; i < 3; i++) {
-		temp[i] = point[i]-coord[i];
-	}
-	for(i = 0; i < 3; i++) {
-		dotprod += temp[i]*norm[i];
-	}
-	MEM_freeN(temp);
-	for(i = 0; i < 3; i++) {
-		dst[i] = point[i] - dotprod*norm[i];
-	}
+static void getNearestPointOnPlane(const float norm[3], const float coord[3], const float point[3], float dst_r[3])
+{
+	float temp[3];
+	float dotprod;
+
+	sub_v3_v3v3(temp, point, coord);
+	dotprod= dot_v3v3(temp, norm);
+
+	dst_r[0] = point[0] - (norm[0] * dotprod);
+	dst_r[1] = point[1] - (norm[1] * dotprod);
+	dst_r[2] = point[2] - (norm[2] * dotprod);
 }
 /* Jason */
 /* distance of two vectors a and b of size length */
@@ -902,8 +900,8 @@
 	float *projA, *projB;
 	projA = MEM_callocN(sizeof(float)*3, "projectedA");
 	projB = MEM_callocN(sizeof(float)*3, "projectedB");
-	getNearestPointOnPlane(norm, d, coord, start, projA);
-	getNearestPointOnPlane(norm, d, coord, end, projB);
+	getNearestPointOnPlane(norm, coord, start, projA);
+	getNearestPointOnPlane(norm, coord, end, projB);
 	// (vertical and horizontal refer to the plane's y and xz respectively)
 	// vertical distance
 	dists[index] = norm[0]*end[0] + norm[1]*end[1] + norm[2]*end[2] + d;
@@ -918,12 +916,10 @@
 }
 // Jason
 // I need the derived mesh to be forgotten so the positions are recalculated with weight changes (see dm_deform_recalc)
-static int dm_deform_clear(DerivedMesh *dm, Object *ob) {
+static void dm_deform_clear(DerivedMesh *dm, Object *ob) {
 	dm->needsFree = 1;
 	dm->release(dm);
 	ob->derivedDeform=NULL;
-	// dm = NULL;
-	return NULL;
 }
 // Jason
 // recalculate the deformation
@@ -986,7 +982,7 @@
 			}
 			for(k = 0; k < 2; k++) {
 				if(dm) {
-					dm = dm_deform_clear(dm, ob);
+					dm_deform_clear(dm, ob); dm = NULL;
 				}
 				oldw = dw->weight;
 				if(k) {
@@ -1096,7 +1092,7 @@
 				wasChange = FALSE;
 			}
 			if(dm) {
-				dm = dm_deform_clear(dm, ob);
+				dm_deform_clear(dm, ob); dm = NULL;
 			}
 		}
 	}while(wasChange && (distToStart-distToBe)/fabs(distToStart-distToBe) == (dists[bestIndex]-distToBe)/fabs(dists[bestIndex]-distToBe));
@@ -1137,7 +1133,7 @@
 				}
 				
 				if(count >= 3) {
-					float d, dist, mag;
+					float d /*, dist */ /* UNUSED */, mag;
 					float *coord = MEM_callocN(sizeof(float)*3, "deformedCoord");
 					float *norm = MEM_callocN(sizeof(float)*3, "planeNorm");
 					getSingleCoordinate(p, count, coord);
@@ -1150,7 +1146,7 @@
 						norm[k]/=mag;
 					}
 					d = -norm[0]*coord[0] -norm[1]*coord[1] -norm[2]*coord[2];
-					dist = (norm[0]*m.co[0] + norm[1]*m.co[1] + norm[2]*m.co[2] + d);
+					/* dist = (norm[0]*m.co[0] + norm[1]*m.co[1] + norm[2]*m.co[2] + d); */ /* UNUSED */
 					moveCloserToDistanceFromPlane(scene, ob, me, i, norm, coord, d, distToBe, strength, cp);
 					MEM_freeN(coord);
 					MEM_freeN(norm);
@@ -2380,7 +2376,7 @@
 	RNA_def_float(ot->srna, "cp", 1.0f, 0.05f, FLT_MAX, "Change Sensitivity", "Changes the amount weights are altered with each iteration: lower values are slower.", 0.05f, 1.f);
 }
 /* Jason was here */
-static int vertex_group_invert_locks_exec(bContext *C, wmOperator *op)
+static int vertex_group_invert_locks_exec(bContext *C, wmOperator *UNUSED(op))
 {
 	Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
 
@@ -2403,7 +2399,7 @@
 	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 /* Jason was here */
-static int vertex_group_lock_all_exec(bContext *C, wmOperator *op)
+static int vertex_group_lock_all_exec(bContext *C, wmOperator *UNUSED(op))
 {
 	Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
 
@@ -2426,7 +2422,7 @@
 	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 /* Jason was here */
-static int vertex_group_unlock_all_exec(bContext *C, wmOperator *op)
+static int vertex_group_unlock_all_exec(bContext *C, wmOperator *UNUSED(op))
 {
 	Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
 

Modified: branches/soc-2011-radish/source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
--- branches/soc-2011-radish/source/blender/editors/sculpt_paint/paint_vertex.c	2011-09-14 02:45:44 UTC (rev 40200)
+++ branches/soc-2011-radish/source/blender/editors/sculpt_paint/paint_vertex.c	2011-09-14 05:25:43 UTC (rev 40201)
@@ -1074,6 +1074,7 @@
 }
 
 
+#if 0 /* UNUSED */
 static void do_weight_paint_auto_normalize(MDeformVert *dvert, 
 					   int paint_nr, char *map)
 {
@@ -1108,6 +1109,8 @@
 		}
 	}
 }
+#endif
+
 // Jason was here: the active group should be involved in auto normalize
 static void do_weight_paint_auto_normalize_all_groups(MDeformVert *dvert, char *map)
 {
@@ -1151,18 +1154,17 @@
 	}
 	return FALSE;
 }
-/*Jason was here
-gen_lck_flags gets the status of "flag" for each bDeformGroup
-in ob->defbase and returns an array containing them
-*/
-static char* gen_lck_flags(Object* ob, int defcnt, char *map)
+/* Jason was here
+ * gen_lck_flags gets the status of "flag" for each bDeformGroup
+ *in ob->defbase and returns an array containing them
+ */
+static char *gen_lck_flags(Object* ob, int defcnt)
 {
 	char is_locked = FALSE;
 	int i;
 	//int defcnt = BLI_countlist(&ob->defbase);
 	char *flags = MEM_mallocN(defcnt*sizeof(char), "defflags");
 	bDeformGroup *defgroup;
-	int selected = 0;
 
 	for(i = 0, defgroup = ob->defbase.first; i < defcnt && defgroup; defgroup = defgroup->next, i++) {
 		flags[i] = defgroup->flag;
@@ -1189,6 +1191,7 @@
 }
 
 /* Jason was here */
+#if 0 /* UNUSED */
 static int has_unselected_unlocked_bone_group(int defcnt, char *selection, int selected, char *flags, char *bone_groups) {
 	int i;
 	if(defcnt == selected) {
@@ -1201,6 +1204,7 @@
 	}
 	return FALSE;
 }
+#endif
 
 /*Jason*/
 static void multipaint_selection(MDeformVert *dvert, float change, char *selection, int defcnt) {
@@ -1448,16 +1452,16 @@
 /*Jason*/
 /* fresh start to make multi-paint and locking modular */
 /* returns TRUE if it thinks you need to reset the weights due to normalizing while multi-painting */
-static int apply_mp_lcks_normalize(Object *ob, Mesh *me, int index, MDeformWeight *dw, MDeformWeight *tdw, int defcnt, float change, float oldChange, float oldw, float neww, char *selection, int selected, char *bone_groups, char *validmap, char *flags, int multipaint) {
+static int apply_mp_lcks_normalize(Mesh *me, int index, MDeformWeight *dw, MDeformWeight *tdw, int defcnt, float change, float oldChange, float oldw, float neww, char *selection, int selected, char *bone_groups, char *validmap, char *flags, int multipaint) {
 	MDeformVert *dvert = me->dvert+index;
-	MDeformVert *dv = MEM_mallocN(sizeof (*(me->dvert+index)), "oldMDeformVert");
+	MDeformVert dv= {NULL};
 
-	dv->dw= MEM_dupallocN(dvert->dw);
-	dv->flag = dvert->flag;
-	dv->totweight = dvert->totweight;
+	dv.dw= MEM_dupallocN(dvert->dw);
+	dv.flag = dvert->flag;
+	dv.totweight = dvert->totweight;
 	// do not multi-paint if a locked group is selected or the active group is locked
 	// !flags[dw->def_nr] helps if nothing is selected, but active group is locked
-	if(!flags || flags && !has_locked_group_selected(defcnt, selection, flags) && !flags[dw->def_nr]) {
+	if((flags == NULL) || (has_locked_group_selected(defcnt, selection, flags) == FALSE && flags[dw->def_nr] == FALSE)) {
 		if(multipaint && selected > 1) {
 			if(change && change!=1) {
 				multipaint_selection(dvert, change, selection, defcnt);
@@ -1468,7 +1472,7 @@
 	}
 	clamp_weights(dvert);
 
-	enforce_locks(dv, dvert, defcnt, flags, bone_groups, validmap);
+	enforce_locks(&dv, dvert, defcnt, flags, bone_groups, validmap);
 
 	do_weight_paint_auto_normalize_all_groups(dvert, validmap);
 
@@ -1476,21 +1480,18 @@
 		if(tdw->weight != oldw) {
 			if( neww > oldw ) {
 				if(tdw->weight <= oldw) {
-					MEM_freeN(dv->dw);
-					MEM_freeN(dv);
+					MEM_freeN(dv.dw);
 					return TRUE;
 				}
 			} else {
 				if(tdw->weight >= oldw) {
-					MEM_freeN(dv->dw);
-					MEM_freeN(dv);
+					MEM_freeN(dv.dw);
 					return TRUE;
 				}
 			}
 		}
 	}
-	MEM_freeN(dv->dw);
-	MEM_freeN(dv);
+	MEM_freeN(dv.dw);
 	return FALSE;
 }
 
@@ -1551,7 +1552,7 @@
 	if(dw==NULL || uw==NULL)
 		return;
 	/* Jason was here */
-	flags = gen_lck_flags(ob, defcnt = BLI_countlist(&ob->defbase), bone_groups);
+	flags = gen_lck_flags(ob, defcnt = BLI_countlist(&ob->defbase));
 	selection = get_selected_defgroups(ob, defcnt);
 	selected = count_selected_defgroups(selection, defcnt);
 	if(!selected && ob->actdef) {
@@ -1610,7 +1611,7 @@
 		}
 	}
 	/* Jason was here */
-	if(apply_mp_lcks_normalize(ob, me, index, dw, tdw, defcnt, change, oldChange, oldw, neww, selection, selected, bone_groups, validmap, flags, multipaint)) {
+	if(apply_mp_lcks_normalize(me, index, dw, tdw, defcnt, change, oldChange, oldw, neww, selection, selected, bone_groups, validmap, flags, multipaint)) {
 		reset_to_prev(dv, me->dvert+index);
 		change = 0;
 		oldChange = 0;
@@ -1633,7 +1634,7 @@
 			/* Jason */
 			//uw->weight= dw->weight;
 			/* Jason */
-			apply_mp_lcks_normalize(ob, me, j, uw, tdw, defcnt, change, oldChange, oldw, neww, selection, selected, bone_groups, validmap, flags, multipaint);
+			apply_mp_lcks_normalize(me, j, uw, tdw, defcnt, change, oldChange, oldw, neww, selection, selected, bone_groups, validmap, flags, multipaint);
 		}
 	}
 	/* Jason */

Modified: branches/soc-2011-radish/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- branches/soc-2011-radish/source/blender/editors/space_view3d/drawobject.c	2011-09-14 02:45:44 UTC (rev 40200)

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list