diff options
author | Ton Roosendaal <ton@blender.org> | 2007-10-31 16:56:07 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2007-10-31 16:56:07 +0300 |
commit | 10680b34f231a6907b65407bd27e146f61b2b2e0 (patch) | |
tree | 9225a86bb255149d94832ead0801b4e0d0bad15f /source | |
parent | 2ae5da3fc287874746967ecf988f744dc56ebfbc (diff) |
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/
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_DerivedMesh.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_texture.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 44 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/texture.c | 14 | ||||
-rw-r--r-- | source/blender/include/BSE_trans_types.h | 1 | ||||
-rw-r--r-- | source/blender/include/blendef.h | 1 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_texture_types.h | 1 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_userdef_types.h | 4 | ||||
-rw-r--r-- | source/blender/src/buttons_editing.c | 1 | ||||
-rw-r--r-- | source/blender/src/ghostwinlay.c | 2 | ||||
-rw-r--r-- | source/blender/src/space.c | 46 | ||||
-rw-r--r-- | source/blender/src/usiblender.c | 3 |
12 files changed, 98 insertions, 26 deletions
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index c710e16ad1a..1852dc72a40 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -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 */ diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h index 83229ec35a2..902423482b1 100644 --- a/source/blender/blenkernel/BKE_texture.h +++ b/source/blender/blenkernel/BKE_texture.h @@ -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); diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 299bbc10241..04b111ffe2f 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -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; diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index d41ceb5a4b7..a53db265c52 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -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; } diff --git a/source/blender/include/BSE_trans_types.h b/source/blender/include/BSE_trans_types.h index d75da302436..9c8b9e5595f 100644 --- a/source/blender/include/BSE_trans_types.h +++ b/source/blender/include/BSE_trans_types.h @@ -35,6 +35,7 @@ struct Object; struct MDeformVert; +struct ColorBand; typedef struct TransOb { float *loc; diff --git a/source/blender/include/blendef.h b/source/blender/include/blendef.h index d3ad441c863..4c42ba85968 100644 --- a/source/blender/include/blendef.h +++ b/source/blender/include/blendef.h @@ -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 diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h index 794d818d8fe..cf51990c9bf 100644 --- a/source/blender/makesdna/DNA_texture_types.h +++ b/source/blender/makesdna/DNA_texture_types.h @@ -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]; diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 07168e004e4..1ce6f151db6 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -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 diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index f4fc9b85ada..a9a75126f51 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -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; diff --git a/source/blender/src/ghostwinlay.c b/source/blender/src/ghostwinlay.c index 4a76d2d292f..597a23a20d7 100644 --- a/source/blender/src/ghostwinlay.c +++ b/source/blender/src/ghostwinlay.c @@ -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*/ diff --git a/source/blender/src/space.c b/source/blender/src/space.c index 2d5d4fbac8a..0d27eb8afe3 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -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; diff --git a/source/blender/src/usiblender.c b/source/blender/src/usiblender.c index 3928f736f1a..3b22b84ad99 100644 --- a/source/blender/src/usiblender.c +++ b/source/blender/src/usiblender.c @@ -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!) */ |