New feature:

Weightpaint drawing now allows to define your own range of colors;
using a ColorBand, available in the User settings.

Log:
http://www.blender.org/development/current-projects/changes-since-244/animation-features/
This commit is contained in:
2007-10-31 13:56:07 +00:00
parent 2ae5da3fc2
commit 10680b34f2
12 changed files with 98 additions and 26 deletions

View File

@@ -57,6 +57,7 @@ struct Mesh;
struct EditMesh;
struct ModifierData;
struct MCol;
struct ColorBand;
/* number of sub-elements each mesh element has (for interpolation) */
#define SUB_ELEMS_VERT 0
@@ -395,6 +396,9 @@ void DM_interp_face_data(struct DerivedMesh *source, struct DerivedMesh *dest,
void DM_swap_face_data(struct DerivedMesh *dm, int index, int *corner_indices);
/* Temporary? A function to give a colorband to derivedmesh for vertexcolor ranges */
void vDM_ColorBand_store(struct ColorBand *coba);
/* Simple function to get me->totvert amount of vertices/normals,
correctly deformed and subsurfered. Needed especially when vertexgroups are involved.
In use now by vertex/weigt paint and particles */

View File

@@ -52,8 +52,11 @@ int test_dlerr(const char *name, const char *symbol);
void open_plugin_tex(struct PluginTex *pit);
struct PluginTex *add_plugin_tex(char *str);
void free_plugin_tex(struct PluginTex *pit);
void init_colorband(struct ColorBand *coba, int rangetype);
struct ColorBand *add_colorband(int rangetype);
int do_colorband(struct ColorBand *coba, float in, float out[4]);
void default_tex(struct Tex *tex);
struct Tex *add_texture(char *name);
void default_mtex(struct MTex *mtex);

View File

@@ -51,6 +51,7 @@
#include "DNA_object_force.h"
#include "DNA_object_fluidsim.h" // N_T
#include "DNA_scene_types.h" // N_T
#include "DNA_texture_types.h"
#include "DNA_view3d_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
@@ -61,20 +62,21 @@
#include "BLI_editVert.h"
#include "BLI_linklist.h"
#include "BKE_utildefines.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_customdata.h"
#include "BKE_DerivedMesh.h"
#include "BKE_deform.h"
#include "BKE_displist.h"
#include "BKE_effect.h"
#include "BKE_global.h"
#include "BKE_key.h"
#include "BKE_material.h"
#include "BKE_modifier.h"
#include "BKE_mesh.h"
#include "BKE_object.h"
#include "BKE_subsurf.h"
#include "BKE_deform.h"
#include "BKE_modifier.h"
#include "BKE_key.h"
#include "BKE_texture.h"
#include "BKE_utildefines.h"
#ifdef WITH_VERSE
#include "BKE_verse.h"
@@ -2268,10 +2270,10 @@ void weight_to_rgb(float input, float *fr, float *fg, float *fb)
*fb= 0.0f;
}
}
static void calc_weightpaint_vert_color(Object *ob, int vert, unsigned char *col)
static void calc_weightpaint_vert_color(Object *ob, ColorBand *coba, int vert, unsigned char *col)
{
Mesh *me = ob->data;
float fr, fg, fb, input = 0.0f;
float colf[4], input = 0.0f;
int i;
if (me->dvert) {
@@ -2282,29 +2284,41 @@ static void calc_weightpaint_vert_color(Object *ob, int vert, unsigned char *col
CLAMP(input, 0.0f, 1.0f);
weight_to_rgb(input, &fr, &fg, &fb);
if(coba)
do_colorband(coba, input, colf);
else
weight_to_rgb(input, colf, colf+1, colf+2);
col[3] = (unsigned char)(fr * 255.0f);
col[2] = (unsigned char)(fg * 255.0f);
col[1] = (unsigned char)(fb * 255.0f);
col[3] = (unsigned char)(colf[0] * 255.0f);
col[2] = (unsigned char)(colf[1] * 255.0f);
col[1] = (unsigned char)(colf[2] * 255.0f);
col[0] = 255;
}
static ColorBand *stored_cb= NULL;
void vDM_ColorBand_store(ColorBand *coba)
{
stored_cb= coba;
}
static unsigned char *calc_weightpaint_colors(Object *ob)
{
Mesh *me = ob->data;
MFace *mf = me->mface;
ColorBand *coba= stored_cb; /* warning, not a local var */
unsigned char *wtcol;
int i;
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, mf->v1, &wtcol[(i*4 + 0)*4]);
calc_weightpaint_vert_color(ob, mf->v2, &wtcol[(i*4 + 1)*4]);
calc_weightpaint_vert_color(ob, mf->v3, &wtcol[(i*4 + 2)*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]);
if (mf->v4)
calc_weightpaint_vert_color(ob, mf->v4, &wtcol[(i*4 + 3)*4]);
calc_weightpaint_vert_color(ob, coba, mf->v4, &wtcol[(i*4 + 3)*4]);
}
return wtcol;

View File

@@ -238,13 +238,10 @@ void init_mapping(TexMapping *texmap)
/* ****************** COLORBAND ******************* */
ColorBand *add_colorband(int rangetype)
void init_colorband(ColorBand *coba, int rangetype)
{
ColorBand *coba;
int a;
coba= MEM_callocN( sizeof(ColorBand), "colorband");
coba->data[0].pos= 0.0;
coba->data[1].pos= 1.0;
@@ -281,6 +278,15 @@ ColorBand *add_colorband(int rangetype)
coba->tot= 2;
}
ColorBand *add_colorband(int rangetype)
{
ColorBand *coba;
coba= MEM_callocN( sizeof(ColorBand), "colorband");
init_colorband(coba, rangetype);
return coba;
}

View File

@@ -35,6 +35,7 @@
struct Object;
struct MDeformVert;
struct ColorBand;
typedef struct TransOb {
float *loc;

View File

@@ -287,6 +287,7 @@
#define B_UITHEMEEXPORT 324
#define B_MEMCACHELIMIT 325
#define B_WPAINT_RANGE 326
/* Definitions for the fileselect buttons in user prefs */
#define B_FONTDIRFILESEL 330

View File

@@ -107,6 +107,7 @@ typedef struct CBData {
} CBData;
/* 32 = MAXCOLORBAND */
/* note that this has to remain a single struct, for UserDef */
typedef struct ColorBand {
short flag, tot, cur, ipotype;
CBData data[32];

View File

@@ -36,8 +36,10 @@
#define DNA_USERDEF_TYPES_H
#include "DNA_listBase.h"
#include "DNA_texture_types.h"
/* themes; defines in BIF_resource.h */
struct ColorBand;
// global, button colors
@@ -184,6 +186,7 @@ typedef struct UserDef {
char verseuser[160];
float glalphaclip, pad;
struct ColorBand coba_weight; /* from texture.h */
} UserDef;
extern UserDef U; /* from usiblender.c !!!! */
@@ -208,6 +211,7 @@ extern UserDef U; /* from usiblender.c !!!! */
#define USER_LMOUSESELECT (1 << 14)
#define USER_FILECOMPRESS (1 << 15)
#define USER_SAVE_PREVIEWS (1 << 16)
#define USER_CUSTOM_RANGE (1 << 17)
/* viewzom */
#define USER_ZOOM_CONT 0

View File

@@ -5290,7 +5290,6 @@ static void editing_panel_mesh_paint(void)
static void editing_panel_mesh_texface(void)
{
extern VPaint Gvp; /* from vpaint */
uiBlock *block;
MTFace *tf;

View File

@@ -63,6 +63,8 @@
#ifdef __APPLE__
#include <OpenGL/OpenGL.h>
#define __CARBONSOUND__
/* XXX BIG WARNING: carbon.h should not be included in blender/src code, it conflicts with struct ID */
#define ID ID_
#include <Carbon/Carbon.h>
/*declarations*/

View File

@@ -78,6 +78,7 @@
#include "BKE_colortools.h"
#include "BKE_curve.h"
#include "BKE_depsgraph.h"
#include "BKE_Derivedmesh.h"
#include "BKE_displist.h"
#include "BKE_global.h"
#include "BKE_group.h"
@@ -86,6 +87,7 @@
#include "BKE_mesh.h"
#include "BKE_node.h"
#include "BKE_scene.h"
#include "BKE_texture.h"
#include "BKE_utildefines.h"
#include "BKE_image.h" /* for IMA_TYPE_COMPOSITE and IMA_TYPE_R_RESULT */
@@ -140,6 +142,7 @@
#include "BSE_headerbuttons.h"
#include "BSE_editnla_types.h"
#include "BSE_time.h"
#include "BSE_trans_types.h"
#include "BDR_vpaint.h"
#include "BDR_editmball.h"
@@ -3895,22 +3898,46 @@ void drawinfospace(ScrArea *sa, void *spacedata)
(xpos+edgsp+(5*mpref)+(5*midsp)), y1, mpref, buth,
&U.texcollectrate, 1.0, 3600.0, 30, 2, "Number of seconds between each run of the GL texture garbage collector.");
/* *** */
uiDefBut(block, LABEL,0,"Color range for weight paint",
(xpos+edgsp+(2*midsp)+(2*mpref)),y6label,mpref,buth,
0, 0, 0, 0, 0, "");
uiDefButBitI(block, TOG, USER_CUSTOM_RANGE, B_WPAINT_RANGE, "ColorBand",
(xpos+edgsp+(2*midsp)+(2*mpref)),y5,mpref,buth,
&(U.flag), 0, 0, 0, 0,
"");
if((U.flag & USER_CUSTOM_RANGE)==0) {
vDM_ColorBand_store(NULL);
}
else {
rctf butrect;
vDM_ColorBand_store(&U.coba_weight); /* also signal for derivedmesh to use colorband */
BLI_init_rctf(&butrect, (xpos+edgsp+(2*midsp)+(2*mpref)),
(xpos+edgsp+(2*midsp)+(2*mpref)) + mpref,
y3, y3+30);
draw_colorband_buts_small(block, &U.coba_weight, &butrect, B_WPAINT_RANGE);
}
uiDefBut(block, LABEL,0,"Audio mixing buffer:",
(xpos+edgsp+(2*midsp)+(2*mpref)),y3label,mpref,buth,
(xpos+edgsp+(2*midsp)+(2*mpref)),y2label,mpref,buth,
0, 0, 0, 0, 0, "");
uiBlockBeginAlign(block);
uiDefButI(block, ROW, 0, "256",
(xpos+edgsp+(2*midsp)+(2*mpref)),y2,(mpref/4),buth,
(xpos+edgsp+(2*midsp)+(2*mpref)),y1,(mpref/4),buth,
&U.mixbufsize, 2.0, 256.0, 0, 0, "Set audio mixing buffer size to 256 samples");
uiDefButI(block, ROW, 0, "512",
(xpos+edgsp+(2*midsp)+(2*mpref)+(mpref/4)),y2,(mpref/4),buth,
(xpos+edgsp+(2*midsp)+(2*mpref)+(mpref/4)),y1,(mpref/4),buth,
&U.mixbufsize, 2.0, 512.0, 0, 0, "Set audio mixing buffer size to 512 samples");
uiDefButI(block, ROW, 0, "1024",
(xpos+edgsp+(2*midsp)+(2*mpref)+(2*mpref/4)),y2,(mpref/4),buth,
(xpos+edgsp+(2*midsp)+(2*mpref)+(2*mpref/4)),y1,(mpref/4),buth,
&U.mixbufsize, 2.0, 1024.0, 0, 0, "Set audio mixing buffer size to 1024 samples");
uiDefButI(block, ROW, 0, "2048",
(xpos+edgsp+(2*midsp)+(2*mpref)+(3*mpref/4)),y2,(mpref/4),buth,
(xpos+edgsp+(2*midsp)+(2*mpref)+(3*mpref/4)),y1,(mpref/4),buth,
&U.mixbufsize, 2.0, 2048.0, 0, 0, "Set audio mixing buffer size to 2048 samples");
uiBlockEndAlign(block);
@@ -4105,6 +4132,13 @@ static void winqreadinfospace(ScrArea *sa, void *spacedata, BWinEvent *evt)
MEM_CacheLimiter_set_maximum(
U.memcachelimit * 1024 * 1024);
}
else if (val==B_WPAINT_RANGE) {
addqueue(sa->win, REDRAW, 1);
if(OBACT && (G.f & G_WEIGHTPAINT)) {
DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA);
allqueue(REDRAWVIEW3D, 0);
}
}
else do_global_buttons(val);
break;

View File

@@ -81,6 +81,7 @@
#include "BKE_mball.h"
#include "BKE_node.h"
#include "BKE_packedFile.h"
#include "BKE_texture.h"
#include "BKE_utildefines.h"
#ifdef WITH_VERSE
@@ -365,6 +366,8 @@ static void init_userdef_file(void)
for(btheme= U.themes.first; btheme; btheme= btheme->next) {
SETCOL(btheme->tv3d.editmesh_active, 255, 255, 255, 128);
}
if(U.coba_weight.tot==0)
init_colorband(&U.coba_weight, 1);
}
/* GL Texture Garbage Collection (variable abused above!) */