[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38192] branches/soc-2011-salad: This is incorporating every change I made to Radish branch into Salad.

Jason Hays jason_hays22 at mymail.eku.edu
Thu Jul 7 17:42:51 CEST 2011


Revision: 38192
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38192
Author:   jason_hays22
Date:     2011-07-07 15:42:50 +0000 (Thu, 07 Jul 2011)
Log Message:
-----------
This is incorporating every change I made to Radish branch into Salad.
That means that vgroup locking, multipaint, and weight paint mode's basic vertex selection have been added.

Also, I created a patch file with all of the changes (its only fully compatible with salad)--if anyone wants it.

Modified Paths:
--------------
    branches/soc-2011-salad/release/scripts/startup/bl_ui/properties_data_mesh.py
    branches/soc-2011-salad/release/scripts/startup/bl_ui/space_view3d_toolbar.py
    branches/soc-2011-salad/source/blender/blenkernel/BKE_DerivedMesh.h
    branches/soc-2011-salad/source/blender/blenkernel/intern/DerivedMesh.c
    branches/soc-2011-salad/source/blender/blenkernel/intern/cdderivedmesh.c
    branches/soc-2011-salad/source/blender/editors/armature/editarmature.c
    branches/soc-2011-salad/source/blender/editors/include/ED_mesh.h
    branches/soc-2011-salad/source/blender/editors/include/ED_view3d.h
    branches/soc-2011-salad/source/blender/editors/interface/interface_templates.c
    branches/soc-2011-salad/source/blender/editors/mesh/editmesh.c
    branches/soc-2011-salad/source/blender/editors/object/object_intern.h
    branches/soc-2011-salad/source/blender/editors/object/object_ops.c
    branches/soc-2011-salad/source/blender/editors/object/object_vgroup.c
    branches/soc-2011-salad/source/blender/editors/sculpt_paint/paint_vertex.c
    branches/soc-2011-salad/source/blender/editors/space_view3d/drawobject.c
    branches/soc-2011-salad/source/blender/editors/space_view3d/view3d_select.c
    branches/soc-2011-salad/source/blender/makesdna/DNA_object_types.h
    branches/soc-2011-salad/source/blender/makesdna/DNA_scene_types.h
    branches/soc-2011-salad/source/blender/makesrna/intern/rna_internal.h
    branches/soc-2011-salad/source/blender/makesrna/intern/rna_object.c
    branches/soc-2011-salad/source/blender/makesrna/intern/rna_scene.c

Modified: branches/soc-2011-salad/release/scripts/startup/bl_ui/properties_data_mesh.py
===================================================================
--- branches/soc-2011-salad/release/scripts/startup/bl_ui/properties_data_mesh.py	2011-07-07 13:59:28 UTC (rev 38191)
+++ branches/soc-2011-salad/release/scripts/startup/bl_ui/properties_data_mesh.py	2011-07-07 15:42:50 UTC (rev 38192)
@@ -134,7 +134,8 @@
 
         ob = context.object
         group = ob.vertex_groups.active
-
+        
+        
         rows = 2
         if group:
             rows = 5
@@ -143,6 +144,9 @@
         row.template_list(ob, "vertex_groups", ob.vertex_groups, "active_index", rows=rows)
 
         col = row.column(align=True)
+        # Jason was here, this was replaced by hardcoded list view checkboxes. #
+        #col.prop(group, "flag")
+        
         col.operator("object.vertex_group_add", icon='ZOOMIN', text="")
         col.operator("object.vertex_group_remove", icon='ZOOMOUT', text="")
         col.menu("MESH_MT_vertex_group_specials", icon='DOWNARROW_HLT', text="")
@@ -153,6 +157,13 @@
         if group:
             row = layout.row()
             row.prop(group, "name")
+        #Jason was here
+        if ob.mode == 'WEIGHT_PAINT' and len(ob.vertex_groups) > 0:
+            row = layout.row()
+            sub = row.row(align=True)
+            sub.operator("object.vertex_group_lock_all", text="Lock All")
+            sub.operator("object.vertex_group_invert_locks", text="Invert Locks")
+            sub.operator("object.vertex_group_unlock_all", text="Unlock All")
 
         if ob.mode == 'EDIT' and len(ob.vertex_groups) > 0:
             row = layout.row()

Modified: branches/soc-2011-salad/release/scripts/startup/bl_ui/space_view3d_toolbar.py
===================================================================
--- branches/soc-2011-salad/release/scripts/startup/bl_ui/space_view3d_toolbar.py	2011-07-07 13:59:28 UTC (rev 38191)
+++ branches/soc-2011-salad/release/scripts/startup/bl_ui/space_view3d_toolbar.py	2011-07-07 15:42:50 UTC (rev 38192)
@@ -676,6 +676,9 @@
         elif context.weight_paint_object and brush:
             layout.prop(context.tool_settings, "vertex_group_weight", text="Weight", slider=True)
             layout.prop(context.tool_settings, "use_auto_normalize", text="Auto Normalize")
