Code cleanup: use typedefs for DerivedMesh drawing callbacks.
There are still fairly bewildering set of callbacks being tossed around, but it's at least a little less verbose now.
This commit is contained in:
@@ -124,6 +124,14 @@ typedef enum DerivedMeshType {
|
||||
DM_TYPE_CCGDM
|
||||
} DerivedMeshType;
|
||||
|
||||
/* Drawing callback types */
|
||||
typedef int (*DMSetMaterial)(int mat_nr, void *attribs);
|
||||
typedef int (*DMCompareDrawOptions)(void *userData, int cur_index, int next_index);
|
||||
typedef void (*DMSetDrawInterpOptions)(void *userData, int index, float t);
|
||||
typedef int (*DMSetDrawOptions)(void *userData, int index);
|
||||
typedef int (*DMSetDrawOptionsTex)(struct MTFace *tface, int has_vcol, int matnr);
|
||||
typedef int (*DMSetDrawOptionsShading)(void *userData, int index, int *drawSmooth_r);
|
||||
|
||||
typedef struct DerivedMesh DerivedMesh;
|
||||
struct DerivedMesh {
|
||||
/* Private DerivedMesh data, only for internal DerivedMesh use */
|
||||
@@ -308,25 +316,21 @@ struct DerivedMesh {
|
||||
* Also called for *final* editmode DerivedMeshes
|
||||
*/
|
||||
void (*drawFacesSolid)(DerivedMesh *dm, float (*partial_redraw_planes)[4],
|
||||
int fast, int (*setMaterial)(int, void *attribs));
|
||||
int fast, DMSetMaterial setMaterial);
|
||||
|
||||
/* Draw all faces using MTFace
|
||||
* o Drawing options too complicated to enumerate, look at code.
|
||||
*/
|
||||
void (*drawFacesTex)(DerivedMesh *dm,
|
||||
int (*setDrawOptions)(struct MTFace *tface,
|
||||
int has_vcol, int matnr),
|
||||
int (*compareDrawOptions)(void *userData,
|
||||
int cur_index,
|
||||
int next_index),
|
||||
void *userData);
|
||||
DMSetDrawOptionsTex setDrawOptions,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData);
|
||||
|
||||
/* Draw all faces with GLSL materials
|
||||
* o setMaterial is called for every different material nr
|
||||
* o Only if setMaterial returns true
|
||||
*/
|
||||
void (*drawFacesGLSL)(DerivedMesh *dm,
|
||||
int (*setMaterial)(int, void *attribs));
|
||||
void (*drawFacesGLSL)(DerivedMesh *dm, DMSetMaterial setMaterial);
|
||||
|
||||
/* Draw mapped faces (no color, or texture)
|
||||
* o Only if !setDrawOptions or
|
||||
@@ -342,23 +346,17 @@ struct DerivedMesh {
|
||||
* smooth shaded.
|
||||
*/
|
||||
void (*drawMappedFaces)(DerivedMesh *dm,
|
||||
int (*setDrawOptions)(void *userData, int index,
|
||||
int *drawSmooth_r),
|
||||
int (*setMaterial)(int, void *attribs),
|
||||
int (*compareDrawOptions)(void *userData,
|
||||
int cur_index,
|
||||
int next_index),
|
||||
DMSetDrawOptionsShading setDrawOptions,
|
||||
DMSetMaterial setMaterial,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData, int useColors);
|
||||
|
||||
/* Draw mapped faces using MTFace
|
||||
* o Drawing options too complicated to enumerate, look at code.
|
||||
*/
|
||||
void (*drawMappedFacesTex)(DerivedMesh *dm,
|
||||
int (*setDrawOptions)(void *userData,
|
||||
int index),
|
||||
int (*compareDrawOptions)(void *userData,
|
||||
int cur_index,
|
||||
int next_index),
|
||||
DMSetDrawOptions setDrawOptions,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData);
|
||||
|
||||
/* Draw mapped faces with GLSL materials
|
||||
@@ -367,8 +365,8 @@ struct DerivedMesh {
|
||||
* o Only if setMaterial and setDrawOptions return true
|
||||
*/
|
||||
void (*drawMappedFacesGLSL)(DerivedMesh *dm,
|
||||
int (*setMaterial)(int, void *attribs),
|
||||
int (*setDrawOptions)(void *userData, int index),
|
||||
DMSetMaterial setMaterial,
|
||||
DMSetDrawOptions setDrawOptions,
|
||||
void *userData);
|
||||
|
||||
/* Draw mapped edges as lines
|
||||
@@ -376,7 +374,7 @@ struct DerivedMesh {
|
||||
* returns true
|
||||
*/
|
||||
void (*drawMappedEdges)(DerivedMesh *dm,
|
||||
int (*setDrawOptions)(void *userData, int index),
|
||||
DMSetDrawOptions setDrawOptions,
|
||||
void *userData);
|
||||
|
||||
/* Draw mapped edges as lines with interpolation values
|
||||
@@ -387,11 +385,8 @@ struct DerivedMesh {
|
||||
* NOTE: This routine is optional!
|
||||
*/
|
||||
void (*drawMappedEdgesInterp)(DerivedMesh *dm,
|
||||
int (*setDrawOptions)(void *userData,
|
||||
int index),
|
||||
void (*setDrawInterpOptions)(void *userData,
|
||||
int index,
|
||||
float t),
|
||||
DMSetDrawOptions setDrawOptions,
|
||||
DMSetDrawInterpOptions setDrawInterpOptions,
|
||||
void *userData);
|
||||
|
||||
/* Draw all faces with materials
|
||||
|
||||
@@ -505,7 +505,7 @@ static void cdDM_drawLooseEdges(DerivedMesh *dm)
|
||||
|
||||
static void cdDM_drawFacesSolid(DerivedMesh *dm,
|
||||
float (*partial_redraw_planes)[4],
|
||||
int UNUSED(fast), int (*setMaterial)(int, void *attribs))
|
||||
int UNUSED(fast), DMSetMaterial setMaterial)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
||||
MVert *mvert = cddm->mvert;
|
||||
@@ -600,9 +600,9 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm,
|
||||
}
|
||||
|
||||
static void cdDM_drawFacesTex_common(DerivedMesh *dm,
|
||||
int (*drawParams)(MTFace *tface, int has_mcol, int matnr),
|
||||
int (*drawParamsMapped)(void *userData, int index),
|
||||
int (*compareDrawOptions)(void *userData, int cur_index, int next_index),
|
||||
DMSetDrawOptionsTex drawParams,
|
||||
DMSetDrawOptions drawParamsMapped,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
||||
@@ -788,17 +788,17 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
|
||||
}
|
||||
|
||||
static void cdDM_drawFacesTex(DerivedMesh *dm,
|
||||
int (*setDrawOptions)(MTFace *tface, int has_mcol, int matnr),
|
||||
int (*compareDrawOptions)(void *userData, int cur_index, int next_index),
|
||||
DMSetDrawOptionsTex setDrawOptions,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData)
|
||||
{
|
||||
cdDM_drawFacesTex_common(dm, setDrawOptions, NULL, compareDrawOptions, userData);
|
||||
}
|
||||
|
||||
static void cdDM_drawMappedFaces(DerivedMesh *dm,
|
||||
int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r),
|
||||
int (*setMaterial)(int, void *attribs),
|
||||
int (*compareDrawOptions)(void *userData, int cur_index, int next_index),
|
||||
DMSetDrawOptionsShading setDrawOptions,
|
||||
DMSetMaterial setMaterial,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData, int useColors)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
||||
@@ -961,8 +961,8 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm,
|
||||
}
|
||||
|
||||
static void cdDM_drawMappedFacesTex(DerivedMesh *dm,
|
||||
int (*setDrawOptions)(void *userData, int index),
|
||||
int (*compareDrawOptions)(void *userData, int cur_index, int next_index),
|
||||
DMSetDrawOptions setDrawOptions,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData)
|
||||
{
|
||||
cdDM_drawFacesTex_common(dm, NULL, setDrawOptions, compareDrawOptions, userData);
|
||||
@@ -1013,8 +1013,8 @@ static void cddm_draw_attrib_vertex(DMVertexAttribs *attribs, MVert *mvert, int
|
||||
}
|
||||
|
||||
static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
|
||||
int (*setMaterial)(int, void *attribs),
|
||||
int (*setDrawOptions)(void *userData, int index),
|
||||
DMSetMaterial setMaterial,
|
||||
DMSetDrawOptions setDrawOptions,
|
||||
void *userData)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
||||
@@ -1302,7 +1302,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
|
||||
glShadeModel(GL_FLAT);
|
||||
}
|
||||
|
||||
static void cdDM_drawFacesGLSL(DerivedMesh *dm,int (*setMaterial)(int, void *attribs))
|
||||
static void cdDM_drawFacesGLSL(DerivedMesh *dm, DMSetMaterial setMaterial)
|
||||
{
|
||||
dm->drawMappedFacesGLSL(dm, setMaterial, NULL, NULL);
|
||||
}
|
||||
@@ -1386,7 +1386,7 @@ static void cdDM_drawMappedFacesMat(DerivedMesh *dm,
|
||||
glShadeModel(GL_FLAT);
|
||||
}
|
||||
|
||||
static void cdDM_drawMappedEdges(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index), void *userData)
|
||||
static void cdDM_drawMappedEdges(DerivedMesh *dm, DMSetDrawOptions setDrawOptions, void *userData)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
||||
MVert *vert = cddm->mvert;
|
||||
|
||||
@@ -399,7 +399,7 @@ static void emDM_foreachMappedEdge(
|
||||
|
||||
static void emDM_drawMappedEdges(
|
||||
DerivedMesh *dm,
|
||||
int (*setDrawOptions)(void *userData, int index),
|
||||
DMSetDrawOptions setDrawOptions,
|
||||
void *userData)
|
||||
{
|
||||
EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm;
|
||||
@@ -443,8 +443,8 @@ static void emDM_drawEdges(
|
||||
|
||||
static void emDM_drawMappedEdgesInterp(
|
||||
DerivedMesh *dm,
|
||||
int (*setDrawOptions)(void *userData, int index),
|
||||
void (*setDrawInterpOptions)(void *userData, int index, float t),
|
||||
DMSetDrawOptions setDrawOptions,
|
||||
DMSetDrawInterpOptions setDrawInterpOptions,
|
||||
void *userData)
|
||||
{
|
||||
EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm;
|
||||
@@ -579,9 +579,9 @@ static void emDM_foreachMappedFaceCenter(
|
||||
|
||||
static void emDM_drawMappedFaces(
|
||||
DerivedMesh *dm,
|
||||
int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r),
|
||||
int (*setMaterial)(int, void *attribs),
|
||||
int (*compareDrawOptions)(void *userData, int cur_index, int next_index),
|
||||
DMSetDrawOptionsShading setDrawOptions,
|
||||
DMSetMaterial setMaterial,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData, int UNUSED(useColors))
|
||||
{
|
||||
EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm;
|
||||
@@ -777,9 +777,9 @@ static void bmdm_get_tri_tex(BMesh *bm, BMLoop **ls, MLoopUV *luv[3], MLoopCol *
|
||||
|
||||
static void emDM_drawFacesTex_common(
|
||||
DerivedMesh *dm,
|
||||
int (*drawParams)(MTFace *tface, int has_vcol, int matnr),
|
||||
int (*drawParamsMapped)(void *userData, int index),
|
||||
int (*compareDrawOptions)(void *userData, int cur_index, int next_index),
|
||||
DMSetDrawOptionsTex drawParams,
|
||||
DMSetDrawOptions drawParamsMapped,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData)
|
||||
{
|
||||
EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm;
|
||||
@@ -960,8 +960,8 @@ static void emDM_drawFacesTex_common(
|
||||
|
||||
static void emDM_drawFacesTex(
|
||||
DerivedMesh *dm,
|
||||
int (*setDrawOptions)(MTFace *tface, int has_vcol, int matnr),
|
||||
int (*compareDrawOptions)(void *userData, int cur_index, int next_index),
|
||||
DMSetDrawOptionsTex setDrawOptions,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData)
|
||||
{
|
||||
emDM_drawFacesTex_common(dm, setDrawOptions, NULL, compareDrawOptions, userData);
|
||||
@@ -969,8 +969,8 @@ static void emDM_drawFacesTex(
|
||||
|
||||
static void emDM_drawMappedFacesTex(
|
||||
DerivedMesh *dm,
|
||||
int (*setDrawOptions)(void *userData, int index),
|
||||
int (*compareDrawOptions)(void *userData, int cur_index, int next_index),
|
||||
DMSetDrawOptions setDrawOptions,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData)
|
||||
{
|
||||
emDM_drawFacesTex_common(dm, NULL, setDrawOptions, compareDrawOptions, userData);
|
||||
@@ -978,8 +978,8 @@ static void emDM_drawMappedFacesTex(
|
||||
|
||||
static void emDM_drawMappedFacesGLSL(
|
||||
DerivedMesh *dm,
|
||||
int (*setMaterial)(int, void *attribs),
|
||||
int (*setDrawOptions)(void *userData, int index),
|
||||
DMSetMaterial setMaterial,
|
||||
DMSetDrawOptions setDrawOptions,
|
||||
void *userData)
|
||||
{
|
||||
EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm;
|
||||
|
||||
@@ -1534,7 +1534,7 @@ static void ccgDM_glNormalFast(float *a, float *b, float *c, float *d)
|
||||
}
|
||||
|
||||
/* Only used by non-editmesh types */
|
||||
static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)[4], int fast, int (*setMaterial)(int, void *attribs))
|
||||
static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)[4], int fast, DMSetMaterial setMaterial)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
@@ -1624,8 +1624,8 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)
|
||||
|
||||
/* Only used by non-editmesh types */
|
||||
static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
|
||||
int (*setMaterial)(int, void *attribs),
|
||||
int (*setDrawOptions)(void *userData, int index),
|
||||
DMSetMaterial setMaterial,
|
||||
DMSetDrawOptions setDrawOptions,
|
||||
void *userData)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
@@ -1764,7 +1764,7 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
|
||||
#undef PASSATTRIB
|
||||
}
|
||||
|
||||
static void ccgDM_drawFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, void *attribs))
|
||||
static void ccgDM_drawFacesGLSL(DerivedMesh *dm, DMSetMaterial setMaterial)
|
||||
{
|
||||
dm->drawMappedFacesGLSL(dm, setMaterial, NULL, NULL);
|
||||
}
|
||||
@@ -1916,9 +1916,9 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void *
|
||||
}
|
||||
|
||||
static void ccgDM_drawFacesTex_common(DerivedMesh *dm,
|
||||
int (*drawParams)(MTFace *tface, int has_mcol, int matnr),
|
||||
int (*drawParamsMapped)(void *userData, int index),
|
||||
int (*compareDrawOptions)(void *userData, int cur_index, int next_index),
|
||||
DMSetDrawOptionsTex drawParams,
|
||||
DMSetDrawOptions drawParamsMapped,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
@@ -2062,16 +2062,16 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm,
|
||||
}
|
||||
|
||||
static void ccgDM_drawFacesTex(DerivedMesh *dm,
|
||||
int (*setDrawOptions)(MTFace *tface, int has_vcol, int matnr),
|
||||
int (*compareDrawOptions)(void *userData, int cur_index, int next_index),
|
||||
DMSetDrawOptionsTex setDrawOptions,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData)
|
||||
{
|
||||
ccgDM_drawFacesTex_common(dm, setDrawOptions, NULL, compareDrawOptions, userData);
|
||||
}
|
||||
|
||||
static void ccgDM_drawMappedFacesTex(DerivedMesh *dm,
|
||||
int (*setDrawOptions)(void *userData, int index),
|
||||
int (*compareDrawOptions)(void *userData, int cur_index, int next_index),
|
||||
DMSetDrawOptions setDrawOptions,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData)
|
||||
{
|
||||
ccgDM_drawFacesTex_common(dm, NULL, setDrawOptions, compareDrawOptions, userData);
|
||||
@@ -2111,9 +2111,9 @@ static void ccgDM_drawUVEdges(DerivedMesh *dm)
|
||||
}
|
||||
|
||||
static void ccgDM_drawMappedFaces(DerivedMesh *dm,
|
||||
int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r),
|
||||
int (*setMaterial)(int, void *attribs),
|
||||
int (*compareDrawOptions)(void *userData, int cur_index, int next_index),
|
||||
DMSetDrawOptionsShading setDrawOptions,
|
||||
DMSetMaterial setMaterial,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData, int useColors)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
@@ -2237,7 +2237,9 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
|
||||
}
|
||||
}
|
||||
|
||||
static void ccgDM_drawMappedEdges(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index), void *userData)
|
||||
static void ccgDM_drawMappedEdges(DerivedMesh *dm,
|
||||
DMSetDrawOptions setDrawOptions,
|
||||
void *userData)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
@@ -2269,7 +2271,10 @@ static void ccgDM_drawMappedEdges(DerivedMesh *dm, int (*setDrawOptions)(void *u
|
||||
ccgEdgeIterator_free(ei);
|
||||
}
|
||||
|
||||
static void ccgDM_drawMappedEdgesInterp(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index), void (*setDrawInterpOptions)(void *userData, int index, float t), void *userData)
|
||||
static void ccgDM_drawMappedEdgesInterp(DerivedMesh *dm,
|
||||
DMSetDrawOptions setDrawOptions,
|
||||
DMSetDrawInterpOptions setDrawInterpOptions,
|
||||
void *userData)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
|
||||
@@ -1560,7 +1560,7 @@ int BLI_pbvh_node_planes_contain_AABB(PBVHNode *node, void *data)
|
||||
}
|
||||
|
||||
void BLI_pbvh_draw(PBVH *bvh, float (*planes)[4], float (*face_nors)[3],
|
||||
int (*setMaterial)(int, void *attribs))
|
||||
DMSetMaterial setMaterial)
|
||||
{
|
||||
PBVHNode **nodes;
|
||||
int totnode;
|
||||
|
||||
@@ -170,7 +170,7 @@ void GPU_update_grid_buffers(GPU_Buffers *buffers, struct DMGridData **grids,
|
||||
const struct DMFlagMat *grid_flag_mats,
|
||||
int *grid_indices, int totgrid, int gridsize);
|
||||
|
||||
void GPU_draw_buffers(GPU_Buffers *buffers, int (*setMaterial)(int, void *attribs));
|
||||
void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial);
|
||||
|
||||
void GPU_free_buffers(GPU_Buffers *buffers);
|
||||
|
||||
|
||||
@@ -1613,7 +1613,7 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth)
|
||||
}
|
||||
}
|
||||
|
||||
void GPU_draw_buffers(GPU_Buffers *buffers, int (*setMaterial)(int, void *attribs))
|
||||
void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial)
|
||||
{
|
||||
int smooth = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user