[Bf-blender-cvs] [8e2e44b58b3] master: Cleanup: Move mesh_convert.c to C++
Hans Goudey
noreply at git.blender.org
Thu Sep 16 22:45:10 CEST 2021
Commit: 8e2e44b58b3a48d7fe7c1d5946ec6e0f3001ab1e
Author: Hans Goudey
Date: Thu Sep 16 15:44:43 2021 -0500
Branches: master
https://developer.blender.org/rB8e2e44b58b3a48d7fe7c1d5946ec6e0f3001ab1e
Cleanup: Move mesh_convert.c to C++
This should allow easier changes when it's helpful to use C++ types.
The diff is for a test on the buildbot.
Differential Revision: https://developer.blender.org/D12528
===================================================================
M source/blender/blenkernel/CMakeLists.txt
R085 source/blender/blenkernel/intern/mesh_convert.c source/blender/blenkernel/intern/mesh_convert.cc
===================================================================
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 26d81ec3b34..0b082bf1c5a 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -186,7 +186,7 @@ set(SRC
intern/mball_tessellate.c
intern/mesh.c
intern/mesh_boolean_convert.cc
- intern/mesh_convert.c
+ intern/mesh_convert.cc
intern/mesh_evaluate.cc
intern/mesh_fair.cc
intern/mesh_iterators.c
diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.cc
similarity index 85%
rename from source/blender/blenkernel/intern/mesh_convert.c
rename to source/blender/blenkernel/intern/mesh_convert.cc
index 50c80f8d0a4..07dc6db05aa 100644
--- a/source/blender/blenkernel/intern/mesh_convert.c
+++ b/source/blender/blenkernel/intern/mesh_convert.cc
@@ -68,7 +68,7 @@
#ifdef VALIDATE_MESH
# define ASSERT_IS_VALID_MESH(mesh) \
- (BLI_assert((mesh == NULL) || (BKE_mesh_is_valid(mesh) == true)))
+ (BLI_assert((mesh == nullptr) || (BKE_mesh_is_valid(mesh) == true)))
#else
# define ASSERT_IS_VALID_MESH(mesh)
#endif
@@ -84,15 +84,16 @@ void BKE_mesh_from_metaball(ListBase *lb, Mesh *me)
const float *nors, *verts;
int a, *index;
- dl = lb->first;
- if (dl == NULL) {
+ dl = (DispList *)lb->first;
+ if (dl == nullptr) {
return;
}
if (dl->type == DL_INDEX4) {
- mvert = CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, dl->nr);
- allloop = mloop = CustomData_add_layer(&me->ldata, CD_MLOOP, CD_CALLOC, NULL, dl->parts * 4);
- mpoly = CustomData_add_layer(&me->pdata, CD_MPOLY, CD_CALLOC, NULL, dl->parts);
+ mvert = (MVert *)CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, nullptr, dl->nr);
+ allloop = mloop = (MLoop *)CustomData_add_layer(
+ &me->ldata, CD_MLOOP, CD_CALLOC, nullptr, dl->parts * 4);
+ mpoly = (MPoly *)CustomData_add_layer(&me->pdata, CD_MPOLY, CD_CALLOC, nullptr, dl->parts);
me->mvert = mvert;
me->mloop = mloop;
me->mpoly = mpoly;
@@ -177,9 +178,10 @@ static void make_edges_mdata_extend(
MEdge *medge;
uint e_index = totedge;
- *r_alledge = medge = (*r_alledge ?
- MEM_reallocN(*r_alledge, sizeof(MEdge) * (totedge + totedge_new)) :
- MEM_calloc_arrayN(totedge_new, sizeof(MEdge), __func__));
+ *r_alledge = medge = (MEdge *)(*r_alledge ?
+ MEM_reallocN(*r_alledge,
+ sizeof(MEdge) * (totedge + totedge_new)) :
+ MEM_calloc_arrayN(totedge_new, sizeof(MEdge), __func__));
medge += totedge;
totedge += totedge_new;
@@ -209,7 +211,7 @@ static void make_edges_mdata_extend(
}
}
- BLI_edgehash_free(eh, NULL);
+ BLI_edgehash_free(eh, nullptr);
}
/* Initialize mverts, medges and, faces for converting nurbs to mesh and derived mesh */
@@ -229,7 +231,7 @@ static int mesh_nurbs_displist_to_mdata(const Curve *cu,
MVert *mvert;
MPoly *mpoly;
MLoop *mloop;
- MLoopUV *mloopuv = NULL;
+ MLoopUV *mloopuv = nullptr;
MEdge *medge;
const float *data;
int a, b, ofs, vertcount, startvert, totvert = 0, totedge = 0, totloop = 0, totpoly = 0;
@@ -277,14 +279,15 @@ static int mesh_nurbs_displist_to_mdata(const Curve *cu,
return -1;
}
- *r_allvert = mvert = MEM_calloc_arrayN(totvert, sizeof(MVert), "nurbs_init mvert");
- *r_alledge = medge = MEM_calloc_arrayN(totedge, sizeof(MEdge), "nurbs_init medge");
- *r_allloop = mloop = MEM_calloc_arrayN(
+ *r_allvert = mvert = (MVert *)MEM_calloc_arrayN(totvert, sizeof(MVert), "nurbs_init mvert");
+ *r_alledge = medge = (MEdge *)MEM_calloc_arrayN(totedge, sizeof(MEdge), "nurbs_init medge");
+ *r_allloop = mloop = (MLoop *)MEM_calloc_arrayN(
totpoly, sizeof(MLoop[4]), "nurbs_init mloop"); /* totloop */
- *r_allpoly = mpoly = MEM_calloc_arrayN(totpoly, sizeof(MPoly), "nurbs_init mloop");
+ *r_allpoly = mpoly = (MPoly *)MEM_calloc_arrayN(totpoly, sizeof(MPoly), "nurbs_init mloop");
if (r_alluv) {
- *r_alluv = mloopuv = MEM_calloc_arrayN(totpoly, sizeof(MLoopUV[4]), "nurbs_init mloopuv");
+ *r_alluv = mloopuv = (MLoopUV *)MEM_calloc_arrayN(
+ totpoly, sizeof(MLoopUV[4]), "nurbs_init mloopuv");
}
/* verts and faces */
@@ -500,13 +503,13 @@ static void mesh_copy_texture_space_from_curve_type(const Curve *cu, Mesh *me)
Mesh *BKE_mesh_new_nomain_from_curve_displist(const Object *ob, const ListBase *dispbase)
{
- const Curve *cu = ob->data;
+ const Curve *cu = (const Curve *)ob->data;
Mesh *mesh;
MVert *allvert;
MEdge *alledge;
MLoop *allloop;
MPoly *allpoly;
- MLoopUV *alluv = NULL;
+ MLoopUV *alluv = nullptr;
int totvert, totedge, totloop, totpoly;
if (mesh_nurbs_displist_to_mdata(cu,
@@ -561,7 +564,7 @@ Mesh *BKE_mesh_new_nomain_from_curve_displist(const Object *ob, const ListBase *
Mesh *BKE_mesh_new_nomain_from_curve(const Object *ob)
{
- ListBase disp = {NULL, NULL};
+ ListBase disp = {nullptr, nullptr};
if (ob->runtime.curve_cache) {
disp = ob->runtime.curve_cache->disp;
@@ -578,16 +581,16 @@ static void mesh_from_nurbs_displist(Object *ob, ListBase *dispbase, const char
Mesh *me_eval = (Mesh *)ob->runtime.data_eval;
Mesh *me;
- MVert *allvert = NULL;
- MEdge *alledge = NULL;
- MLoop *allloop = NULL;
- MLoopUV *alluv = NULL;
- MPoly *allpoly = NULL;
+ MVert *allvert = nullptr;
+ MEdge *alledge = nullptr;
+ MLoop *allloop = nullptr;
+ MLoopUV *alluv = nullptr;
+ MPoly *allpoly = nullptr;
int totvert, totedge, totloop, totpoly;
- Curve *cu = ob->data;
+ Curve *cu = (Curve *)ob->data;
- if (me_eval == NULL) {
+ if (me_eval == nullptr) {
if (mesh_nurbs_displist_to_mdata(cu,
dispbase,
&allvert,
@@ -604,30 +607,34 @@ static void mesh_from_nurbs_displist(Object *ob, ListBase *dispbase, const char
}
/* make mesh */
- me = BKE_id_new_nomain(ID_ME, obdata_name);
+ me = (Mesh *)BKE_id_new_nomain(ID_ME, obdata_name);
me->totvert = totvert;
me->totedge = totedge;
me->totloop = totloop;
me->totpoly = totpoly;
- me->mvert = CustomData_add_layer(&me->vdata, CD_MVERT, CD_ASSIGN, allvert, me->totvert);
- me->medge = CustomData_add_layer(&me->edata, CD_MEDGE, CD_ASSIGN, alledge, me->totedge);
- me->mloop = CustomData_add_layer(&me->ldata, CD_MLOOP, CD_ASSIGN, allloop, me->totloop);
- me->mpoly = CustomData_add_layer(&me->pdata, CD_MPOLY, CD_ASSIGN, allpoly, me->totpoly);
+ me->mvert = (MVert *)CustomData_add_layer(
+ &me->vdata, CD_MVERT, CD_ASSIGN, allvert, me->totvert);
+ me->medge = (MEdge *)CustomData_add_layer(
+ &me->edata, CD_MEDGE, CD_ASSIGN, alledge, me->totedge);
+ me->mloop = (MLoop *)CustomData_add_layer(
+ &me->ldata, CD_MLOOP, CD_ASSIGN, allloop, me->totloop);
+ me->mpoly = (MPoly *)CustomData_add_layer(
+ &me->pdata, CD_MPOLY, CD_ASSIGN, allpoly, me->totpoly);
if (alluv) {
const char *uvname = "UVMap";
- me->mloopuv = CustomData_add_layer_named(
+ me->mloopuv = (MLoopUV *)CustomData_add_layer_named(
&me->ldata, CD_MLOOPUV, CD_ASSIGN, alluv, me->totloop, uvname);
}
BKE_mesh_calc_normals(me);
}
else {
- me = BKE_id_new_nomain(ID_ME, obdata_name);
+ me = (Mesh *)BKE_id_new_nomain(ID_ME, obdata_name);
- ob->runtime.data_eval = NULL;
+ ob->runtime.data_eval = nullptr;
BKE_mesh_nomain_to_mesh(me_eval, me, ob, &CD_MASK_MESH, true);
}
@@ -636,7 +643,7 @@ static void mesh_from_nurbs_displist(Object *ob, ListBase *dispbase, const char
mesh_copy_texture_space_from_curve_type(cu, me);
- cu->mat = NULL;
+ cu->mat = nullptr;
cu->totcol = 0;
/* Do not decrement ob->data usercount here,
@@ -647,29 +654,29 @@ static void mesh_from_nurbs_displist(Object *ob, ListBase *dispbase, const char
/* For temporary objects in BKE_mesh_new_from_object don't remap
* the entire scene with associated depsgraph updates, which are
* problematic for renderers exporting data. */
- BKE_id_free(NULL, cu);
+ BKE_id_free(nullptr, cu);
}
-typedef struct EdgeLink {
+struct EdgeLink {
struct EdgeLink *next, *prev;
void *edge;
-} EdgeLink;
+};
-typedef struct VertLink {
+struct VertLink {
Link *next, *prev;
uint index;
-} VertLink;
+};
static void prependPolyLineVert(ListBase *lb, uint index)
{
- VertLink *vl = MEM_callocN(sizeof(VertLink), "VertLink");
+ VertLink *vl = (VertLink *)MEM_callocN(sizeof(VertLink), "VertLink");
vl->index = index;
BLI_addhead(lb, vl);
}
static void appendPolyLineVert(ListBase *lb, uint index)
{
- VertLink *vl = MEM_callocN(sizeof(VertLink), "VertLink");
+ VertLink *vl = (VertLink *)MEM_callocN(sizeof(VertLink), "VertLink");
vl->index = index;
BLI_addtail(lb, vl);
}
@@ -689,10 +696,10 @@ void BKE_mesh_to_curve_nurblist(const Mesh *me, ListBase *nurblist, const int ed
/* only to detect edge polylines */
int *edge_users;
- ListBase edges = {NULL, NULL};
+ ListBase edges = {nullptr, nullptr};
/* get boundary edges */
- edge_users = MEM_calloc_arrayN(medge_len, sizeof(int), __func__);
+ edge_users = (int *)MEM_calloc_arrayN(medge_len, sizeof(int), __func__);
for (i = 0, mp = mpoly; i < mpoly_len; i++, mp++) {
MLoop *ml = &mloop[mp->loopstart];
int j;
@@ -705,7 +712,7 @@ void BKE_mesh_to_curve_nurblist(const Mesh *me, ListBase *nurblist, const int ed
med = medge;
for (i = 0; i < medge_len; i++, med++) {
if (edge_users[i] == edge_users_test) {
- EdgeLink *edl = MEM_callocN(sizeof(EdgeLink), "EdgeLink");
+ EdgeLink *edl = (EdgeLink *)MEM_callocN(sizeof(EdgeLink), "EdgeLink");
edl->edge = med;
BLI_addtail(&edges, edl);
@@ -718,10 +725,10 @@ void BKE_mesh_to_curve_nurblist(const Mesh *me, ListBase *nurblist, const int ed
while (edges.first) {
/* each iteration find a polyline and add this as a nurbs poly spline */
- ListBase polyline = {NULL, NULL}; /* store a list of VertLink's */
+ ListBase po
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list