[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19252] branches/blender2.5/blender/source /blender: Changed vertexpaint and weightpaint to use the standard Brush struct, so they too work with the brush panel.
Nicholas Bishop
nicholasbishop at gmail.com
Wed Mar 11 01:43:08 CET 2009
Revision: 19252
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19252
Author: nicholasbishop
Date: 2009-03-11 01:43:08 +0100 (Wed, 11 Mar 2009)
Log Message:
-----------
Changed vertexpaint and weightpaint to use the standard Brush struct, so they too work with the brush panel.
Note: these modes are only using color/alpha/size from Brush, so there's more integration work todo yet.
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/blenkernel/BKE_brush.h
branches/blender2.5/blender/source/blender/blenkernel/intern/brush.c
branches/blender2.5/blender/source/blender/editors/mesh/editdeform.c
branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_utils.c
branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_vertex.c
branches/blender2.5/blender/source/blender/editors/sculpt_paint/sculpt.c
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_buttons.c
branches/blender2.5/blender/source/blender/makesdna/DNA_scene_types.h
branches/blender2.5/blender/source/blender/makesrna/intern/rna_vpaint.c
Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_brush.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_brush.h 2009-03-11 00:24:34 UTC (rev 19251)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_brush.h 2009-03-11 00:43:08 UTC (rev 19252)
@@ -34,6 +34,7 @@
struct ID;
struct Brush;
struct ImBuf;
+struct Scene;
struct wmOperator;
/* datablock functions */
@@ -43,6 +44,7 @@
void free_brush(struct Brush *brush);
/* brush library operations used by different paint panels */
+struct Brush **current_brush_source(struct Scene *sce);
int brush_set_nr(struct Brush **current_brush, int nr);
int brush_delete(struct Brush **current_brush);
void brush_check_exists(struct Brush **brush);
Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/brush.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/brush.c 2009-03-11 00:24:34 UTC (rev 19251)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/brush.c 2009-03-11 00:43:08 UTC (rev 19252)
@@ -185,6 +185,19 @@
/* Library Operations */
+Brush **current_brush_source(Scene *sce)
+{
+ if(G.f & G_SCULPTMODE)
+ return &sce->toolsettings->sculpt->brush;
+ else if(G.f & G_VERTEXPAINT)
+ return &sce->toolsettings->vpaint->brush;
+ else if(G.f & G_WEIGHTPAINT)
+ return &sce->toolsettings->wpaint->brush;
+ else if(G.f & G_TEXTUREPAINT)
+ return &sce->toolsettings->imapaint.brush;
+ return NULL;
+}
+
int brush_set_nr(Brush **current_brush, int nr)
{
ID *idtest, *id;
Modified: branches/blender2.5/blender/source/blender/editors/mesh/editdeform.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/mesh/editdeform.c 2009-03-11 00:24:34 UTC (rev 19251)
+++ branches/blender2.5/blender/source/blender/editors/mesh/editdeform.c 2009-03-11 00:43:08 UTC (rev 19252)
@@ -1007,11 +1007,11 @@
switch (mode) {
case 1: /* add to new group */
add_defgroup(ob);
- assign_verts_defgroup(ob, wp->weight);
+ assign_verts_defgroup(ob, wp->brush->alpha);
BIF_undo_push("Assign to vertex group");
break;
case 2: /* add to current group */
- assign_verts_defgroup(ob, wp->weight);
+ assign_verts_defgroup(ob, wp->brush->alpha);
BIF_undo_push("Assign to vertex group");
break;
case 3: /* remove from current group */
Modified: branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_utils.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_utils.c 2009-03-11 00:24:34 UTC (rev 19251)
+++ branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_utils.c 2009-03-11 00:43:08 UTC (rev 19252)
@@ -11,6 +11,7 @@
#include "BLI_arithb.h"
+#include "BKE_brush.h"
#include "BKE_DerivedMesh.h"
#include "BKE_global.h"
#include "BKE_utildefines.h"
@@ -159,7 +160,7 @@
/* used for both 3d view and image window */
void paint_sample_color(Scene *scene, ARegion *ar, int x, int y) /* frontbuf */
{
- VPaint *vp= scene->toolsettings->vpaint;
+ Brush **br = current_brush_source(scene);
unsigned int col;
char *cp;
@@ -172,20 +173,10 @@
cp = (char *)&col;
- if(G.f & (G_VERTEXPAINT|G_WEIGHTPAINT)) {
- vp->r= cp[0]/255.0f;
- vp->g= cp[1]/255.0f;
- vp->b= cp[2]/255.0f;
+ if(br && *br) {
+ (*br)->rgb[0]= cp[0]/255.0f;
+ (*br)->rgb[1]= cp[1]/255.0f;
+ (*br)->rgb[2]= cp[2]/255.0f;
}
- else {
- Brush *brush= scene->toolsettings->imapaint.brush;
-
- if(brush) {
- brush->rgb[0]= cp[0]/255.0f;
- brush->rgb[1]= cp[1]/255.0f;
- brush->rgb[2]= cp[2]/255.0f;
-
- }
- }
}
Modified: branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_vertex.c 2009-03-11 00:24:34 UTC (rev 19251)
+++ branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_vertex.c 2009-03-11 00:43:08 UTC (rev 19252)
@@ -64,6 +64,7 @@
#include "RNA_access.h"
#include "BKE_armature.h"
+#include "BKE_brush.h"
#include "BKE_DerivedMesh.h"
#include "BKE_cloth.h"
#include "BKE_context.h"
@@ -74,7 +75,6 @@
#include "BKE_global.h"
#include "BKE_mesh.h"
#include "BKE_modifier.h"
-#include "BKE_multires.h"
#include "BKE_object.h"
#include "BKE_utildefines.h"
@@ -143,7 +143,7 @@
glColor4ub(255, 255, 255, 128);
glEnable( GL_LINE_SMOOTH );
glEnable(GL_BLEND);
- glutil_draw_lined_arc(0.0, M_PI*2.0, ts->vpaint->size, 40);
+ glutil_draw_lined_arc(0.0, M_PI*2.0, ts->vpaint->brush->size, 40);
glDisable(GL_BLEND);
glDisable( GL_LINE_SMOOTH );
@@ -159,7 +159,7 @@
glColor4ub(200, 200, 255, 128);
glEnable( GL_LINE_SMOOTH );
glEnable(GL_BLEND);
- glutil_draw_lined_arc(0.0, M_PI*2.0, ts->wpaint->size, 40);
+ glutil_draw_lined_arc(0.0, M_PI*2.0, ts->wpaint->brush->size, 40);
glDisable(GL_BLEND);
glDisable( GL_LINE_SMOOTH );
@@ -186,20 +186,13 @@
{
VPaint *vp= MEM_callocN(sizeof(VPaint), "VPaint");
- vp->r= 1.0f;
- vp->g= 1.0f;
- vp->b= 1.0f;
- vp->a= 0.2f;
- vp->size= 25.0f;
vp->gamma= vp->mul= 1.0f;
vp->flag= VP_AREA+VP_SOFT+VP_SPRAY;
- if(wpaint) {
- vp->weight= 1.0f;
- vp->a= 1.0f;
+ if(wpaint)
vp->flag= VP_AREA+VP_SOFT;
- }
+
return vp;
}
@@ -239,7 +232,7 @@
static unsigned int vpaint_get_current_col(VPaint *vp)
{
- return rgba_to_mcol(vp->r, vp->g, vp->b, 1.0f);
+ return rgba_to_mcol(vp->brush->rgb[0], vp->brush->rgb[1], vp->brush->rgb[2], 1.0f);
}
void do_shared_vertexcol(Mesh *me)
@@ -334,8 +327,6 @@
else
memset(me->mcol, 255, 4*sizeof(MCol)*me->totface);
-// XXX if (me->mr) multires_load_cols(me);
-
DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
}
@@ -434,7 +425,7 @@
void clear_wpaint_selectedfaces(Scene *scene)
{
VPaint *wp= scene->toolsettings->wpaint;
- float paintweight= wp->weight;
+ float paintweight= wp->brush->alpha;
Mesh *me;
MFace *mface;
Object *ob;
@@ -742,7 +733,7 @@
unsigned int testcol=0, a;
char *cp, *ct, *co;
- alpha= (int)(255.0*vp->a);
+ alpha= (int)(255.0*vp->brush->alpha);
if(vp->mode==VP_MIX || vp->mode==VP_BLUR) testcol= mcol_blend( *colorig, paintcol, alpha);
else if(vp->mode==VP_ADD) testcol= mcol_add( *colorig, paintcol, alpha);
@@ -818,14 +809,14 @@
dy= mval[1]-vertco[1];
fac= sqrt(dx*dx + dy*dy);
- if(fac > vp->size) return 0;
+ if(fac > vp->brush->size) return 0;
if(vp->flag & VP_HARD)
alpha= 255;
else
- alpha= 255.0*vp->a*(1.0-fac/vp->size);
+ alpha= 255.0*vp->brush->alpha*(1.0-fac/vp->brush->size);
}
else {
- alpha= 255.0*vp->a;
+ alpha= 255.0*vp->brush->alpha;
}
if(vp->flag & VP_NORMALS) {
@@ -872,7 +863,7 @@
if((wp->flag & VP_SPRAY)==0) {
float testw=0.0f;
- alpha= wp->a;
+ alpha= wp->brush->alpha;
if(wp->mode==VP_MIX || wp->mode==VP_BLUR)
testw = paintval*alpha + uw->weight*(1.0-alpha);
else if(wp->mode==VP_ADD)
@@ -1028,20 +1019,20 @@
fac= MIN4(w1, w2, w3, w4);
if(w1==fac) {
dw= get_defweight(me->dvert+mface->v1, ob->actdef-1);
- if(dw) wp->weight= dw->weight; else wp->weight= 0.0f;
+ if(dw) wp->brush->alpha= dw->weight; else wp->brush->alpha= 0.0f;
}
else if(w2==fac) {
dw= get_defweight(me->dvert+mface->v2, ob->actdef-1);
- if(dw) wp->weight= dw->weight; else wp->weight= 0.0f;
+ if(dw) wp->brush->alpha= dw->weight; else wp->brush->alpha= 0.0f;
}
else if(w3==fac) {
dw= get_defweight(me->dvert+mface->v3, ob->actdef-1);
- if(dw) wp->weight= dw->weight; else wp->weight= 0.0f;
+ if(dw) wp->brush->alpha= dw->weight; else wp->brush->alpha= 0.0f;
}
else if(w4==fac) {
if(mface->v4) {
dw= get_defweight(me->dvert+mface->v4, ob->actdef-1);
- if(dw) wp->weight= dw->weight; else wp->weight= 0.0f;
+ if(dw) wp->brush->alpha= dw->weight; else wp->brush->alpha= 0.0f;
}
}
}
@@ -1120,6 +1111,8 @@
if(wp==NULL)
wp= scene->toolsettings->wpaint= new_vpaint(1);
+
+ brush_check_exists(&wp->brush);
toggle_paint_cursor(C, 1);
@@ -1184,9 +1177,9 @@
float original_value;
if(mode == WM_RADIALCONTROL_SIZE)
- original_value = vp->size;
+ original_value = vp->brush->size;
else if(mode == WM_RADIALCONTROL_STRENGTH)
- original_value = vp->a;
+ original_value = vp->brush->alpha;
RNA_float_set(op->ptr, "initial_value", original_value);
}
@@ -1197,9 +1190,9 @@
float new_value = RNA_float_get(op->ptr, "new_value");
if(mode == WM_RADIALCONTROL_SIZE)
- vp->size = new_value;
+ vp->brush->size = new_value;
else if(mode == WM_RADIALCONTROL_STRENGTH)
- vp->a = new_value;
+ vp->brush->alpha = new_value;
return OPERATOR_FINISHED;
}
@@ -1347,7 +1340,7 @@
Object *ob= vc->obact;
Mesh *me= ob->data;
float mat[4][4];
- float paintweight= wp->weight;
+ float paintweight= wp->brush->alpha;
int *indexar= wpd->indexar;
int totindex, index, alpha, totw;
short mval[2];
@@ -1366,7 +1359,7 @@
/* which faces are involved */
if(wp->flag & VP_AREA) {
- totindex= sample_backbuf_area(vc, indexar, me->totface, mval[0], mval[1], wp->size);
+ totindex= sample_backbuf_area(vc, indexar, me->totface, mval[0], mval[1], wp->brush->size);
}
else {
indexar[0]= view3d_sample_backbuf(vc, mval[0], mval[1]);
@@ -1404,7 +1397,7 @@
if(wp->mode==VP_BLUR)
paintweight= 0.0f;
else
- paintweight= wp->weight;
+ paintweight= wp->brush->alpha;
for(index=0; index<totindex; index++) {
if(indexar[index] && indexar[index]<=me->totface) {
@@ -1655,6 +1648,7 @@
vp= scene->toolsettings->vpaint= new_vpaint(0);
toggle_paint_cursor(C, 0);
+ brush_check_exists(&scene->toolsettings->vpaint->brush);
}
if (me)
@@ -1765,7 +1759,7 @@
/* which faces are involved */
if(vp->flag & VP_AREA) {
- totindex= sample_backbuf_area(vc, indexar, me->totface, mval[0], mval[1], vp->size);
+ totindex= sample_backbuf_area(vc, indexar, me->totface, mval[0], mval[1], vp->brush->size);
}
else {
indexar[0]= view3d_sample_backbuf(vc, mval[0], mval[1]);
Modified: branches/blender2.5/blender/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list