~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to source/blender/makesrna/intern/rna_mesh_api.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2014-02-19 11:24:23 UTC
  • mfrom: (14.2.23 sid)
  • Revision ID: package-import@ubuntu.com-20140219112423-rkmaz2m7ha06d4tk
Tags: 2.69-3ubuntu1
* Merge with Debian; remaining changes:
  - Configure without OpenImageIO on armhf, as it is not available on
    Ubuntu.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
#include "BLI_sys_types.h"
38
38
 
39
39
#include "BLI_utildefines.h"
 
40
#include "BLI_math.h"
40
41
 
41
42
#include "BKE_mesh.h"
42
43
#include "ED_mesh.h"
47
48
 
48
49
#include "DNA_mesh_types.h"
49
50
 
50
 
static const char *rna_Mesh_unit_test_compare(struct Mesh *mesh, bContext *C, struct Mesh *mesh2)
 
51
static const char *rna_Mesh_unit_test_compare(struct Mesh *mesh, struct Mesh *mesh2)
51
52
{
52
53
        const char *ret = BKE_mesh_cmp(mesh, mesh2, FLT_EPSILON * 60);
53
54
        
57
58
        return ret;
58
59
}
59
60
 
60
 
void rna_Mesh_calc_smooth_groups(struct Mesh *mesh, int *r_poly_group_len, int **r_poly_group, int *r_group_total)
 
61
static void rna_Mesh_calc_normals_split(Mesh *mesh, float min_angle)
 
62
{
 
63
        float (*r_loopnors)[3];
 
64
        float (*polynors)[3];
 
65
        bool free_polynors = false;
 
66
 
 
67
        if (CustomData_has_layer(&mesh->ldata, CD_NORMAL)) {
 
68
                r_loopnors = CustomData_get_layer(&mesh->ldata, CD_NORMAL);
 
69
                memset(r_loopnors, 0, sizeof(float[3]) * mesh->totloop);
 
70
        }
 
71
        else {
 
72
                r_loopnors = CustomData_add_layer(&mesh->ldata, CD_NORMAL, CD_CALLOC, NULL, mesh->totloop);
 
73
                CustomData_set_layer_flag(&mesh->ldata, CD_NORMAL, CD_FLAG_TEMPORARY);
 
74
        }
 
75
 
 
76
        if (CustomData_has_layer(&mesh->pdata, CD_NORMAL)) {
 
77
                /* This assume that layer is always up to date, not sure this is the case (esp. in Edit mode?)... */
 
78
                polynors = CustomData_get_layer(&mesh->pdata, CD_NORMAL);
 
79
                free_polynors = false;
 
80
        }
 
81
        else {
 
82
                polynors = MEM_mallocN(sizeof(float[3]) * mesh->totpoly, __func__);
 
83
                BKE_mesh_calc_normals_poly(mesh->mvert, mesh->totvert, mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly,
 
84
                                           polynors, false);
 
85
                free_polynors = true;
 
86
        }
 
87
 
 
88
        BKE_mesh_normals_loop_split(mesh->mvert, mesh->totvert, mesh->medge, mesh->totedge,
 
89
                                    mesh->mloop, r_loopnors, mesh->totloop, mesh->mpoly, polynors, mesh->totpoly,
 
90
                                    min_angle);
 
91
 
 
92
        if (free_polynors) {
 
93
                MEM_freeN(polynors);
 
94
        }
 
95
}
 
96
 
 
97
static void rna_Mesh_free_normals_split(Mesh *mesh)
 
98
{
 
99
        CustomData_free_layers(&mesh->ldata, CD_NORMAL, mesh->totloop);
 
100
}
 
101
 
 
102
static void rna_Mesh_calc_smooth_groups(Mesh *mesh, int use_bitflags, int *r_poly_group_len,
 
103
                                        int **r_poly_group, int *r_group_total)
61
104
{
62
105
        *r_poly_group_len = mesh->totpoly;
63
106
        *r_poly_group = BKE_mesh_calc_smoothgroups(
64
107
                            mesh->medge, mesh->totedge,
65
108
                            mesh->mpoly, mesh->totpoly,
66
109
                            mesh->mloop, mesh->totloop,
67
 
                            r_group_total);
 
110
                            r_group_total, use_bitflags);
68
111
}
69
112
 
70
113
#else
82
125
        func = RNA_def_function(srna, "calc_normals", "BKE_mesh_calc_normals");
83
126
        RNA_def_function_ui_description(func, "Calculate vertex normals");
84
127
 
 
128
        func = RNA_def_function(srna, "calc_normals_split", "rna_Mesh_calc_normals_split");
 
129
        RNA_def_function_ui_description(func, "Calculate split vertex normals, which preserve sharp edges");
 
130
        parm = RNA_def_float(func, "split_angle", M_PI, 0.0f, M_PI, "",
 
131
                             "Angle between polys' normals above which an edge is always sharp (180° to disable)",
 
132
                             0.0f, M_PI);
 
133
        RNA_def_property_subtype(parm, (PropertySubType)PROP_UNIT_ROTATION);
 
134
 
 
135
        func = RNA_def_function(srna, "free_normals_split", "rna_Mesh_free_normals_split");
 
136
        RNA_def_function_ui_description(func, "Free split vertex normals");
 
137
 
85
138
        func = RNA_def_function(srna, "calc_tessface", "ED_mesh_calc_tessface");
86
139
        RNA_def_function_ui_description(func, "Calculate face tessellation (supports editmode too)");
87
140
 
88
141
        func = RNA_def_function(srna, "calc_smooth_groups", "rna_Mesh_calc_smooth_groups");
89
142
        RNA_def_function_ui_description(func, "Calculate smooth groups from sharp edges");
 
143
        RNA_def_boolean(func, "use_bitflags", false, "", "Produce bitflags groups instead of simple numeric values");
90
144
        /* return values */
91
145
        parm = RNA_def_int_array(func, "poly_groups", 1, NULL, 0, 0, "", "Smooth Groups", 0, 0);
92
146
        RNA_def_property_flag(parm, PROP_DYNAMIC | PROP_OUTPUT);
101
155
 
102
156
        func = RNA_def_function(srna, "unit_test_compare", "rna_Mesh_unit_test_compare");
103
157
        RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh to compare to");
104
 
        RNA_def_function_flag(func, FUNC_USE_CONTEXT);
105
158
        /* return value */
106
159
        parm = RNA_def_string(func, "result", "nothing", 64, "Return value", "String description of result of comparison");
107
160
        RNA_def_function_return(func, parm);