~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to source/blender/editors/mesh/mesh_data.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 *  \ingroup edmesh
29
29
 */
30
30
 
31
 
 
32
 
#include <math.h>
33
 
#include <stdlib.h>
34
 
#include <string.h>
35
 
 
36
31
#include "MEM_guardedalloc.h"
37
32
 
38
 
#include "DNA_material_types.h"
39
33
#include "DNA_mesh_types.h"
40
34
#include "DNA_meshdata_types.h"
41
35
#include "DNA_object_types.h"
42
36
#include "DNA_scene_types.h"
43
37
#include "DNA_view3d_types.h"
44
38
 
45
 
#include "BLI_utildefines.h"
 
39
#include "BLI_path_util.h"
46
40
#include "BLI_array.h"
47
41
#include "BLI_math.h"
48
 
#include "BLI_edgehash.h"
49
 
#include "BLI_utildefines.h"
50
42
 
51
43
#include "BKE_context.h"
52
44
#include "BKE_depsgraph.h"
53
 
#include "BKE_displist.h"
54
45
#include "BKE_image.h"
55
46
#include "BKE_library.h"
56
47
#include "BKE_main.h"
57
 
#include "BKE_material.h"
58
48
#include "BKE_mesh.h"
59
49
#include "BKE_report.h"
60
50
#include "BKE_tessmesh.h"
70
60
#include "ED_uvedit.h"
71
61
#include "ED_view3d.h"
72
62
 
73
 
#include "RE_render_ext.h"
74
 
 
75
63
#include "mesh_intern.h"
76
64
 
 
65
 
 
66
static CustomData *mesh_customdata_get_type(Mesh *me, const char htype, int *r_tot)
 
67
{
 
68
        CustomData *data;
 
69
        BMesh *bm = (me->edit_btmesh) ? me->edit_btmesh->bm : NULL;
 
70
        int tot;
 
71
 
 
72
        /* this  */
 
73
        switch (htype) {
 
74
                case BM_VERT:
 
75
                        if (bm) {
 
76
                                data = &bm->vdata;
 
77
                                tot  = bm->totvert;
 
78
                        }
 
79
                        else {
 
80
                                data = &me->vdata;
 
81
                                tot  = me->totvert;
 
82
                        }
 
83
                        break;
 
84
                case BM_EDGE:
 
85
                        if (bm) {
 
86
                                data = &bm->edata;
 
87
                                tot  = bm->totedge;
 
88
                        }
 
89
                        else {
 
90
                                data = &me->edata;
 
91
                                tot  = me->totedge;
 
92
                        }
 
93
                        break;
 
94
                case BM_LOOP:
 
95
                        if (bm) {
 
96
                                data = &bm->ldata;
 
97
                                tot  = bm->totloop;
 
98
                        }
 
99
                        else {
 
100
                                data = &me->ldata;
 
101
                                tot  = me->totloop;
 
102
                        }
 
103
                        break;
 
104
                case BM_FACE:
 
105
                        if (bm) {
 
106
                                data = &bm->pdata;
 
107
                                tot  = bm->totface;
 
108
                        }
 
109
                        else {
 
110
                                data = &me->pdata;
 
111
                                tot  = me->totpoly;
 
112
                        }
 
113
                        break;
 
114
                default:
 
115
                        BLI_assert(0);
 
116
                        tot = 0;
 
117
                        data = NULL;
 
118
        }
 
119
 
 
120
        *r_tot = tot;
 
121
        return data;
 
122
}
 
123
 
