53 if (mesh_ !=
nullptr) {
56 new_component->vertex_group_names_ =
blender::Map(vertex_group_names_);
64 if (mesh_ !=
nullptr) {
70 vertex_group_names_.
clear();
75 return mesh_ !=
nullptr;
84 ownership_ = ownership;
94 if (mesh_ !=
nullptr) {
101 ownership_ = ownership;
117 vertex_group_names_.
clear();
120 vertex_group_names_.
add(group->name, index);
127 return vertex_group_names_;
133 return vertex_group_names_;
157 return mesh_ ==
nullptr;
182 if (mesh_ ==
nullptr) {
211 const T value = attribute[loop_index];
213 const int point_index = loop.
v;
214 mixer.mix_in(point_index, value);
225 using T = decltype(dummy);
230 adapt_mesh_domain_corner_to_point_impl<T>(
mesh, *attribute, values);
235 return new_attribute;
246 const int vertex_index =
mesh.
mloop[loop_index].
v;
247 r_values[loop_index] = attribute[vertex_index];
257 using T = decltype(dummy);
263 adapt_mesh_domain_point_to_corner_impl<T>(
mesh, *attribute, values);
267 return new_attribute;
286 const T value = old_values[loop_index];
287 mixer.mix_in(poly_index, value);
300 using T = decltype(dummy);
303 adapt_mesh_domain_corner_to_face_impl<T>(
mesh, attribute->get_span<
T>(), values);
308 return new_attribute;
324 const int loop_index_next = (loop_index + 1) % poly.
totloop;
326 const int edge_index = loop.
e;
327 mixer.mix_in(edge_index, old_values[loop_index]);
328 mixer.mix_in(edge_index, old_values[loop_index_next]);
341 using T = decltype(dummy);
344 adapt_mesh_domain_corner_to_edge_impl<T>(
mesh, attribute->get_span<
T>(), values);
349 return new_attribute;
362 const T value = old_values[poly_index];
365 const int point_index = loop.
v;
366 mixer.mix_in(point_index, value);
379 using T = decltype(dummy);
382 adapt_mesh_domain_face_to_point_impl<T>(
mesh, attribute->get_span<
T>(), values);
387 return new_attribute;
400 poly_corner_values.
fill(old_values[poly_index]);
410 using T = decltype(dummy);
413 adapt_mesh_domain_face_to_corner_impl<T>(
mesh, attribute->get_span<
T>(), values);
418 return new_attribute;
431 const T value = old_values[poly_index];
434 mixer.mix_in(loop.
e, value);
446 using T = decltype(dummy);
449 adapt_mesh_domain_face_to_edge_impl<T>(
mesh, attribute->get_span<
T>(), values);
454 return new_attribute;
474 const int point_index = loop.
v;
475 mixer.mix_in(poly_index, old_values[point_index]);
487 using T = decltype(dummy);
490 adapt_mesh_domain_point_to_face_impl<T>(
mesh, attribute->get_span<
T>(), values);
495 return new_attribute;
513 mixer.mix_in(edge_index, old_values[edge.
v1]);
514 mixer.mix_in(edge_index, old_values[edge.
v2]);
526 using T = decltype(dummy);
529 adapt_mesh_domain_point_to_edge_impl<T>(
mesh, attribute->get_span<
T>(), values);
534 return new_attribute;
550 const int loop_index_prev = loop_index - 1 + (loop_index == poly.
loopstart) * poly.
totloop;
553 mixer.mix_in(loop_index, old_values[loop.e]);
554 mixer.mix_in(loop_index, old_values[loop_prev.e]);
567 using T = decltype(dummy);
570 adapt_mesh_domain_edge_to_corner_impl<T>(
mesh, attribute->get_span<
T>(), values);
575 return new_attribute;
588 const T value = old_values[edge_index];
589 mixer.mix_in(edge.
v1, value);
590 mixer.mix_in(edge.
v2, value);
602 using T = decltype(dummy);
605 adapt_mesh_domain_edge_to_point_impl<T>(
mesh, attribute->get_span<
T>(), values);
610 return new_attribute;
630 mixer.mix_in(poly_index, old_values[loop.
e]);
643 using T = decltype(dummy);
646 adapt_mesh_domain_edge_to_face_impl<T>(
mesh, attribute->get_span<
T>(), values);
651 return new_attribute;
662 if (attribute->size() == 0) {
666 if (old_domain == new_domain) {
670 switch (old_domain) {
672 switch (new_domain) {
685 switch (new_domain) {
698 switch (new_domain) {
711 switch (new_domain) {
746 template<
typename StructT,
748 ElemT (*GetFunc)(
const StructT &),
752 return std::make_unique<DerivedArrayReadAttribute<StructT, ElemT, GetFunc>>(
756 template<
typename StructT,
758 ElemT (*GetFunc)(
const StructT &),
759 void (*SetFunc)(StructT &,
const ElemT &),
763 return std::make_unique<DerivedArrayWriteAttribute<StructT, ElemT, GetFunc, SetFunc>>(
780 if (
mesh !=
nullptr) {
787 return static_cast<int>(mpoly.
mat_nr);
831 return edge.
crease / 255.0f;
842 const int dvert_index_;
848 dvert_index_(dvert_index)
860 weight->
weight = *
reinterpret_cast<const float *
>(value);
864 const int dvert_index,
868 if (dverts ==
nullptr) {
869 *(
float *)r_value = 0.0f;
874 if (weight.def_nr == dvert_index) {
875 *(
float *)r_value = weight.weight;
879 *(
float *)r_value = 0.0f;
886 const int dvert_index_;
892 dvert_index_(dvert_index)
908 const StringRef attribute_name)
const final
915 if (vertex_group_index < 0) {
919 static const float default_value = 0.0f;
920 return std::make_unique<ConstantReadAttribute>(
923 return std::make_unique<VertexWeightReadAttribute>(
928 const StringRef attribute_name)
const final
933 if (
mesh ==
nullptr) {
938 if (vertex_group_index < 0) {
949 return std::make_unique<blender::bke::VertexWeightWriteAttribute>(
960 if (vertex_group_index < 0) {
964 if (
mesh ==
nullptr) {
984 const int vertex_group_index = item.value;
985 if (vertex_group_index >= 0) {
1016 if (
mesh ==
nullptr) {
1025 return std::make_unique<ArrayReadAttribute<float3>>(
1067 if (
mesh !=
nullptr) {
1072 #define MAKE_MUTABLE_CUSTOM_DATA_GETTER(NAME) \
1073 [](GeometryComponent &component) -> CustomData * { \
1074 Mesh *mesh = get_mesh_from_component_for_write(component); \
1075 return mesh ? &mesh->NAME : nullptr; \
1077 #define MAKE_CONST_CUSTOM_DATA_GETTER(NAME) \
1078 [](const GeometryComponent &component) -> const CustomData * { \
1079 const Mesh *mesh = get_mesh_from_component_for_read(component); \
1080 return mesh ? &mesh->NAME : nullptr; \
1085 update_custom_data_pointers};
1088 update_custom_data_pointers};
1091 update_custom_data_pointers};
1094 update_custom_data_pointers};
1096 #undef MAKE_CONST_CUSTOM_DATA_GETTER
1097 #undef MAKE_MUTABLE_CUSTOM_DATA_GETTER
1108 make_derived_read_attribute<MVert, float3, get_vertex_position, ATTR_DOMAIN_POINT>,
1127 make_derived_read_attribute<MPoly, int, get_material_index, ATTR_DOMAIN_FACE>,
1144 make_derived_read_attribute<MPoly, bool, get_shade_smooth, ATTR_DOMAIN_FACE>,
1161 make_derived_read_attribute<MEdge, float, get_crease, ATTR_DOMAIN_EDGE>,
1162 make_derived_write_attribute<MEdge, float, get_crease, set_crease, ATTR_DOMAIN_EDGE>,
1170 make_derived_read_attribute<MLoopUV, float2, get_loop_uv, ATTR_DOMAIN_CORNER>,
1171 make_derived_write_attribute<MLoopUV, float2, get_loop_uv, set_loop_uv, ATTR_DOMAIN_CORNER>);
1178 make_derived_read_attribute<MLoopCol, Color4f, get_loop_color, ATTR_DOMAIN_CORNER>,
1194 &corner_custom_data,
1198 &face_custom_data});
typedef float(TangentPoint)[2]
bool CustomData_has_layer(const struct CustomData *data, int type)
void * CustomData_duplicate_referenced_layer(struct CustomData *data, const int type, const int totelem)
void * CustomData_get_layer(const struct CustomData *data, int type)
@ GEO_COMPONENT_TYPE_MESH
void BKE_id_free(struct Main *bmain, void *idv)
struct Mesh * BKE_mesh_copy_for_eval(struct Mesh *source, bool reference)
void BKE_mesh_calc_poly_normal(const struct MPoly *mpoly, const struct MLoop *loopstart, const struct MVert *mvarray, float r_no[3])
void BKE_mesh_update_customdata_pointers(struct Mesh *me, const bool do_ensure_tess_cd)
#define LISTBASE_FOREACH(type, var, list)
MINLINE unsigned char round_fl_to_uchar_clamp(float a)
MINLINE void srgb_to_linearrgb_v4(float linear[4], const float srgb[4])
void rgba_uchar_to_float(float r_col[4], const unsigned char col_ub[4])
MINLINE void linearrgb_to_srgb_uchar4(unsigned char srgb[4], const float linear[4])
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void copy_v3_v3(float r[3], const float a[3])
#define SET_FLAG_FROM_TEST(value, test, flag)
static uint8 component(Color32 c, uint i)
Object is a sort of wrapper for general info.
const Mesh * get_for_read() const
void replace_mesh_but_keep_vertex_group_names(Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
bool is_empty() const final
void replace(Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
void copy_vertex_group_names_from_object(const struct Object &object)
GeometryComponent * copy() const override
bool owns_direct_data() const override
void ensure_owns_direct_data() override
blender::bke::ReadAttributePtr attribute_try_adapt_domain(blender::bke::ReadAttributePtr attribute, const AttributeDomain new_domain) const final
const blender::Map< std::string, int > & vertex_group_names() const
int attribute_domain_size(const AttributeDomain domain) const final
Value pop_default_as(const ForwardKey &key, ForwardValue &&default_value)
bool add(const Key &key, const Value &value)
ItemIterator items() const
Value lookup_default_as(const ForwardKey &key, ForwardValue &&default_value) const
constexpr int64_t size() const
constexpr void fill(const T &value)
constexpr MutableSpan slice(const int64_t start, const int64_t size) const
bool exists(const GeometryComponent &component) const final
ReadAttributePtr try_get_for_read(const GeometryComponent &component) const final
WriteAttributePtr try_get_for_write(GeometryComponent &UNUSED(component)) const final
bool try_create(GeometryComponent &UNUSED(component)) const final
NormalAttributeProvider()
bool try_delete(GeometryComponent &UNUSED(component)) const final
void get(const int64_t index, void *r_value) const
void foreach_domain(const FunctionRef< void(AttributeDomain)> callback) const final
bool foreach_attribute(const GeometryComponent &component, const AttributeForeachCallback callback) const final
WriteAttributePtr try_get_for_write(GeometryComponent &component, const StringRef attribute_name) const final
ReadAttributePtr try_get_for_read(const GeometryComponent &component, const StringRef attribute_name) const final
bool try_delete(GeometryComponent &component, const StringRef attribute_name) const final
void get_internal(const int64_t index, void *r_value) const override
VertexWeightReadAttribute(const MDeformVert *dverts, const int totvert, const int dvert_index)
static void get_internal(const MDeformVert *dverts, const int dvert_index, const int64_t index, void *r_value)
VertexWeightWriteAttribute(MDeformVert *dverts, const int totvert, const int dvert_index)
void get_internal(const int64_t index, void *r_value) const override
void set_internal(const int64_t index, const void *value) override
void get(const int64_t index, void *r_value) const
DEGForeachIDComponentCallback callback
static float normals[][3]
#define MAKE_CONST_CUSTOM_DATA_GETTER(NAME)
MDeformVert * BKE_object_defgroup_data_create(ID *id)
#define MAKE_MUTABLE_CUSTOM_DATA_GETTER(NAME)
static Mesh * get_mesh_from_component_for_write(GeometryComponent &component)
static const Mesh * get_mesh_from_component_for_read(const GeometryComponent &component)
IconTextureDrawCall normal
typename DefaultMixerStruct< T >::type DefaultMixer
void convert_to_static_type(const CustomDataType data_type, const Func &func)
static ReadAttributePtr adapt_mesh_domain_point_to_face(const Mesh &mesh, ReadAttributePtr attribute)
static float3 get_vertex_position(const MVert &vert)
static ReadAttributePtr adapt_mesh_domain_edge_to_corner(const Mesh &mesh, ReadAttributePtr attribute)
static ReadAttributePtr adapt_mesh_domain_edge_to_point(const Mesh &mesh, ReadAttributePtr attribute)
static void adapt_mesh_domain_edge_to_point_impl(const Mesh &mesh, const Span< T > old_values, MutableSpan< T > r_values)
static void adapt_mesh_domain_point_to_face_impl(const Mesh &mesh, const Span< T > old_values, MutableSpan< T > r_values)
void adapt_mesh_domain_edge_to_corner_impl(const Mesh &mesh, const Span< T > old_values, MutableSpan< T > r_values)
static ReadAttributePtr adapt_mesh_domain_corner_to_point(const Mesh &mesh, ReadAttributePtr attribute)
static float get_crease(const MEdge &edge)
void adapt_mesh_domain_face_to_point_impl(const Mesh &mesh, Span< T > old_values, MutableSpan< T > r_values)
static void set_crease(MEdge &edge, const float &value)
static ReadAttributePtr adapt_mesh_domain_face_to_point(const Mesh &mesh, ReadAttributePtr attribute)
static void adapt_mesh_domain_point_to_corner_impl(const Mesh &mesh, const TypedReadAttribute< T > &attribute, MutableSpan< T > r_values)
static void adapt_mesh_domain_corner_to_point_impl(const Mesh &mesh, const TypedReadAttribute< T > &attribute, MutableSpan< T > r_values)
static WriteAttributePtr make_derived_write_attribute(void *data, const int domain_size)
static ReadAttributePtr adapt_mesh_domain_face_to_edge(const Mesh &mesh, ReadAttributePtr attribute)
static bool get_shade_smooth(const MPoly &mpoly)
static Color4f get_loop_color(const MLoopCol &col)
static ReadAttributePtr adapt_mesh_domain_face_to_corner(const Mesh &mesh, ReadAttributePtr attribute)
static ReadAttributePtr adapt_mesh_domain_corner_to_face(const Mesh &mesh, ReadAttributePtr attribute)
std::unique_ptr< WriteAttribute > WriteAttributePtr
static ReadAttributePtr adapt_mesh_domain_point_to_edge(const Mesh &mesh, ReadAttributePtr attribute)
static ReadAttributePtr make_derived_read_attribute(const void *data, const int domain_size)
static void set_loop_uv(MLoopUV &uv, const float2 &co)
static ReadAttributePtr adapt_mesh_domain_point_to_corner(const Mesh &mesh, ReadAttributePtr attribute)
static ReadAttributePtr adapt_mesh_domain_corner_to_edge(const Mesh &mesh, ReadAttributePtr attribute)
static void adapt_mesh_domain_edge_to_face_impl(const Mesh &mesh, const Span< T > old_values, MutableSpan< T > r_values)
static void tag_normals_dirty_when_writing_position(GeometryComponent &component)
static void set_loop_color(MLoopCol &col, const Color4f &linear_color)
void adapt_mesh_domain_face_to_corner_impl(const Mesh &mesh, const Span< T > old_values, MutableSpan< T > r_values)
static ComponentAttributeProviders create_attribute_providers_for_mesh()
static void set_vertex_position(MVert &vert, const float3 &position)
std::unique_ptr< ReadAttribute > ReadAttributePtr
static void adapt_mesh_domain_corner_to_edge_impl(const Mesh &mesh, Span< T > old_values, MutableSpan< T > r_values)
void adapt_mesh_domain_face_to_edge_impl(const Mesh &mesh, const Span< T > old_values, MutableSpan< T > r_values)
static void set_shade_smooth(MPoly &mpoly, const bool &value)
static ReadAttributePtr adapt_mesh_domain_edge_to_face(const Mesh &mesh, ReadAttributePtr attribute)
static float2 get_loop_uv(const MLoopUV &uv)
static void adapt_mesh_domain_corner_to_face_impl(const Mesh &mesh, Span< T > old_values, MutableSpan< T > r_values)
static void adapt_mesh_domain_point_to_edge_impl(const Mesh &mesh, const Span< T > old_values, MutableSpan< T > r_values)
static int get_material_index(const MPoly &mpoly)
static void set_material_index(MPoly &mpoly, const int &index)
struct MDeformVert * dvert
ccl_device_inline int clamp(int a, int mn, int mx)