diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-07-15 05:08:32 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-07-15 05:08:32 +0300 |
commit | 7407ed7637da4148127cfb5e7a4de6dab01c5b1c (patch) | |
tree | 692be5effc9e62fd30d34705a7b2cef93d8446de /source/blender/blenkernel/intern/cdderivedmesh.c | |
parent | 52fa5b12e10354adbb3541c0e9106620fe16d2fc (diff) |
Cleanup: ws
Diffstat (limited to 'source/blender/blenkernel/intern/cdderivedmesh.c')
-rw-r--r-- | source/blender/blenkernel/intern/cdderivedmesh.c | 162 |
1 files changed, 92 insertions, 70 deletions
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 9838d1d96f1..b493931b025 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -212,9 +212,10 @@ static const MeshElemMap *cdDM_getPolyMap(Object *ob, DerivedMesh *dm) if (!cddm->pmap && ob->type == OB_MESH) { Mesh *me = ob->data; - BKE_mesh_vert_poly_map_create(&cddm->pmap, &cddm->pmap_mem, - me->mpoly, me->mloop, - me->totvert, me->totpoly, me->totloop); + BKE_mesh_vert_poly_map_create( + &cddm->pmap, &cddm->pmap_mem, + me->mpoly, me->mloop, + me->totvert, me->totpoly, me->totloop); } return cddm->pmap; @@ -430,9 +431,10 @@ static void cdDM_drawLooseEdges(DerivedMesh *dm) GPU_buffer_unbind(); } -static void cdDM_drawFacesSolid(DerivedMesh *dm, - float (*partial_redraw_planes)[4], - bool UNUSED(fast), DMSetMaterial setMaterial) +static void cdDM_drawFacesSolid( + DerivedMesh *dm, + float (*partial_redraw_planes)[4], + bool UNUSED(fast), DMSetMaterial setMaterial) { CDDerivedMesh *cddm = (CDDerivedMesh *) dm; int a; @@ -455,7 +457,9 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm, glShadeModel(GL_SMOOTH); for (a = 0; a < dm->drawObject->totmaterial; a++) { if (!setMaterial || setMaterial(dm->drawObject->materials[a].mat_nr + 1, NULL)) { - GPU_buffer_draw_elements(dm->drawObject->triangles, GL_TRIANGLES, dm->drawObject->materials[a].start, dm->drawObject->materials[a].totelements); + GPU_buffer_draw_elements( + dm->drawObject->triangles, GL_TRIANGLES, + dm->drawObject->materials[a].start, dm->drawObject->materials[a].totelements); } } GPU_buffer_unbind(); @@ -463,11 +467,12 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm, glShadeModel(GL_FLAT); } -static void cdDM_drawFacesTex_common(DerivedMesh *dm, - DMSetDrawOptionsTex drawParams, - DMSetDrawOptionsMappedTex drawParamsMapped, - DMCompareDrawOptions compareDrawOptions, - void *userData, DMDrawFlag uvflag) +static void cdDM_drawFacesTex_common( + DerivedMesh *dm, + DMSetDrawOptionsTex drawParams, + DMSetDrawOptionsMappedTex drawParamsMapped, + DMCompareDrawOptions compareDrawOptions, + void *userData, DMDrawFlag uvflag) { CDDerivedMesh *cddm = (CDDerivedMesh *) dm; const MFace *mf = DM_get_tessface_data_layer(dm, CD_MFACE); @@ -613,19 +618,21 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, } -static void cdDM_drawFacesTex(DerivedMesh *dm, - DMSetDrawOptionsTex setDrawOptions, - DMCompareDrawOptions compareDrawOptions, - void *userData, DMDrawFlag uvflag) +static void cdDM_drawFacesTex( + DerivedMesh *dm, + DMSetDrawOptionsTex setDrawOptions, + DMCompareDrawOptions compareDrawOptions, + void *userData, DMDrawFlag uvflag) { cdDM_drawFacesTex_common(dm, setDrawOptions, NULL, compareDrawOptions, userData, uvflag); } -static void cdDM_drawMappedFaces(DerivedMesh *dm, - DMSetDrawOptions setDrawOptions, - DMSetMaterial setMaterial, - DMCompareDrawOptions compareDrawOptions, - void *userData, DMDrawFlag flag) +static void cdDM_drawMappedFaces( + DerivedMesh *dm, + DMSetDrawOptions setDrawOptions, + DMSetMaterial setMaterial, + DMCompareDrawOptions compareDrawOptions, + void *userData, DMDrawFlag flag) { CDDerivedMesh *cddm = (CDDerivedMesh *) dm; MVert *mv = cddm->mvert; @@ -782,7 +789,7 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, /* just draw the entire face array */ GPU_buffer_draw_elements(dm->drawObject->triangles, GL_TRIANGLES, 0, tottri); } - else { + else { for (mat_index = 0; mat_index < dm->drawObject->totmaterial; mat_index++) { GPUBufferMaterial *bufmat = dm->drawObject->materials + mat_index; DMDrawOption draw_option = DM_DRAW_OPTION_NORMAL; @@ -856,10 +863,11 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, } } -static void cdDM_drawMappedFacesTex(DerivedMesh *dm, - DMSetDrawOptionsMappedTex setDrawOptions, - DMCompareDrawOptions compareDrawOptions, - void *userData, DMDrawFlag flag) +static void cdDM_drawMappedFacesTex( + DerivedMesh *dm, + DMSetDrawOptionsMappedTex setDrawOptions, + DMCompareDrawOptions compareDrawOptions, + void *userData, DMDrawFlag flag) { cdDM_drawFacesTex_common(dm, NULL, setDrawOptions, compareDrawOptions, userData, flag); } @@ -888,10 +896,11 @@ typedef struct { GPUAttrib datatypes[GPU_MAX_ATTRIB]; /* TODO, messing up when switching materials many times - [#21056]*/ } GPUMaterialConv; -static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, - DMSetMaterial setMaterial, - DMSetDrawOptions setDrawOptions, - void *userData) +static void cdDM_drawMappedFacesGLSL( + DerivedMesh *dm, + DMSetMaterial setMaterial, + DMSetDrawOptions setDrawOptions, + void *userData) { CDDerivedMesh *cddm = (CDDerivedMesh *) dm; GPUVertexAttribs gattribs; @@ -1201,9 +1210,10 @@ static void cdDM_drawFacesGLSL(DerivedMesh *dm, DMSetMaterial setMaterial) dm->drawMappedFacesGLSL(dm, setMaterial, NULL, NULL); } -static void cdDM_drawMappedFacesMat(DerivedMesh *dm, - void (*setMaterial)(void *userData, int matnr, void *attribs), - bool (*setFace)(void *userData, int index), void *userData) +static void cdDM_drawMappedFacesMat( + DerivedMesh *dm, + void (*setMaterial)(void *userData, int matnr, void *attribs), + bool (*setFace)(void *userData, int index), void *userData) { CDDerivedMesh *cddm = (CDDerivedMesh *) dm; GPUVertexAttribs gattribs; @@ -2030,10 +2040,11 @@ void CDDM_recalc_tessellation_ex(DerivedMesh *dm, const bool do_face_nor_cpy) { CDDerivedMesh *cddm = (CDDerivedMesh *)dm; - dm->numTessFaceData = BKE_mesh_recalc_tessellation(&dm->faceData, &dm->loopData, &dm->polyData, - cddm->mvert, - dm->numTessFaceData, dm->numLoopData, dm->numPolyData, - do_face_nor_cpy); + dm->numTessFaceData = BKE_mesh_recalc_tessellation( + &dm->faceData, &dm->loopData, &dm->polyData, + cddm->mvert, + dm->numTessFaceData, dm->numLoopData, dm->numPolyData, + do_face_nor_cpy); cddm->mface = CustomData_get_layer(&dm->faceData, CD_MFACE); @@ -2231,9 +2242,10 @@ DerivedMesh *CDDM_from_curve_displist(Object *ob, ListBase *dispbase) int totvert, totedge, totloop, totpoly; bool use_orco_uv = (cu->flag & CU_UV_ORCO) != 0; - if (BKE_mesh_nurbs_displist_to_mdata(ob, dispbase, &allvert, &totvert, &alledge, - &totedge, &allloop, &allpoly, (use_orco_uv) ? &alluv : NULL, - &totloop, &totpoly) != 0) + if (BKE_mesh_nurbs_displist_to_mdata( + ob, dispbase, &allvert, &totvert, &alledge, + &totedge, &allloop, &allpoly, (use_orco_uv) ? &alluv : NULL, + &totloop, &totpoly) != 0) { /* Error initializing mdata. This often happens when curve is empty */ return CDDM_new(0, 0, 0, 0, 0); @@ -2264,9 +2276,10 @@ DerivedMesh *CDDM_from_curve_displist(Object *ob, ListBase *dispbase) return dm; } -static void loops_to_customdata_corners(BMesh *bm, CustomData *facedata, - int cdindex, const BMLoop *l3[3], - int numCol, int numTex) +static void loops_to_customdata_corners( + BMesh *bm, CustomData *facedata, + int cdindex, const BMLoop *l3[3], + int numCol, int numTex) { const BMLoop *l; BMFace *f = l3[0]->f; @@ -2312,11 +2325,11 @@ static void loops_to_customdata_corners(BMesh *bm, CustomData *facedata, } /* used for both editbmesh and bmesh */ -static DerivedMesh *cddm_from_bmesh_ex(struct BMesh *bm, const bool use_mdisps, - /* EditBMesh vars for use_tessface */ - const bool use_tessface, - const int em_tottri, const BMLoop *(*em_looptris)[3] - ) +static DerivedMesh *cddm_from_bmesh_ex( + struct BMesh *bm, const bool use_mdisps, + /* EditBMesh vars for use_tessface */ + const bool use_tessface, + const int em_tottri, const BMLoop *(*em_looptris)[3]) { DerivedMesh *dm = CDDM_new(bm->totvert, bm->totedge, @@ -2481,16 +2494,18 @@ static DerivedMesh *cddm_from_bmesh_ex(struct BMesh *bm, const bool use_mdisps, struct DerivedMesh *CDDM_from_bmesh(struct BMesh *bm, const bool use_mdisps) { - return cddm_from_bmesh_ex(bm, use_mdisps, false, - /* these vars are for editmesh only */ - 0, NULL); + return cddm_from_bmesh_ex( + bm, use_mdisps, false, + /* these vars are for editmesh only */ + 0, NULL); } DerivedMesh *CDDM_from_editbmesh(BMEditMesh *em, const bool use_mdisps, const bool use_tessface) { - return cddm_from_bmesh_ex(em->bm, use_mdisps, - /* editmesh */ - use_tessface, em->tottri, (const BMLoop *(*)[3])em->looptris); + return cddm_from_bmesh_ex( + em->bm, use_mdisps, + /* editmesh */ + use_tessface, em->tottri, (const BMLoop *(*)[3])em->looptris); } static DerivedMesh *cddm_copy_ex(DerivedMesh *source, int faces_from_tessfaces) @@ -2552,9 +2567,10 @@ DerivedMesh *CDDM_copy_from_tessface(DerivedMesh *source) /* note, the CD_ORIGINDEX layers are all 0, so if there is a direct * relationship between mesh data this needs to be set by the caller. */ -DerivedMesh *CDDM_from_template(DerivedMesh *source, - int numVerts, int numEdges, int numTessFaces, - int numLoops, int numPolys) +DerivedMesh *CDDM_from_template( + DerivedMesh *source, + int numVerts, int numEdges, int numTessFaces, + int numLoops, int numPolys) { CDDerivedMesh *cddm = cdDM_create("CDDM_from_template dest"); DerivedMesh *dm = &cddm->dm; @@ -2660,10 +2676,11 @@ void CDDM_calc_normals_mapping_ex(DerivedMesh *dm, const bool only_face_normals) face_nors = MEM_mallocN(sizeof(*face_nors) * dm->numTessFaceData, "face_nors"); /* calculate face normals */ - BKE_mesh_calc_normals_mapping_ex(cddm->mvert, dm->numVertData, CDDM_get_loops(dm), CDDM_get_polys(dm), - dm->numLoopData, dm->numPolyData, NULL, cddm->mface, dm->numTessFaceData, - CustomData_get_layer(&dm->faceData, CD_ORIGINDEX), face_nors, - only_face_normals); + BKE_mesh_calc_normals_mapping_ex( + cddm->mvert, dm->numVertData, CDDM_get_loops(dm), CDDM_get_polys(dm), + dm->numLoopData, dm->numPolyData, NULL, cddm->mface, dm->numTessFaceData, + CustomData_get_layer(&dm->faceData, CD_ORIGINDEX), face_nors, + only_face_normals); CustomData_add_layer(&dm->faceData, CD_NORMAL, CD_ASSIGN, face_nors, dm->numTessFaceData); @@ -2833,7 +2850,10 @@ void CDDM_calc_normals_tessface(DerivedMesh *dm) * and may be called again with direct_reverse=-1 for reverse order. * \return 1 if polys are identical, 0 if polys are different. */ -static int cddm_poly_compare(MLoop *mloop_array, MPoly *mpoly_source, MPoly *mpoly_target, const int *vtargetmap, const int direct_reverse) +static int cddm_poly_compare( + MLoop *mloop_array, + MPoly *mpoly_source, MPoly *mpoly_target, + const int *vtargetmap, const int direct_reverse) { int vert_source, first_vert_source, vert_target; int i_loop_source; @@ -3295,7 +3315,8 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap, const int } /*create new cddm*/ - cddm2 = (CDDerivedMesh *) CDDM_from_template((DerivedMesh *)cddm, STACK_SIZE(mvert), STACK_SIZE(medge), 0, STACK_SIZE(mloop), STACK_SIZE(mpoly)); + cddm2 = (CDDerivedMesh *)CDDM_from_template(( + DerivedMesh *)cddm, STACK_SIZE(mvert), STACK_SIZE(medge), 0, STACK_SIZE(mloop), STACK_SIZE(mpoly)); /*update edge indices and copy customdata*/ med = medge; @@ -3612,12 +3633,13 @@ void CDDM_tessfaces_to_faces(DerivedMesh *dm) /* converts mfaces to mpolys/mloops */ CDDerivedMesh *cddm = (CDDerivedMesh *)dm; - BKE_mesh_convert_mfaces_to_mpolys_ex(NULL, &cddm->dm.faceData, &cddm->dm.loopData, &cddm->dm.polyData, - cddm->dm.numEdgeData, cddm->dm.numTessFaceData, - cddm->dm.numLoopData, cddm->dm.numPolyData, - cddm->medge, cddm->mface, - &cddm->dm.numLoopData, &cddm->dm.numPolyData, - &cddm->mloop, &cddm->mpoly); + BKE_mesh_convert_mfaces_to_mpolys_ex( + NULL, &cddm->dm.faceData, &cddm->dm.loopData, &cddm->dm.polyData, + cddm->dm.numEdgeData, cddm->dm.numTessFaceData, + cddm->dm.numLoopData, cddm->dm.numPolyData, + cddm->medge, cddm->mface, + &cddm->dm.numLoopData, &cddm->dm.numPolyData, + &cddm->mloop, &cddm->mpoly); } void CDDM_set_mvert(DerivedMesh *dm, MVert *mvert) @@ -3626,7 +3648,7 @@ void CDDM_set_mvert(DerivedMesh *dm, MVert *mvert) if (!CustomData_has_layer(&dm->vertData, CD_MVERT)) CustomData_add_layer(&dm->vertData, CD_MVERT, CD_ASSIGN, mvert, dm->numVertData); - + cddm->mvert = mvert; } |