77
124
#define GET_CD_DATA(me, data) (me->edit_btmesh ? &me->edit_btmesh->bm->data : &me->data)
78
125
static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *layer)
79
126
{
85
132
        int i, actindex, rndindex, cloneindex, stencilindex, tot;
86
133
 
87
134
        if (layer->type == CD_MLOOPCOL || layer->type == CD_MLOOPUV) {
88
 
                if (me->edit_btmesh) {
89
 
                        data = &me->edit_btmesh->bm->ldata;
90
 
                        tot = me->edit_btmesh->bm->totloop;
91
 
                }
92
 
                else {
93
 
                        data = &me->ldata;
94
 
                        tot = me->totloop;
95
 
                }
 
135
                data = mesh_customdata_get_type(me, BM_LOOP, &tot);
96
136
        }
97
137
        else {
98
 
                if (me->edit_btmesh) {
99
 
                        data = &me->edit_btmesh->bm->pdata;
100
 
                        tot = me->edit_btmesh->bm->totface;
101
 
                }
102
 
                else {
103
 
                        data = &me->pdata;
104
 
                        tot = me->totpoly;
105
 
                }
 
138
                data = mesh_customdata_get_type(me, BM_FACE, &tot);
106
139
        }
107
140
        
108
141
        index = CustomData_get_layer_index(data, type);
189
222
        }
190
223
}
191
224
 
192
 
int ED_mesh_uv_loop_reset_ex(struct bContext *C, struct Mesh *me, const int layernum)
 
225
/* without bContext, called in uvedit */
 
226
int ED_mesh_uv_loop_reset_ex(struct Mesh *me, const int layernum)
193
227
{
194
228
        BMEditMesh *em = me->edit_btmesh;
195
229
        MLoopUV *luv;
275
309
                else if (len > 2) {
276
310
                        float fac = 0.0f, dfac = 1.0f / (float)len;
277
311
 
278
 
                        dfac *= M_PI * 2;
 
312
                        dfac *= (float)M_PI * 2.0f;
279
313
 
280
314
                        for (i = 0; i < len; i++) {
281
 
                                fuvs[i][0] = 0.5f * sin(fac) + 0.5f;
282
 
                                fuvs[i][1] = 0.5f * cos(fac) + 0.5f;
 
315
                                fuvs[i][0] = 0.5f * sinf(fac) + 0.5f;
 
316
                                fuvs[i][1] = 0.5f * cosf(fac) + 0.5f;
283
317
 
284
318
                                fac += dfac;
285
319
                        }
292
326
        BLI_array_free(polylengths);
293
327
 
294
328
        DAG_id_tag_update(&me->id, 0);
295
 
        WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
296
329
 
297
330
        return 1;
298
331
}
302
335
        /* could be ldata or pdata */
303
336
        CustomData *pdata = GET_CD_DATA(me, pdata);
304
337
        const int layernum = CustomData_get_active_layer_index(pdata, CD_MTEXPOLY);
305
 
        return ED_mesh_uv_loop_reset_ex(C, me, layernum);
 
338
        int retval = ED_mesh_uv_loop_reset_ex(me, layernum);
 
339
        
 
340
        WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
 
341
        
 
342
        return retval;
306
343
}
307
344
 
