42static const char *rna_Mesh_unit_test_compare(
Mesh *
mesh,
Mesh *mesh2,
float threshold)
54static void rna_Mesh_sharp_from_angle_set(
Mesh *
mesh,
const float angle)
56 mesh->attributes_for_write().remove(
"sharp_edge");
57 mesh->attributes_for_write().remove(
"sharp_face");
66 r_looptangents =
static_cast<float4 *
>(
68 memset(
reinterpret_cast<void *
>(r_looptangents), 0,
sizeof(
float4) *
mesh->corners_num);
77 uvmap =
mesh->active_uv_map_name().c_str();
82 if (uv_map.is_empty()) {
85 "Tangent space computation needs a UV Map, \"%s\" not found, aborting",
93 mesh->corner_normals(),
95 {r_looptangents, mesh->corners_num},
99static void rna_Mesh_free_tangents(
Mesh *
mesh)
104static void rna_Mesh_calc_corner_tri(
Mesh *
mesh)
109static void rna_Mesh_calc_smooth_groups(
Mesh *
mesh,
111 bool use_boundary_vertices_for_bitflags,
113 int *r_poly_group_num,
116 *r_poly_group_num =
mesh->faces_num;
124 mesh->corner_edges(),
125 mesh->corner_verts(),
128 use_boundary_vertices_for_bitflags,
134 mesh->corner_edges(),
141static void rna_Mesh_normals_split_custom_set(
Mesh *
mesh,
143 const float *normals,
146 float3 *corner_normals =
reinterpret_cast<float3 *
>(
const_cast<float *
>(normals));
147 const int numloops =
mesh->corners_num;
148 if (normals_num != numloops * 3) {
151 "Number of custom normals is not number of loops (%f / %d)",
152 float(normals_num) / 3.0f,
162static void rna_Mesh_normals_split_custom_set_from_vertices(
Mesh *
mesh,
164 const float *normals,
167 float3 *vert_normals =
reinterpret_cast<float3 *
>(
const_cast<float *
>(normals));
168 const int numverts =
mesh->verts_num;
169 if (normals_num != numverts * 3) {
172 "Number of custom normals is not number of vertices (%f / %d)",
173 float(normals_num) / 3.0f,
183static void rna_Mesh_transform(
Mesh *
mesh,
const float mat[16],
bool shape_keys)
190static void rna_Mesh_flip_normals(
Mesh *
mesh)
198static void rna_Mesh_update(
Mesh *
mesh,
201 const bool calc_edges_loose)
207 if (calc_edges_loose) {
208 mesh->runtime->loose_edges_cache.tag_dirty();
214 mesh->runtime->vert_normals_cache.tag_dirty();
215 mesh->runtime->face_normals_cache.tag_dirty();
216 mesh->runtime->corner_normals_cache.tag_dirty();
217 mesh->runtime->vert_normals_true_cache.tag_dirty();
218 mesh->runtime->face_normals_true_cache.tag_dirty();
224static void rna_Mesh_update_gpu_tag(
Mesh *
mesh)
229static void rna_Mesh_count_selected_items(
Mesh *
mesh,
int r_count[3])
234static void rna_Mesh_clear_geometry(
Mesh *
mesh)
245static bool rna_Mesh_validate(
Mesh *
mesh,
const bool verbose,
const bool )
250static bool rna_Mesh_validate_material_indices(
Mesh *
mesh)
265 const int normals_array_dim[] = {1, 3};
269 "Transform mesh vertices by a matrix "
270 "(Warning: inverts normals if matrix is negative)");
271 parm =
RNA_def_float_matrix(func,
"matrix", 4, 4,
nullptr, 0.0f, 0.0f,
"",
"Matrix", 0.0f, 0.0f);
273 RNA_def_boolean(func,
"shape_keys",
false,
"",
"Transform Shape Keys");
277 "Invert winding of all polygons "
278 "(clears tessellation, does not handle custom normals)");
280 func =
RNA_def_function(srna,
"set_sharp_from_angle",
"rna_Mesh_sharp_from_angle_set");
282 "Reset and fill the \"sharp_edge\" attribute based on the angle "
283 "of faces neighboring manifold edges");
290 "Angle between faces beyond which edges are marked sharp",
301 "Compute tangents and bitangent signs, to be used together with the custom normals "
302 "to get a complete tangent space for normal mapping "
303 "(custom normals are also computed if not yet present)");
309 "Name of the UV map to use for tangent space computation");
314 func =
RNA_def_function(srna,
"calc_loop_triangles",
"rna_Mesh_calc_corner_tri");
316 "Calculate loop triangle tessellation (supports editmode too)");
318 func =
RNA_def_function(srna,
"calc_smooth_groups",
"rna_Mesh_calc_smooth_groups");
321 func,
"use_bitflags",
false,
"",
"Produce bitflags groups instead of simple numeric values");
324 "use_boundary_vertices_for_bitflags",
327 "Also consider different smoothgroups sharing only vertices (but without any common edge) "
328 "as neighbors, preventing them from sharing the same bitflag value. Only effective when "
329 "``use_bitflags`` is set. "
330 "WARNING: Will overflow (run out of available bits) easily with some types of topology, "
331 "e.g. large fans of sharp edges");
333 parm =
RNA_def_int_array(func,
"poly_groups", 1,
nullptr, 0, 0,
"",
"Smooth Groups", 0, 0);
336 func,
"groups", 0, 0,
INT_MAX,
"groups",
"Total number of groups", 0,
INT_MAX);
339 func =
RNA_def_function(srna,
"normals_split_custom_set",
"rna_Mesh_normals_split_custom_set");
341 "Define custom normals of this mesh "
342 "(use zero-vectors to keep auto ones)");
345 parm =
RNA_def_float_array(func,
"normals", 1,
nullptr, -1.0f, 1.0f,
"",
"Normals", 0.0f, 0.0f);
350 "normals_split_custom_set_from_vertices",
351 "rna_Mesh_normals_split_custom_set_from_vertices");
353 "Define custom normals of this mesh, from vertices' normals "
354 "(use zero-vectors to keep auto ones)");
357 parm =
RNA_def_float_array(func,
"normals", 1,
nullptr, -1.0f, 1.0f,
"",
"Normals", 0.0f, 0.0f);
362 RNA_def_boolean(func,
"calc_edges",
false,
"Calculate Edges",
"Force recalculation of edges");
366 "Calculate Loose Edges",
367 "Calculate the loose state of each edge");
372 func =
RNA_def_function(srna,
"unit_test_compare",
"rna_Mesh_unit_test_compare");
380 "Comparison tolerance threshold",
385 func,
"result",
"nothing", 64,
"Return value",
"String description of result of comparison");
391 "Remove all geometry from the mesh. Note that this does not free shape keys or materials.");
395 "Validate geometry, return True when the mesh has had "
396 "invalid geometry corrected/removed");
397 RNA_def_boolean(func,
"verbose",
false,
"Verbose",
"Output information about the errors found");
399 func,
"clean_customdata",
true,
"Clean Custom Data",
"Deprecated, has no effect");
403 func =
RNA_def_function(srna,
"validate_material_indices",
"rna_Mesh_validate_material_indices");
406 "Validate material indices of polygons, return True when the mesh has had "
407 "invalid indices corrected (to default 0)");
411 func =
RNA_def_function(srna,
"count_selected_items",
"rna_Mesh_count_selected_items ");
CustomData interface, see also DNA_customdata_types.h.
#define MAX_CUSTOMDATA_LAYER_NAME_NO_PREFIX
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
std::optional< GeoMismatch > compare_meshes(const Mesh &mesh1, const Mesh &mesh2, float threshold)
Checks if the two meshes are different, returning the type of mismatch if any. Changes in index order...
const char * mismatch_to_string(const GeoMismatch &mismatch)
void calc_uv_tangent_tris_quads(Span< float3 > vert_positions, OffsetIndices< int > faces, Span< int > corner_verts, Span< float3 > corner_normals, Span< float2 > uv_map, MutableSpan< float4 > results, ReportList *reports)
bool mesh_validate_material_indices(Mesh &mesh)
void mesh_sharp_edges_set_from_angle(Mesh &mesh, float angle, bool keep_sharp_edges=false)
void mesh_flip_faces(Mesh &mesh, const IndexMask &selection)
void mesh_calc_edges(Mesh &mesh, bool keep_existing_edges, bool select_new_edges)
void mesh_transform(Mesh &mesh, const float4x4 &transform, bool do_shape_keys)
void mesh_set_custom_normals_from_verts(Mesh &mesh, MutableSpan< float3 > vert_normals)
bool mesh_validate(Mesh &mesh, bool verbose=false, bool allow_missing_edges=false)
void mesh_ensure_required_data_layers(Mesh &mesh)
void mesh_set_custom_normals(Mesh &mesh, MutableSpan< float3 > corner_normals)
void WM_main_add_notifier(uint type, void *reference)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
void RNA_def_function_output(FunctionRNA *, PropertyRNA *ret)
void BKE_mesh_clear_geometry_and_metadata(Mesh *mesh)
bool CustomData_free_layers(CustomData *data, eCustomDataType type)
PropertyRNA * RNA_def_float_array(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
bool CustomData_has_layer(const CustomData *data, eCustomDataType type)
void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[])
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
PropertyRNA * RNA_def_int_vector(StructOrFunctionRNA *cont_, const char *identifier, const int len, const int *default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void BKE_mesh_tessface_clear(Mesh *mesh)
MatBase< float, 4, 4 > float4x4
void BKE_mesh_count_selected_items(const Mesh *mesh, int r_count[3])
int * BKE_mesh_calc_smoothgroups(int edges_num, OffsetIndices< int > faces, Span< int > corner_edges, Span< bool > sharp_edges, Span< bool > sharp_faces, int *r_totgroup)
VecBase< float, 4 > float4
PropertyRNA * RNA_def_float_factor(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
VecBase< float, 2 > float2
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void DEG_id_tag_update(ID *id, unsigned int flags)
void BKE_mesh_batch_cache_dirty_tag(Mesh *mesh, eMeshBatchDirtyMode mode)
void BKE_animdata_free(ID *id, bool do_id_user)
void CustomData_set_layer_flag(CustomData *data, eCustomDataType type, eCustomDataLayer_Flag flag)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier_c_str, const char *call)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void RNA_def_function_flag(FunctionRNA *func, FunctionFlag flag)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void RNA_api_mesh(StructRNA *srna)
@ ID_RECALC_GEOMETRY_ALL_MODES
PropertyRNA * RNA_def_int_array(StructOrFunctionRNA *cont_, const char *identifier, const int len, const int *default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
void * CustomData_get_layer_for_write(CustomData *data, eCustomDataType type, int totelem)
VecBase< float, 3 > float3
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_float_matrix(StructOrFunctionRNA *cont_, const char *identifier, const int rows, const int columns, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
@ BKE_MESH_BATCH_DIRTY_ALL
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
void BKE_mesh_runtime_clear_geometry(Mesh *mesh)
void * CustomData_add_layer(CustomData *data, eCustomDataType type, eCDAllocType alloctype, int totelem)
int * BKE_mesh_calc_smoothgroups_bitflags(int edges_num, int verts_num, OffsetIndices< int > faces, Span< int > corner_edges, Span< int > corner_verts, Span< bool > sharp_edges, Span< bool > sharp_faces, bool use_boundary_vertices_for_bitflags, int *r_totgroup)