[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40310] branches/soc-2011-radish/source/ blender: I made multitude of fixes based on the comments provided online:

Jason Hays jason_hays22 at mymail.eku.edu
Sun Sep 18 03:09:22 CEST 2011


Revision: 40310
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40310
Author:   jason_hays22
Date:     2011-09-18 01:09:18 +0000 (Sun, 18 Sep 2011)
Log Message:
-----------
I made multitude of fixes based on the comments provided online:

Removed the drawSelectedVerts and added drawSelectedVertices, which uses dm->foreachMappedVert.

In calc_weightpaint_vert_color():
Made the weight paint color black and return instead of input=-1

Made the pose bone selection normal when multi-paint is inactive.

Name fix for functions using mv instead of mvert.

Used vector functions provided by the math lib.

Changed some MEM_callocN references to be stacks.

Changed dm_deform_clear to use ob->derivedDeform primarily

Made the variable "float **changes" into "float (*changes)[2]"

Used CTX_data_active_object() in place of CTX_data_pointer_get_type()

Added the invert selection hotkey "Ctrl+I" to weight paint's vertex mask.

Modified Paths:
--------------
    branches/soc-2011-radish/source/blender/blenkernel/BKE_DerivedMesh.h
    branches/soc-2011-radish/source/blender/blenkernel/intern/DerivedMesh.c
    branches/soc-2011-radish/source/blender/blenkernel/intern/cdderivedmesh.c
    branches/soc-2011-radish/source/blender/editors/armature/editarmature.c
    branches/soc-2011-radish/source/blender/editors/mesh/editmesh.c
    branches/soc-2011-radish/source/blender/editors/object/object_vgroup.c
    branches/soc-2011-radish/source/blender/editors/sculpt_paint/paint_intern.h
    branches/soc-2011-radish/source/blender/editors/sculpt_paint/paint_ops.c
    branches/soc-2011-radish/source/blender/editors/sculpt_paint/paint_utils.c
    branches/soc-2011-radish/source/blender/editors/space_view3d/drawobject.c

Modified: branches/soc-2011-radish/source/blender/blenkernel/BKE_DerivedMesh.h
===================================================================
--- branches/soc-2011-radish/source/blender/blenkernel/BKE_DerivedMesh.h	2011-09-17 23:45:06 UTC (rev 40309)
+++ branches/soc-2011-radish/source/blender/blenkernel/BKE_DerivedMesh.h	2011-09-18 01:09:18 UTC (rev 40310)
@@ -222,9 +222,6 @@
 	/* Draw all vertices as bgl points (no options) */
 	void (*drawVerts)(DerivedMesh *dm);
 
-	/* Jason Draw all selected vertices as bgl points (no options) */
-	void (*drawSelectedVerts)(DerivedMesh *dm);
-
 	/* Draw edges in the UV mesh (if exists) */
 	void (*drawUVEdges)(DerivedMesh *dm);
 

Modified: branches/soc-2011-radish/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- branches/soc-2011-radish/source/blender/blenkernel/intern/DerivedMesh.c	2011-09-17 23:45:06 UTC (rev 40309)
+++ branches/soc-2011-radish/source/blender/blenkernel/intern/DerivedMesh.c	2011-09-18 01:09:18 UTC (rev 40310)
@@ -1726,13 +1726,15 @@
 	}
 	
 	if (make_black) {
-		input = -1;
+		col[3] = 0;
+		col[2] = 0;
+		col[1] = 0;
+		col[0] = 255;
+		return;
 	}
-	else {
-		CLAMP(input, 0.0f, 1.0f);
-	}
-	
-	
+
+	CLAMP(input, 0.0f, 1.0f);	
+
 	if(coba)
 		do_colorband(coba, input, colf);
 	else

Modified: branches/soc-2011-radish/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- branches/soc-2011-radish/source/blender/blenkernel/intern/cdderivedmesh.c	2011-09-17 23:45:06 UTC (rev 40309)
+++ branches/soc-2011-radish/source/blender/blenkernel/intern/cdderivedmesh.c	2011-09-18 01:09:18 UTC (rev 40310)
@@ -265,45 +265,7 @@
 
 	BLI_pbvh_update(cddm->pbvh, PBVH_UpdateNormals, face_nors);
 }
