31#include "RNA_prototypes.hh"
80 float fac = 0.0f, dfac = 1.0f /
float(
len);
84 for (
int i = 0; i <
len; i++) {
85 fuv[i][0] = 0.5f *
sinf(fac) + 0.5f;
86 fuv[i][1] = 0.5f *
cosf(fac) + 0.5f;
111 for (
int i = 0; i < face.
size(); i++) {
112 fuv[i] = &uv_map[face[i]].x;
155 Mesh *
mesh,
const char *name,
const bool active_set,
const bool do_init,
ReportList *reports)
162 name =
DATA_(
"UVMap");
167 bool is_init =
false;
179 if (layernum_dst && do_init) {
185 if (active_set || layernum_dst == 0) {
186 mesh->uv_maps_active_set(unique_name);
191 layernum_dst =
mesh->uv_map_names().size();
198 if (!active_name.
is_empty() && do_init) {
211 if (active_set || layernum_dst == 0) {
212 mesh->uv_maps_active_set(unique_name);
217 if (!is_init && do_init) {
237 const char *uv_name =
mesh->uv_map_names()[uv_index].c_str();
252 const char *uv_name =
mesh->uv_map_names()[uv_index].c_str();
260 if (layernum_dst == 0) {
265 if (
mesh->uv_map_names().is_empty()) {
279 const bool active_set,
315 active_attr.materialize(new_attr.
span);
340 if (!
mesh->attributes_for_write().add(unique_name,
385 if (!
mesh->uv_map_names().contains_as(active_name)) {
413 ot->
name =
"Add UV Map";
415 ot->
idname =
"MESH_OT_uv_texture_add";
448 ot->
name =
"Remove UV Map";
450 ot->
idname =
"MESH_OT_uv_texture_remove";
492 if (
mesh->attributes().contains(
".sculpt_mask")) {
505 if (!(removed_a || removed_b)) {
510 const bool removed_a =
mesh->attributes_for_write().remove(
".sculpt_mask");
512 if (!(removed_a || removed_b)) {
537 return mesh->attributes().contains(
".sculpt_face_set");
545 bool changed =
false;
550 changed =
mesh->attributes_for_write().remove(
".sculpt_face_set");
565 ot->
name =
"Clear Sculpt Face Sets";
566 ot->
idname =
"MESH_OT_customdata_face_sets_clear";
567 ot->
description =
"Clear sculpt face set data from the mesh";
577 ot->
name =
"Clear Sculpt Mask Data";
578 ot->
idname =
"MESH_OT_customdata_mask_clear";
579 ot->
description =
"Clear vertex sculpt masking data from the mesh";
634 ot->
name =
"Add Skin Data";
635 ot->
idname =
"MESH_OT_customdata_skin_add";
662 if (!
mesh->attributes_for_write().remove(
"skin_modifier_radius")) {
665 mesh->attributes_for_write().remove(
"skin_modifier_root");
666 mesh->attributes_for_write().remove(
"skin_modifier_loose");
675 ot->
name =
"Clear Skin Data";
676 ot->
idname =
"MESH_OT_customdata_skin_clear";
711 ot->
name =
"Add Custom Normals Data";
712 ot->
idname =
"MESH_OT_customdata_custom_splitnormals_add";
713 ot->
description =
"Add a custom normals layer, if none exists yet";
736 if (!attributes.
remove(
"custom_normal")) {
741 mesh->tag_custom_normals_changed();
750 ot->
name =
"Clear Custom Normals Data";
751 ot->
idname =
"MESH_OT_customdata_custom_splitnormals_clear";
752 ot->
description =
"Remove the custom normals layer, if it exists";
772 const int old_size =
mesh->verts_num;
773 const int totvert = old_size +
len;
779 mesh->verts_num = totvert;
787 select_vert.finish();
797 const int old_size =
mesh->edges_num;
798 const int totedge = old_size +
len;
804 mesh->edges_num = totedge;
812 select_edge.finish();
822 const int old_size =
mesh->corners_num;
823 const int totloop = old_size +
len;
829 mesh->corners_num = totloop;
839 if (
mesh->face_offset_indices) {
840 mesh->face_offsets_for_write().last() =
mesh->corners_num;
850 const int old_size =
mesh->faces_num;
851 const int faces_num = old_size +
len;
856 &
mesh->runtime->face_offsets_sharing_info,
857 mesh->faces_num == 0 ? 0 : (
mesh->faces_num + 1),
860 mesh->face_offset_indices[0] = 0;
861 mesh->face_offset_indices[faces_num] =
mesh->corners_num;
865 mesh->faces_num = faces_num;
873 select_poly.finish();
878 if (
mesh->runtime->edit_mesh) {
887 if (
mesh->runtime->edit_mesh) {
896 if (
mesh->runtime->edit_mesh) {
905 if (
mesh->runtime->edit_mesh) {
924 const int totvert =
mesh->verts_num -
len;
926 mesh->verts_num = totvert;
935 const int totedge =
mesh->edges_num -
len;
937 mesh->edges_num = totedge;
946 const int totloop =
mesh->corners_num -
len;
948 mesh->corners_num = totloop;
957 const int faces_num =
mesh->faces_num -
len;
959 mesh->faces_num = faces_num;
964 if (
mesh->runtime->edit_mesh) {
968 if (count >
mesh->verts_num) {
978 if (
mesh->runtime->edit_mesh) {
982 if (count >
mesh->edges_num) {
992 if (
mesh->runtime->edit_mesh) {
996 if (count >
mesh->corners_num) {
1006 if (
mesh->runtime->edit_mesh) {
1010 if (count >
mesh->faces_num) {
1034 const char *elem_type;
1037 elem_type =
"vertices";
1040 elem_type =
"edges";
1043 elem_type =
"faces";
1069 if (
mesh !=
nullptr) {
1074 if (ob ==
nullptr) {
1083 return id_cast<Mesh *>(
data);
1100 for (const int face_i : range) {
1101 if (!sharp_faces.is_empty() && sharp_faces[face_i]) {
1102 for (const int edge : corner_edges.slice(polys[face_i])) {
1103 sharp_edges[edge] = true;
Generic geometry attributes built on CustomData.
CustomData interface, see also DNA_customdata_types.h.
#define ID_IS_EDITABLE(_id)
#define ID_IS_OVERRIDE_LIBRARY(_id)
Object is a sort of wrapper for general info.
Read Blender memory allocation and freeing.
#define BM_ELEM_CD_GET_VOID_P(ele, offset)
#define BM_elem_flag_test(ele, hflag)
#define BM_ITER_MESH(ele, iter, bm, itype)
#define BM_ITER_ELEM_INDEX(ele, iter, data, itype, indexvar)
#define MAX_CUSTOMDATA_LAYER_NAME
static AttributeOwner from_id(ID *id)
GMutableSpan take_back(const int64_t n) const
static IndexMask from_bools(Span< bool > bools, LinearAllocator<> &memory)
constexpr int64_t size() const
static constexpr IndexRange from_begin_size(const int64_t begin, const int64_t size)
void materialize(MutableSpan< T > r_span) const
GAttributeReader lookup_or_default(StringRef name, AttrDomain domain, AttrType data_type, const void *default_value=nullptr) const
GAttributeReader lookup(const StringRef name) const
bool add(const StringRef name, const AttrDomain domain, const AttrType data_type, const AttributeInit &initializer)
GSpanAttributeWriter lookup_or_add_for_write_span(StringRef name, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
bool remove(const StringRef name)
GAttributeWriter lookup_or_add_for_write(StringRef name, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
GSpanAttributeWriter lookup_for_write_span(StringRef name)
constexpr bool is_empty() const
IndexRange index_range() const
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
void fill_attribute_range_default(MutableAttributeAccessor dst_attributes, AttrDomain domain, const AttributeFilter &attribute_filter, IndexRange range)
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))
void WM_main_add_notifier(uint type, void *reference)
static void mesh_remove_edges(Mesh *mesh, int len)
static wmOperatorStatus mesh_customdata_skin_add_exec(bContext *C, wmOperator *)
bool BM_data_layer_free_named(BMesh *bm, CustomData *data, StringRef name)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
static SkinState mesh_customdata_skin_state(bContext *C)
static void reset_uvs_bmesh(BMFace *f, const int cd_loop_uv_offset)
void ED_mesh_edges_remove(Mesh *mesh, ReportList *reports, int count)
void MESH_OT_customdata_face_sets_clear(wmOperatorType *ot)
static wmOperatorStatus mesh_customdata_mask_clear_exec(bContext *C, wmOperator *)
bool BKE_attribute_remove(AttributeOwner &owner, StringRef name, struct ReportList *reports)
void ED_mesh_loops_add(Mesh *mesh, ReportList *reports, int count)
void ED_mesh_geometry_clear(Mesh *mesh)
static bool mesh_customdata_skin_add_poll(bContext *C)
void BKE_id_attributes_default_color_set(struct ID *id, std::optional< StringRef > name)
int CustomData_number_of_layers(const CustomData *data, eCustomDataType type)
BMesh * BKE_editmesh_bmesh_get_for_write(Mesh *mesh)
void ED_mesh_verts_add(Mesh *mesh, ReportList *reports, int count)
static wmOperatorStatus mesh_uv_texture_remove_exec(bContext *C, wmOperator *op)
bool CustomData_free_layers(CustomData *data, eCustomDataType type)
void CustomData_realloc(CustomData *data, int old_size, int new_size, eCDAllocType alloctype=CD_CONSTRUCT)
static void mesh_remove_verts(Mesh *mesh, int len)
void CustomData_free_elem(CustomData *data, int index, int count)
ATTR_WARN_UNUSED_RESULT const BMLoop * l
bool CustomData_has_layer(const CustomData *data, eCustomDataType type)
void MESH_OT_customdata_mask_clear(wmOperatorType *ot)
void ED_mesh_edges_add(Mesh *mesh, ReportList *reports, int count)
VArray< bool > ED_mesh_uv_map_pin_layer_get(const Mesh *mesh, int uv_index)
void ED_mesh_loops_remove(Mesh *mesh, ReportList *reports, int count)
void MESH_OT_customdata_custom_splitnormals_clear(wmOperatorType *ot)
static void mesh_add_verts(Mesh *mesh, int len)
void MESH_OT_customdata_custom_splitnormals_add(wmOperatorType *ot)
void ED_mesh_uv_ensure(Mesh *mesh, const char *name)
static void mesh_add_faces(Mesh *mesh, int len)
static wmOperatorStatus mesh_customdata_custom_splitnormals_add_exec(bContext *C, wmOperator *)
void BKE_mesh_tessface_clear(Mesh *mesh)
bool CustomData_free_layer_named(CustomData *data, StringRef name)
std::string BKE_attribute_calc_unique_name(const AttributeOwner &owner, StringRef name)
static void mesh_add_loops(Mesh *mesh, int len)
void ED_mesh_uv_loop_reset(bContext *C, Mesh *mesh)
static bool mesh_customdata_face_sets_clear_poll(bContext *C)
static void mesh_uv_reset_array(float **fuv, const int len)
static bool mesh_customdata_mask_clear_poll(bContext *C)
void ED_mesh_faces_add(Mesh *mesh, ReportList *reports, int count)
static wmOperatorStatus mesh_customdata_face_sets_clear_exec(bContext *C, wmOperator *)
KeyBlock * BKE_keyblock_find_by_index(Key *key, int index)
static void mesh_remove_loops(Mesh *mesh, int len)
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
static bke::AttributeWriter< bool > ensure_corner_boolean_attribute(Mesh &mesh, const StringRef name)
void DEG_id_tag_update(ID *id, unsigned int flags)
static wmOperatorStatus mesh_customdata_skin_clear_exec(bContext *C, wmOperator *)
void BKE_report(ReportList *reports, eReportType type, const char *message)
static VArray< bool > get_corner_boolean_attribute(const Mesh &mesh, const StringRef name)
BMesh const char void * data
static bool uv_maps_poll(bContext *C)
static void mesh_remove_faces(Mesh *mesh, int len)
void BKE_lnor_spacearr_clear(MLoopNorSpaceArray *lnors_spacearr)
int CustomData_get_offset_named(const CustomData *data, eCustomDataType type, StringRef name)
static void mesh_add_edges(Mesh *mesh, int len)
void ED_mesh_split_faces(Mesh *mesh)
void BKE_mesh_runtime_clear_cache(Mesh *mesh)
static bool uv_texture_remove_poll(bContext *C)
void ED_mesh_faces_remove(Mesh *mesh, ReportList *reports, int count)
bool ED_operator_editable_mesh(bContext *C)
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)
BMDataLayerLookup BM_data_layer_lookup(const BMesh &bm, const StringRef name)
bool ED_mesh_color_ensure(Mesh *mesh, const char *name)
void ED_mesh_report_mirror_ex(ReportList &reports, int totmirr, int totfail, char selectmode)
std::optional< std::string > ED_mesh_color_add(Mesh *mesh, const char *name, bool active_set, bool do_init, ReportList *reports)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void BKE_mesh_ensure_skin_customdata(Mesh *mesh)
bke::AttributeWriter< bool > ED_mesh_uv_map_pin_layer_ensure(Mesh *mesh, int uv_index)
void MESH_OT_uv_texture_add(wmOperatorType *ot)
void MESH_OT_uv_texture_remove(wmOperatorType *ot)
Mesh * ED_mesh_context(bContext *C)
void BM_data_layer_ensure_named(BMesh *bm, CustomData *data, int type, const StringRef name)
void ED_mesh_report_mirror(ReportList &reports, int totmirr, int totfail)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
VecBase< int16_t, 2 > short2
void BM_data_layer_copy(BMesh *bm, CustomData *data, int type, int src_n, int dst_n)
void BKE_id_attributes_active_color_set(struct ID *id, std::optional< StringRef > name)
ID_Type GS(const char *name)
void MESH_OT_customdata_skin_add(wmOperatorType *ot)
static bool mesh_customdata_skin_clear_poll(bContext *C)
int CustomData_get_active_layer(const CustomData *data, eCustomDataType type)
const BMesh * BKE_editmesh_bmesh_get(const Object *ob)
std::optional< std::string > ED_mesh_uv_add(Mesh *mesh, const char *name, bool active_set, bool do_init, ReportList *reports)
void MESH_OT_customdata_skin_clear(wmOperatorType *ot)
void BM_data_layer_add_named(BMesh *bm, CustomData *data, int type, const StringRef name)
Scene * CTX_data_scene(const bContext *C)
static void reset_uv_map(Mesh *mesh, const StringRef name)
void BM_uv_map_attr_pin_ensure_for_all_layers(BMesh *bm)
VecBase< float, 3 > float3
void CustomData_ensure_layers_are_mutable(CustomData *data, int totelem)
void ED_mesh_verts_remove(Mesh *mesh, ReportList *reports, int count)
static wmOperatorStatus mesh_customdata_custom_splitnormals_clear_exec(bContext *C, wmOperator *)
bool CustomData_has_layer_named(const CustomData *data, eCustomDataType type, StringRef name)
StringRef BKE_uv_map_pin_name_get(StringRef uv_map_name, char *buffer)
static wmOperatorStatus mesh_uv_texture_add_exec(bContext *C, wmOperator *op)
int CustomData_get_named_layer(const CustomData *data, eCustomDataType type, StringRef name)
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
KeyBlock * ED_mesh_get_edit_shape_key(const Mesh *me)
static void reset_uvs_mesh(const IndexRange face, MutableSpan< float2 > uv_map)
ColorSceneLinearByteEncoded4b< eAlpha::Premultiplied > ColorGeometry4b
bool BKE_id_attributes_color_find(const struct ID *id, StringRef name)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
bke::MeshRuntime * runtime
std::shared_ptr< BMEditMesh > edit_mesh
MutableVArraySpan< T > span
struct MLoopNorSpaceArray * lnor_spacearr
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports