[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21410] branches/soc-2009-imbusy/source/ blender: Vertex Paint mode works in some hacky way, don' t like the way I did it, but couldn't think of anything better.
Lukas Steiblys
imbusy at imbusy.org
Tue Jul 7 19:16:06 CEST 2009
Revision: 21410
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21410
Author: imbusy
Date: 2009-07-07 19:16:05 +0200 (Tue, 07 Jul 2009)
Log Message:
-----------
Vertex Paint mode works in some hacky way, don't like the way I did it, but couldn't think of anything better. There's still some bug with not being able to paint on one final vertex of a mesh.
Modified Paths:
--------------
branches/soc-2009-imbusy/source/blender/blenkernel/intern/cdderivedmesh.c
branches/soc-2009-imbusy/source/blender/editors/space_view3d/drawobject.c
branches/soc-2009-imbusy/source/blender/gpu/intern/gpu_buffers.c
branches/soc-2009-imbusy/source/blender/windowmanager/intern/wm_subwindow.c
branches/soc-2009-imbusy/source/blender/windowmanager/wm_subwindow.h
Modified: branches/soc-2009-imbusy/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- branches/soc-2009-imbusy/source/blender/blenkernel/intern/cdderivedmesh.c 2009-07-07 15:42:08 UTC (rev 21409)
+++ branches/soc-2009-imbusy/source/blender/blenkernel/intern/cdderivedmesh.c 2009-07-07 17:16:05 UTC (rev 21410)
@@ -590,12 +590,13 @@
float *nors= dm->getFaceDataArray(dm, CD_NORMAL);
int i, orig, *index = DM_get_face_data_layer(dm, CD_ORIGINDEX);
+
mc = DM_get_face_data_layer(dm, CD_WEIGHT_MCOL);
if(!mc)
mc = DM_get_face_data_layer(dm, CD_MCOL);
if( GPU_buffer_legacy(dm) ) {
- DEBUG_VBO( "Using legacy code. cdDM_drawFacesTex_common\n" );
+ DEBUG_VBO( "Using legacy code. cdDM_drawMappedFaces\n" );
for(i = 0; i < dm->numFaceData; i++, mf++) {
int drawSmooth = (mf->flag & ME_SMOOTH);
Modified: branches/soc-2009-imbusy/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- branches/soc-2009-imbusy/source/blender/editors/space_view3d/drawobject.c 2009-07-07 15:42:08 UTC (rev 21409)
+++ branches/soc-2009-imbusy/source/blender/editors/space_view3d/drawobject.c 2009-07-07 17:16:05 UTC (rev 21410)
@@ -1716,12 +1716,44 @@
static void draw_dm_faces_sel(DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol, unsigned char *actCol, EditFace *efa_act)
{
struct { unsigned char *cols[3]; EditFace *efa_act; } data;
+ unsigned char *colors;
+ int i,j;
data.cols[0] = baseCol;
data.cols[1] = selCol;
data.cols[2] = actCol;
data.efa_act = efa_act;
-
+
+ /* TODO: check this later. not this function... */
+ /*colors = MEM_mallocN((sizeof(unsigned char)*dm->getNumFaces(dm)*16),"draw_dm_faces_sel");
+ for(i=0; i < dm->getNumFaces(dm); i++) {
+ EditFace *efa = EM_get_face_for_index(i);
+ unsigned char *col;
+ if (efa->h==0) {
+ if (efa == efa_act) {
+ for(j=0;j<4;j++) {
+ colors[i*16+j*4] = data.cols[2][0];
+ colors[i*16+j*4+1] = data.cols[2][1];
+ colors[i*16+j*4+2] = data.cols[2][2];
+ colors[i*16+j*4+3] = data.cols[2][3];
+ }
+ } else {
+ col = data.cols[(efa->f&SELECT)?1:0];
+ if (col[3]==0) memset(&colors[i*16],0,sizeof(unsigned char)*16);
+ for(j=0;j<4;j++) {
+ colors[i*16+j*4] = col[0];
+ colors[i*16+j*4+1] = col[1];
+ colors[i*16+j*4+2] = col[2];
+ colors[i*16+j*4+3] = col[3];
+ }
+ }
+ } else
+ {
+ memset(&colors[i*16],0,sizeof(unsigned char)*16);
+ }
+ }*/
+ //CustomData_add_layer( &dm->faceData, CD_WEIGHT_PAINT, CD_ASSIGN, colors, dm->numFaceData );
dm->drawMappedFaces(dm, draw_dm_faces_sel__setDrawOptions, &data, 0);
+ //CustomData_free_layer( &dm->faceData, CD_WEIGHT_PAINT, dm->numFaceData, 0 );
}
static int draw_dm_creases__setDrawOptions(void *userData, int index)
@@ -5579,10 +5611,34 @@
{
DerivedMesh *dm = mesh_get_derived_final(scene, ob, v3d->customdata_mask);
Mesh *me = (Mesh*)ob->data;
+ MCol *colors;
+ int i,j;
glColor3ub(0, 0, 0);
- dm->drawMappedFaces(dm, bbs_mesh_solid__setDrawOpts, me, 0);
+
+ colors = MEM_mallocN(dm->getNumFaces(dm)*sizeof(MCol)*4,"bbs_mesh_solid");
+ for(i=0;i<dm->getNumFaces(dm);i++) {
+ if (!(me->mface[i].flag&ME_HIDE)) {
+ unsigned int fbindex = index_to_framebuffer(i);
+ for(j=0;j<4;j++) {
+ colors[i*4+j].b = ((fbindex)&0xFF);
+ colors[i*4+j].g = (((fbindex)>>8)&0xFF);
+ colors[i*4+j].r = (((fbindex)>>16)&0xFF);
+ colors[i*4+j].a = 255;
+ }
+ }
+ else {
+ memset(&colors[i*4],0,sizeof(MCol));
+ }
+ }
+
+ CustomData_add_layer( &dm->faceData, CD_WEIGHT_MCOL, CD_ASSIGN, colors, dm->numFaceData );
+ GPU_buffer_free(dm->drawObject->colors,0);
+ dm->drawObject->colors = 0;
+ dm->drawMappedFaces(dm, bbs_mesh_solid__setDrawOpts, me, 1);
+ CustomData_free_layer( &dm->faceData, CD_WEIGHT_MCOL, dm->numFaceData, 0 );
+
dm->release(dm);
}
Modified: branches/soc-2009-imbusy/source/blender/gpu/intern/gpu_buffers.c
===================================================================
--- branches/soc-2009-imbusy/source/blender/gpu/intern/gpu_buffers.c 2009-07-07 15:42:08 UTC (rev 21409)
+++ branches/soc-2009-imbusy/source/blender/gpu/intern/gpu_buffers.c 2009-07-07 17:16:05 UTC (rev 21410)
@@ -600,7 +600,8 @@
DEBUG_VBO("GPU_buffer_color\n");
mcol = DM_get_face_data_layer(dm, CD_WEIGHT_MCOL);
- dm->drawObject->colType = CD_WEIGHT_MCOL;
+ if( mcol )
+ dm->drawObject->colType = CD_WEIGHT_MCOL;
if(!mcol) {
mcol = DM_get_face_data_layer(dm, CD_MCOL);
dm->drawObject->colType = CD_MCOL;
Modified: branches/soc-2009-imbusy/source/blender/windowmanager/intern/wm_subwindow.c
===================================================================
--- branches/soc-2009-imbusy/source/blender/windowmanager/intern/wm_subwindow.c 2009-07-07 15:42:08 UTC (rev 21409)
+++ branches/soc-2009-imbusy/source/blender/windowmanager/intern/wm_subwindow.c 2009-07-07 17:16:05 UTC (rev 21410)
@@ -434,7 +434,7 @@
/* apple seems to round colors to below and up on some configs */
-static unsigned int index_to_framebuffer(int index)
+unsigned int index_to_framebuffer(int index)
{
unsigned int i= index;
@@ -464,7 +464,7 @@
/* this is the old method as being in use for ages.... seems to work? colors are rounded to lower values */
-static unsigned int index_to_framebuffer(int index)
+unsigned int index_to_framebuffer(int index)
{
unsigned int i= index;
Modified: branches/soc-2009-imbusy/source/blender/windowmanager/wm_subwindow.h
===================================================================
--- branches/soc-2009-imbusy/source/blender/windowmanager/wm_subwindow.h 2009-07-07 15:42:08 UTC (rev 21409)
+++ branches/soc-2009-imbusy/source/blender/windowmanager/wm_subwindow.h 2009-07-07 17:16:05 UTC (rev 21410)
@@ -45,6 +45,7 @@
void wm_subwindow_getorigin(wmWindow *win, int swinid, int *x, int *y);
void wm_subwindow_getmatrix(wmWindow *win, int swinid, float mat[][4]);
+unsigned int index_to_framebuffer(int index);
#endif /* WM_SUBWINDOW_H */
More information about the Bf-blender-cvs
mailing list