29#include "RNA_prototypes.hh"
139 float fac = 0.0f, dfac = 1.0f /
float(
len);
143 for (
int i = 0;
i <
len;
i++) {
144 fuv[
i][0] = 0.5f *
sinf(fac) + 0.5f;
145 fuv[
i][1] = 0.5f *
cosf(fac) + 0.5f;
170 for (
int i = 0;
i < face.
size();
i++) {
171 fuv[
i] = &uv_map[face[
i]].x;
199 for (
const int i :
faces.index_range()) {
219 Mesh *mesh,
const char *
name,
const bool active_set,
const bool do_init,
ReportList *reports)
231 bool is_init =
false;
243 if (layernum_dst && do_init) {
249 if (active_set || layernum_dst == 0) {
276 if (active_set || layernum_dst == 0) {
282 if (!is_init && do_init) {
328 if (layernum_dst == 0) {
334 if (layernum_dst == 0) {
354 const char *active_name =
mesh->active_color_attribute;
413 ID *
data = (ob) ?
static_cast<ID *
>(ob->
data) :
nullptr;
458 ot->name =
"Add UV Map";
459 ot->description =
"Add UV map";
460 ot->idname =
"MESH_OT_uv_texture_add";
497 ot->name =
"Remove UV Map";
498 ot->description =
"Remove UV map";
499 ot->idname =
"MESH_OT_uv_texture_remove";
522 if (
mesh->runtime->edit_mesh) {
581 ot->name =
"Clear Sculpt Mask Data";
582 ot->idname =
"MESH_OT_customdata_mask_clear";
583 ot->description =
"Clear vertex sculpt masking data from the mesh";
632 ot->name =
"Add Skin Data";
633 ot->idname =
"MESH_OT_customdata_skin_add";
634 ot->description =
"Add a vertex skin layer";
657 ot->name =
"Clear Skin Data";
658 ot->idname =
"MESH_OT_customdata_skin_clear";
659 ot->description =
"Clear vertex skin layer";
679 if (
mesh->runtime->edit_mesh) {
684 if (!
mesh->attributes_for_write().add<
short2>(
700 ot->name =
"Add Custom Normals Data";
701 ot->idname =
"MESH_OT_customdata_custom_splitnormals_add";
702 ot->description =
"Add a custom normals layer, if none exists yet";
723 if (
bm.lnor_spacearr) {
728 if (!
mesh->attributes_for_write().remove(
"custom_normal")) {
733 mesh->tag_custom_normals_changed();
743 ot->name =
"Clear Custom Normals Data";
744 ot->idname =
"MESH_OT_customdata_custom_splitnormals_clear";
745 ot->description =
"Remove the custom normals layer, if it exists";
762 int totvert =
mesh->verts_num +
len;
773 mesh->vert_data = vert_data;
777 mesh->verts_num = totvert;
782 select_vert.
span.take_back(
len).fill(
true);
796 totedge =
mesh->edges_num +
len;
809 mesh->edge_data = edge_data;
813 mesh->edges_num = totedge;
818 select_edge.
span.take_back(
len).fill(
true);
831 totloop =
mesh->corners_num +
len;
848 mesh->corner_data = ldata;
850 mesh->corners_num = totloop;
854 if (
mesh->face_offset_indices) {
855 mesh->face_offsets_for_write().last() =
mesh->corners_num;
869 faces_num =
mesh->faces_num +
len;
877 &
mesh->runtime->face_offsets_sharing_info,
878 mesh->faces_num == 0 ? 0 : (
mesh->faces_num + 1),
881 mesh->face_offset_indices[0] = 0;
882 mesh->face_offset_indices[faces_num] =
mesh->corners_num;
885 mesh->face_data = face_data;
889 mesh->faces_num = faces_num;
894 select_poly.
span.take_back(
len).fill(
true);
904 if (
mesh->runtime->edit_mesh) {
913 if (
mesh->runtime->edit_mesh) {
922 if (
mesh->runtime->edit_mesh) {
931 if (
mesh->runtime->edit_mesh) {
950 const int totvert =
mesh->verts_num -
len;
952 mesh->verts_num = totvert;
961 const int totedge =
mesh->edges_num -
len;
963 mesh->edges_num = totedge;
972 const int totloop =
mesh->corners_num -
len;
974 mesh->corners_num = totloop;
983 const int faces_num =
mesh->faces_num -
len;
985 mesh->faces_num = faces_num;
990 if (
mesh->runtime->edit_mesh) {
1004 if (
mesh->runtime->edit_mesh) {
1018 if (
mesh->runtime->edit_mesh) {
1032 if (
mesh->runtime->edit_mesh) {
1056 const char *elem_type;
1059 elem_type =
"vertices";
1062 elem_type =
"edges";
1065 elem_type =
"faces";
1091 if (
mesh !=
nullptr) {
1096 if (ob ==
nullptr) {
1123 for (const int face_i : range) {
1124 if (!sharp_faces.is_empty() && sharp_faces[face_i]) {
1125 for (const int edge : corner_edges.slice(polys[face_i])) {
1126 sharp_edges[edge] = true;
void BKE_id_attributes_default_color_set(struct ID *id, std::optional< blender::StringRef > name)
struct CustomDataLayer * BKE_attribute_new(AttributeOwner &owner, blender::StringRef name, eCustomDataType type, blender::bke::AttrDomain domain, struct ReportList *reports)
blender::StringRef BKE_uv_map_pin_name_get(blender::StringRef uv_map_name, char *buffer)
std::string BKE_attribute_calc_unique_name(const AttributeOwner &owner, blender::StringRef name)
bool BKE_attribute_remove(AttributeOwner &owner, blender::StringRef name, struct ReportList *reports)
const struct CustomDataLayer * BKE_id_attributes_color_find(const struct ID *id, blender::StringRef name)
bool BKE_color_attribute_supported(const struct Mesh &mesh, blender::StringRef name)
void BKE_id_attributes_active_color_set(struct ID *id, std::optional< blender::StringRef > name)
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
Scene * CTX_data_scene(const bContext *C)
CustomData interface, see also DNA_customdata_types.h.
int CustomData_get_named_layer(const CustomData *data, eCustomDataType type, blender::StringRef name)
const void * CustomData_get_layer(const CustomData *data, eCustomDataType type)
void * CustomData_add_layer_named(CustomData *data, eCustomDataType type, eCDAllocType alloctype, int totelem, blender::StringRef name)
bool CustomData_has_layer_named(const CustomData *data, eCustomDataType type, blender::StringRef name)
const char * CustomData_get_layer_name(const CustomData *data, eCustomDataType type, int n)
int CustomData_get_offset_named(const CustomData *data, eCustomDataType type, blender::StringRef name)
void CustomData_free(CustomData *data)
void CustomData_free_layers(CustomData *data, eCustomDataType type)
void CustomData_init_layout_from(const CustomData *source, CustomData *dest, eCustomDataMask mask, eCDAllocType alloctype, int totelem)
int CustomData_get_active_layer(const CustomData *data, eCustomDataType type)
void CustomData_free_elem(CustomData *data, int index, int count)
void CustomData_copy_data(const CustomData *source, CustomData *dest, int source_index, int dest_index, int count)
bool CustomData_has_layer(const CustomData *data, eCustomDataType type)
size_t CustomData_get_elem_size(const CustomDataLayer *layer)
void CustomData_ensure_layers_are_mutable(CustomData *data, int totelem)
bool CustomData_layertype_is_singleton(eCustomDataType type)
const char * CustomData_get_active_layer_name(const CustomData *data, eCustomDataType type)
const void * CustomData_add_layer_named_with_data(CustomData *data, eCustomDataType type, void *layer_data, int totelem, blender::StringRef name, const blender::ImplicitSharingInfo *sharing_info)
int CustomData_number_of_layers(const CustomData *data, eCustomDataType type)
void CustomData_set_layer_active(CustomData *data, eCustomDataType type, int n)
const CustomData_MeshMasks CD_MASK_MESH
KeyBlock * BKE_keyblock_find_by_index(Key *key, int index)
void BKE_mesh_tessface_clear(Mesh *mesh)
void BKE_mesh_ensure_skin_customdata(Mesh *mesh)
bool BKE_mesh_has_custom_loop_normals(Mesh *mesh)
void BKE_lnor_spacearr_clear(MLoopNorSpaceArray *lnors_spacearr)
void BKE_mesh_runtime_clear_cache(Mesh *mesh)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
void DEG_id_tag_update(ID *id, unsigned int flags)
#define ID_IS_EDITABLE(_id)
#define ID_IS_OVERRIDE_LIBRARY(_id)
#define MAX_CUSTOMDATA_LAYER_NAME
Object is a sort of wrapper for general info.
bool ED_paint_proj_mesh_data_check(Scene &scene, Object &ob, bool *r_has_uvs, bool *r_has_mat, bool *r_has_tex, bool *r_has_stencil)
bool ED_operator_editable_mesh(bContext *C)
Read Guarded memory(de)allocation.
#define BM_ELEM_CD_GET_VOID_P(ele, offset)
#define BM_elem_flag_test(ele, hflag)
bool BM_data_layer_free_named(BMesh *bm, CustomData *data, StringRef name)
void BM_data_layer_free(BMesh *bm, CustomData *data, int type)
void BM_data_layer_copy(BMesh *bm, CustomData *data, int type, int src_n, int dst_n)
void BM_data_layer_add_named(BMesh *bm, CustomData *data, int type, const StringRef name)
void BM_uv_map_attr_pin_ensure_for_all_layers(BMesh *bm)
void BM_data_layer_ensure_named(BMesh *bm, CustomData *data, int type, const StringRef name)
#define BM_ITER_MESH(ele, iter, bm, itype)
#define BM_ITER_ELEM_INDEX(ele, iter, data, itype, indexvar)
BMesh const char void * data
ATTR_WARN_UNUSED_RESULT const BMLoop * l
static AttributeOwner from_id(ID *id)
static IndexMask from_bools(Span< bool > bools, IndexMaskMemory &memory)
constexpr int64_t size() const
void materialize(MutableSpan< T > r_span) const
GAttributeReader lookup_or_default(StringRef attribute_id, AttrDomain domain, AttrType data_type, const void *default_value=nullptr) const
GAttributeReader lookup(const StringRef attribute_id) const
GSpanAttributeWriter lookup_or_add_for_write_span(StringRef attribute_id, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
GAttributeWriter lookup_or_add_for_write(StringRef attribute_id, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
GSpanAttributeWriter lookup_for_write_span(StringRef attribute_id)
IndexRange index_range() const
VecBase< short, 2 > short2
void * MEM_dupallocN(const void *vmemh)
void MESH_OT_customdata_mask_clear(wmOperatorType *ot)
void ED_mesh_uv_ensure(Mesh *mesh, const char *name)
static blender::VArray< bool > get_corner_boolean_attribute(const Mesh &mesh, const StringRef name)
void ED_mesh_edges_remove(Mesh *mesh, ReportList *reports, int count)
static bool layers_poll(bContext *C)
void ED_mesh_report_mirror(ReportList &reports, int totmirr, int totfail)
static void mesh_remove_loops(Mesh *mesh, int len)
bool ED_mesh_color_ensure(Mesh *mesh, const char *name)
void MESH_OT_customdata_skin_add(wmOperatorType *ot)
static wmOperatorStatus mesh_customdata_mask_clear_exec(bContext *C, wmOperator *op)
static wmOperatorStatus mesh_uv_texture_add_exec(bContext *C, wmOperator *op)
static wmOperatorStatus mesh_customdata_skin_clear_exec(bContext *C, wmOperator *)
void MESH_OT_uv_texture_remove(wmOperatorType *ot)
void ED_mesh_edges_add(Mesh *mesh, ReportList *reports, int count)
static bool uv_texture_remove_poll(bContext *C)
static blender::bke::AttributeWriter< bool > ensure_corner_boolean_attribute(Mesh &mesh, const StringRef name)
void ED_mesh_loops_add(Mesh *mesh, ReportList *reports, int count)
static void reset_uvs_mesh(const blender::IndexRange face, MutableSpan< float2 > uv_map)
blender::bke::AttributeWriter< bool > ED_mesh_uv_map_pin_layer_ensure(Mesh *mesh, const int uv_index)
void ED_mesh_verts_add(Mesh *mesh, ReportList *reports, int count)
blender::VArray< bool > ED_mesh_uv_map_pin_layer_get(const Mesh *mesh, const int uv_index)
void MESH_OT_customdata_skin_clear(wmOperatorType *ot)
static void mesh_remove_faces(Mesh *mesh, int len)
void ED_mesh_geometry_clear(Mesh *mesh)
static void mesh_add_edges(Mesh *mesh, int len)
void ED_mesh_faces_remove(Mesh *mesh, ReportList *reports, int count)
int ED_mesh_uv_add(Mesh *mesh, const char *name, const bool active_set, const bool do_init, ReportList *reports)
void ED_mesh_faces_add(Mesh *mesh, ReportList *reports, int count)
static bool mesh_customdata_skin_add_poll(bContext *C)
static wmOperatorStatus mesh_customdata_skin_add_exec(bContext *C, wmOperator *)
static CustomData * mesh_customdata_get_type(Mesh *mesh, const char htype, int *r_tot)
void ED_mesh_loops_remove(Mesh *mesh, ReportList *reports, int count)
void ED_mesh_report_mirror_ex(ReportList &reports, int totmirr, int totfail, char selectmode)
static wmOperatorStatus mesh_uv_texture_remove_exec(bContext *C, wmOperator *op)
static void mesh_add_faces(Mesh *mesh, int len)
void ED_mesh_uv_loop_reset(bContext *C, Mesh *mesh)
static int mesh_customdata_skin_state(bContext *C)
static void reset_uv_map(Mesh *mesh, const StringRef name)
static wmOperatorStatus mesh_customdata_clear_exec__internal(bContext *C, char htype, const eCustomDataType type)
int ED_mesh_color_add(Mesh *mesh, const char *name, const bool active_set, const bool do_init, ReportList *reports)
void ED_mesh_split_faces(Mesh *mesh)
static void mesh_remove_verts(Mesh *mesh, int len)
static void mesh_add_verts(Mesh *mesh, int len)
void MESH_OT_uv_texture_add(wmOperatorType *ot)
static void mesh_add_loops(Mesh *mesh, int len)
static bool mesh_customdata_mask_clear_poll(bContext *C)
static wmOperatorStatus mesh_customdata_custom_splitnormals_clear_exec(bContext *C, wmOperator *)
static void reset_uvs_bmesh(BMFace *f, const int cd_loop_uv_offset)
static void mesh_remove_edges(Mesh *mesh, int len)
KeyBlock * ED_mesh_get_edit_shape_key(const Mesh *me)
void MESH_OT_customdata_custom_splitnormals_add(wmOperatorType *ot)
static bool mesh_customdata_skin_clear_poll(bContext *C)
void ED_mesh_verts_remove(Mesh *mesh, ReportList *reports, int count)
static void mesh_uv_reset_array(float **fuv, const int len)
static wmOperatorStatus mesh_customdata_custom_splitnormals_add_exec(bContext *C, wmOperator *)
void MESH_OT_customdata_custom_splitnormals_clear(wmOperatorType *ot)
Mesh * ED_mesh_context(bContext *C)
Object * context_object(const bContext *C)
Object * context_active_object(const bContext *C)
void split_edges(Mesh &mesh, const IndexMask &selected_edges, const bke::AttributeFilter &attribute_filter={})
void resize_trivial_array(T **data, const ImplicitSharingInfo **sharing_info, int64_t old_size, int64_t new_size)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
VecBase< float, 2 > float2
VecBase< float, 3 > float3
static void unique_name(bNode *node)
MeshRuntimeHandle * runtime
MutableVArraySpan< T > span
struct ReportList * reports
void WM_main_add_notifier(uint type, void *reference)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)