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.c124
1 files changed, 64 insertions, 60 deletions
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index 10fdd31db3e..a8836b466a8 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -87,7 +87,8 @@ static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *la
if (layer->type == CD_MLOOPCOL || layer->type == CD_MLOOPUV) {
data = (me->edit_btmesh)? &me->edit_btmesh->bm->ldata: &me->ldata;
tot = me->totloop;
- } else {
+ }
+ else {
data = (me->edit_btmesh)? &me->edit_btmesh->bm->pdata: &me->pdata;
tot = me->totpoly;
}
@@ -107,7 +108,7 @@ 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_btmesh) {
+ if (me->edit_btmesh) {
BM_data_layer_free(me->edit_btmesh->bm, data, type);
}
else {
@@ -115,7 +116,7 @@ static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *la
mesh_update_customdata_pointers(me, TRUE);
}
- if(!CustomData_has_layer(data, type) && (type == CD_MLOOPCOL && (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 */
@@ -186,7 +187,7 @@ static void copy_editface_active_customdata(BMEditMesh *em, int type, int index)
EditFace *efa;
int n= CustomData_get_active_layer(&em->fdata, type);
- for(efa= em->faces.first; efa; efa= efa->next) {
+ for (efa= em->faces.first; efa; efa= efa->next) {
void *data= CustomData_em_get_n(&em->fdata, efa->data, type, n);
CustomData_em_set_n(&em->fdata, efa->data, type, index, data);
}
@@ -259,7 +260,8 @@ int ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me)
fuvs[2][0] = 1.0;
fuvs[2][1] = 1.0;
- } else if (len == 4) {
+ }
+ else if (len == 4) {
fuvs[0][0] = 0.0;
fuvs[0][1] = 0.0;
@@ -272,7 +274,8 @@ int ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me)
fuvs[3][0] = 0.0;
fuvs[3][1] = 1.0;
/*make sure we ignore 2-sided faces*/
- } else if (len > 2) {
+ }
+ else if (len > 2) {
float fac = 0.0f, dfac = 1.0f / (float)len;
dfac *= M_PI*2;
@@ -327,7 +330,7 @@ int ED_mesh_uv_texture_add(bContext *C, Mesh *me, const char *name, int active_s
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) {
+ if (active_set || layernum == 0) {
CustomData_set_layer_active(&em->bm->ldata, CD_MLOOPUV, layernum);
}
}
@@ -340,7 +343,8 @@ int ED_mesh_uv_texture_add(bContext *C, Mesh *me, const char *name, int active_s
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);
CustomData_add_layer_named(&me->fdata, CD_MTFACE, CD_DUPLICATE, me->mtface, me->totface, name);
- } else {
+ }
+ 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);
CustomData_add_layer_named(&me->fdata, CD_MTFACE, CD_DEFAULT, NULL, me->totface, name);
@@ -419,7 +423,7 @@ int ED_mesh_color_add(bContext *C, Scene *UNUSED(scene), Object *UNUSED(ob), Mes
return -1;
}
- if(me->mloopcol) {
+ if (me->mloopcol) {
CustomData_add_layer_named(&me->ldata, CD_MLOOPCOL, CD_DUPLICATE, me->mloopcol, me->totloop, name);
CustomData_add_layer_named(&me->fdata, CD_MCOL, CD_DUPLICATE, me->mcol, me->totface, name);
}
@@ -428,7 +432,7 @@ int ED_mesh_color_add(bContext *C, Scene *UNUSED(scene), Object *UNUSED(ob), Mes
CustomData_add_layer_named(&me->fdata, CD_MCOL, CD_DEFAULT, NULL, me->totface, name);
}
- if(active_set || layernum==0) {
+ if (active_set || layernum==0) {
CustomData_set_layer_active(&me->ldata, CD_MLOOPCOL, layernum);
CustomData_set_layer_active(&me->fdata, CD_MCOL, layernum);
}
@@ -450,7 +454,7 @@ int ED_mesh_color_remove(bContext *C, Object *ob, Mesh *me)
index= CustomData_get_active_layer_index(&me->ldata, CD_MLOOPCOL);
cdl= (index == -1)? NULL: &me->ldata.layers[index];
- if(!cdl)
+ if (!cdl)
return 0;
delete_customdata_layer(C, ob, cdl);
@@ -468,7 +472,7 @@ int ED_mesh_color_remove_named(bContext *C, Object *ob, Mesh *me, const char *na
index= CustomData_get_named_layer_index(&me->ldata, CD_MLOOPCOL, name);
cdl= (index == -1)? NULL: &me->ldata.layers[index];
- if(!cdl)
+ if (!cdl)
return 0;
delete_customdata_layer(C, ob, cdl);
@@ -492,7 +496,7 @@ static int mesh_uv_texture_add_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob= ED_object_context(C);
Mesh *me= ob->data;
- if(ED_mesh_uv_texture_add(C, me, NULL, TRUE) == -1)
+ if (ED_mesh_uv_texture_add(C, me, NULL, TRUE) == -1)
return OPERATOR_CANCELLED;
return OPERATOR_FINISHED;
@@ -526,13 +530,13 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event)
char name[MAX_ID_NAME-2];
/* Check context */
- if(base==NULL || base->object->type!=OB_MESH) {
+ 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_struct_property_is_set(op->ptr, "filepath")) {
+ if (RNA_struct_property_is_set(op->ptr, "filepath")) {
char path[FILE_MAX];
RNA_string_get(op->ptr, "filepath", path);
@@ -543,7 +547,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event)
ima= (Image *)find_id("IM", name);
}
- if(!ima) {
+ if (!ima) {
BKE_report(op->reports, RPT_ERROR, "Not an Image");
return OPERATOR_CANCELLED;
}
@@ -552,16 +556,16 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event)
obedit= base->object;
me= obedit->data;
- if(me->edit_btmesh==NULL) {
+ if (me->edit_btmesh==NULL) {
EDBM_MakeEditBMesh(scene->toolsettings, scene, obedit);
exitmode= 1;
}
- if(me->edit_btmesh==NULL)
+ if (me->edit_btmesh==NULL)
return OPERATOR_CANCELLED;
ED_uvedit_assign_image(bmain, scene, obedit, ima, NULL);
- if(exitmode) {
+ if (exitmode) {
EDBM_LoadEditBMesh(scene, obedit);
EDBM_FreeEditBMesh(me->edit_btmesh);
MEM_freeN(me->edit_btmesh);
@@ -573,7 +577,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event)
}
/* dummie drop support; ensure view shows a result :) */
- if(v3d)
+ if (v3d)
v3d->flag2 |= V3D_SOLID_TEX;
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
@@ -605,7 +609,7 @@ static int mesh_uv_texture_remove_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob= ED_object_context(C);
Mesh *me= ob->data;
- if(!ED_mesh_uv_texture_remove(C, ob, me))
+ if (!ED_mesh_uv_texture_remove(C, ob, me))
return OPERATOR_CANCELLED;
return OPERATOR_FINISHED;
@@ -634,7 +638,7 @@ static int mesh_vertex_color_add_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob= ED_object_context(C);
Mesh *me= ob->data;
- if(ED_mesh_color_add(C, scene, ob, me, NULL, TRUE) == -1)
+ if (ED_mesh_color_add(C, scene, ob, me, NULL, TRUE) == -1)
return OPERATOR_CANCELLED;
return OPERATOR_FINISHED;
@@ -660,7 +664,7 @@ static int mesh_vertex_color_remove_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob= ED_object_context(C);
Mesh *me= ob->data;
- if(!ED_mesh_color_remove(C, ob, me))
+ if (!ED_mesh_color_remove(C, ob, me))
return OPERATOR_CANCELLED;
return OPERATOR_FINISHED;
@@ -692,7 +696,7 @@ static int mesh_sticky_add_exec(bContext *C, wmOperator *UNUSED(op))
/* why is this commented out? */
#if 0
- if(me->msticky)
+ if (me->msticky)
return OPERATOR_CANCELLED;
#endif
@@ -724,7 +728,7 @@ static int mesh_sticky_remove_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob= ED_object_context(C);
Mesh *me= ob->data;
- if(!me->msticky)
+ if (!me->msticky)
return OPERATOR_CANCELLED;
CustomData_free_layer_active(&me->vdata, CD_MSTICKY, me->totvert);
@@ -759,7 +763,7 @@ void ED_mesh_update(Mesh *mesh, bContext *C, int calc_edges, int calc_tessface)
float (*face_nors)[3];
int tessface_input = FALSE;
- if(mesh->totface > 0 && mesh->totpoly == 0) {
+ if (mesh->totface > 0 && mesh->totpoly == 0) {
convert_mfaces_to_mpolys(mesh);
/* would only be converting back again, don't bother */
@@ -769,7 +773,7 @@ void ED_mesh_update(Mesh *mesh, bContext *C, int calc_edges, int calc_tessface)
calc_edges = FALSE;
}
- if(calc_edges || (mesh->totpoly && mesh->totedge == 0))
+ if (calc_edges || (mesh->totpoly && mesh->totedge == 0))
BKE_mesh_calc_edges(mesh, calc_edges);
if (calc_tessface) {
@@ -815,14 +819,14 @@ static void mesh_add_verts(Mesh *mesh, int len)
MVert *mvert;
int i, totvert;
- if(len == 0)
+ if (len == 0)
return;
totvert= mesh->totvert + len;
CustomData_copy(&mesh->vdata, &vdata, CD_MASK_MESH, CD_DEFAULT, totvert);
CustomData_copy_data(&mesh->vdata, &vdata, 0, 0, mesh->totvert);
- if(!CustomData_has_layer(&vdata, CD_MVERT))
+ if (!CustomData_has_layer(&vdata, CD_MVERT))
CustomData_add_layer(&vdata, CD_MVERT, CD_CALLOC, NULL, totvert);
CustomData_free(&mesh->vdata, mesh->totvert);
@@ -832,7 +836,7 @@ static void mesh_add_verts(Mesh *mesh, int len)
/* scan the input list and insert the new vertices */
mvert= &mesh->mvert[mesh->totvert];
- for(i=0; i<len; i++, mvert++)
+ for (i=0; i<len; i++, mvert++)
mvert->flag |= SELECT;
/* set final vertex list size */
@@ -844,7 +848,7 @@ void ED_mesh_transform(Mesh *me, float *mat)
int i;
MVert *mvert= me->mvert;
- for(i= 0; i < me->totvert; i++, mvert++)
+ for (i= 0; i < me->totvert; i++, mvert++)
mul_m4_v3((float (*)[4])mat, mvert->co);
mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL);
@@ -856,7 +860,7 @@ static void mesh_add_edges(Mesh *mesh, int len)
MEdge *medge;
int i, totedge;
- if(len == 0)
+ if (len == 0)
return;
totedge= mesh->totedge+len;
@@ -865,7 +869,7 @@ static void mesh_add_edges(Mesh *mesh, int len)
CustomData_copy(&mesh->edata, &edata, CD_MASK_MESH, CD_DEFAULT, totedge);
CustomData_copy_data(&mesh->edata, &edata, 0, 0, mesh->totedge);
- if(!CustomData_has_layer(&edata, CD_MEDGE))
+ if (!CustomData_has_layer(&edata, CD_MEDGE))
CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge);
CustomData_free(&mesh->edata, mesh->totedge);
@@ -874,7 +878,7 @@ static void mesh_add_edges(Mesh *mesh, int len)
/* set default flags */
medge= &mesh->medge[mesh->totedge];
- for(i=0; i<len; i++, medge++)
+ for (i=0; i<len; i++, medge++)
medge->flag= ME_EDGEDRAW|ME_EDGERENDER|SELECT;
mesh->totedge= totedge;
@@ -886,7 +890,7 @@ static void mesh_add_faces(Mesh *mesh, int len)
MFace *mface;
int i, totface;
- if(len == 0)
+ if (len == 0)
return;
totface= mesh->totface + len; /* new face count */
@@ -895,7 +899,7 @@ static void mesh_add_faces(Mesh *mesh, int len)
CustomData_copy(&mesh->fdata, &fdata, CD_MASK_MESH, CD_DEFAULT, totface);
CustomData_copy_data(&mesh->fdata, &fdata, 0, 0, mesh->totface);
- if(!CustomData_has_layer(&fdata, CD_MFACE))
+ if (!CustomData_has_layer(&fdata, CD_MFACE))
CustomData_add_layer(&fdata, CD_MFACE, CD_CALLOC, NULL, totface);
CustomData_free(&mesh->fdata, mesh->totface);
@@ -904,7 +908,7 @@ static void mesh_add_faces(Mesh *mesh, int len)
/* set default flags */
mface= &mesh->mface[mesh->totface];
- for(i=0; i<len; i++, mface++)
+ for (i=0; i<len; i++, mface++)
mface->flag= ME_FACE_SEL;
mesh->totface= totface;
@@ -915,7 +919,7 @@ static void mesh_add_loops(Mesh *mesh, int len)
CustomData ldata;
int totloop;
- if(len == 0)
+ if (len == 0)
return;
totloop= mesh->totloop + len; /* new face count */
@@ -924,7 +928,7 @@ static void mesh_add_loops(Mesh *mesh, int len)
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))
+ if (!CustomData_has_layer(&ldata, CD_MLOOP))
CustomData_add_layer(&ldata, CD_MLOOP, CD_CALLOC, NULL, totloop);
CustomData_free(&mesh->ldata, mesh->totloop);
@@ -940,7 +944,7 @@ static void mesh_add_polys(Mesh *mesh, int len)
MPoly *mpoly;
int i, totpoly;
- if(len == 0)
+ if (len == 0)
return;
totpoly= mesh->totpoly + len; /* new face count */
@@ -949,7 +953,7 @@ static void mesh_add_polys(Mesh *mesh, int len)
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))
+ if (!CustomData_has_layer(&pdata, CD_MPOLY))
CustomData_add_layer(&pdata, CD_MPOLY, CD_CALLOC, NULL, totpoly);
CustomData_free(&mesh->pdata, mesh->totpoly);
@@ -958,7 +962,7 @@ static void mesh_add_polys(Mesh *mesh, int len)
/* set default flags */
mpoly= &mesh->mpoly[mesh->totpoly];
- for(i=0; i<len; i++, mpoly++)
+ for (i=0; i<len; i++, mpoly++)
mpoly->flag= ME_FACE_SEL;
mesh->totpoly= totpoly;
@@ -968,7 +972,7 @@ static void mesh_remove_verts(Mesh *mesh, int len)
{
int totvert;
- if(len == 0)
+ if (len == 0)
return;
totvert= mesh->totvert - len;
@@ -982,7 +986,7 @@ static void mesh_remove_edges(Mesh *mesh, int len)
{
int totedge;
- if(len == 0)
+ if (len == 0)
return;
totedge= mesh->totedge - len;
@@ -995,7 +999,7 @@ static void mesh_remove_faces(Mesh *mesh, int len)
{
int totface;
- if(len == 0)
+ if (len == 0)
return;
totface= mesh->totface - len; /* new face count */
@@ -1007,23 +1011,23 @@ static void mesh_remove_faces(Mesh *mesh, int len)
#if 0
void ED_mesh_geometry_add(Mesh *mesh, ReportList *reports, int verts, int edges, int faces)
{
- if(mesh->edit_btmesh) {
+ if (mesh->edit_btmesh) {
BKE_report(reports, RPT_ERROR, "Can't add geometry in edit mode");
return;
}
- if(verts)
+ if (verts)
mesh_add_verts(mesh, verts);
- if(edges)
+ if (edges)
mesh_add_edges(mesh, edges);
- if(faces)
+ if (faces)
mesh_add_faces(mesh, faces);
}
#endif
void ED_mesh_faces_add(Mesh *mesh, ReportList *reports, int count)
{
- if(mesh->edit_btmesh) {
+ if (mesh->edit_btmesh) {
BKE_report(reports, RPT_ERROR, "Can't add faces in edit mode");
return;
}
@@ -1033,7 +1037,7 @@ 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_btmesh) {
+ if (mesh->edit_btmesh) {
BKE_report(reports, RPT_ERROR, "Can't add edges in edit mode");
return;
}
@@ -1043,7 +1047,7 @@ void ED_mesh_edges_add(Mesh *mesh, ReportList *reports, int count)
void ED_mesh_vertices_add(Mesh *mesh, ReportList *reports, int count)
{
- if(mesh->edit_btmesh) {
+ if (mesh->edit_btmesh) {
BKE_report(reports, RPT_ERROR, "Can't add vertices in edit mode");
return;
}
@@ -1053,11 +1057,11 @@ void ED_mesh_vertices_add(Mesh *mesh, ReportList *reports, int count)
void ED_mesh_faces_remove(Mesh *mesh, ReportList *reports, int count)
{
- if(mesh->edit_btmesh) {
+ if (mesh->edit_btmesh) {
BKE_report(reports, RPT_ERROR, "Can't remove faces in edit mode");
return;
}
- else if(count > mesh->totface) {
+ else if (count > mesh->totface) {
BKE_report(reports, RPT_ERROR, "Can't remove more faces than the mesh contains");
return;
}
@@ -1067,11 +1071,11 @@ void ED_mesh_faces_remove(Mesh *mesh, ReportList *reports, int count)
void ED_mesh_edges_remove(Mesh *mesh, ReportList *reports, int count)
{
- if(mesh->edit_btmesh) {
+ if (mesh->edit_btmesh) {
BKE_report(reports, RPT_ERROR, "Can't remove edges in edit mode");
return;
}
- else if(count > mesh->totedge) {
+ else if (count > mesh->totedge) {
BKE_report(reports, RPT_ERROR, "Can't remove more edges than the mesh contains");
return;
}
@@ -1081,11 +1085,11 @@ void ED_mesh_edges_remove(Mesh *mesh, ReportList *reports, int count)
void ED_mesh_vertices_remove(Mesh *mesh, ReportList *reports, int count)
{
- if(mesh->edit_btmesh) {
+ if (mesh->edit_btmesh) {
BKE_report(reports, RPT_ERROR, "Can't remove vertices in edit mode");
return;
}
- else if(count > mesh->totvert) {
+ else if (count > mesh->totvert) {
BKE_report(reports, RPT_ERROR, "Can't remove more vertices than the mesh contains");
return;
}
@@ -1095,7 +1099,7 @@ void ED_mesh_vertices_remove(Mesh *mesh, ReportList *reports, int count)
void ED_mesh_loops_add(Mesh *mesh, ReportList *reports, int count)
{
- if(mesh->edit_btmesh) {
+ if (mesh->edit_btmesh) {
BKE_report(reports, RPT_ERROR, "Can't add loops in edit mode.");
return;
}
@@ -1105,7 +1109,7 @@ void ED_mesh_loops_add(Mesh *mesh, ReportList *reports, int count)
void ED_mesh_polys_add(Mesh *mesh, ReportList *reports, int count)
{
- if(mesh->edit_btmesh) {
+ if (mesh->edit_btmesh) {
BKE_report(reports, RPT_ERROR, "Can't add polys in edit mode.");
return;
}