+            # Jason was here
+            layout.prop(context.tool_settings, "use_multipaint", text="Multi-Paint")
+            layout.prop(context.tool_settings, "use_wp_vert_sel", text="Select Vertices")
 
             col = layout.column()
 

Modified: branches/soc-2011-salad/source/blender/blenkernel/BKE_DerivedMesh.h
===================================================================
--- branches/soc-2011-salad/source/blender/blenkernel/BKE_DerivedMesh.h	2011-07-07 13:59:28 UTC (rev 38191)
+++ branches/soc-2011-salad/source/blender/blenkernel/BKE_DerivedMesh.h	2011-07-07 15:42:50 UTC (rev 38192)
@@ -220,6 +220,9 @@
 	/* 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-salad/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- branches/soc-2011-salad/source/blender/blenkernel/intern/DerivedMesh.c	2011-07-07 13:59:28 UTC (rev 38191)
+++ branches/soc-2011-salad/source/blender/blenkernel/intern/DerivedMesh.c	2011-07-07 15:42:50 UTC (rev 38192)
@@ -40,6 +40,9 @@
 #include "DNA_cloth_types.h"
 #include "DNA_key_types.h"
 #include "DNA_meshdata_types.h"
+// Jason
+#include "DNA_armature_types.h"
+
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h" // N_T
 
@@ -72,7 +75,8 @@
 #include "GPU_material.h"
 
 #include "ED_sculpt.h" /* for ED_paint_modifiers_changed */
-
+// Jason was here, this is for multi-paint
+#include "ED_armature.h"
 ///////////////////////////////////
 ///////////////////////////////////
 
@@ -1601,19 +1605,51 @@
 	}
 }
 
-static void calc_weightpaint_vert_color(Object *ob, ColorBand *coba, int vert, unsigned char *col)
+static void calc_weightpaint_vert_color(Object *ob, ColorBand *coba, int vert, unsigned char *col, char *dg_flags, int selected, int unselected, int multipaint, int auto_normalize)
 {
 	Mesh *me = ob->data;
-	float colf[4], input = 0.0f;
+	float colf[4], input = 0.0f, unsel_sum = 0.0f;// Jason
 	int i;
+	char make_black = FALSE;
+	char was_a_nonzero = FALSE;
+	if (me->dvert) {
+		for (i=0; i<me->dvert[vert].totweight; i++) {
+			// Jason was here
+			if(multipaint && selected > 1) {
+				if(dg_flags[me->dvert[vert].dw[i].def_nr]) {
+					if(me->dvert[vert].dw[i].weight) {
+						input+=me->dvert[vert].dw[i].weight;
+						was_a_nonzero = TRUE;
+					}
+				}
+				// TODO unselected non-bone groups should not be involved in this sum
+				else if(auto_normalize) {
+					unsel_sum+=me->dvert[vert].dw[i].weight;
+				}
+			} else if (me->dvert[vert].dw[i].def_nr==ob->actdef-1) {
+				input+=me->dvert[vert].dw[i].weight;
+			}
+		}
+		
+		// Jason was here
+		if(!make_black && multipaint && selected > 1) {
+			/*if(input == 1.0f && auto_normalize && !unsel_sum) {
+				make_black = TRUE;
+			} else */
+			if(!was_a_nonzero) {
+				make_black = TRUE;
+			} else if (!auto_normalize){
+				input /= selected;
+			}
 
-	if (me->dvert) {
-		for (i=0; i<me->dvert[vert].totweight; i++)
-			if (me->dvert[vert].dw[i].def_nr==ob->actdef-1)
-				input+=me->dvert[vert].dw[i].weight;		
+		}
 	}
 
-	CLAMP(input, 0.0f, 1.0f);
+	if(make_black) {
+		input = -1;
+	}else {
+		CLAMP(input, 0.0f, 1.0f);
+	}
 	
 	if(coba)
 		do_colorband(coba, input, colf);
@@ -1633,25 +1669,69 @@
 	stored_cb= coba;
 }
 
-static void add_weight_mcol_dm(Object *ob, DerivedMesh *dm)
+/* TODO move duplicates to header */
+/* Jason was here duplicate function in paint_vertex.c*/
+static char* get_selected_defgroups(Object *ob, int defcnt) {
+	bPoseChannel *chan;
+	bPose *pose;
+	bDeformGroup *defgroup;
+	//Bone *bone;
+	char *dg_flags = MEM_callocN(defcnt*sizeof(char), "dg_selected_flags");
+	int i;
+	Object *armob = ED_object_pose_armature(ob);
+	if(armob) {
+		pose = armob->pose;
+		for (chan=pose->chanbase.first; chan; chan=chan->next) {
+			for (i = 0, defgroup = ob->defbase.first; i < defcnt && defgroup; defgroup = defgroup->next, i++) {
+				if(!strcmp(defgroup->name, chan->bone->name)) {
+					dg_flags[i] = (chan->bone->flag & BONE_SELECTED);
+				}
+			}
+		}
+	}
+
+	return dg_flags;
+}
+/* TODO move duplicates to header */
+/* Jason was here duplicate function */
+static int count_true(char *list, int len)
 {
+	int i;
+	int cnt = 0;
+	for(i = 0; i < len; i++) {
+		if (list[i]) {
+			cnt++;
+		}
+	}
+	return cnt;
+}
+static void add_weight_mcol_dm(Object *ob, DerivedMesh *dm, int multipaint, int auto_normalize)
+{
 	Mesh *me = ob->data;
 	MFace *mf = me->mface;
 	ColorBand *coba= stored_cb;	/* warning, not a local var */
 	unsigned char *wtcol;
 	int i;
 	
+	// Jason was here
+	int defcnt = BLI_countlist(&ob->defbase);
+	char *dg_flags = get_selected_defgroups(ob, defcnt);
+	int selected = count_true(dg_flags, defcnt);
+	int unselected = defcnt - selected;
+
 	wtcol = MEM_callocN (sizeof (unsigned char) * me->totface*4*4, "weightmap");
 	
 	memset(wtcol, 0x55, sizeof (unsigned char) * me->totface*4*4);
 	for (i=0; i<me->totface; i++, mf++) {
-		calc_weightpaint_vert_color(ob, coba, mf->v1, &wtcol[(i*4 + 0)*4]); 
-		calc_weightpaint_vert_color(ob, coba, mf->v2, &wtcol[(i*4 + 1)*4]); 
-		calc_weightpaint_vert_color(ob, coba, mf->v3, &wtcol[(i*4 + 2)*4]); 
+		calc_weightpaint_vert_color(ob, coba, mf->v1, &wtcol[(i*4 + 0)*4], dg_flags, selected, unselected, multipaint, auto_normalize);
+		calc_weightpaint_vert_color(ob, coba, mf->v2, &wtcol[(i*4 + 1)*4], dg_flags, selected, unselected, multipaint, auto_normalize);
+		calc_weightpaint_vert_color(ob, coba, mf->v3, &wtcol[(i*4 + 2)*4], dg_flags, selected, unselected, multipaint, auto_normalize);
 		if (mf->v4)
-			calc_weightpaint_vert_color(ob, coba, mf->v4, &wtcol[(i*4 + 3)*4]); 
+			calc_weightpaint_vert_color(ob, coba, mf->v4, &wtcol[(i*4 + 3)*4], dg_flags, selected, unselected, multipaint, auto_normalize);
 	}
-	
+	// Jason
+	MEM_freeN(dg_flags);
+
 	CustomData_add_layer(&dm->faceData, CD_WEIGHT_MCOL, CD_ASSIGN, wtcol, dm->numFaceData);
 }
 
@@ -1858,7 +1938,7 @@
 				}
 
 				if((dataMask & CD_MASK_WEIGHT_MCOL) && (ob->mode & OB_MODE_WEIGHT_PAINT))
