Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2005-08-20 01:37:29 +0400
committerTon Roosendaal <ton@blender.org>2005-08-20 01:37:29 +0400
commit6d60b0acfe9dd30239cb3223bec525d456efb3b2 (patch)
tree2858f99367a18dd7eb093cfc953a88ad2b962116
parent91e39a0ec3b8a468b1dbe11550416c2a09adce94 (diff)
More armature stuff;
- The "Skinnable" option for Bones now is taken into account for the Envelope drawmode. If not Skinnable, it also doesn't draw the soft deform area. Maybe bone should be hidden... dunno yet. - Use CTRL+LMB in weightpaint mode to sample the weight in a mesh. Note; it returns the weight of the closest visible vertex, not of a Blended result. - NKey Panel for Mesh edit now shows a menu with the VertexGroup name(s) of a selected Vertex, plus the Weight. Fix: - while scaling Bone points in editmode (Envelope drawtype), the Bone root scale was not copied from (or to) the parent tip. This was not visible (is not drawn) but deform did use it... causing weird errors. For those who saw this error today: just go into editmode, select all Bones, press Skey, enter. That fixes it :)
-rw-r--r--source/blender/blenkernel/intern/armature.c3
-rw-r--r--source/blender/include/BDR_vpaint.h6
-rw-r--r--source/blender/src/drawarmature.c10
-rw-r--r--source/blender/src/drawobject.c37
-rw-r--r--source/blender/src/drawview.c42
-rwxr-xr-xsource/blender/src/transform_generics.c2
-rw-r--r--source/blender/src/vpaint.c117
7 files changed, 179 insertions, 38 deletions
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 317659ade68..ec1ad7548b1 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -691,7 +691,8 @@ void armature_deform_verts(Object *armOb, Object *target, float (*vertexCos)[3],
}
else {
for(pchan= armOb->pose->chanbase.first; pchan; pchan= pchan->next) {
- contrib+= dist_bone_deform(pchan, vec, co);
+ if(pchan->bone->boneclass==BONE_SKINNABLE)
+ contrib+= dist_bone_deform(pchan, vec, co);
}
}
diff --git a/source/blender/include/BDR_vpaint.h b/source/blender/include/BDR_vpaint.h
index 36189b3e367..b54af0fbe6d 100644
--- a/source/blender/include/BDR_vpaint.h
+++ b/source/blender/include/BDR_vpaint.h
@@ -48,12 +48,14 @@ void sample_vpaint(void);
void init_vertexpaint(void);
void free_vertexpaint(void);
void vertex_paint(void);
-void set_vpaint(void);
-void set_wpaint(void);
+void set_vpaint(void);
+void set_wpaint(void);
void weight_paint(void);
void wpaint_undo (void);
void copy_wpaint_undo (struct MDeformVert *dverts, int dcount);
+void weight_to_rgb(float input, float *fr, float *fg, float *fb);
+
#endif /* BDR_VPAINT_H */
diff --git a/source/blender/src/drawarmature.c b/source/blender/src/drawarmature.c
index 55cd70c6959..b7521b23138 100644
--- a/source/blender/src/drawarmature.c
+++ b/source/blender/src/drawarmature.c
@@ -1099,8 +1099,9 @@ static void draw_pose_channels(Base *base, int dt)
for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
bone= pchan->bone;
if(bone && !(bone->flag & BONE_HIDDEN_P)) {
- if(bone->flag & (BONE_SELECTED))
- draw_sphere_bone_dist(smat, imat, bone->flag, pchan, NULL);
+ if(bone->boneclass==BONE_SKINNABLE)
+ if(bone->flag & (BONE_SELECTED))
+ draw_sphere_bone_dist(smat, imat, bone->flag, pchan, NULL);
}
}
@@ -1301,8 +1302,9 @@ static void draw_ebones(Object *ob, int dt)
for (eBone=G.edbo.first, index=0; eBone; eBone=eBone->next, index++){
if(!(eBone->flag & BONE_HIDDEN_A))
- if(eBone->flag & (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL))
- draw_sphere_bone_dist(smat, imat, eBone->flag, NULL, eBone);
+ if(eBone->boneclass==BONE_SKINNABLE)
+ if(eBone->flag & (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL))
+ draw_sphere_bone_dist(smat, imat, eBone->flag, NULL, eBone);
}
if(G.vd->zbuf) glEnable(GL_DEPTH_TEST);
diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c
index 2609202b5a7..2f0547b137e 100644
--- a/source/blender/src/drawobject.c
+++ b/source/blender/src/drawobject.c
@@ -101,6 +101,7 @@
#include "BDR_drawmesh.h"
#include "BDR_drawobject.h"
#include "BDR_editobject.h"
+#include "BDR_vpaint.h"
#include "BSE_view.h"
#include "BSE_drawview.h"
@@ -1066,7 +1067,7 @@ void nurbs_foreachScreenVert(void (*func)(void *userData, Nurb *nu, BPoint *bp,
static void calc_weightpaint_vert_color(Object *ob, int vert, unsigned char *col)
{
Mesh *me = ob->data;
- float fr, fg, fb, input = 0.0;
+ float fr, fg, fb, input = 0.0f;
int i;
if (me->dvert) {
@@ -1075,33 +1076,13 @@ static void calc_weightpaint_vert_color(Object *ob, int vert, unsigned char *col
input+=me->dvert[vert].dw[i].weight;
}
- CLAMP(input, 0.0, 1.0);
-
- fr = fg = fb = 85;
- if (input<=0.25f){
- fr=0.0f;
- fg=255.0f * (input*4.0f);
- fb=255.0f;
- }
- else if (input<=0.50f){
- fr=0.0f;
- fg=255.0f;
- fb=255.0f * (1.0f-((input-0.25f)*4.0f));
- }
- else if (input<=0.75){
- fr=255.0f * ((input-0.50f)*4.0f);
- fg=255.0f;
- fb=0.0f;
- }
- else if (input<=1.0){
- fr=255.0f;
- fg=255.0f * (1.0f-((input-0.75f)*4.0f));
- fb=0.0f;
- }
-
- col[3] = (unsigned char)(fr * ((input/2.0f)+0.5f));
- col[2] = (unsigned char)(fg * ((input/2.0f)+0.5f));
- col[1] = (unsigned char)(fb * ((input/2.0f)+0.5f));
+ CLAMP(input, 0.0f, 1.0f);
+
+ weight_to_rgb(input, &fr, &fg, &fb);
+
+ col[3] = (unsigned char)(fr * 255.0f);
+ col[2] = (unsigned char)(fg * 255.0f);
+ col[1] = (unsigned char)(fb * 255.0f);
col[0] = 255;
}
static unsigned char *calc_weightpaint_colors(Object *ob)
diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c
index 0fdb22da3ff..25bd2442880 100644
--- a/source/blender/src/drawview.c
+++ b/source/blender/src/drawview.c
@@ -62,6 +62,7 @@
#include "DNA_image_types.h"
#include "DNA_lattice_types.h"
#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
#include "DNA_meta_types.h"
#include "DNA_object_types.h"
#include "DNA_screen_types.h"
@@ -1098,21 +1099,26 @@ static float ve_median[4];
/* is used for both read and write... */
static void v3d_editvertex_buts(uiBlock *block, Object *ob, float lim)
{
+ static int curdef=0;
+ static float *defweightp= NULL;
EditMesh *em = G.editMesh;
- EditVert *eve;
+ EditVert *eve, *evedef=NULL;
EditEdge *eed;
float median[4];
int tot, totw, totedge;
+ char defstr[320];
median[0]= median[1]= median[2]= median[3]= 0.0;
tot= totw= totedge= 0;
-
+ defstr[0]= 0;
+
if(ob->type==OB_MESH) {
Mesh *me= ob->data;
eve= em->verts.first;
while(eve) {
if(eve->f & 1) {
+ evedef= eve;
tot++;
VecAddf(median, median, eve->co);
}
@@ -1128,6 +1134,28 @@ static void v3d_editvertex_buts(uiBlock *block, Object *ob, float lim)
eed= eed->next;
}
}
+ /* check for defgroups */
+ if(tot==1 && evedef->totweight) {
+ bDeformGroup *dg;
+ int i, max=1, init=1;
+ char str[32];
+
+ for (i=0; i<evedef->totweight; i++){
+ dg = BLI_findlink (&ob->defbase, evedef->dw[i].def_nr);
+ max+= sprintf(str, "%s %%x%d|", dg->name, evedef->dw[i].def_nr);
+ if(max<320) strcat(defstr, str);
+
+ if(curdef==evedef->dw[i].def_nr) {
+ init= 0;
+ defweightp= &evedef->dw[i].weight;
+ }
+ }
+
+ if(init) { // needs new initialized
+ curdef= evedef->dw[0].def_nr;
+ defweightp= &evedef->dw[0].weight;
+ }
+ }
}
else if(ob->type==OB_CURVE || ob->type==OB_SURF) {
extern ListBase editNurb; /* editcurve.c */
@@ -1206,7 +1234,7 @@ static void v3d_editvertex_buts(uiBlock *block, Object *ob, float lim)
uiBlockBeginAlign(block);
uiDefButBitS(block, TOG, V3D_GLOBAL_STATS, REDRAWVIEW3D, "Global", 160, 150, 70, 19, &G.vd->flag, 0, 0, 0, 0, "Displays global values");
- uiDefButBitS(block, TOGN, V3D_GLOBAL_STATS, REDRAWVIEW3D, "Local", 230, 150, 70, 19, &G.vd->flag, 0, 0, 0, 0, "Displays local values");
+ uiDefButBitS(block, TOGN, V3D_GLOBAL_STATS, REDRAWVIEW3D, "Local", 230, 150, 70, 19, &G.vd->flag, 0, 0, 0, 0, "Displays local values");
QUATCOPY(ve_median, median);
@@ -1217,6 +1245,14 @@ static void v3d_editvertex_buts(uiBlock *block, Object *ob, float lim)
uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Vertex Z:", 10, 70, 290, 19, &(ve_median[2]), -lim, lim, 10, 3, "");
if(totw==1)
uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Vertex W:", 10, 50, 290, 19, &(ve_median[3]), 0.01, 100.0, 10, 3, "");
+
+ if(defstr[0]) {
+ uiDefBut(block, LABEL, 1, "Vertex Deform Groups", 10, 40, 290, 20, NULL, 0.0, 0.0, 0, 0, "");
+
+ uiBlockBeginAlign(block);
+ uiDefButF(block, NUM, B_NOP, "Weight:", 10, 20, 150, 19, defweightp, 0.0f, 1.0f, 10, 3, "Weight value");
+ uiDefButI(block, MENU, REDRAWVIEW3D, defstr, 160, 20, 140, 19, &curdef, 0.0, 0.0, 0, 0, "Current Vertex Group");
+ }
}
else {
uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Median X:", 10, 110, 290, 19, &(ve_median[0]), -lim, lim, 10, 3, "");
diff --git a/source/blender/src/transform_generics.c b/source/blender/src/transform_generics.c
index 9ab175d2681..1e3b0e86f12 100755
--- a/source/blender/src/transform_generics.c
+++ b/source/blender/src/transform_generics.c
@@ -174,10 +174,12 @@ void recalcData(TransInfo *t)
/* If this bone has a parent tip that has been moved */
if (ebo->parent->flag & BONE_TIPSEL){
VECCOPY (ebo->head, ebo->parent->tail);
+ if(t->mode==TFM_BONE_ENVELOPE) ebo->rad_head= ebo->parent->rad_tail;
}
/* If this bone has a parent tip that has NOT been moved */
else{
VECCOPY (ebo->parent->tail, ebo->head);
+ if(t->mode==TFM_BONE_ENVELOPE) ebo->parent->rad_tail= ebo->rad_head;
}
}
diff --git a/source/blender/src/vpaint.c b/source/blender/src/vpaint.c
index f0bf9a9003d..65a2387fd83 100644
--- a/source/blender/src/vpaint.c
+++ b/source/blender/src/vpaint.c
@@ -442,6 +442,35 @@ void sample_vpaint() /* frontbuf */
addqueue(curarea->win, REDRAW, 1); // needed for when panel is open...
}
+/* only used in drawobject.c now... */
+void weight_to_rgb(float input, float *fr, float *fg, float *fb)
+{
+ float blend;
+
+ blend= ((input/2.0f)+0.5f);
+
+ if (input<=0.25f){ // blue->cyan
+ *fr= 0.0f;
+ *fg= blend*input*4.0f;
+ *fb= blend;
+ }
+ else if (input<=0.50f){ // cyan->green
+ *fr= 0.0f;
+ *fg= blend;
+ *fb= blend*(1.0f-((input-0.25f)*4.0f));
+ }
+ else if (input<=0.75){ // green->yellow
+ *fr= blend * ((input-0.50f)*4.0f);
+ *fg= blend;
+ *fb= 0.0f;
+ }
+ else if (input<=1.0){ // yellow->red
+ *fr= blend;
+ *fg= blend * (1.0f-((input-0.75f)*4.0f));
+ *fb= 0.0f;
+ }
+}
+
void init_vertexpaint()
{
@@ -797,6 +826,89 @@ static void wpaint_blend(MDeformWeight *dw, MDeformWeight *uw, float alpha, floa
}
+static MDeformWeight *get_defweight(MDeformVert *dv, int defgroup)
+{
+ int i;
+ for (i=0; i<dv->totweight; i++){
+ if (dv->dw[i].def_nr == defgroup)
+ return dv->dw+i;
+ }
+ return NULL;
+}
+
+/* used for 3d view */
+/* cant sample frontbuf, weight colors are interpolated too unpredictable */
+/* so we return the closest value to vertex, wich is actually correct anyway */
+void sample_wpaint()
+{
+ extern float editbutvweight;
+ Object *ob= OBACT;
+ Mesh *me= get_mesh(ob);
+ int index;
+ short mval[2], sco[2];
+
+ getmouseco_areawin(mval);
+ index= sample_backbuf(mval[0], mval[1]);
+
+ if(index && index<=me->totface) {
+ MFace *mface;
+ DerivedMesh *dm;
+ MDeformWeight *dw;
+ float w1, w2, w3, w4, co[3], fac;
+ int needsFree;
+
+ dm = mesh_get_derived_deform(ob, &needsFree);
+
+ mface= ((MFace *)me->mface) + index-1;
+
+ /* calc 3 or 4 corner weights */
+ dm->getVertCo(dm, mface->v1, co);
+ project_short_noclip(co, sco);
+ w1= ((mval[0]-sco[0])*(mval[0]-sco[0]) + (mval[1]-sco[1])*(mval[1]-sco[1]));
+
+ dm->getVertCo(dm, mface->v2, co);
+ project_short_noclip(co, sco);
+ w2= ((mval[0]-sco[0])*(mval[0]-sco[0]) + (mval[1]-sco[1])*(mval[1]-sco[1]));
+
+ dm->getVertCo(dm, mface->v3, co);
+ project_short_noclip(co, sco);
+ w3= ((mval[0]-sco[0])*(mval[0]-sco[0]) + (mval[1]-sco[1])*(mval[1]-sco[1]));
+
+ if(mface->v4) {
+ dm->getVertCo(dm, mface->v4, co);
+ project_short_noclip(co, sco);
+ w4= ((mval[0]-sco[0])*(mval[0]-sco[0]) + (mval[1]-sco[1])*(mval[1]-sco[1]));
+ }
+ else w4= 1.0e10;
+
+ fac= MIN4(w1, w2, w3, w4);
+ if(w1==fac) {
+ dw= get_defweight(me->dvert+mface->v1, ob->actdef-1);
+ if(dw) editbutvweight= dw->weight; else editbutvweight= 0.0f;
+ }
+ else if(w2==fac) {
+ dw= get_defweight(me->dvert+mface->v2, ob->actdef-1);
+ if(dw) editbutvweight= dw->weight; else editbutvweight= 0.0f;
+ }
+ else if(w3==fac) {
+ dw= get_defweight(me->dvert+mface->v3, ob->actdef-1);
+ if(dw) editbutvweight= dw->weight; else editbutvweight= 0.0f;
+ }
+ else if(w4==fac) {
+ if(mface->v4) {
+ dw= get_defweight(me->dvert+mface->v4, ob->actdef-1);
+ if(dw) editbutvweight= dw->weight; else editbutvweight= 0.0f;
+ }
+ }
+
+ if (needsFree)
+ dm->release(dm);
+
+ }
+ allqueue(REDRAWBUTSEDIT, 0);
+
+}
+
void weight_paint(void)
{
@@ -813,6 +925,11 @@ void weight_paint(void)
if((G.f & G_WEIGHTPAINT)==0) return;
if(G.obedit) return;
+ if(G.qual & LR_CTRLKEY) {
+ sample_wpaint();
+ return;
+ }
+
if(indexar==NULL) init_vertexpaint();
ob= OBACT;