48
49
#include "DNA_mesh_types.h"
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)
52
53
const char *ret = BKE_mesh_cmp(mesh, mesh2, FLT_EPSILON * 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)
63
float (*r_loopnors)[3];
65
bool free_polynors = false;
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);
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);
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;
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,
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,
97
static void rna_Mesh_free_normals_split(Mesh *mesh)
99
CustomData_free_layers(&mesh->ldata, CD_NORMAL, mesh->totloop);
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)
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,
110
r_group_total, use_bitflags);
82
125
func = RNA_def_function(srna, "calc_normals", "BKE_mesh_calc_normals");
83
126
RNA_def_function_ui_description(func, "Calculate vertex normals");
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)",
133
RNA_def_property_subtype(parm, (PropertySubType)PROP_UNIT_ROTATION);
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");
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)");
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);
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);