308
345
/* note: keep in sync with ED_mesh_color_add */
309
346
int ED_mesh_uv_texture_add(bContext *C, Mesh *me, const char *name, int active_set)
310
347
{
311
348
        BMEditMesh *em;
312
 
        int layernum;
 
349
        int layernum_dst;
313
350
 
314
351
        short is_init = FALSE;
315
352
 
316
353
        if (me->edit_btmesh) {
317
354
                em = me->edit_btmesh;
318
355
 
319
 
                layernum = CustomData_number_of_layers(&em->bm->pdata, CD_MTEXPOLY);
320
 
                if (layernum >= MAX_MTFACE)
 
356
                layernum_dst = CustomData_number_of_layers(&em->bm->pdata, CD_MTEXPOLY);
 
357
                if (layernum_dst >= MAX_MTFACE)
321
358
                        return -1;
322
359
 
323
360
                /* CD_MTEXPOLY */
324
361
                BM_data_layer_add_named(em->bm, &em->bm->pdata, CD_MTEXPOLY, name);
325
362
                /* copy data from active UV */
326
 
                if (layernum) {
327
 
                        const int layernum_dst = CustomData_get_active_layer(&em->bm->pdata, CD_MTEXPOLY);
328
 
                        BM_data_layer_copy(em->bm, &em->bm->pdata, CD_MTEXPOLY, layernum, layernum_dst);
 
363
                if (layernum_dst) {
 
364
                        const int layernum_src = CustomData_get_active_layer(&em->bm->pdata, CD_MTEXPOLY);
 
365
                        BM_data_layer_copy(em->bm, &em->bm->pdata, CD_MTEXPOLY, layernum_src, layernum_dst);
329
366
                }
330
 
                if (active_set || layernum == 0) {
331
 
                        CustomData_set_layer_active(&em->bm->pdata, CD_MTEXPOLY, layernum);
 
367
                if (active_set || layernum_dst == 0) {
 
368
                        CustomData_set_layer_active(&em->bm->pdata, CD_MTEXPOLY, layernum_dst);
332
369
                }
333
370
 
334
371
                /* CD_MLOOPUV */
335
372
                BM_data_layer_add_named(em->bm, &em->bm->ldata, CD_MLOOPUV, name);
336
373
                /* copy data from active UV */
337
 
                if (layernum) {
338
 
                        const int layernum_dst = CustomData_get_active_layer(&em->bm->ldata, CD_MLOOPUV);
339
 
                        BM_data_layer_copy(em->bm, &em->bm->ldata, CD_MLOOPUV, layernum, layernum_dst);
 
374
                if (layernum_dst) {
 
375
                        const int layernum_src = CustomData_get_active_layer(&em->bm->ldata, CD_MLOOPUV);
 
376
                        BM_data_layer_copy(em->bm, &em->bm->ldata, CD_MLOOPUV, layernum_src, layernum_dst);
340
377
 
341
378
                        is_init = TRUE;
342
379
                }
343
 
                if (active_set || layernum == 0) {
344
 
                        CustomData_set_layer_active(&em->bm->ldata, CD_MLOOPUV, layernum);
 
380
                if (active_set || layernum_dst == 0) {
 
381
                        CustomData_set_layer_active(&em->bm->ldata, CD_MLOOPUV, layernum_dst);
345
382
                }
346
383
        }
347
384
        else {
348
 
                layernum = CustomData_number_of_layers(&me->pdata, CD_MTEXPOLY);
349
 
                if (layernum >= MAX_MTFACE)
 
385
                layernum_dst = CustomData_number_of_layers(&me->pdata, CD_MTEXPOLY);
 
386
                if (layernum_dst >= MAX_MTFACE)
350
387
                        return -1;
351
388
 
352
389
                if (me->mtpoly) {
361
398
                        CustomData_add_layer_named(&me->fdata, CD_MTFACE, CD_DEFAULT, NULL, me->totface, name);
362
399
                }
363
400
                
364
 
                if (active_set || layernum == 0) {
365
 
                        CustomData_set_layer_active(&me->pdata, CD_MTEXPOLY, layernum);
366
 
                        CustomData_set_layer_active(&me->ldata, CD_MLOOPUV, layernum);
 
401
                if (active_set || layernum_dst == 0) {
 
402
                        CustomData_set_layer_active(&me->pdata, CD_MTEXPOLY, layernum_dst);
 
403
                        CustomData_set_layer_active(&me->ldata, CD_MLOOPUV, layernum_dst);
367
404
 
368
 
                        CustomData_set_layer_active(&me->fdata, CD_MTFACE, layernum);
 
405
                        CustomData_set_layer_active(&me->fdata, CD_MTFACE, layernum_dst);
369
406
                }
370
407
 
371
408
                mesh_update_customdata_pointers(me, TRUE);
373
410
 
374
411
        /* don't overwrite our copied coords */
375
412
        if (is_init == FALSE) {
376
 
                ED_mesh_uv_loop_reset_ex(C, me, layernum);
 
413
                ED_mesh_uv_loop_reset_ex(me, layernum_dst);
377
414
        }
378
415
 
379
416
        DAG_id_tag_update(&me->id, 0);
380
417
        WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
381
418
 
382
 
        return layernum;
 
419
        return layernum_dst;
383
420
}
384
421
 
385
422
int ED_mesh_uv_texture_remove(bContext *C, Object *ob, Mesh *me)
425
462
                /* copy data from active vertex color layer */
426
463
                if (layernum) {
427
464
                        const int layernum_dst = CustomData_get_active_layer(&em->bm->ldata, CD_MLOOPCOL);
428
 
                        BM_data_layer_copy(em->bm, &em->bm->ldata, CD_MLOOPUV, layernum, layernum_dst);
 
465
                        BM_data_layer_copy(em->bm, &em->bm->ldata, CD_MLOOPCOL, layernum, layernum_dst);
429
466
                }
430
467
                if (active_set || layernum == 0) {
431
468
                        CustomData_set_layer_active(&em->bm->ldata, CD_MLOOPCOL, layernum);
538
575
        Main *bmain = CTX_data_main(C);
539
576
        Scene *scene = CTX_data_scene(C);
540
577
        View3D *v3d = CTX_wm_view3d(C);
541
 
        Base *base = ED_view3d_give_base_under_cursor(C, event->mval);
 
578
        Base *base;
542
579
        Image *ima = NULL;
543
580
        Mesh *me;
544
581
        Object *obedit;
545
582
        int exitmode = 0;
546
 
        char name[MAX_ID_NAME - 2];
547
583
        
 
584
        if (v3d == NULL) {
 
585
                BKE_report(op->reports, RPT_ERROR, "No 3D View Available");
 
586
                return OPERATOR_CANCELLED;
 
587
        }
 
588
 
 
589
        base = ED_view3d_give_base_under_cursor(C, event->mval);
 
590
 
548
591
        /* Check context */
549
592
        if (base == NULL || base->object->type != OB_MESH) {
550
 
                BKE_report(op->reports, RPT_ERROR, "Not an Object or Mesh");
 
593
                BKE_report(op->reports, RPT_ERROR, "Not an object or mesh");
551
594
                return OPERATOR_CANCELLED;
552
595
        }
553
596
        
556
599
                char path[FILE_MAX];
557
600
                
558
601
                RNA_string_get(op->ptr, "filepath", path);
559
 
                ima = BKE_add_image_file(path);
 
602
                ima = BKE_image_load_exists(path);
560
603
        }
561
604
        else {
 
605
                char name[MAX_ID_NAME - 2];
562
606
                RNA_string_get(op->ptr, "name", name);
563
 
                ima = (Image *)find_id("IM", name);
 
607
                ima = (Image *)BKE_libblock_find_name(ID_IM, name);
564
608
        }
565
609
        
566
610
        if (!ima) {
567
 
                BKE_report(op->reports, RPT_ERROR, "Not an Image");
 
611
                BKE_report(op->reports, RPT_ERROR, "Not an image");
568
612
                return OPERATOR_CANCELLED;
569
613
        }
570
614
        
604
648
void MESH_OT_drop_named_image(wmOperatorType *ot)
605
649
{
606
650
        /* identifiers */
607
 
        ot->name = "Assign Image to UV Map";
 
651
        ot->name = "Drop Image to Mesh UV Map";
608
652
        ot->description = "Assign Image to active UV Map, or create an UV Map";
609
653
        ot->idname = "MESH_OT_drop_named_image";
610
654
        
613
657
        ot->invoke = drop_named_image_invoke;
614
658
        
615
659
        /* flags */
616
 
        ot->flag = OPTYPE_UNDO;
 
660
        ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL;
617
661
        
618
662
        /* properties */
619
663
        RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME - 2, "Name", "Image name to assign");
701
745
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
702
746
}
703
747
 
704
 
/*********************** sticky operators ************************/
705
 
 
706
 
static int mesh_sticky_add_exec(bContext *C, wmOperator *UNUSED(op))
707
 
{
708
 
        Scene *scene = CTX_data_scene(C);
709
 
        View3D *v3d = CTX_wm_view3d(C);
 
748
/* *** CustomData clear functions, we need an operator for each *** */
 
749
 
 
750
static int mesh_customdata_clear_exec__internal(bContext *C,
 
751
                                                char htype, int type)
 
752
{
 
753
        Object *obedit = ED_object_context(C);
 
754
        Mesh       *me = obedit->data;
 
755
 
 
756
        int tot;
 
757
        CustomData *data = mesh_customdata_get_type(me, htype, &tot);
 
758
 
 
759
        BLI_assert(CustomData_layertype_is_singleton(type) == TRUE);
 
760
 
 
761
        if (CustomData_has_layer(data, type)) {
 
762
                if (me->edit_btmesh) {
 
763
                        BM_data_layer_free(me->edit_btmesh->bm, data, type);
 
764
                }
 
765
                else {
 
766
                        CustomData_free_layers(data, type, tot);
 
767
                }
 
768
 
 
769
                DAG_id_tag_update(&me->id, 0);
 
770
                WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
 
771
 
 
772
                return OPERATOR_FINISHED;
 
773
        }
 
774
        else {
 
775
                return OPERATOR_CANCELLED;
 
776
        }
 
777
}
 
778
 
 
779
/* Clear Mask */
 
780
static int mesh_customdata_clear_mask_poll(bContext *C)
 
781
{
710
782
        Object *ob = ED_object_context(C);
711
 
        Mesh *me = ob->data;
712
 
 
713
 
        /* why is this commented out? */
714
 
#if 0
715
 
        if (me->msticky)
 
783
        if (ob && ob->type == OB_MESH) {
 
784
                Mesh *me = ob->data;
 
785
 
 
786
                /* special case - can't run this if we're in sculpt mode */
 
787
                if (ob->mode & OB_MODE_SCULPT) {
 
788
                        return FALSE;
 
789
                }
 
790
 
 
791
                if (me->id.lib == NULL) {
 
792
                        CustomData *data = GET_CD_DATA(me, vdata);
 
793
                        if (CustomData_has_layer(data, CD_PAINT_MASK)) {
 
794
                                return TRUE;
 
795
                        }
 
796
                        data = GET_CD_DATA(me, ldata);
 
797
                        if (CustomData_has_layer(data, CD_GRID_PAINT_MASK)) {
 
798
                                return TRUE;
 
799
                        }
 
800
                }
 
801
        }
 
802
        return FALSE;
 
803
}
 
804
static int mesh_customdata_clear_mask_exec(bContext *C, wmOperator *UNUSED(op))
 
805
{
 
806
        int ret_a = mesh_customdata_clear_exec__internal(C, BM_VERT, CD_PAINT_MASK);
 
807
        int ret_b = mesh_customdata_clear_exec__internal(C, BM_LOOP, CD_GRID_PAINT_MASK);
 
808
 
 
809
        if (ret_a == OPERATOR_FINISHED ||
 
810
                ret_b == OPERATOR_FINISHED)
 
811
        {
 
812
                return OPERATOR_FINISHED;
 
813
        }
 
814
        else {
716
815
                return OPERATOR_CANCELLED;
717
 
#endif
718
 
 
719
 
        RE_make_sticky(scene, v3d);
720
 
 
721
 
        DAG_id_tag_update(&me->id, 0);
722
 
        WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
723
 
 
724
 
        return OPERATOR_FINISHED;
 
816
        }
725
817
}
726
818
 
727
 
void MESH_OT_sticky_add(wmOperatorType *ot)
 
819
void MESH_OT_customdata_clear_mask(wmOperatorType *ot)
728
820
{
 
821
 
729
822
        /* identifiers */
730
 
        ot->name = "Add Sticky";
731
 
        ot->description = "Add sticky UV texture layer";
732
 
        ot->idname = "MESH_OT_sticky_add";
733
 
        
 
823
        ot->name = "Clear Sculpt-Mask Data";
 
824
        ot->idname = "MESH_OT_customdata_clear_mask";
 
825
        ot->description = "Clear vertex sculpt masking data from the mesh";
 
826
 
734
827
        /* api callbacks */
735
 
        ot->poll = layers_poll;
736
 
        ot->exec = mesh_sticky_add_exec;
 
828
        ot->exec = mesh_customdata_clear_mask_exec;
 
829
        ot->poll = mesh_customdata_clear_mask_poll;
737
830
 
738
831
        /* flags */
739
832
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
740
833
}
741
834
 
742
 
static int mesh_sticky_remove_exec(bContext *C, wmOperator *UNUSED(op))
 
835
/* Clear Skin */
 
836
static int mesh_customdata_clear_skin_poll(bContext *C)
743
837
{
744
838
        Object *ob = ED_object_context(C);
745
 
        Mesh *me = ob->data;
746
 
 
747
 
        if (!me->msticky)
748
 
                return OPERATOR_CANCELLED;
749
 
 
750
 
        CustomData_free_layer_active(&me->vdata, CD_MSTICKY, me->totvert);
751
 
        me->msticky = NULL;
752
 
 
753
 
        DAG_id_tag_update(&me->id, 0);
754
 
        WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
755
 
 
756
 
        return OPERATOR_FINISHED;
757
 
}
758
 
 
759
 
void MESH_OT_sticky_remove(wmOperatorType *ot)
 
839
 
 
840
        if (ob && ob->type == OB_MESH) {
 
841
                Mesh *me = ob->data;
 
842
                if (me->id.lib == NULL) {
 
843
                        CustomData *data = GET_CD_DATA(me, vdata);
 
844
                        if (CustomData_has_layer(data, CD_MVERT_SKIN)) {
 
845
                                return TRUE;
 
846
                        }
 
847
                }
 
848
        }
 
849
        return FALSE;
 
850
}
 
851
static int mesh_customdata_clear_skin_exec(bContext *C, wmOperator *UNUSED(op))
 
852
{
 
853
        return mesh_customdata_clear_exec__internal(C, BM_VERT, CD_MVERT_SKIN);
 
854
}
 
855
 
 
856
void MESH_OT_customdata_clear_skin(wmOperatorType *ot)
760
857
{
761
858
        /* identifiers */
762
 
        ot->name = "Remove Sticky";
763
 
        ot->description = "Remove sticky UV texture layer";
764
 
        ot->idname = "MESH_OT_sticky_remove";
765
 
        
 
859
        ot->name = "Clear Skin Data";
 
860
        ot->idname = "MESH_OT_customdata_clear_skin";
 
861
        ot->description = "Clear vertex skin layer";
 
862
 
766
863
        /* api callbacks */
767
 
        ot->poll = layers_poll;
768
 
        ot->exec = mesh_sticky_remove_exec;
 
864
        ot->exec = mesh_customdata_clear_skin_exec;
 
865
        ot->poll = mesh_customdata_clear_skin_poll;
769
866
 
770
867
        /* flags */
771
868
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
803
900
         * so rather then add poly-index layer and calculate normals for it
804
901
         * calculate normals only for the mvert's. - campbell */
805
902
#ifdef USE_BMESH_MPOLY_NORMALS
806
 
        polyindex = CustomData_get_layer(&mesh->fdata, CD_POLYINDEX);
 
903
        polyindex = CustomData_get_layer(&mesh->fdata, CD_ORIGINDEX);
807
904
        /* add a normals layer for tessellated faces, a tessface normal will
808
905
         * contain the normal of the poly the face was tessellated from. */
809
906
        face_nors = CustomData_add_layer(&mesh->fdata, CD_NORMAL, CD_CALLOC, NULL, mesh->totface);
810
907
 
811
 
        mesh_calc_normals_mapping_ex(mesh->mvert, mesh->totvert,
812
 
                                     mesh->mloop, mesh->mpoly,
813
 
                                     mesh->totloop, mesh->totpoly,
814
 
                                     NULL /* polyNors_r */,
815
 
                                     mesh->mface, mesh->totface,
816
 
                                     polyindex, face_nors, FALSE);
 
908
        BKE_mesh_calc_normals_mapping_ex(mesh->mvert, mesh->totvert,
 
909
                                         mesh->mloop, mesh->mpoly,
 
910
                                         mesh->totloop, mesh->totpoly,
 
911
                                         NULL /* polyNors_r */,
 
912
                                         mesh->mface, mesh->totface,
 
913
                                         polyindex, face_nors, FALSE);
817
914
#else
818
 
        mesh_calc_normals(mesh->mvert, mesh->totvert,
819
 
                          mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly,
820
 
                          NULL);
 
915
        BKE_mesh_calc_normals(mesh->mvert, mesh->totvert,
 
916
                              mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly,
 
917
                              NULL);
821
918
        (void)polyindex;
822
919
        (void)face_nors;
823
920
#endif
848
945
 
849
946
        /* scan the input list and insert the new vertices */
850
947
 
 
948
        /* set default flags */
851
949
        mvert = &mesh->mvert[mesh->totvert];
852
950
        for (i = 0; i < len; i++, mvert++)
853
951
                mvert->flag |= SELECT;
1025
1123
void ED_mesh_geometry_add(Mesh *mesh, ReportList *reports, int verts, int edges, int faces)
1026
1124
{
1027
1125
        if (mesh->edit_btmesh) {
1028
 
                BKE_report(reports, RPT_ERROR, "Can't add geometry in edit mode");
 
1126
                BKE_report(reports, RPT_ERROR, "Cannot add geometry in edit mode");
1029
1127
                return;
1030
1128
        }
1031
1129
 
1041
1139
void ED_mesh_tessfaces_add(Mesh *mesh, ReportList *reports, int count)
1042
1140
{
1043
1141
        if (mesh->edit_btmesh) {
1044
 
                BKE_report(reports, RPT_ERROR, "Can't add tessfaces in edit mode");
 
1142
                BKE_report(reports, RPT_ERROR, "Cannot add tessfaces in edit mode");
1045
1143
                return;
1046
1144
        }
1047
1145
 
1048
1146
        if (mesh->mpoly) {
1049
 
                BKE_report(reports, RPT_ERROR, "Can't add tessfaces to a mesh that already has polygons");
 
1147
                BKE_report(reports, RPT_ERROR, "Cannot add tessfaces to a mesh that already has polygons");
1050
1148
                return;
1051
1149
        }
1052
1150
 
1056
1154
void ED_mesh_edges_add(Mesh *mesh, ReportList *reports, int count)
1057
1155
{
1058
1156
        if (mesh->edit_btmesh) {
1059
 
                BKE_report(reports, RPT_ERROR, "Can't add edges in edit mode");
 
1157
                BKE_report(reports, RPT_ERROR, "Cannot add edges in edit mode");
1060
1158
                return;
1061
1159
        }
1062
1160
 
1066
1164
void ED_mesh_vertices_add(Mesh *mesh, ReportList *reports, int count)
1067
1165
{
1068
1166
        if (mesh->edit_btmesh) {
1069
 
                BKE_report(reports, RPT_ERROR, "Can't add vertices in edit mode");
 
1167
                BKE_report(reports, RPT_ERROR, "Cannot add vertices in edit mode");
1070
1168
                return;
1071
1169
        }
1072
1170
 
1076
1174
void ED_mesh_faces_remove(Mesh *mesh, ReportList *reports, int count)
1077
1175
{
1078
1176
        if (mesh->edit_btmesh) {
1079
 
                BKE_report(reports, RPT_ERROR, "Can't remove faces in edit mode");
 
1177
                BKE_report(reports, RPT_ERROR, "Cannot remove faces in edit mode");
1080
1178
                return;
1081
1179
        }
1082
1180
        else if (count > mesh->totface) {
1083
 
                BKE_report(reports, RPT_ERROR, "Can't remove more faces than the mesh contains");
 
1181
                BKE_report(reports, RPT_ERROR, "Cannot remove more faces than the mesh contains");
1084
1182
                return;
1085
1183
        }
1086
1184
 
1090
1188
void ED_mesh_edges_remove(Mesh *mesh, ReportList *reports, int count)
1091
1189
{
1092
1190
        if (mesh->edit_btmesh) {
1093
 
                BKE_report(reports, RPT_ERROR, "Can't remove edges in edit mode");
 
1191
                BKE_report(reports, RPT_ERROR, "Cannot remove edges in edit mode");
1094
1192
                return;
1095
1193
        }
1096
1194
        else if (count > mesh->totedge) {
1097
 
                BKE_report(reports, RPT_ERROR, "Can't remove more edges than the mesh contains");
 
1195
                BKE_report(reports, RPT_ERROR, "Cannot remove more edges than the mesh contains");
1098
1196
                return;
1099
1197
        }
1100
1198
 
1104
1202
void ED_mesh_vertices_remove(Mesh *mesh, ReportList *reports, int count)
1105
1203
{
1106
1204
        if (mesh->edit_btmesh) {
1107
 
                BKE_report(reports, RPT_ERROR, "Can't remove vertices in edit mode");
 
1205
                BKE_report(reports, RPT_ERROR, "Cannot remove vertices in edit mode");
1108
1206
                return;
1109
1207
        }
1110
1208
        else if (count > mesh->totvert) {
1111
 
                BKE_report(reports, RPT_ERROR, "Can't remove more vertices than the mesh contains");
 
1209
                BKE_report(reports, RPT_ERROR, "Cannot remove more vertices than the mesh contains");
1112
1210
                return;
1113
1211
        }
1114
1212
 
1118
1216
void ED_mesh_loops_add(Mesh *mesh, ReportList *reports, int count)
1119
1217
{
1120
1218
        if (mesh->edit_btmesh) {
1121
 
                BKE_report(reports, RPT_ERROR, "Can't add loops in edit mode.");
 
1219
                BKE_report(reports, RPT_ERROR, "Cannot add loops in edit mode");
1122
1220
                return;
1123
1221
        }
1124
1222
 
1128
1226
void ED_mesh_polys_add(Mesh *mesh, ReportList *reports, int count)
1129
1227
{
1130
1228
        if (mesh->edit_btmesh) {
1131
 
                BKE_report(reports, RPT_ERROR, "Can't add polys in edit mode.");
 
1229
                BKE_report(reports, RPT_ERROR, "Cannot add polygons in edit mode");
1132
1230
                return;
1133
1231
        }
1134
1232
 
1138
1236
void ED_mesh_calc_normals(Mesh *mesh)
1139
1237
{
1140
1238
#ifdef USE_BMESH_MPOLY_NORMALS
1141
 
        mesh_calc_normals_mapping_ex(mesh->mvert, mesh->totvert,
1142
 
                                     mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly,
1143
 
                                     NULL, NULL, 0, NULL, NULL, FALSE);
 
1239
        BKE_mesh_calc_normals_mapping_ex(mesh->mvert, mesh->totvert,
 
1240
                                         mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly,
 
1241
                                         NULL, NULL, 0, NULL, NULL, FALSE);
1144
1242
#else
1145
 
        mesh_calc_normals(mesh->mvert, mesh->totvert,
1146
 
                          mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly,
1147
 
                          NULL);
 
1243
        BKE_mesh_calc_normals(mesh->mvert, mesh->totvert,
 
1244
                              mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly,
 
1245
                              NULL);
1148
1246
#endif
1149
1247
}
1150
1248