[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12441] trunk/blender/source/blender: New feature:
Ton Roosendaal
ton at blender.org
Wed Oct 31 14:56:07 CET 2007
Revision: 12441
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12441
Author: ton
Date: 2007-10-31 14:56:07 +0100 (Wed, 31 Oct 2007)
Log Message:
-----------
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/
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/BKE_DerivedMesh.h
trunk/blender/source/blender/blenkernel/BKE_texture.h
trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c
trunk/blender/source/blender/blenkernel/intern/texture.c
trunk/blender/source/blender/include/BSE_trans_types.h
trunk/blender/source/blender/include/blendef.h
trunk/blender/source/blender/makesdna/DNA_texture_types.h
trunk/blender/source/blender/makesdna/DNA_userdef_types.h
trunk/blender/source/blender/src/buttons_editing.c
trunk/blender/source/blender/src/ghostwinlay.c
trunk/blender/source/blender/src/space.c
trunk/blender/source/blender/src/usiblender.c
Modified: trunk/blender/source/blender/blenkernel/BKE_DerivedMesh.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_DerivedMesh.h 2007-10-31 10:04:57 UTC (rev 12440)
+++ trunk/blender/source/blender/blenkernel/BKE_DerivedMesh.h 2007-10-31 13:56:07 UTC (rev 12441)
@@ -57,6 +57,7 @@
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_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 */
Modified: trunk/blender/source/blender/blenkernel/BKE_texture.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_texture.h 2007-10-31 10:04:57 UTC (rev 12440)
+++ trunk/blender/source/blender/blenkernel/BKE_texture.h 2007-10-31 13:56:07 UTC (rev 12441)
@@ -52,8 +52,11 @@
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);
Modified: trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c 2007-10-31 10:04:57 UTC (rev 12440)
+++ trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c 2007-10-31 13:56:07 UTC (rev 12441)
@@ -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 @@
*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 @@
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;
Modified: trunk/blender/source/blender/blenkernel/intern/texture.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/texture.c 2007-10-31 10:04:57 UTC (rev 12440)
+++ trunk/blender/source/blender/blenkernel/intern/texture.c 2007-10-31 13:56:07 UTC (rev 12441)
@@ -238,13 +238,10 @@
/* ****************** 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 @@
coba->tot= 2;
+}
+
+ColorBand *add_colorband(int rangetype)
+{
+ ColorBand *coba;
+
+ coba= MEM_callocN( sizeof(ColorBand), "colorband");
+ init_colorband(coba, rangetype);
+
return coba;
}
Modified: trunk/blender/source/blender/include/BSE_trans_types.h
===================================================================
--- trunk/blender/source/blender/include/BSE_trans_types.h 2007-10-31 10:04:57 UTC (rev 12440)
+++ trunk/blender/source/blender/include/BSE_trans_types.h 2007-10-31 13:56:07 UTC (rev 12441)
@@ -35,6 +35,7 @@
struct Object;
struct MDeformVert;
+struct ColorBand;
typedef struct TransOb {
float *loc;
Modified: trunk/blender/source/blender/include/blendef.h
===================================================================
--- trunk/blender/source/blender/include/blendef.h 2007-10-31 10:04:57 UTC (rev 12440)
+++ trunk/blender/source/blender/include/blendef.h 2007-10-31 13:56:07 UTC (rev 12441)
@@ -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
Modified: trunk/blender/source/blender/makesdna/DNA_texture_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_texture_types.h 2007-10-31 10:04:57 UTC (rev 12440)
+++ trunk/blender/source/blender/makesdna/DNA_texture_types.h 2007-10-31 13:56:07 UTC (rev 12441)
@@ -107,6 +107,7 @@
} 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];
Modified: trunk/blender/source/blender/makesdna/DNA_userdef_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_userdef_types.h 2007-10-31 10:04:57 UTC (rev 12440)
+++ trunk/blender/source/blender/makesdna/DNA_userdef_types.h 2007-10-31 13:56:07 UTC (rev 12441)
@@ -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 @@
char verseuser[160];
float glalphaclip, pad;
+ struct ColorBand coba_weight; /* from texture.h */
} UserDef;
extern UserDef U; /* from usiblender.c !!!! */
@@ -208,6 +211,7 @@
#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
Modified: trunk/blender/source/blender/src/buttons_editing.c
===================================================================
--- trunk/blender/source/blender/src/buttons_editing.c 2007-10-31 10:04:57 UTC (rev 12440)
+++ trunk/blender/source/blender/src/buttons_editing.c 2007-10-31 13:56:07 UTC (rev 12441)
@@ -5290,7 +5290,6 @@
static void editing_panel_mesh_texface(void)
{
- extern VPaint Gvp; /* from vpaint */
uiBlock *block;
MTFace *tf;
Modified: trunk/blender/source/blender/src/ghostwinlay.c
===================================================================
--- trunk/blender/source/blender/src/ghostwinlay.c 2007-10-31 10:04:57 UTC (rev 12440)
+++ trunk/blender/source/blender/src/ghostwinlay.c 2007-10-31 13:56:07 UTC (rev 12441)
@@ -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*/
Modified: trunk/blender/source/blender/src/space.c
===================================================================
--- trunk/blender/source/blender/src/space.c 2007-10-31 10:04:57 UTC (rev 12440)
+++ trunk/blender/source/blender/src/space.c 2007-10-31 13:56:07 UTC (rev 12441)
@@ -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 @@
(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, "");
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list