[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31306] branches/soc-2010-nicolasbishop/ source/blender: == Ptex ==
Nicholas Bishop
nicholasbishop at gmail.com
Fri Aug 13 07:59:25 CEST 2010
Revision: 31306
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31306
Author: nicholasbishop
Date: 2010-08-13 07:59:24 +0200 (Fri, 13 Aug 2010)
Log Message:
-----------
== Ptex ==
For ptex-resolution editing mode, show a tiled pattern representing ptex texels.
Modified Paths:
--------------
branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_DerivedMesh.h
branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/DerivedMesh.c
branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/cdderivedmesh.c
branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/subsurf_ccg.c
branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/ptex.c
branches/soc-2010-nicolasbishop/source/blender/editors/space_view3d/drawmesh.c
branches/soc-2010-nicolasbishop/source/blender/editors/space_view3d/drawobject.c
branches/soc-2010-nicolasbishop/source/blender/gpu/GPU_buffers.h
branches/soc-2010-nicolasbishop/source/blender/gpu/intern/gpu_buffers.c
Modified: branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_DerivedMesh.h
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_DerivedMesh.h 2010-08-13 03:17:10 UTC (rev 31305)
+++ branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_DerivedMesh.h 2010-08-13 05:59:24 UTC (rev 31306)
@@ -81,6 +81,13 @@
DM_TYPE_CCGDM
} DerivedMeshType;
+typedef enum {
+ DM_DRAW_FAST_NAV = 1,
+ DM_DRAW_BACKBUF_SEL = 2,
+ DM_DRAW_USE_COLORS = 4,
+ DM_DRAW_PTEX_TEXELS = 8,
+} DMDrawFlags;
+
typedef struct DerivedMesh DerivedMesh;
struct DerivedMesh {
/* Private DerivedMesh data, only for internal DerivedMesh use */
@@ -239,7 +246,8 @@
* Also called for *final* editmode DerivedMeshes
*/
void (*drawFacesSolid)(DerivedMesh *dm, float (*partial_redraw_planes)[4],
- int fast, int (*setMaterial)(int, void *attribs));
+ int (*setMaterial)(int, void *attribs),
+ DMDrawFlags flags);
/* Draw all faces
* o If useTwoSided, draw front and back using col arrays
@@ -277,10 +285,10 @@
* smooth shaded.
*/
void (*drawMappedFaces)(DerivedMesh *dm,
- float (*partial_redraw_planes)[4], int fast,
+ float (*partial_redraw_planes)[4],
int (*setDrawOptions)(void *userData, int index,
int *drawSmooth_r),
- void *userData, int useColors);
+ void *userData, DMDrawFlags flags);
/* Draw mapped faces using MTFace
* o Drawing options too complicated to enumerate, look at code.
Modified: branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/DerivedMesh.c 2010-08-13 03:17:10 UTC (rev 31305)
+++ branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/DerivedMesh.c 2010-08-13 05:59:24 UTC (rev 31306)
@@ -617,7 +617,9 @@
func(userData, i, cent, emdm->vertexCos?emdm->faceNos[i]:efa->n);
}
}
-static void emDM_drawMappedFaces(DerivedMesh *dm, float (*partial_redraw_planes)[4], int fast_navigate, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int useColors)
+static void emDM_drawMappedFaces(DerivedMesh *dm, float (*partial_redraw_planes)[4],
+ int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r),
+ void *userData, DMDrawFlags flags)
{
EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
EditFace *efa;
Modified: branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/cdderivedmesh.c 2010-08-13 03:17:10 UTC (rev 31305)
+++ branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/cdderivedmesh.c 2010-08-13 05:59:24 UTC (rev 31306)
@@ -37,6 +37,7 @@
#include "BIF_gl.h"
#include "BKE_cdderivedmesh.h"
+#include "BKE_DerivedMesh.h"
#include "BKE_global.h"
#include "BKE_mesh.h"
#include "BKE_paint.h"
@@ -192,7 +193,7 @@
Mesh *me= (ob)? ob->data: NULL;
if(ob->paint->sculpt && ob->paint->sculpt->modifiers_active) return 0;
- if(paint_facesel_test(ob)) return 0;
+ //if(paint_facesel_test(ob)) return 0;
return (cddm->mvert == me->mvert) || (ob->paint->sculpt && ob->paint->sculpt->kb);
}
@@ -432,23 +433,31 @@
false if regular drawing should be used */
static int cddm_draw_pbvh(DerivedMesh *dm, float (*partial_redraw_planes)[4],
int (*setMaterial)(int, void *attribs),
- GPUDrawFlags drawflags)
+ DMDrawFlags dm_flags)
{
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
MFace *mface = cddm->mface;
float (*face_nors)[3];
- if(cddm->pbvh && cddm->pbvh_draw) {
+ if(!(dm_flags & DM_DRAW_BACKBUF_SEL) && cddm->pbvh && cddm->pbvh_draw) {
if(dm->numFaceData) {
+ GPUDrawFlags gpu_flags = 0;
+
face_nors = CustomData_get_layer(&dm->faceData, CD_NORMAL);
/* should be per face */
if(setMaterial && !setMaterial(mface->mat_nr+1, NULL))
return 1;
if(mface->flag & ME_SMOOTH)
- drawflags |= GPU_DRAW_SMOOTH;
+ gpu_flags |= GPU_DRAW_SMOOTH;
- BLI_pbvh_draw(cddm->pbvh, partial_redraw_planes, face_nors, drawflags);
+ if(dm_flags & DM_DRAW_USE_COLORS)
+ gpu_flags |= GPU_DRAW_ACTIVE_MCOL;
+
+ if(dm_flags & DM_DRAW_PTEX_TEXELS)
+ gpu_flags |= GPU_DRAW_PTEX_TEXELS;
+
+ BLI_pbvh_draw(cddm->pbvh, partial_redraw_planes, face_nors, gpu_flags);
}
return 1;
@@ -459,7 +468,8 @@
static void cdDM_drawFacesSolid(DerivedMesh *dm,
float (*partial_redraw_planes)[4],
- int fast, int (*setMaterial)(int, void *attribs))
+ int (*setMaterial)(int, void *attribs),
+ DMDrawFlags flags)
{
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
MVert *mvert = cddm->mvert;
@@ -467,15 +477,15 @@
float *nors= dm->getFaceDataArray(dm, CD_NORMAL);
int a, glmode = -1, shademodel = -1, matnr = -1, drawCurrentMat = 1;
-#define PASSVERT(index) { \
- if(shademodel == GL_SMOOTH) { \
- short *no = mvert[index].no; \
- glNormal3sv(no); \
- } \
- glVertex3fv(mvert[index].co); \
-}
+#define PASSVERT(index) { \
+ if(shademodel == GL_SMOOTH) { \
+ short *no = mvert[index].no; \
+ glNormal3sv(no); \
+ } \
+ glVertex3fv(mvert[index].co); \
+ }
- if(cddm_draw_pbvh(dm, partial_redraw_planes, setMaterial, 0))
+ if(cddm_draw_pbvh(dm, partial_redraw_planes, setMaterial, flags))
return;
if( GPU_buffer_legacy(dm) ) {
@@ -805,7 +815,9 @@
cdDM_drawFacesTex_common(dm, setDrawOptions, NULL, NULL);
}
-static void cdDM_drawMappedFaces(DerivedMesh *dm, float (*partial_redraw_planes)[4], int fast_navigate, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int useColors)
+static void cdDM_drawMappedFaces(DerivedMesh *dm, float (*partial_redraw_planes)[4],
+ int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r),
+ void *userData, DMDrawFlags flags)
{
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
MVert *mv = cddm->mvert;
@@ -814,8 +826,7 @@
float *nors= dm->getFaceDataArray(dm, CD_NORMAL);
int i, orig, *index = DM_get_face_data_layer(dm, CD_ORIGINDEX);
- if(cddm_draw_pbvh(dm, partial_redraw_planes, NULL,
- useColors ? GPU_DRAW_ACTIVE_MCOL : 0))
+ if(cddm_draw_pbvh(dm, partial_redraw_planes, NULL, flags))
return;
mc = DM_get_face_data_layer(dm, CD_ID_MCOL);
@@ -842,7 +853,7 @@
if(!setDrawOptions || setDrawOptions(userData, orig, &drawSmooth)) {
unsigned char *cp = NULL;
- if(useColors && mc)
+ if((flags & DM_DRAW_USE_COLORS) && mc)
cp = (unsigned char *)&mc[i * 4];
glShadeModel(drawSmooth?GL_SMOOTH:GL_FLAT);
@@ -899,7 +910,7 @@
int prevstart = 0;
GPU_vertex_setup(dm);
GPU_normal_setup(dm);
- if( useColors && mc )
+ if((flags & DM_DRAW_USE_COLORS) && mc )
GPU_color_setup(dm);
if( !GPU_buffer_legacy(dm) ) {
int tottri = dm->drawObject->nelements/3;
Modified: branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/subsurf_ccg.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/subsurf_ccg.c 2010-08-13 03:17:10 UTC (rev 31305)
+++ branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/subsurf_ccg.c 2010-08-13 05:59:24 UTC (rev 31306)
@@ -1410,17 +1410,18 @@
/* Only used by non-editmesh types */
static void ccgDM_drawFacesSolid(DerivedMesh *dm,
float (*partial_redraw_planes)[4],
- int fast_navigate,
- int (*setMaterial)(int, void *attribs)) {
+ int (*setMaterial)(int, void *attribs),
+ DMDrawFlags flags) {
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
CCGSubSurf *ss = ccgdm->ss;
CCGFaceIterator *fi;
int gridSize = ccgSubSurf_getGridSize(ss);
GridKey *gridkey = ccgSubSurf_getGridKey(ss);
char *faceFlags = ccgdm->faceFlags;
- int step = (fast_navigate)? gridSize-1: 1;
+ int step = (flags & DM_DRAW_FAST_NAV)? gridSize-1: 1;
- if(ccgdm_draw_pbvh(dm, partial_redraw_planes, setMaterial, fast_navigate, 0))
+ if(!(flags & DM_DRAW_BACKBUF_SEL) &&
+ ccgdm_draw_pbvh(dm, partial_redraw_planes, setMaterial, flags & DM_DRAW_FAST_NAV, 0))
return;
fi = ccgSubSurf_getFaceIterator(ss);
@@ -1913,9 +1914,8 @@
static void ccgDM_drawMappedFaces(DerivedMesh *dm,
float (*partial_redraw_planes)[4],
- int fast_navigate,
int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r),
- void *userData, int useColors) {
+ void *userData, DMDrawFlags flags) {
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
CCGSubSurf *ss = ccgdm->ss;
MCol *mcol= NULL;
@@ -1923,14 +1923,14 @@
GridKey *gridkey = ccgSubSurf_getGridKey(ss);
char *faceFlags = ccgdm->faceFlags;
int gridFaces = gridSize - 1, totface;
- int step = (fast_navigate)? gridSize-1: 1;
+ int step = (flags & DM_DRAW_FAST_NAV)? gridSize-1: 1;
- if(ccgdm_draw_pbvh(dm, partial_redraw_planes, NULL, fast_navigate,
- useColors ? GPU_DRAW_ACTIVE_MCOL : 0))
+ if(ccgdm_draw_pbvh(dm, partial_redraw_planes, NULL, (flags & DM_DRAW_FAST_NAV),
+ (flags & DM_DRAW_USE_COLORS) ? GPU_DRAW_ACTIVE_MCOL : 0))
return;
- if(useColors) {
- if(fast_navigate) {
+ if(flags & DM_DRAW_USE_COLORS) {
+ if(flags & DM_DRAW_FAST_NAV) {
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
}
@@ -2058,7 +2058,7 @@
}
}
- if(fast_navigate)
+ if(flags & DM_DRAW_FAST_NAV)
glDisable(GL_COLOR_MATERIAL);
}
static void ccgDM_drawMappedEdges(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index), void *userData) {
Modified: branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/ptex.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/ptex.c 2010-08-13 03:17:10 UTC (rev 31305)
+++ branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/ptex.c 2010-08-13 05:59:24 UTC (rev 31306)
@@ -527,6 +527,8 @@
}
}
+ WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
+
return OPERATOR_FINISHED;
}
Modified: branches/soc-2010-nicolasbishop/source/blender/editors/space_view3d/drawmesh.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/editors/space_view3d/drawmesh.c 2010-08-13 03:17:10 UTC (rev 31305)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list