[Bf-blender-cvs] [42dfbf79c3f] blender2.8: Added BKE_mesh_new()
Sybren A. Stüvel
noreply at git.blender.org
Tue May 8 10:47:11 CEST 2018
Commit: 42dfbf79c3f850a7a5d4ec01e7467505c316461b
Author: Sybren A. Stüvel
Date: Fri May 4 11:42:55 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB42dfbf79c3f850a7a5d4ec01e7467505c316461b
Added BKE_mesh_new()
This function creates a Mesh struct with a number of vertices/edges/etc.
It allocates the minimal number of CD layers needed.
Currently not yet used, but will be soon in the upcoming
BKE_new_mesh_from_curve_displist().
===================================================================
M source/blender/blenkernel/BKE_mesh.h
M source/blender/blenkernel/intern/mesh.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index afb087ed822..41b2b875d9a 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -101,6 +101,7 @@ struct Mesh *BKE_mesh_copy(struct Main *bmain, const struct Mesh *me);
void BKE_mesh_update_customdata_pointers(struct Mesh *me, const bool do_ensure_tess_cd);
void BKE_mesh_ensure_skin_customdata(struct Mesh *me);
+struct Mesh *BKE_mesh_new(int numVerts, int numEdges, int numTessFaces,int numLoops, int numPolys);
struct Mesh * BKE_mesh_from_template(
const struct Mesh *me_src,
int numVerts, int numEdges, int numTessFaces,
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 3163ea6551e..177a8433eab 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -51,6 +51,7 @@
#include "BKE_main.h"
#include "BKE_DerivedMesh.h"
#include "BKE_global.h"
+#include "BKE_idcode.h"
#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
#include "BKE_displist.h"
@@ -614,6 +615,42 @@ void BKE_mesh_copy_data(Main *bmain, Mesh *me_dst, const Mesh *me_src, const int
}
}
+Mesh *BKE_mesh_new(int numVerts, int numEdges, int numTessFaces,int numLoops, int numPolys)
+{
+ Mesh *mesh = BKE_libblock_alloc(NULL, ID_ME,
+ BKE_idcode_to_name(ID_ME),
+ LIB_ID_CREATE_NO_MAIN |
+ LIB_ID_CREATE_NO_USER_REFCOUNT |
+ LIB_ID_CREATE_NO_DEG_TAG);
+ BKE_libblock_init_empty(&mesh->id);
+
+ /* don't use CustomData_reset(...); because we dont want to touch customdata */
+ copy_vn_i(mesh->vdata.typemap, CD_NUMTYPES, -1);
+ copy_vn_i(mesh->edata.typemap, CD_NUMTYPES, -1);
+ copy_vn_i(mesh->fdata.typemap, CD_NUMTYPES, -1);
+ copy_vn_i(mesh->ldata.typemap, CD_NUMTYPES, -1);
+ copy_vn_i(mesh->pdata.typemap, CD_NUMTYPES, -1);
+
+ CustomData_add_layer(&mesh->vdata, CD_ORIGINDEX, CD_CALLOC, NULL, numVerts);
+ CustomData_add_layer(&mesh->edata, CD_ORIGINDEX, CD_CALLOC, NULL, numEdges);
+ CustomData_add_layer(&mesh->fdata, CD_ORIGINDEX, CD_CALLOC, NULL, numTessFaces);
+ CustomData_add_layer(&mesh->pdata, CD_ORIGINDEX, CD_CALLOC, NULL, numPolys);
+
+ CustomData_add_layer(&mesh->vdata, CD_MVERT, CD_CALLOC, NULL, numVerts);
+ CustomData_add_layer(&mesh->edata, CD_MEDGE, CD_CALLOC, NULL, numEdges);
+ CustomData_add_layer(&mesh->fdata, CD_MFACE, CD_CALLOC, NULL, numTessFaces);
+ CustomData_add_layer(&mesh->ldata, CD_MLOOP, CD_CALLOC, NULL, numLoops);
+ CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_CALLOC, NULL, numPolys);
+
+ mesh->mvert = CustomData_get_layer(&mesh->vdata, CD_MVERT);
+ mesh->medge = CustomData_get_layer(&mesh->edata, CD_MEDGE);
+ mesh->mface = CustomData_get_layer(&mesh->fdata, CD_MFACE);
+ mesh->mloop = CustomData_get_layer(&mesh->ldata, CD_MLOOP);
+ mesh->mpoly = CustomData_get_layer(&mesh->pdata, CD_MPOLY);
+
+ return mesh;
+}
+
static Mesh *mesh_from_template_ex(
const Mesh *me_src,
int numVerts, int numEdges, int numTessFaces,
More information about the Bf-blender-cvs
mailing list