diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-12-20 12:47:36 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-12-20 12:47:36 +0400 |
commit | 2f9925f9137ada4a88f8a619e6a95221b6690dfb (patch) | |
tree | 1a012d46892abc00c65840021289e6f6c58b634a /source/blender/editors/space_view3d/drawmesh.c | |
parent | 0be004bb2ff380c41365506ae3d8488ff2691a85 (diff) |
Get rid of hardcoded structure definition in DM drawing callbacks
Structures passing to DM callbacks as userData used to be defined in both callee
and callbacks itself which made it difficult and unsafe to add new properties
to user data.
Added typedefs for this structures and use them in callbacks and callee functions.
Diffstat (limited to 'source/blender/editors/space_view3d/drawmesh.c')
-rw-r--r-- | source/blender/editors/space_view3d/drawmesh.c | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 6dd362b827f..e0b1741b0d0 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -70,6 +70,25 @@ #include "view3d_intern.h" // own include +/* user data structures for derived mesh callbacks */ +typedef struct drawMeshFaceSelect_userData { + Mesh *me; + EdgeHash *eh; +} drawMeshFaceSelect_userData; + +typedef struct drawEMTFMapped_userData { + EditMesh *em; + short has_mcol; + short has_mtface; + MFace *mf; + MTFace *tf; +} drawEMTFMapped_userData; + +typedef struct drawTFace_userData { + MFace *mf; + MTFace *tf; +} drawTFace_userData; + /**************************** Face Select Mode *******************************/ /* Flags for marked edges */ @@ -121,7 +140,7 @@ static EdgeHash *get_tface_mesh_marked_edge_info(Mesh *me) static int draw_mesh_face_select__setHiddenOpts(void *userData, int index) { - struct { Mesh *me; EdgeHash *eh; } *data = userData; + drawMeshFaceSelect_userData *data = userData; Mesh *me= data->me; MEdge *med = &me->medge[index]; uintptr_t flags = (intptr_t) BLI_edgehash_lookup(data->eh, med->v1, med->v2); @@ -138,7 +157,7 @@ static int draw_mesh_face_select__setHiddenOpts(void *userData, int index) static int draw_mesh_face_select__setSelectOpts(void *userData, int index) { - struct { Mesh *me; EdgeHash *eh; } *data = userData; + drawMeshFaceSelect_userData *data = userData; MEdge *med = &data->me->medge[index]; uintptr_t flags = (intptr_t) BLI_edgehash_lookup(data->eh, med->v1, med->v2); @@ -159,7 +178,7 @@ static int draw_mesh_face_select__drawFaceOptsInv(void *userData, int index) static void draw_mesh_face_select(RegionView3D *rv3d, Mesh *me, DerivedMesh *dm) { - struct { Mesh *me; EdgeHash *eh; } data; + drawMeshFaceSelect_userData data; data.me = me; data.eh = get_tface_mesh_marked_edge_info(me); @@ -513,7 +532,7 @@ static int draw_tface_mapped__set_draw(void *userData, int index) static int draw_em_tf_mapped__set_draw(void *userData, int index) { - struct {EditMesh *em; short has_mcol; short has_mtface; MFace *mf; MTFace *tf;} *data = userData; + drawEMTFMapped_userData *data = userData; EditMesh *em = data->em; EditFace *efa= EM_get_face_for_index(index); MTFace *tface; @@ -631,7 +650,7 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl) static int compareDrawOptions(void *userData, int cur_index, int next_index) { - struct { MFace *mf; MTFace *tf; } *data = userData; + drawTFace_userData *data = userData; if(data->mf && data->mf[cur_index].mat_nr != data->mf[next_index].mat_nr) return 0; @@ -644,7 +663,7 @@ static int compareDrawOptions(void *userData, int cur_index, int next_index) static int compareDrawOptionsEm(void *userData, int cur_index, int next_index) { - struct {EditMesh *em; short has_mcol; short has_mtface; MFace *mf; MTFace *tf;} *data= userData; + drawEMTFMapped_userData *data= userData; if(data->mf && data->mf[cur_index].mat_nr != data->mf[next_index].mat_nr) return 0; @@ -669,7 +688,7 @@ void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec glColor4f(1.0f,1.0f,1.0f,1.0f); if(ob->mode & OB_MODE_EDIT) { - struct {EditMesh *em; short has_mcol; short has_mtface; MFace *mf; MTFace *tf;} data; + drawEMTFMapped_userData data; data.em= me->edit_mesh; data.has_mcol= CustomData_has_layer(&me->edit_mesh->fdata, CD_MCOL); @@ -693,7 +712,7 @@ void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec dm->drawFacesTex(dm, draw_tface__set_draw_legacy, NULL, NULL); } else { - struct { MFace *mf; MTFace *tf; } userData; + drawTFace_userData userData; if(!CustomData_has_layer(&dm->faceData,CD_TEXTURE_MCOL)) add_tface_color_layer(dm); |