-// Jason
-static void cdDM_drawSelectedVerts(DerivedMesh *dm)
-{
-	CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
-	MVert *mv = cddm->mvert;
-	int i;
-	if( GPU_buffer_legacy(dm) ) {
-		char prev_sel= 0; /* always invalid */;
 
-		glBegin(GL_POINTS);
-		for(i = 0; i < dm->numVertData; i++, mv++) {
-			if(!(mv->flag & ME_HIDE)) {
-				const char sel= mv->flag & 1;
-				if(prev_sel != sel) {
-					prev_sel= sel;
-
-					// TODO define selected color
-					if(sel) {
-						glColor3f(1.0f, 1.0f, 0.0f);
-					}else {
-						glColor3f(0.0f, 0.0f, 0.0f);
-					}
-				}
-
-				glVertex3fv(mv->co);
-			}
-		}
-		glEnd();
-	}
-	else {	/* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */
-		GPU_vertex_setup(dm);
-		if( !GPU_buffer_legacy(dm) ) {
-			if(dm->drawObject->tot_triangle_point)	glDrawArrays(GL_POINTS,0, dm->drawObject->tot_triangle_point);
-			else							glDrawArrays(GL_POINTS,0, dm->drawObject->tot_loose_point);
-		}
-		GPU_buffer_unbind();
-	}
-}
-
 static void cdDM_drawVerts(DerivedMesh *dm)
 {
 	CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
@@ -1589,8 +1551,6 @@
 	dm->getFaceMap = cdDM_getFaceMap;
 
 	dm->drawVerts = cdDM_drawVerts;
-	// Jason
-	dm->drawSelectedVerts = cdDM_drawSelectedVerts;
 
 	dm->drawUVEdges = cdDM_drawUVEdges;
 	dm->drawEdges = cdDM_drawEdges;

Modified: branches/soc-2011-radish/source/blender/editors/armature/editarmature.c
===================================================================
--- branches/soc-2011-radish/source/blender/editors/armature/editarmature.c	2011-09-17 23:45:06 UTC (rev 40309)
+++ branches/soc-2011-radish/source/blender/editors/armature/editarmature.c	2011-09-18 01:09:18 UTC (rev 40310)
@@ -4297,8 +4297,6 @@
 {
 	Object *ob= base->object;
 	Bone *nearBone;
-	// Jason
-	Bone *new_act_bone;
 
 	if (!ob || !ob->pose) return 0;
 
@@ -4310,7 +4308,8 @@
 		
 		/* since we do unified select, we don't shift+select a bone if the armature object was not active yet */
 		/* Jason was here, I'm doing a select for multibone painting */
-		if ((base != scene->basact)) {//if (!(extend) || (base != scene->basact)) {
+		if (scene->toolsettings->multipaint && (base != scene->basact)) {//if (!(extend) || (base != scene->basact)) {
+			Bone *new_act_bone;
 			/* Jason was here */
 			/* only deselect all if they aren't using 'shift' */
 			if(!extend) {
@@ -4341,6 +4340,10 @@
 			DAG_id_tag_update(&OBACT->id, OB_RECALC_DATA);
 				// XXX old cruft! use notifiers instead
 			//select_actionchannel_by_name(ob->action, nearBone->name, 1);
+		} else if (!(extend) || (base != scene->basact)) {
+			ED_pose_deselectall(ob, 0);
+			nearBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
+			arm->act_bone= nearBone;
 		}
 		else {
 			if (nearBone->flag & BONE_SELECTED) {

Modified: branches/soc-2011-radish/source/blender/editors/mesh/editmesh.c
===================================================================
--- branches/soc-2011-radish/source/blender/editors/mesh/editmesh.c	2011-09-17 23:45:06 UTC (rev 40309)
+++ branches/soc-2011-radish/source/blender/editors/mesh/editmesh.c	2011-09-18 01:09:18 UTC (rev 40310)
@@ -1992,7 +1992,7 @@
 		}
 	}
 }
-/* Jason note: caller needs to run paintvert_flush_flags(ob) after this */
+/* Jason note: if the caller passes FALSE to flush_flags, then they will need to run paintvert_flush_flags(ob) themselves */
 void paintvert_deselect_all_visible(Object *ob, int action, short flush_flags)
 {
 	Mesh *me;

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-17 23:45:06 UTC (rev 40309)
+++ branches/soc-2011-radish/source/blender/editors/object/object_vgroup.c	2011-09-18 01:09:18 UTC (rev 40310)
@@ -705,7 +705,7 @@
 	int i, def_nr, dvert_tot=0;
 	// Jason
 	Mesh *me = ob->data;
-	MVert *mv = me->mvert;
+	MVert *mvert = me->mvert;
 	const int use_vert_sel= (me->editflag & ME_EDIT_VERT_SEL) != 0;
 
 	ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot);
@@ -719,7 +719,7 @@
 
 		for(i = 0; i < dvert_tot; i++) {
 			// Jason
-			if(use_vert_sel && !((mv+i)->flag & SELECT)) {
+			if(use_vert_sel && !((mvert+i)->flag & SELECT)) {
 				continue;
 			}
 
@@ -733,7 +733,7 @@
 		if(weight_max > 0.0f) {
 			for(i = 0; i < dvert_tot; i++) {
 				// Jason
-				if(use_vert_sel && !((mv+i)->flag & SELECT)) {
+				if(use_vert_sel && !((mvert+i)->flag & SELECT)) {
 					continue;
 				}
 
@@ -848,19 +848,13 @@
 /* get a single point in space by averaging a point cloud (vectors of size 3)
 coord is the place the average is stored, points is the point cloud, count is the number of points in the cloud
 */
-static void getSingleCoordinate(MVert **points, int count, float *coord) {
-	int i, k;
-	for(k = 0; k < 3; k++) {
-		coord[k] = 0;
-	}
+static void getSingleCoordinate(MVert *points, int count, float coord[3]) {
+	int i;
+	zero_v3(coord);
 	for(i = 0; i < count; i++) {
-		for(k = 0; k < 3; k++) {
-			coord[k] += points[i]->co[k];
-		}
+		add_v3_v3(coord, points[i].co);
 	}
-	for(k = 0; k < 3; k++) {
-		coord[k] /= count;
-	}
+	mul_v3_fl(coord, 1.0f/count);
 }
 /* Jason */
 /* find the closest point on a plane to another point and store it in dst */
@@ -894,12 +888,11 @@
 compute the amount of vertical distance relative to the plane and store it in dists,
 then get the horizontal and vertical change and store them in changes
 */
-static void getVerticalAndHorizontalChange(float *norm, float d, float *coord, float *start, float distToStart, float *end, float **changes, float *dists, int index) {
+static void getVerticalAndHorizontalChange(float *norm, float d, float *coord, float *start, float distToStart, float *end, float (*changes)[2], float *dists, int index) {
 	// A=Q-((Q-P).N)N
 	// D = (a*x0 + b*y0 +c*z0 +d)
-	float *projA, *projB;
-	projA = MEM_callocN(sizeof(float)*3, "projectedA");
-	projB = MEM_callocN(sizeof(float)*3, "projectedB");
+	float projA[3] = {0}, projB[3] = {0};
+
 	getNearestPointOnPlane(norm, coord, start, projA);
 	getNearestPointOnPlane(norm, coord, end, projB);
 	// (vertical and horizontal refer to the plane's y and xz respectively)
@@ -910,16 +903,19 @@
 	//printf("vc %f %f\n", distance(end, projB, 3)-distance(start, projA, 3), changes[index][0]);
 	// horizontal change
 	changes[index][1] = distance(projA, projB, 3);
-	
-	MEM_freeN(projA);
-	MEM_freeN(projB);
 }
 // Jason
 // I need the derived mesh to be forgotten so the positions are recalculated with weight changes (see dm_deform_recalc)
 static void dm_deform_clear(DerivedMesh *dm, Object *ob) {
-	dm->needsFree = 1;
-	dm->release(dm);
-	ob->derivedDeform=NULL;
+	if(ob->derivedDeform && (ob->derivedDeform)==dm) {
+		ob->derivedDeform->needsFree = 1;
+		ob->derivedDeform->release(ob->derivedDeform);
+		ob->derivedDeform = NULL;
+	}
+	else if(dm) {
+		dm->needsFree = 1;
+		dm->release(dm);
+	}
 }
 // Jason
 // recalculate the deformation
@@ -935,17 +931,17 @@
 norm and d are the plane's properties for the equation: ax + by + cz + d = 0
 coord is a point on the plane
 */
-static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, int index, float *norm, float *coord, float d, float distToBe, float strength, float cp) {
+static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, int index, float norm[3], float coord[3], float d, float distToBe, float strength, float cp) {
 	DerivedMesh *dm;
 	MDeformWeight *dw;
 	MVert m;
 	MDeformVert *dvert = me->dvert+index;
 	int totweight = dvert->totweight;
 	float oldw = 0;
-	float *oldPos = MEM_callocN(sizeof(float)*3, "oldPosition");
+	float oldPos[3] = {0};
 	float vc, hc, dist;
 	int i, k;
-	float **changes = MEM_mallocN(sizeof(float *)*totweight, "vertHorzChange");
+	float (*changes)[2] = MEM_mallocN(sizeof(float *)*totweight*2, "vertHorzChange");
 	float *dists = MEM_mallocN(sizeof(float)*totweight, "distance");
 	int *upDown = MEM_callocN(sizeof(int)*totweight, "upDownTracker");// track if up or down moved it closer for each bone
 	int *dwIndices = MEM_callocN(sizeof(int)*totweight, "dwIndexTracker");
@@ -955,9 +951,6 @@
 	char wasUp;
 	int lastIndex = -1;
 	float originalDistToBe = distToBe;
-	for(i = 0; i < totweight; i++) {
-		changes[i] = MEM_callocN(sizeof(float)*2, "vertHorzChange_"+i);
-	}
 	do {
 		wasChange = FALSE;
 		dm = dm_deform_recalc(scene, ob);
@@ -1097,13 +1090,9 @@
 		}
 	}while(wasChange && (distToStart-distToBe)/fabs(distToStart-distToBe) == (dists[bestIndex]-distToBe)/fabs(dists[bestIndex]-distToBe));
 	MEM_freeN(upDown);
-	for(i = 0; i < totweight; i++) {
-		MEM_freeN(changes[i]);
-	}
 	MEM_freeN(changes);
 	MEM_freeN(dists);

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list