Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@stuvel.eu>2018-05-04 12:42:55 +0300
committerSybren A. Stüvel <sybren@stuvel.eu>2018-05-08 11:47:00 +0300
commit42dfbf79c3f850a7a5d4ec01e7467505c316461b (patch)
treee6a38be63a6999a58e0bc1cfb484bbe89999444e /source
parentf309c34cfe050c4567e1af7825bed4eacb0d8302 (diff)
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().
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_mesh.h1
-rw-r--r--source/blender/blenkernel/intern/mesh.c37
2 files changed, 38 insertions, 0 deletions
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,