-					add_weight_mcol_dm(ob, dm);
+					add_weight_mcol_dm(ob, dm, scene->toolsettings->multipaint, scene->toolsettings->auto_normalize);// Jason
 
 				/* Constructive modifiers need to have an origindex
 				 * otherwise they wont have anywhere to copy the data from.
@@ -1968,7 +2048,7 @@
 		CDDM_calc_normals(finaldm);
 
 		if((dataMask & CD_MASK_WEIGHT_MCOL) && (ob->mode & OB_MODE_WEIGHT_PAINT))
-			add_weight_mcol_dm(ob, finaldm);
+			add_weight_mcol_dm(ob, finaldm, scene->toolsettings->multipaint, scene->toolsettings->auto_normalize);// Jason
 	} else if(dm) {
 		finaldm = dm;
 	} else {
@@ -1980,7 +2060,7 @@
 		}
 
 		if((dataMask & CD_MASK_WEIGHT_MCOL) && (ob->mode & OB_MODE_WEIGHT_PAINT))
-			add_weight_mcol_dm(ob, finaldm);
+			add_weight_mcol_dm(ob, finaldm, scene->toolsettings->multipaint, scene->toolsettings->auto_normalize);// Jason
 	}
 
 	/* add an orco layer if needed */

Modified: branches/soc-2011-salad/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- branches/soc-2011-salad/source/blender/blenkernel/intern/cdderivedmesh.c	2011-07-07 13:59:28 UTC (rev 38191)
+++ branches/soc-2011-salad/source/blender/blenkernel/intern/cdderivedmesh.c	2011-07-07 15:42:50 UTC (rev 38192)
@@ -284,6 +284,36 @@
 	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) ) {
+		glBegin(GL_POINTS);
+		for(i = 0; i < dm->numVertData; i++, mv++) {
+			if((mv->flag & 1)) {//TODO define selected
+				glColor3f(1.0f, 1.0f, 0.0f);
+			}else {
+				glColor3f(0.0f, 0.0f, 0.0f);
+			}
+			if(!(mv->flag & ME_HIDE)) {
+				glVertex3fv(mv->co);
+			}
+		}
+		glEnd();
+	}
+	else {	/* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list