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
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/mesh/mesh_data.c')
-rw-r--r--source/blender/editors/mesh/mesh_data.c286
1 files changed, 221 insertions, 65 deletions
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index ed890fd9b90..29e3615a1ae 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -41,6 +41,7 @@
#include "DNA_scene_types.h"
#include "DNA_view3d_types.h"
+#include "BLI_utildefines.h"
#include "BLI_math.h"
#include "BLI_editVert.h"
#include "BLI_edgehash.h"
@@ -54,6 +55,7 @@
#include "BKE_material.h"
#include "BKE_mesh.h"
#include "BKE_report.h"
+#include "BKE_tessmesh.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -70,19 +72,31 @@
#include "mesh_intern.h"
+#define GET_CD_DATA(me, data) (me->edit_btmesh ? &me->edit_btmesh->bm->data : &me->data)
static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *layer)
{
Mesh *me = ob->data;
- CustomData *data= (me->edit_mesh)? &me->edit_mesh->fdata: &me->fdata;
+ CustomData *data;
void *actlayerdata, *rndlayerdata, *clonelayerdata, *stencillayerdata, *layerdata=layer->data;
int type= layer->type;
- int index= CustomData_get_layer_index(data, type);
- int i, actindex, rndindex, cloneindex, stencilindex;
+ int index;
+ int i, actindex, rndindex, cloneindex, stencilindex, tot;
+
+ if (layer->type == CD_MLOOPCOL || layer->type == CD_MLOOPUV) {
+ data = (me->edit_btmesh)? &me->edit_btmesh->bm->ldata: &me->ldata;
+ tot = me->totloop;
+ } else {
+ data = (me->edit_btmesh)? &me->edit_btmesh->bm->pdata: &me->pdata;
+ tot = me->totpoly;
+ }
+ index = CustomData_get_layer_index(data, type);
+
/* ok, deleting a non-active layer needs to preserve the active layer indices.
to do this, we store a pointer to the .data member of both layer and the active layer,
(to detect if we're deleting the active layer or not), then use the active
layer data pointer to find where the active layer has ended up.
+
this is necassary because the deletion functions only support deleting the active
layer. */
@@ -92,15 +106,15 @@ static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *la
stencillayerdata = data->layers[CustomData_get_stencil_layer_index(data, type)].data;
CustomData_set_layer_active(data, type, layer - &data->layers[index]);
- if(me->edit_mesh) {
- EM_free_data_layer(me->edit_mesh, data, type);
+ if(me->edit_btmesh) {
+ BM_free_data_layer(me->edit_btmesh->bm, data, type);
}
else {
- CustomData_free_layer_active(data, type, me->totface);
+ CustomData_free_layer_active(data, type, tot);
mesh_update_customdata_pointers(me);
}
- if(!CustomData_has_layer(data, type) && (type == CD_MCOL && (ob->mode & OB_MODE_VERTEX_PAINT)))
+ if(!CustomData_has_layer(data, type) && (type == CD_MLOOPCOL && (ob->mode & OB_MODE_VERTEX_PAINT)))
ED_object_toggle_modes(C, OB_MODE_VERTEX_PAINT);
/* reconstruct active layer */
@@ -113,10 +127,12 @@ static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *la
break;
}
}
+
/* set index */
CustomData_set_layer_active(data, type, actindex);
}
+
if (rndlayerdata != layerdata) {
/* find index */
@@ -127,10 +143,12 @@ static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *la
break;
}
}
+
/* set index */
CustomData_set_layer_render(data, type, rndindex);
}
+
if (clonelayerdata != layerdata) {
/* find index */
@@ -141,10 +159,12 @@ static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *la
break;
}
}
+
/* set index */
CustomData_set_layer_clone(data, type, cloneindex);
}
+
if (stencillayerdata != layerdata) {
/* find index */
@@ -155,14 +175,20 @@ static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *la
break;
}
}
+
/* set index */
CustomData_set_layer_stencil(data, type, stencilindex);
}
}
-static void copy_editface_active_customdata(EditMesh *em, int type, int index)
+static void copy_editface_active_customdata(BMEditMesh *em, int type, int index)
{
+#if 1 /*BMESH_TODO*/
+ (void)em;
+ (void)type;
+ (void)index;
+#else
EditFace *efa;
int n= CustomData_get_active_layer(&em->fdata, type);
@@ -170,40 +196,56 @@ static void copy_editface_active_customdata(EditMesh *em, int type, int index)
void *data= CustomData_em_get_n(&em->fdata, efa->data, type, n);
CustomData_em_set_n(&em->fdata, efa->data, type, index, data);
}
+#endif
}
int ED_mesh_uv_texture_add(bContext *C, Mesh *me, const char *name, int active_set)
{
- EditMesh *em;
+ BMEditMesh *em;
int layernum;
- if(me->edit_mesh) {
- em= me->edit_mesh;
+ if(me->edit_btmesh) {
+ em= me->edit_btmesh;
- layernum= CustomData_number_of_layers(&em->fdata, CD_MTFACE);
+ layernum= CustomData_number_of_layers(&em->bm->pdata, CD_MTEXPOLY);
if(layernum >= MAX_MTFACE)
return 0;
- EM_add_data_layer(em, &em->fdata, CD_MTFACE, name);
+ BM_add_data_layer(em->bm, &em->bm->pdata, CD_MTEXPOLY);
+ CustomData_set_layer_active(&em->bm->pdata, CD_MTEXPOLY, layernum);
+ CustomData_set_layer_name(&em->bm->pdata, CD_MTEXPOLY, layernum, name);
if(layernum) /* copy data from active UV */
copy_editface_active_customdata(em, CD_MTFACE, layernum);
if(active_set || layernum==0)
- CustomData_set_layer_active(&em->fdata, CD_MTFACE, layernum);
+ CustomData_set_layer_active(&em->bm->pdata, CD_MTEXPOLY, layernum);
+
+ BM_add_data_layer(em->bm, &em->bm->ldata, CD_MLOOPUV);
+ CustomData_set_layer_name(&em->bm->ldata, CD_MLOOPUV, layernum, name);
+
+ CustomData_set_layer_active(&em->bm->ldata, CD_MLOOPUV, layernum);
+ if(active_set || layernum==0)
+ CustomData_set_layer_active(&em->bm->ldata, CD_MLOOPUV, layernum);
}
else {
- layernum= CustomData_number_of_layers(&me->fdata, CD_MTFACE);
+ layernum= CustomData_number_of_layers(&me->pdata, CD_MTEXPOLY);
if(layernum >= MAX_MTFACE)
return 0;
- if(me->mtface)
- CustomData_add_layer_named(&me->fdata, CD_MTFACE, CD_DUPLICATE, me->mtface, me->totface, name);
- else
- CustomData_add_layer_named(&me->fdata, CD_MTFACE, CD_DEFAULT, NULL, me->totface, name);
-
- if(active_set || layernum==0)
- CustomData_set_layer_active(&me->fdata, CD_MTFACE, layernum);
+ if(me->mtpoly) {
+ CustomData_add_layer_named(&me->pdata, CD_MTEXPOLY, CD_DUPLICATE, me->mtpoly, me->totpoly, name);
+ CustomData_add_layer_named(&me->ldata, CD_MLOOPUV, CD_DUPLICATE, me->mloopuv, me->totloop, name);
+ } else {
+ CustomData_add_layer_named(&me->pdata, CD_MTEXPOLY, CD_DEFAULT, NULL, me->totpoly, name);
+ CustomData_add_layer_named(&me->ldata, CD_MLOOPUV, CD_DEFAULT, NULL, me->totloop, name);
+ }
+
+ if(active_set || layernum==0) {
+ CustomData_set_layer_active(&me->pdata, CD_MTEXPOLY, layernum);
+ CustomData_set_layer_active(&me->ldata, CD_MLOOPUV, layernum);
+ }
+
mesh_update_customdata_pointers(me);
}
@@ -216,17 +258,22 @@ int ED_mesh_uv_texture_add(bContext *C, Mesh *me, const char *name, int active_s
int ED_mesh_uv_texture_remove(bContext *C, Object *ob, Mesh *me)
{
- CustomData *data= (me->edit_mesh)? &me->edit_mesh->fdata: &me->fdata;
- CustomDataLayer *cdl;
+ CustomData *pdata = GET_CD_DATA(me, pdata), *ldata = GET_CD_DATA(me, ldata);
+ CustomDataLayer *cdlp, *cdlu;
int index;
- index= CustomData_get_active_layer_index(data, CD_MTFACE);
- cdl= (index == -1) ? NULL: &data->layers[index];
+ index= CustomData_get_active_layer_index(pdata, CD_MTEXPOLY);
+ cdlp= (index == -1)? NULL: &pdata->layers[index];
- if(!cdl)
+ index= CustomData_get_active_layer_index(ldata, CD_MLOOPUV);
+ cdlu= (index == -1)? NULL: &ldata->layers[index];
+
+ if (!cdlp || !cdlu)
return 0;
- delete_customdata_layer(C, ob, cdl);
+ delete_customdata_layer(C, ob, cdlp);
+ delete_customdata_layer(C, ob, cdlu);
+
DAG_id_tag_update(&me->id, 0);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, me);
@@ -235,36 +282,37 @@ int ED_mesh_uv_texture_remove(bContext *C, Object *ob, Mesh *me)
int ED_mesh_color_add(bContext *C, Scene *UNUSED(scene), Object *UNUSED(ob), Mesh *me, const char *name, int active_set)
{
- EditMesh *em;
+ BMEditMesh *em;
int layernum;
- if(me->edit_mesh) {
- em= me->edit_mesh;
+ if(me->edit_btmesh) {
+ em= me->edit_btmesh;
- layernum= CustomData_number_of_layers(&em->fdata, CD_MCOL);
+ layernum= CustomData_number_of_layers(&em->bm->ldata, CD_MLOOPCOL);
if(layernum >= MAX_MCOL)
return 0;
- EM_add_data_layer(em, &em->fdata, CD_MCOL, name);
+ BM_add_data_layer(em->bm, &em->bm->pdata, CD_MLOOPCOL);
+ CustomData_set_layer_active(&em->bm->ldata, CD_MLOOPCOL, layernum);
if(layernum) /* copy data from active vertex color layer */
copy_editface_active_customdata(em, CD_MCOL, layernum);
if(active_set || layernum==0)
- CustomData_set_layer_active(&em->fdata, CD_MCOL, layernum);
+ CustomData_set_layer_active(&em->bm->ldata, CD_MLOOPCOL, layernum);
}
else {
- layernum= CustomData_number_of_layers(&me->fdata, CD_MCOL);
- if(layernum >= MAX_MCOL)
+ layernum= CustomData_number_of_layers(&me->ldata, CD_MLOOPCOL);
+ if(layernum >= CD_MLOOPCOL)
return 0;
- if(me->mcol)
- CustomData_add_layer_named(&me->fdata, CD_MCOL, CD_DUPLICATE, me->mcol, me->totface, name);
+ if(me->mloopcol)
+ CustomData_add_layer_named(&me->ldata, CD_MLOOPCOL, CD_DUPLICATE, me->mloopcol, me->totloop, name);
else
- CustomData_add_layer_named(&me->fdata, CD_MCOL, CD_DEFAULT, NULL, me->totface, name);
+ CustomData_add_layer_named(&me->ldata, CD_MLOOPCOL, CD_DEFAULT, NULL, me->totloop, name);
if(active_set || layernum==0)
- CustomData_set_layer_active(&me->fdata, CD_MCOL, layernum);
+ CustomData_set_layer_active(&me->ldata, CD_MLOOPCOL, layernum);
mesh_update_customdata_pointers(me);
}
@@ -277,12 +325,11 @@ int ED_mesh_color_add(bContext *C, Scene *UNUSED(scene), Object *UNUSED(ob), Mes
int ED_mesh_color_remove(bContext *C, Object *ob, Mesh *me)
{
- CustomData *data= (me->edit_mesh)? &me->edit_mesh->fdata: &me->fdata;
CustomDataLayer *cdl;
int index;
- index= CustomData_get_active_layer_index(data, CD_MCOL);
- cdl= (index == -1)? NULL: &data->layers[index];
+ index= CustomData_get_active_layer_index(&me->ldata, CD_MLOOPCOL);
+ cdl= (index == -1)? NULL: &me->ldata.layers[index];
if(!cdl)
return 0;
@@ -320,6 +367,7 @@ void MESH_OT_uv_texture_add(wmOperatorType *ot)
ot->name= "Add UV Texture";
ot->description= "Add UV texture layer";
ot->idname= "MESH_OT_uv_texture_add";
+
/* api callbacks */
ot->poll= layers_poll;
@@ -339,16 +387,19 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event)
Object *obedit;
int exitmode= 0;
char name[32];
+
/* Check context */
if(base==NULL || base->object->type!=OB_MESH) {
BKE_report(op->reports, RPT_ERROR, "Not an Object or Mesh");
return OPERATOR_CANCELLED;
}
+
/* check input variables */
if(RNA_property_is_set(op->ptr, "filepath")) {
char path[FILE_MAX];
+
RNA_string_get(op->ptr, "filepath", path);
ima= BKE_add_image_file(path);
@@ -357,38 +408,42 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event)
RNA_string_get(op->ptr, "name", name);
ima= (Image *)find_id("IM", name);
}
+
if(!ima) {
BKE_report(op->reports, RPT_ERROR, "Not an Image");
return OPERATOR_CANCELLED;
}
+
- /* turn mesh in editmode */
- /* BKE_mesh_get/end_editmesh: ED_uvedit_assign_image also calls this */
+ /* put mesh in editmode */
obedit= base->object;
me= obedit->data;
- if(me->edit_mesh==NULL) {
- make_editMesh(scene, obedit);
+ if(me->edit_btmesh==NULL) {
+ EDBM_MakeEditBMesh(scene->toolsettings, scene, obedit);
exitmode= 1;
}
- if(me->edit_mesh==NULL)
+ if(me->edit_btmesh==NULL)
return OPERATOR_CANCELLED;
+
ED_uvedit_assign_image(scene, obedit, ima, NULL);
if(exitmode) {
- load_editMesh(scene, obedit);
- free_editMesh(me->edit_mesh);
- MEM_freeN(me->edit_mesh);
- me->edit_mesh= NULL;
+ EDBM_LoadEditBMesh(scene, obedit);
+ EDBM_FreeEditBMesh(me->edit_btmesh);
+ MEM_freeN(me->edit_btmesh);
+ me->edit_btmesh= NULL;
}
/* dummie drop support; ensure view shows a result :) */
if(v3d)
v3d->flag2 |= V3D_SOLID_TEX;
+
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
+
return OPERATOR_FINISHED;
}
@@ -399,13 +454,16 @@ void MESH_OT_drop_named_image(wmOperatorType *ot)
ot->name= "Assign Image to UV Texture";
ot->description= "Assigns Image to active UV layer, or creates a UV layer";
ot->idname= "MESH_OT_drop_named_image";
+
/* api callbacks */
ot->poll= layers_poll;
ot->invoke= drop_named_image_invoke;
+
/* flags */
ot->flag= OPTYPE_UNDO;
+
/* properties */
RNA_def_string(ot->srna, "name", "Image", 24, "Name", "Image name to assign");
@@ -429,6 +487,7 @@ void MESH_OT_uv_texture_remove(wmOperatorType *ot)
ot->name= "Remove UV Texture";
ot->description= "Remove UV texture layer";
ot->idname= "MESH_OT_uv_texture_remove";
+
/* api callbacks */
ot->poll= layers_poll;
@@ -458,6 +517,7 @@ void MESH_OT_vertex_color_add(wmOperatorType *ot)
ot->name= "Add Vertex Color";
ot->description= "Add vertex color layer";
ot->idname= "MESH_OT_vertex_color_add";
+
/* api callbacks */
ot->poll= layers_poll;
@@ -484,6 +544,7 @@ void MESH_OT_vertex_color_remove(wmOperatorType *ot)
ot->name= "Remove Vertex Color";
ot->description= "Remove vertex color layer";
ot->idname= "MESH_OT_vertex_color_remove";
+
/* api callbacks */
ot->exec= vertex_color_remove_exec;
@@ -519,6 +580,7 @@ void MESH_OT_sticky_add(wmOperatorType *ot)
ot->name= "Add Sticky";
ot->description= "Add sticky UV texture layer";
ot->idname= "MESH_OT_sticky_add";
+
/* api callbacks */
ot->poll= layers_poll;
@@ -551,6 +613,7 @@ void MESH_OT_sticky_remove(wmOperatorType *ot)
ot->name= "Remove Sticky";
ot->description= "Remove sticky UV texture layer";
ot->idname= "MESH_OT_sticky_remove";
+
/* api callbacks */
ot->poll= layers_poll;
@@ -564,10 +627,26 @@ void MESH_OT_sticky_remove(wmOperatorType *ot)
void ED_mesh_update(Mesh *mesh, bContext *C, int calc_edges)
{
- if(calc_edges || (mesh->totface && mesh->totedge == 0))
+ if(mesh->totface > 0 && mesh->totpoly == 0)
+ convert_mfaces_to_mpolys(mesh);
+
+ if(calc_edges || (mesh->totpoly && mesh->totedge == 0))
BKE_mesh_calc_edges(mesh, calc_edges);
- mesh_calc_normals(mesh->mvert, mesh->totvert, mesh->mface, mesh->totface, NULL);
+ mesh_calc_normals(mesh->mvert, mesh->totvert, mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, NULL, NULL, 0, NULL, NULL);
+
+ mesh->totface = mesh_recalcTesselation(
+ &mesh->fdata,
+ &mesh->ldata,
+ &mesh->pdata,
+ mesh->mvert,
+ mesh->totface,
+ mesh->totloop,
+ mesh->totpoly,
+ 0,
+ 0);
+
+ mesh_update_customdata_pointers(mesh);
DAG_id_tag_update(&mesh->id, 0);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, mesh);
@@ -603,15 +682,15 @@ static void mesh_add_verts(Mesh *mesh, int len)
mesh->totvert= totvert;
}
-void ED_mesh_transform(Mesh *me, float *mat)
+void ED_mesh_transform(Mesh *mesh, float *mat)
{
int i;
- MVert *mvert= me->mvert;
+ MVert *mvert= mesh->mvert;
- for(i= 0; i < me->totvert; i++, mvert++)
+ for(i= 0; i < mesh->totvert; i++, mvert++)
mul_m4_v3((float (*)[4])mat, mvert->co);
- mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL);
+ mesh_calc_normals(mesh->mvert, mesh->totvert, mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, NULL, NULL, 0, NULL, NULL);
}
static void mesh_add_edges(Mesh *mesh, int len)
@@ -644,6 +723,8 @@ static void mesh_add_edges(Mesh *mesh, int len)
mesh->totedge= totedge;
}
+
+
static void mesh_add_faces(Mesh *mesh, int len)
{
CustomData fdata;
@@ -674,10 +755,64 @@ static void mesh_add_faces(Mesh *mesh, int len)
mesh->totface= totface;
}
+static void mesh_add_loops(Mesh *mesh, int len)
+{
+ CustomData ldata;
+ int totloop;
+
+ if(len == 0)
+ return;
+
+ totloop= mesh->totloop + len; /* new face count */
+
+ /* update customdata */
+ CustomData_copy(&mesh->ldata, &ldata, CD_MASK_MESH, CD_DEFAULT, totloop);
+ CustomData_copy_data(&mesh->ldata, &ldata, 0, 0, mesh->totloop);
+
+ if(!CustomData_has_layer(&ldata, CD_MLOOP))
+ CustomData_add_layer(&ldata, CD_MLOOP, CD_CALLOC, NULL, totloop);
+
+ CustomData_free(&mesh->ldata, mesh->totloop);
+ mesh->ldata= ldata;
+ mesh_update_customdata_pointers(mesh);
+
+ mesh->totloop= totloop;
+}
+
+static void mesh_add_polys(Mesh *mesh, int len)
+{
+ CustomData pdata;
+ MPoly *mpoly;
+ int i, totpoly;
+
+ if(len == 0)
+ return;
+
+ totpoly= mesh->totpoly + len; /* new face count */
+
+ /* update customdata */
+ CustomData_copy(&mesh->pdata, &pdata, CD_MASK_MESH, CD_DEFAULT, totpoly);
+ CustomData_copy_data(&mesh->pdata, &pdata, 0, 0, mesh->totpoly);
+
+ if(!CustomData_has_layer(&pdata, CD_MPOLY))
+ CustomData_add_layer(&pdata, CD_MPOLY, CD_CALLOC, NULL, totpoly);
+
+ CustomData_free(&mesh->pdata, mesh->totpoly);
+ mesh->pdata= pdata;
+ mesh_update_customdata_pointers(mesh);
+
+ /* set default flags */
+ mpoly= &mesh->mpoly[mesh->totpoly];
+ for(i=0; i<len; i++, mpoly++)
+ mpoly->flag= ME_FACE_SEL;
+
+ mesh->totpoly= totpoly;
+}
+
/*
void ED_mesh_geometry_add(Mesh *mesh, ReportList *reports, int verts, int edges, int faces)
{
- if(mesh->edit_mesh) {
+ if(mesh->edit_btmesh) {
BKE_report(reports, RPT_ERROR, "Can't add geometry in edit mode");
return;
}
@@ -693,7 +828,7 @@ void ED_mesh_geometry_add(Mesh *mesh, ReportList *reports, int verts, int edges,
void ED_mesh_faces_add(Mesh *mesh, ReportList *reports, int count)
{
- if(mesh->edit_mesh) {
+ if(mesh->edit_btmesh) {
BKE_report(reports, RPT_ERROR, "Can't add faces in edit mode");
return;
}
@@ -703,17 +838,18 @@ void ED_mesh_faces_add(Mesh *mesh, ReportList *reports, int count)
void ED_mesh_edges_add(Mesh *mesh, ReportList *reports, int count)
{
- if(mesh->edit_mesh) {
+ if(mesh->edit_btmesh) {
BKE_report(reports, RPT_ERROR, "Can't add edges in edit mode");
- return;
+ return;
}
mesh_add_edges(mesh, count);
}
+
void ED_mesh_vertices_add(Mesh *mesh, ReportList *reports, int count)
{
- if(mesh->edit_mesh) {
+ if(mesh->edit_btmesh) {
BKE_report(reports, RPT_ERROR, "Can't add vertices in edit mode");
return;
}
@@ -721,7 +857,27 @@ void ED_mesh_vertices_add(Mesh *mesh, ReportList *reports, int count)
mesh_add_verts(mesh, count);
}
-void ED_mesh_calc_normals(Mesh *me)
+void ED_mesh_loops_add(Mesh *mesh, ReportList *reports, int count)
+{
+ if(mesh->edit_btmesh) {
+ BKE_report(reports, RPT_ERROR, "Can't add loops in edit mode.");
+ return;
+ }
+
+ mesh_add_loops(mesh, count);
+}
+
+void ED_mesh_polys_add(Mesh *mesh, ReportList *reports, int count)
+{
+ if(mesh->edit_btmesh) {
+ BKE_report(reports, RPT_ERROR, "Can't add polys in edit mode.");
+ return;
+ }
+
+ mesh_add_polys(mesh, count);
+}
+
+void ED_mesh_calc_normals(Mesh *mesh)
{
- mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL);
+ mesh_calc_normals(mesh->mvert, mesh->totvert, mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, NULL, NULL, 0, NULL, NULL);
}