mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
Refactor: Use AttrType instead of CustomData type in attribute API
Change `eCustomDataType` to `bke::AttrType` for uses of the attribute API (the `AttributeAccessor` one anyway). I didn't touch any values that might be saved in files; those should be handled on a case by case basis. Part of #122398 Pull Request: https://projects.blender.org/blender/blender/pulls/141301
This commit is contained in:
parent
09902044ff
commit
1f92fd7577
112 changed files with 616 additions and 580 deletions
|
|
@ -750,7 +750,7 @@ static void attr_create_generic(Scene *scene,
|
|||
const ustring name{std::string_view(iter.name)};
|
||||
|
||||
const blender::bke::AttrDomain b_domain = iter.domain;
|
||||
const eCustomDataType b_data_type = iter.data_type;
|
||||
const blender::bke::AttrType b_data_type = iter.data_type;
|
||||
|
||||
if (need_motion && name == u_velocity) {
|
||||
const blender::VArraySpan b_attr = *iter.get<blender::float3>(
|
||||
|
|
@ -760,7 +760,7 @@ static void attr_create_generic(Scene *scene,
|
|||
}
|
||||
|
||||
/* Weak, use first float2 attribute as standard UV. */
|
||||
if (need_uv && !have_uv && b_data_type == CD_PROP_FLOAT2 &&
|
||||
if (need_uv && !have_uv && b_data_type == blender::bke::AttrType::Float2 &&
|
||||
b_domain == blender::bke::AttrDomain::Curve)
|
||||
{
|
||||
Attribute *attr = attributes.add(ATTR_STD_UV, name);
|
||||
|
|
|
|||
|
|
@ -114,7 +114,8 @@ static void attr_create_generic(Scene *scene,
|
|||
return;
|
||||
}
|
||||
|
||||
if (b_attr.domain == blender::bke::AttrDomain::Corner && iter.data_type == CD_PROP_BYTE_COLOR)
|
||||
if (b_attr.domain == blender::bke::AttrDomain::Corner &&
|
||||
iter.data_type == blender::bke::AttrType::ColorByte)
|
||||
{
|
||||
Attribute *attr = attributes.add(name, TypeRGBA, ATTR_ELEMENT_CORNER_BYTE);
|
||||
if (is_render_color) {
|
||||
|
|
@ -221,7 +222,9 @@ static set<ustring> get_blender_uv_names(const ::Mesh &b_mesh)
|
|||
{
|
||||
set<ustring> uv_names;
|
||||
b_mesh.attributes().foreach_attribute([&](const blender::bke::AttributeIter &iter) {
|
||||
if (iter.domain == blender::bke::AttrDomain::Corner && iter.data_type == CD_PROP_FLOAT2) {
|
||||
if (iter.domain == blender::bke::AttrDomain::Corner &&
|
||||
iter.data_type == blender::bke::AttrType::Float2)
|
||||
{
|
||||
if (!blender::bke::attribute_name_is_anonymous(iter.name)) {
|
||||
uv_names.emplace(std::string_view(iter.name));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,14 +89,14 @@ eCustomDataType cpp_type_to_custom_data_type(const CPPType &type);
|
|||
*/
|
||||
struct AttributeMetaData {
|
||||
AttrDomain domain;
|
||||
eCustomDataType data_type;
|
||||
AttrType data_type;
|
||||
|
||||
BLI_STRUCT_EQUALITY_OPERATORS_2(AttributeMetaData, domain, data_type)
|
||||
};
|
||||
|
||||
struct AttributeDomainAndType {
|
||||
AttrDomain domain;
|
||||
eCustomDataType data_type;
|
||||
AttrType data_type;
|
||||
BLI_STRUCT_EQUALITY_OPERATORS_2(AttributeDomainAndType, domain, data_type)
|
||||
};
|
||||
|
||||
|
|
@ -426,7 +426,7 @@ class AttributeIter {
|
|||
public:
|
||||
StringRefNull name;
|
||||
AttrDomain domain;
|
||||
eCustomDataType data_type;
|
||||
AttrType data_type;
|
||||
bool is_builtin = false;
|
||||
mutable const AttributeAccessor *accessor = nullptr;
|
||||
|
||||
|
|
@ -437,7 +437,7 @@ class AttributeIter {
|
|||
public:
|
||||
AttributeIter(const StringRefNull name,
|
||||
const AttrDomain domain,
|
||||
const eCustomDataType data_type,
|
||||
const AttrType data_type,
|
||||
const FunctionRef<GAttributeReader()> get_fn)
|
||||
: name(name), domain(domain), data_type(data_type), get_fn_(get_fn)
|
||||
{
|
||||
|
|
@ -461,15 +461,14 @@ class AttributeIter {
|
|||
}
|
||||
|
||||
/** Same as above, but may perform type and domain interpolation. This may return none. */
|
||||
GAttributeReader get(std::optional<AttrDomain> domain,
|
||||
std::optional<eCustomDataType> data_type) const;
|
||||
GAttributeReader get(std::optional<AttrDomain> domain, std::optional<AttrType> data_type) const;
|
||||
|
||||
GAttributeReader get(const AttrDomain domain) const
|
||||
{
|
||||
return this->get(domain, std::nullopt);
|
||||
}
|
||||
|
||||
GAttributeReader get(const eCustomDataType data_type) const
|
||||
GAttributeReader get(const AttrType data_type) const
|
||||
{
|
||||
return this->get(std::nullopt, data_type);
|
||||
}
|
||||
|
|
@ -478,7 +477,7 @@ class AttributeIter {
|
|||
AttributeReader<T> get(const std::optional<AttrDomain> domain = std::nullopt) const
|
||||
{
|
||||
const CPPType &cpp_type = CPPType::get<T>();
|
||||
const eCustomDataType data_type = cpp_type_to_custom_data_type(cpp_type);
|
||||
const AttrType data_type = cpp_type_to_attribute_type(cpp_type);
|
||||
return this->get(domain, data_type).typed<T>();
|
||||
}
|
||||
};
|
||||
|
|
@ -511,7 +510,7 @@ struct AttributeAccessorFunctions {
|
|||
bool (*add)(void *owner,
|
||||
StringRef attribute_id,
|
||||
AttrDomain domain,
|
||||
eCustomDataType data_type,
|
||||
AttrType data_type,
|
||||
const AttributeInit &initializer);
|
||||
};
|
||||
|
||||
|
|
@ -618,7 +617,7 @@ class AttributeAccessor {
|
|||
*/
|
||||
GAttributeReader lookup(StringRef attribute_id,
|
||||
std::optional<AttrDomain> domain,
|
||||
std::optional<eCustomDataType> data_type) const;
|
||||
std::optional<AttrType> data_type) const;
|
||||
|
||||
/**
|
||||
* Get read-only access to the attribute whereby the attribute is interpolated to the given
|
||||
|
|
@ -633,7 +632,7 @@ class AttributeAccessor {
|
|||
* Get read-only access to the attribute whereby the attribute is converted to the given type.
|
||||
* The result may be empty.
|
||||
*/
|
||||
GAttributeReader lookup(const StringRef attribute_id, const eCustomDataType data_type) const
|
||||
GAttributeReader lookup(const StringRef attribute_id, const AttrType data_type) const
|
||||
{
|
||||
return this->lookup(attribute_id, std::nullopt, data_type);
|
||||
}
|
||||
|
|
@ -647,7 +646,7 @@ class AttributeAccessor {
|
|||
const std::optional<AttrDomain> domain = std::nullopt) const
|
||||
{
|
||||
const CPPType &cpp_type = CPPType::get<T>();
|
||||
const eCustomDataType data_type = cpp_type_to_custom_data_type(cpp_type);
|
||||
const AttrType data_type = cpp_type_to_attribute_type(cpp_type);
|
||||
return this->lookup(attribute_id, domain, data_type).typed<T>();
|
||||
}
|
||||
|
||||
|
|
@ -659,7 +658,7 @@ class AttributeAccessor {
|
|||
*/
|
||||
GAttributeReader lookup_or_default(StringRef attribute_id,
|
||||
AttrDomain domain,
|
||||
eCustomDataType data_type,
|
||||
AttrType data_type,
|
||||
const void *default_value = nullptr) const;
|
||||
|
||||
/**
|
||||
|
|
@ -784,7 +783,7 @@ class MutableAttributeAccessor : public AttributeAccessor {
|
|||
*/
|
||||
bool add(const StringRef attribute_id,
|
||||
const AttrDomain domain,
|
||||
const eCustomDataType data_type,
|
||||
const AttrType data_type,
|
||||
const AttributeInit &initializer)
|
||||
{
|
||||
if (this->contains(attribute_id)) {
|
||||
|
|
@ -796,7 +795,7 @@ class MutableAttributeAccessor : public AttributeAccessor {
|
|||
bool add(const StringRef attribute_id, const AttrDomain domain, const AttributeInit &initializer)
|
||||
{
|
||||
const CPPType &cpp_type = CPPType::get<T>();
|
||||
const eCustomDataType data_type = cpp_type_to_custom_data_type(cpp_type);
|
||||
const AttrType data_type = cpp_type_to_attribute_type(cpp_type);
|
||||
return this->add(attribute_id, domain, data_type, initializer);
|
||||
}
|
||||
|
||||
|
|
@ -808,7 +807,7 @@ class MutableAttributeAccessor : public AttributeAccessor {
|
|||
GAttributeWriter lookup_or_add_for_write(
|
||||
StringRef attribute_id,
|
||||
AttrDomain domain,
|
||||
eCustomDataType data_type,
|
||||
AttrType data_type,
|
||||
const AttributeInit &initializer = AttributeInitDefaultValue());
|
||||
|
||||
/**
|
||||
|
|
@ -819,7 +818,7 @@ class MutableAttributeAccessor : public AttributeAccessor {
|
|||
GSpanAttributeWriter lookup_or_add_for_write_span(
|
||||
StringRef attribute_id,
|
||||
AttrDomain domain,
|
||||
eCustomDataType data_type,
|
||||
AttrType data_type,
|
||||
const AttributeInit &initializer = AttributeInitDefaultValue());
|
||||
|
||||
/**
|
||||
|
|
@ -832,7 +831,7 @@ class MutableAttributeAccessor : public AttributeAccessor {
|
|||
const AttributeInit &initializer = AttributeInitDefaultValue())
|
||||
{
|
||||
const CPPType &cpp_type = CPPType::get<T>();
|
||||
const eCustomDataType data_type = cpp_type_to_custom_data_type(cpp_type);
|
||||
const AttrType data_type = cpp_type_to_attribute_type(cpp_type);
|
||||
return this->lookup_or_add_for_write(attribute_id, domain, data_type, initializer).typed<T>();
|
||||
}
|
||||
|
||||
|
|
@ -865,7 +864,7 @@ class MutableAttributeAccessor : public AttributeAccessor {
|
|||
*/
|
||||
GSpanAttributeWriter lookup_or_add_for_write_only_span(StringRef attribute_id,
|
||||
AttrDomain domain,
|
||||
eCustomDataType data_type);
|
||||
AttrType data_type);
|
||||
|
||||
/**
|
||||
* Same as above, but should be used when the type is known at compile time.
|
||||
|
|
@ -919,7 +918,7 @@ Vector<AttributeTransferData> retrieve_attributes_for_transfer(
|
|||
bool allow_procedural_attribute_access(StringRef attribute_name);
|
||||
extern const char *no_procedural_access_message;
|
||||
|
||||
eCustomDataType attribute_data_type_highest_complexity(Span<eCustomDataType> data_types);
|
||||
AttrType attribute_data_type_highest_complexity(Span<AttrType> data_types);
|
||||
/**
|
||||
* Domains with a higher "information density" have a higher priority,
|
||||
* in order to choose a domain that will not lose data through domain conversion.
|
||||
|
|
|
|||
|
|
@ -57,9 +57,9 @@ inline void convert_to_static_type(const CPPType &cpp_type, const Func &func)
|
|||
}
|
||||
|
||||
template<typename Func>
|
||||
inline void convert_to_static_type(const eCustomDataType data_type, const Func &func)
|
||||
inline void convert_to_static_type(const bke::AttrType data_type, const Func &func)
|
||||
{
|
||||
const CPPType &cpp_type = *bke::custom_data_type_to_cpp_type(data_type);
|
||||
const CPPType &cpp_type = bke::attribute_type_to_cpp_type(data_type);
|
||||
convert_to_static_type(cpp_type, func);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
namespace blender::bke {
|
||||
|
||||
enum class AttrDomain : int8_t;
|
||||
enum class AttrType : int16_t;
|
||||
struct AttributeAccessorFunctions;
|
||||
|
||||
namespace mesh {
|
||||
|
|
@ -414,7 +415,7 @@ void mesh_select_face_flush(Mesh &mesh);
|
|||
void mesh_ensure_default_color_attribute_on_add(Mesh &mesh,
|
||||
StringRef id,
|
||||
AttrDomain domain,
|
||||
eCustomDataType data_type);
|
||||
bke::AttrType data_type);
|
||||
|
||||
void mesh_data_update(Depsgraph &depsgraph,
|
||||
const Scene &scene,
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include "BLT_translation.hh"
|
||||
|
||||
#include "BKE_attribute.hh"
|
||||
#include "BKE_attribute_legacy_convert.hh"
|
||||
#include "BKE_curves.hh"
|
||||
#include "BKE_customdata.hh"
|
||||
#include "BKE_editmesh.hh"
|
||||
|
|
@ -207,7 +208,7 @@ static bool name_valid_for_builtin_domain_and_type(
|
|||
const blender::bke::AttributeAccessor attributes,
|
||||
const StringRef name,
|
||||
const AttrDomain domain,
|
||||
const eCustomDataType data_type,
|
||||
const blender::bke::AttrType data_type,
|
||||
ReportList *reports)
|
||||
{
|
||||
if (const std::optional metadata = attributes.get_builtin_domain_and_type(name)) {
|
||||
|
|
@ -230,7 +231,7 @@ static bool name_valid_for_builtin_domain_and_type(
|
|||
static bool mesh_attribute_valid(const Mesh &mesh,
|
||||
const StringRef name,
|
||||
const AttrDomain domain,
|
||||
const eCustomDataType data_type,
|
||||
const blender::bke::AttrType data_type,
|
||||
ReportList *reports)
|
||||
{
|
||||
using namespace blender;
|
||||
|
|
@ -297,7 +298,7 @@ bool BKE_attribute_rename(AttributeOwner &owner,
|
|||
if (!mesh_attribute_valid(*mesh,
|
||||
new_name,
|
||||
BKE_attribute_domain(owner, layer),
|
||||
eCustomDataType(layer->type),
|
||||
*bke::custom_data_type_to_attr_type(eCustomDataType(layer->type)),
|
||||
reports))
|
||||
{
|
||||
return false;
|
||||
|
|
@ -305,11 +306,12 @@ bool BKE_attribute_rename(AttributeOwner &owner,
|
|||
}
|
||||
else if (owner.type() == AttributeOwnerType::Curves) {
|
||||
Curves *curves = owner.get_curves();
|
||||
if (!name_valid_for_builtin_domain_and_type(curves->geometry.wrap().attributes(),
|
||||
new_name,
|
||||
BKE_attribute_domain(owner, layer),
|
||||
eCustomDataType(layer->type),
|
||||
reports))
|
||||
if (!name_valid_for_builtin_domain_and_type(
|
||||
curves->geometry.wrap().attributes(),
|
||||
new_name,
|
||||
BKE_attribute_domain(owner, layer),
|
||||
*bke::custom_data_type_to_attr_type(eCustomDataType(layer->type)),
|
||||
reports))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -405,7 +407,9 @@ CustomDataLayer *BKE_attribute_new(AttributeOwner &owner,
|
|||
if (owner.type() == AttributeOwnerType::Mesh) {
|
||||
Mesh *mesh = owner.get_mesh();
|
||||
if (BMEditMesh *em = mesh->runtime->edit_mesh.get()) {
|
||||
if (!mesh_attribute_valid(*mesh, name, domain, type, reports)) {
|
||||
if (!mesh_attribute_valid(
|
||||
*mesh, name, domain, *custom_data_type_to_attr_type(type), reports))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
BM_data_layer_add_named(em->bm, customdata, type, uniquename.c_str());
|
||||
|
|
@ -419,7 +423,8 @@ CustomDataLayer *BKE_attribute_new(AttributeOwner &owner,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
attributes->add(uniquename, domain, eCustomDataType(type), AttributeInitDefaultValue());
|
||||
attributes->add(
|
||||
uniquename, domain, *custom_data_type_to_attr_type(type), AttributeInitDefaultValue());
|
||||
|
||||
const int index = CustomData_get_named_layer_index(customdata, type, uniquename);
|
||||
if (index == -1) {
|
||||
|
|
@ -445,8 +450,10 @@ static void bke_attribute_copy_if_exists(AttributeOwner &owner,
|
|||
return;
|
||||
}
|
||||
|
||||
const eCustomDataType type = cpp_type_to_custom_data_type(src.varray.type());
|
||||
attributes->add(dstname, src.domain, type, AttributeInitVArray(src.varray));
|
||||
attributes->add(dstname,
|
||||
src.domain,
|
||||
cpp_type_to_attribute_type(src.varray.type()),
|
||||
AttributeInitVArray(src.varray));
|
||||
}
|
||||
|
||||
CustomDataLayer *BKE_attribute_duplicate(AttributeOwner &owner,
|
||||
|
|
@ -475,10 +482,10 @@ CustomDataLayer *BKE_attribute_duplicate(AttributeOwner &owner,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
const eCustomDataType type = cpp_type_to_custom_data_type(src.varray.type());
|
||||
const AttrType type = cpp_type_to_attribute_type(src.varray.type());
|
||||
attributes->add(uniquename, src.domain, type, AttributeInitVArray(src.varray));
|
||||
|
||||
if (owner.type() == AttributeOwnerType::Mesh && type == CD_PROP_FLOAT2) {
|
||||
if (owner.type() == AttributeOwnerType::Mesh && type == AttrType::Float2) {
|
||||
/* Duplicate UV sub-attributes. */
|
||||
char buffer_src[MAX_CUSTOMDATA_LAYER_NAME];
|
||||
char buffer_dst[MAX_CUSTOMDATA_LAYER_NAME];
|
||||
|
|
@ -613,7 +620,7 @@ bool BKE_attribute_remove(AttributeOwner &owner, const StringRef name, ReportLis
|
|||
&mesh->id, color_name_from_index(owner, color_clamp_index(owner, default_color_index)));
|
||||
}
|
||||
|
||||
if (metadata->data_type == CD_PROP_FLOAT2 && metadata->domain == AttrDomain::Corner) {
|
||||
if (metadata->data_type == AttrType::Float2 && metadata->domain == AttrDomain::Corner) {
|
||||
char buffer[MAX_CUSTOMDATA_LAYER_NAME];
|
||||
attributes->remove(BKE_uv_map_vert_select_name_get(name_copy, buffer));
|
||||
attributes->remove(BKE_uv_map_edge_select_name_get(name_copy, buffer));
|
||||
|
|
@ -1056,7 +1063,7 @@ bool BKE_color_attribute_supported(const Mesh &mesh, const StringRef name)
|
|||
return false;
|
||||
}
|
||||
if (!(ATTR_DOMAIN_AS_MASK(meta_data->domain) & ATTR_DOMAIN_MASK_COLOR) ||
|
||||
!(CD_TYPE_AS_MASK(meta_data->data_type) & CD_MASK_COLOR_ALL))
|
||||
!(CD_TYPE_AS_MASK(*attr_type_to_custom_data_type(meta_data->data_type)) & CD_MASK_COLOR_ALL))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include <utility>
|
||||
|
||||
#include "BKE_anonymous_attribute_id.hh"
|
||||
#include "BKE_attribute_legacy_convert.hh"
|
||||
#include "BKE_attribute_math.hh"
|
||||
#include "BKE_curves.hh"
|
||||
#include "BKE_customdata.hh"
|
||||
|
|
@ -188,7 +189,8 @@ eCustomDataType cpp_type_to_custom_data_type(const blender::CPPType &type)
|
|||
if (type.is<MStringProperty>()) {
|
||||
return CD_PROP_STRING;
|
||||
}
|
||||
return eCustomDataType(-1);
|
||||
BLI_assert_unreachable();
|
||||
return CD_PROP_FLOAT;
|
||||
}
|
||||
|
||||
const char *no_procedural_access_message = N_(
|
||||
|
|
@ -229,35 +231,35 @@ bool allow_procedural_attribute_access(StringRef attribute_name)
|
|||
return true;
|
||||
}
|
||||
|
||||
static int attribute_data_type_complexity(const eCustomDataType data_type)
|
||||
static int attribute_data_type_complexity(const AttrType data_type)
|
||||
{
|
||||
switch (data_type) {
|
||||
case CD_PROP_BOOL:
|
||||
case AttrType::Bool:
|
||||
return 0;
|
||||
case CD_PROP_INT8:
|
||||
case AttrType::Int8:
|
||||
return 1;
|
||||
case CD_PROP_INT32:
|
||||
case AttrType::Int32:
|
||||
return 2;
|
||||
case CD_PROP_FLOAT:
|
||||
case AttrType::Float:
|
||||
return 3;
|
||||
case CD_PROP_INT16_2D:
|
||||
case AttrType::Int16_2D:
|
||||
return 4;
|
||||
case CD_PROP_INT32_2D:
|
||||
case AttrType::Int32_2D:
|
||||
return 5;
|
||||
case CD_PROP_FLOAT2:
|
||||
case AttrType::Float2:
|
||||
return 6;
|
||||
case CD_PROP_FLOAT3:
|
||||
case AttrType::Float3:
|
||||
return 7;
|
||||
case CD_PROP_BYTE_COLOR:
|
||||
case AttrType::ColorByte:
|
||||
return 8;
|
||||
case CD_PROP_QUATERNION:
|
||||
case AttrType::Quaternion:
|
||||
return 9;
|
||||
case CD_PROP_COLOR:
|
||||
case AttrType::ColorFloat:
|
||||
return 10;
|
||||
case CD_PROP_FLOAT4X4:
|
||||
case AttrType::Float4x4:
|
||||
return 11;
|
||||
#if 0 /* These attribute types are not supported yet. */
|
||||
case CD_PROP_STRING:
|
||||
case AttrType::String:
|
||||
return 12;
|
||||
#endif
|
||||
default:
|
||||
|
|
@ -267,12 +269,12 @@ static int attribute_data_type_complexity(const eCustomDataType data_type)
|
|||
}
|
||||
}
|
||||
|
||||
eCustomDataType attribute_data_type_highest_complexity(Span<eCustomDataType> data_types)
|
||||
AttrType attribute_data_type_highest_complexity(Span<AttrType> data_types)
|
||||
{
|
||||
int highest_complexity = INT_MIN;
|
||||
eCustomDataType most_complex_type = CD_PROP_COLOR;
|
||||
AttrType most_complex_type = AttrType::ColorFloat;
|
||||
|
||||
for (const eCustomDataType data_type : data_types) {
|
||||
for (const AttrType data_type : data_types) {
|
||||
const int complexity = attribute_data_type_complexity(data_type);
|
||||
if (complexity > highest_complexity) {
|
||||
highest_complexity = complexity;
|
||||
|
|
@ -641,15 +643,16 @@ bool CustomDataAttributeProvider::foreach_attribute(
|
|||
return true;
|
||||
}
|
||||
for (const CustomDataLayer &layer : Span(custom_data->layers, custom_data->totlayer)) {
|
||||
const eCustomDataType data_type = eCustomDataType(layer.type);
|
||||
if (this->type_is_supported(data_type)) {
|
||||
const eCustomDataType cd_type = eCustomDataType(layer.type);
|
||||
if (this->type_is_supported(cd_type)) {
|
||||
const auto get_fn = [&]() {
|
||||
const CPPType *type = custom_data_type_to_cpp_type(data_type);
|
||||
const CPPType *type = custom_data_type_to_cpp_type(cd_type);
|
||||
BLI_assert(type);
|
||||
GSpan data{*type, layer.data, custom_data_access_.get_element_num(owner)};
|
||||
return GAttributeReader{GVArray::ForSpan(data), domain_, layer.sharing_info};
|
||||
};
|
||||
|
||||
const AttrType data_type = *custom_data_type_to_attr_type(cd_type);
|
||||
AttributeIter iter{layer.name, domain_, data_type, get_fn};
|
||||
fn(iter);
|
||||
if (iter.is_stopped()) {
|
||||
|
|
@ -687,11 +690,10 @@ std::optional<AttributeAccessor> AttributeAccessor::from_id(const ID &id)
|
|||
return {};
|
||||
}
|
||||
|
||||
static GAttributeReader adapt_domain_and_type_if_necessary(
|
||||
GAttributeReader attribute,
|
||||
const std::optional<AttrDomain> domain,
|
||||
const std::optional<eCustomDataType> data_type,
|
||||
const AttributeAccessor &accessor)
|
||||
static GAttributeReader adapt_domain_and_type_if_necessary(GAttributeReader attribute,
|
||||
const std::optional<AttrDomain> domain,
|
||||
const std::optional<AttrType> data_type,
|
||||
const AttributeAccessor &accessor)
|
||||
{
|
||||
if (!attribute) {
|
||||
return {};
|
||||
|
|
@ -707,7 +709,7 @@ static GAttributeReader adapt_domain_and_type_if_necessary(
|
|||
}
|
||||
}
|
||||
if (data_type.has_value()) {
|
||||
const CPPType &type = *custom_data_type_to_cpp_type(*data_type);
|
||||
const CPPType &type = attribute_type_to_cpp_type(*data_type);
|
||||
if (attribute.varray.type() != type) {
|
||||
attribute.varray = try_adapt_data_type(std::move(attribute.varray), type);
|
||||
attribute.sharing_info = nullptr;
|
||||
|
|
@ -721,27 +723,27 @@ static GAttributeReader adapt_domain_and_type_if_necessary(
|
|||
|
||||
GAttributeReader AttributeAccessor::lookup(const StringRef attribute_id,
|
||||
const std::optional<AttrDomain> domain,
|
||||
const std::optional<eCustomDataType> data_type) const
|
||||
const std::optional<AttrType> data_type) const
|
||||
{
|
||||
return adapt_domain_and_type_if_necessary(this->lookup(attribute_id), domain, data_type, *this);
|
||||
}
|
||||
|
||||
GAttributeReader AttributeIter::get(std::optional<AttrDomain> domain,
|
||||
std::optional<eCustomDataType> data_type) const
|
||||
std::optional<AttrType> data_type) const
|
||||
{
|
||||
return adapt_domain_and_type_if_necessary(this->get(), domain, data_type, *accessor);
|
||||
}
|
||||
|
||||
GAttributeReader AttributeAccessor::lookup_or_default(const StringRef attribute_id,
|
||||
const AttrDomain domain,
|
||||
const eCustomDataType data_type,
|
||||
const AttrType data_type,
|
||||
const void *default_value) const
|
||||
{
|
||||
GAttributeReader attribute = this->lookup(attribute_id, domain, data_type);
|
||||
if (attribute) {
|
||||
return attribute;
|
||||
}
|
||||
const CPPType &type = *custom_data_type_to_cpp_type(data_type);
|
||||
const CPPType &type = attribute_type_to_cpp_type(data_type);
|
||||
const int64_t domain_size = this->domain_size(domain);
|
||||
if (default_value == nullptr) {
|
||||
return {GVArray::ForSingleRef(type, domain_size, type.default_value()), domain, nullptr};
|
||||
|
|
@ -845,7 +847,7 @@ GSpanAttributeWriter MutableAttributeAccessor::lookup_for_write_span(const Strin
|
|||
GAttributeWriter MutableAttributeAccessor::lookup_or_add_for_write(
|
||||
const StringRef attribute_id,
|
||||
const AttrDomain domain,
|
||||
const eCustomDataType data_type,
|
||||
const AttrType data_type,
|
||||
const AttributeInit &initializer)
|
||||
{
|
||||
std::optional<AttributeMetaData> meta_data = this->lookup_meta_data(attribute_id);
|
||||
|
|
@ -864,7 +866,7 @@ GAttributeWriter MutableAttributeAccessor::lookup_or_add_for_write(
|
|||
GSpanAttributeWriter MutableAttributeAccessor::lookup_or_add_for_write_span(
|
||||
const StringRef attribute_id,
|
||||
const AttrDomain domain,
|
||||
const eCustomDataType data_type,
|
||||
const AttrType data_type,
|
||||
const AttributeInit &initializer)
|
||||
{
|
||||
GAttributeWriter attribute = this->lookup_or_add_for_write(
|
||||
|
|
@ -876,7 +878,7 @@ GSpanAttributeWriter MutableAttributeAccessor::lookup_or_add_for_write_span(
|
|||
}
|
||||
|
||||
GSpanAttributeWriter MutableAttributeAccessor::lookup_or_add_for_write_only_span(
|
||||
const StringRef attribute_id, const AttrDomain domain, const eCustomDataType data_type)
|
||||
const StringRef attribute_id, const AttrDomain domain, const AttrType data_type)
|
||||
{
|
||||
GAttributeWriter attribute = this->lookup_or_add_for_write(
|
||||
attribute_id, domain, data_type, AttributeInitConstruct());
|
||||
|
|
@ -899,7 +901,7 @@ bool MutableAttributeAccessor::rename(const StringRef old_attribute_id,
|
|||
if (!old_attribute) {
|
||||
return false;
|
||||
}
|
||||
const eCustomDataType type = cpp_type_to_custom_data_type(old_attribute.varray.type());
|
||||
const AttrType type = cpp_type_to_attribute_type(old_attribute.varray.type());
|
||||
if (old_attribute.sharing_info != nullptr && old_attribute.varray.is_span()) {
|
||||
if (!this->add(new_attribute_id,
|
||||
old_attribute.domain,
|
||||
|
|
@ -943,7 +945,7 @@ Vector<AttributeTransferData> retrieve_attributes_for_transfer(
|
|||
if (!(ATTR_DOMAIN_AS_MASK(iter.domain) & domain_mask)) {
|
||||
return;
|
||||
}
|
||||
if (iter.data_type == CD_PROP_STRING) {
|
||||
if (iter.data_type == AttrType::String) {
|
||||
return;
|
||||
}
|
||||
if (attribute_filter.allow_skip(iter.name)) {
|
||||
|
|
@ -971,7 +973,7 @@ void gather_attributes(const AttributeAccessor src_attributes,
|
|||
if (iter.domain != src_domain) {
|
||||
return;
|
||||
}
|
||||
if (iter.data_type == CD_PROP_STRING) {
|
||||
if (iter.data_type == AttrType::String) {
|
||||
return;
|
||||
}
|
||||
if (attribute_filter.allow_skip(iter.name)) {
|
||||
|
|
@ -1010,7 +1012,7 @@ void gather_attributes(const AttributeAccessor src_attributes,
|
|||
if (iter.domain != src_domain) {
|
||||
return;
|
||||
}
|
||||
if (iter.data_type == CD_PROP_STRING) {
|
||||
if (iter.data_type == AttrType::String) {
|
||||
return;
|
||||
}
|
||||
if (attribute_filter.allow_skip(iter.name)) {
|
||||
|
|
@ -1049,7 +1051,7 @@ void gather_attributes_group_to_group(const AttributeAccessor src_attributes,
|
|||
if (iter.domain != src_domain) {
|
||||
return;
|
||||
}
|
||||
if (iter.data_type == CD_PROP_STRING) {
|
||||
if (iter.data_type == AttrType::String) {
|
||||
return;
|
||||
}
|
||||
if (attribute_filter.allow_skip(iter.name)) {
|
||||
|
|
@ -1078,7 +1080,7 @@ void gather_attributes_to_groups(const AttributeAccessor src_attributes,
|
|||
if (iter.domain != src_domain) {
|
||||
return;
|
||||
}
|
||||
if (iter.data_type == CD_PROP_STRING) {
|
||||
if (iter.data_type == AttrType::String) {
|
||||
return;
|
||||
}
|
||||
if (attribute_filter.allow_skip(iter.name)) {
|
||||
|
|
@ -1126,7 +1128,7 @@ void copy_attributes_group_to_group(const AttributeAccessor src_attributes,
|
|||
if (iter.domain != src_domain) {
|
||||
return;
|
||||
}
|
||||
if (iter.data_type == CD_PROP_STRING) {
|
||||
if (iter.data_type == AttrType::String) {
|
||||
return;
|
||||
}
|
||||
if (attribute_filter.allow_skip(iter.name)) {
|
||||
|
|
@ -1155,7 +1157,7 @@ void fill_attribute_range_default(MutableAttributeAccessor attributes,
|
|||
if (attribute_filter.allow_skip(iter.name)) {
|
||||
return;
|
||||
}
|
||||
if (iter.data_type == CD_PROP_STRING) {
|
||||
if (iter.data_type == AttrType::String) {
|
||||
return;
|
||||
}
|
||||
GSpanAttributeWriter attribute = attributes.lookup_for_write_span(iter.name);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include "BLI_vector.hh"
|
||||
#include "BLI_vector_set.hh"
|
||||
|
||||
#include "BKE_attribute_legacy_convert.hh"
|
||||
#include "BKE_geometry_set.hh"
|
||||
|
||||
namespace blender::bke {
|
||||
|
|
@ -272,7 +273,8 @@ inline std::optional<AttributeDomainAndType> builtin_domain_and_type(const void
|
|||
if (const BuiltinAttributeProvider *provider =
|
||||
providers.builtin_attribute_providers().lookup_default_as(name, nullptr))
|
||||
{
|
||||
return AttributeDomainAndType{provider->domain(), provider->data_type()};
|
||||
const AttrType data_type = *custom_data_type_to_attr_type(provider->data_type());
|
||||
return AttributeDomainAndType{provider->domain(), data_type};
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
|
@ -315,7 +317,10 @@ inline void foreach_attribute(const void *owner,
|
|||
{
|
||||
if (provider->exists(owner)) {
|
||||
const auto get_fn = [&]() { return provider->try_get_for_read(owner); };
|
||||
AttributeIter iter{provider->name(), provider->domain(), provider->data_type(), get_fn};
|
||||
AttributeIter iter{provider->name(),
|
||||
provider->domain(),
|
||||
*custom_data_type_to_attr_type(provider->data_type()),
|
||||
get_fn};
|
||||
iter.is_builtin = true;
|
||||
iter.accessor = &accessor;
|
||||
fn(iter);
|
||||
|
|
@ -385,23 +390,24 @@ inline bool remove(void *owner, const StringRef name)
|
|||
template<const GeometryAttributeProviders &providers>
|
||||
inline bool add(void *owner,
|
||||
const StringRef name,
|
||||
AttrDomain domain,
|
||||
eCustomDataType data_type,
|
||||
const AttrDomain domain,
|
||||
const AttrType data_type,
|
||||
const AttributeInit &initializer)
|
||||
{
|
||||
const eCustomDataType custom_data_type = *attr_type_to_custom_data_type(data_type);
|
||||
if (const BuiltinAttributeProvider *provider =
|
||||
providers.builtin_attribute_providers().lookup_default_as(name, nullptr))
|
||||
{
|
||||
if (provider->domain() != domain) {
|
||||
return false;
|
||||
}
|
||||
if (provider->data_type() != data_type) {
|
||||
if (provider->data_type() != custom_data_type) {
|
||||
return false;
|
||||
}
|
||||
return provider->try_create(owner, initializer);
|
||||
}
|
||||
for (const DynamicAttributesProvider *provider : providers.dynamic_attribute_providers()) {
|
||||
if (provider->try_create(owner, name, domain, data_type, initializer)) {
|
||||
if (provider->try_create(owner, name, domain, custom_data_type, initializer)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "BKE_anonymous_attribute_id.hh"
|
||||
#include "BKE_attribute_legacy_convert.hh"
|
||||
#include "BKE_bake_items.hh"
|
||||
#include "BKE_bake_items_serialize.hh"
|
||||
#include "BKE_curves.hh"
|
||||
|
|
@ -563,7 +564,7 @@ template<typename T>
|
|||
if (attributes.contains(*name)) {
|
||||
/* If the attribute exists already, copy the values over to the existing array. */
|
||||
GSpanAttributeWriter attribute = attributes.lookup_or_add_for_write_only_span(
|
||||
*name, *domain, *data_type);
|
||||
*name, *domain, *custom_data_type_to_attr_type(*data_type));
|
||||
if (!attribute) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -574,7 +575,7 @@ template<typename T>
|
|||
/* Add a new attribute that shares the data. */
|
||||
if (!attributes.add(*name,
|
||||
*domain,
|
||||
*data_type,
|
||||
*custom_data_type_to_attr_type(*data_type),
|
||||
AttributeInitShared(attribute_data, *attribute_sharing_info)))
|
||||
{
|
||||
return false;
|
||||
|
|
@ -1050,7 +1051,8 @@ static std::shared_ptr<io::serialize::ArrayValue> serialize_attributes(
|
|||
const StringRefNull domain_name = get_domain_io_name(iter.domain);
|
||||
io_attribute->append_str("domain", domain_name);
|
||||
|
||||
const StringRefNull type_name = get_data_type_io_name(iter.data_type);
|
||||
const StringRefNull type_name = get_data_type_io_name(
|
||||
*attr_type_to_custom_data_type(iter.data_type));
|
||||
io_attribute->append_str("type", type_name);
|
||||
|
||||
const GAttributeReader attribute = iter.get();
|
||||
|
|
|
|||
|
|
@ -393,7 +393,7 @@ static bool should_add_attribute_to_mesh(const AttributeAccessor &curve_attribut
|
|||
if (attribute_filter.allow_skip(id)) {
|
||||
return false;
|
||||
}
|
||||
if (meta_data.data_type == CD_PROP_STRING) {
|
||||
if (meta_data.data_type == AttrType::String) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
@ -590,7 +590,7 @@ static bool try_sharing_point_data(const CurvesGeometry &main,
|
|||
return mesh_attributes.add(
|
||||
id,
|
||||
AttrDomain::Point,
|
||||
bke::cpp_type_to_custom_data_type(src.varray.type()),
|
||||
bke::cpp_type_to_attribute_type(src.varray.type()),
|
||||
AttributeInitShared(src.varray.get_internal_span().data(), *src.sharing_info));
|
||||
}
|
||||
|
||||
|
|
@ -622,7 +622,7 @@ static void copy_main_point_domain_attribute_to_mesh(const CurvesInfo &curves_in
|
|||
}
|
||||
}
|
||||
GSpanAttributeWriter dst_attribute = mesh_attributes.lookup_or_add_for_write_only_span(
|
||||
id, dst_domain, bke::cpp_type_to_custom_data_type(src_attribute.varray.type()));
|
||||
id, dst_domain, bke::cpp_type_to_attribute_type(src_attribute.varray.type()));
|
||||
if (!dst_attribute) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -943,7 +943,7 @@ Mesh *curve_to_mesh_sweep(const CurvesGeometry &main,
|
|||
}
|
||||
|
||||
const AttrDomain src_domain = iter.domain;
|
||||
const eCustomDataType type = iter.data_type;
|
||||
const AttrType type = iter.data_type;
|
||||
const GAttributeReader src = iter.get();
|
||||
const AttrDomain dst_domain = get_attribute_domain_for_mesh(mesh_attributes, iter.name);
|
||||
|
||||
|
|
@ -979,7 +979,7 @@ Mesh *curve_to_mesh_sweep(const CurvesGeometry &main,
|
|||
return;
|
||||
}
|
||||
const AttrDomain src_domain = iter.domain;
|
||||
const eCustomDataType type = iter.data_type;
|
||||
const AttrType type = iter.data_type;
|
||||
const GVArray src = *iter.get();
|
||||
|
||||
const AttrDomain dst_domain = get_attribute_domain_for_mesh(mesh_attributes, iter.name);
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ static bool foreach_vertex_group(const void *owner, FunctionRef<void(const Attri
|
|||
const auto get_fn = [&]() {
|
||||
return reader_for_vertex_group_index(*curves, dverts, group_index);
|
||||
};
|
||||
AttributeIter iter{group->name, AttrDomain::Point, CD_PROP_FLOAT, get_fn};
|
||||
AttributeIter iter{group->name, AttrDomain::Point, bke::AttrType::Float, get_fn};
|
||||
fn(iter);
|
||||
if (iter.is_stopped()) {
|
||||
return false;
|
||||
|
|
@ -308,9 +308,7 @@ static AttributeAccessorFunctions get_curves_accessor_functions()
|
|||
if (!info) {
|
||||
return std::nullopt;
|
||||
}
|
||||
const std::optional<eCustomDataType> cd_type = attr_type_to_custom_data_type(info->type);
|
||||
BLI_assert(cd_type.has_value());
|
||||
return AttributeDomainAndType{info->domain, *cd_type};
|
||||
return AttributeDomainAndType{info->domain, info->type};
|
||||
};
|
||||
fn.get_builtin_default = [](const void * /*owner*/, StringRef name) -> GPointer {
|
||||
const AttrBuiltinInfo &info = builtin_attributes().lookup(name);
|
||||
|
|
@ -355,10 +353,7 @@ static AttributeAccessorFunctions get_curves_accessor_functions()
|
|||
const int domain_size = get_domain_size(owner, attr.domain());
|
||||
return attribute_to_reader(attr, attr.domain(), domain_size);
|
||||
};
|
||||
const std::optional<eCustomDataType> cd_type = attr_type_to_custom_data_type(
|
||||
attr.data_type());
|
||||
BLI_assert(cd_type.has_value());
|
||||
AttributeIter iter(attr.name(), attr.domain(), *cd_type, get_fn);
|
||||
AttributeIter iter(attr.name(), attr.domain(), attr.data_type(), get_fn);
|
||||
iter.is_builtin = builtin_attributes().contains(attr.name());
|
||||
iter.accessor = &accessor;
|
||||
fn(iter);
|
||||
|
|
@ -413,13 +408,11 @@ static AttributeAccessorFunctions get_curves_accessor_functions()
|
|||
fn.add = [](void *owner,
|
||||
const StringRef name,
|
||||
const AttrDomain domain,
|
||||
const eCustomDataType data_type,
|
||||
const AttrType type,
|
||||
const AttributeInit &initializer) {
|
||||
CurvesGeometry &curves = *static_cast<CurvesGeometry *>(owner);
|
||||
const int domain_size = get_domain_size(owner, domain);
|
||||
AttributeStorage &storage = curves.attribute_storage.wrap();
|
||||
const std::optional<AttrType> type = custom_data_type_to_attr_type(data_type);
|
||||
BLI_assert(type.has_value());
|
||||
if (const AttrBuiltinInfo *info = builtin_attributes().lookup_ptr(name)) {
|
||||
if (info->domain != domain || info->type != type) {
|
||||
return false;
|
||||
|
|
@ -428,8 +421,8 @@ static AttributeAccessorFunctions get_curves_accessor_functions()
|
|||
if (storage.lookup(name)) {
|
||||
return false;
|
||||
}
|
||||
Attribute::DataVariant data = attribute_init_to_data(*type, domain_size, initializer);
|
||||
storage.add(name, domain, *type, std::move(data));
|
||||
Attribute::DataVariant data = attribute_init_to_data(type, domain_size, initializer);
|
||||
storage.add(name, domain, type, std::move(data));
|
||||
return true;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1646,7 +1646,7 @@ void CurvesGeometry::reverse_curves(const IndexMask &curves_to_reverse)
|
|||
if (iter.domain != AttrDomain::Point) {
|
||||
return;
|
||||
}
|
||||
if (iter.data_type == CD_PROP_STRING) {
|
||||
if (iter.data_type == bke::AttrType::String) {
|
||||
return;
|
||||
}
|
||||
if (bezier_handle_names.contains(iter.name)) {
|
||||
|
|
|
|||
|
|
@ -391,7 +391,7 @@ GVArray InstancesFieldInput::get_varray_for_context(const fn::FieldContext &cont
|
|||
GVArray AttributeFieldInput::get_varray_for_context(const GeometryFieldContext &context,
|
||||
const IndexMask & /*mask*/) const
|
||||
{
|
||||
const eCustomDataType data_type = cpp_type_to_custom_data_type(*type_);
|
||||
const bke::AttrType data_type = cpp_type_to_attribute_type(*type_);
|
||||
const AttrDomain domain = context.domain();
|
||||
if (const GreasePencil *grease_pencil = context.grease_pencil()) {
|
||||
const AttributeAccessor layer_attributes = grease_pencil->attributes();
|
||||
|
|
@ -500,7 +500,7 @@ GVArray IDAttributeFieldInput::get_varray_for_context(const GeometryFieldContext
|
|||
|
||||
const StringRef name = get_random_id_attribute_name(context.domain());
|
||||
if (auto attributes = context.attributes()) {
|
||||
if (GVArray attribute = *attributes->lookup(name, context.domain(), CD_PROP_INT32)) {
|
||||
if (GVArray attribute = *attributes->lookup<int>(name, context.domain())) {
|
||||
return attribute;
|
||||
}
|
||||
}
|
||||
|
|
@ -756,7 +756,7 @@ static std::optional<StringRefNull> try_get_field_direct_attribute_id(const fn::
|
|||
|
||||
static bool attribute_kind_matches(const AttributeMetaData meta_data,
|
||||
const AttrDomain domain,
|
||||
const eCustomDataType data_type)
|
||||
const bke::AttrType data_type)
|
||||
{
|
||||
return meta_data.domain == domain && meta_data.data_type == data_type;
|
||||
}
|
||||
|
|
@ -778,7 +778,7 @@ static bool try_add_shared_field_attribute(MutableAttributeAccessor attributes,
|
|||
if (!meta_data) {
|
||||
return false;
|
||||
}
|
||||
const eCustomDataType data_type = bke::cpp_type_to_custom_data_type(field.cpp_type());
|
||||
const bke::AttrType data_type = bke::cpp_type_to_attribute_type(field.cpp_type());
|
||||
if (!attribute_kind_matches(*meta_data, domain, data_type)) {
|
||||
/* Avoid costly domain and type interpolation, which would make sharing impossible. */
|
||||
return false;
|
||||
|
|
@ -817,7 +817,7 @@ bool try_capture_fields_on_geometry(MutableAttributeAccessor attributes,
|
|||
if (domain_size == 0) {
|
||||
bool all_added = true;
|
||||
for (const int i : attribute_ids.index_range()) {
|
||||
const eCustomDataType data_type = bke::cpp_type_to_custom_data_type(fields[i].cpp_type());
|
||||
const bke::AttrType data_type = bke::cpp_type_to_attribute_type(fields[i].cpp_type());
|
||||
all_added &= attributes.add(attribute_ids[i], domain, data_type, AttributeInitConstruct{});
|
||||
}
|
||||
return all_added;
|
||||
|
|
@ -847,7 +847,7 @@ bool try_capture_fields_on_geometry(MutableAttributeAccessor attributes,
|
|||
for (const int input_index : attribute_ids.index_range()) {
|
||||
const StringRef id = attribute_ids[input_index];
|
||||
const CPPType &type = fields[input_index].cpp_type();
|
||||
const eCustomDataType data_type = bke::cpp_type_to_custom_data_type(type);
|
||||
const bke::AttrType data_type = bke::cpp_type_to_attribute_type(type);
|
||||
|
||||
/* Avoid adding or writing to builtin attributes with an incorrect type or domain. */
|
||||
if (const std::optional<AttributeDomainAndType> meta_data =
|
||||
|
|
@ -908,7 +908,7 @@ bool try_capture_fields_on_geometry(MutableAttributeAccessor attributes,
|
|||
const StringRef id = attribute_ids[result.input_index];
|
||||
attributes.remove(id);
|
||||
const CPPType &type = fields[result.input_index].cpp_type();
|
||||
const eCustomDataType data_type = bke::cpp_type_to_custom_data_type(type);
|
||||
const bke::AttrType data_type = bke::cpp_type_to_attribute_type(type);
|
||||
if (!attributes.add(id, domain, data_type, AttributeInitMoveArray(result.buffer))) {
|
||||
/* If the name corresponds to a builtin attribute, removing the attribute might fail if
|
||||
* it's required, adding the attribute might fail if the domain or type is incorrect. */
|
||||
|
|
|
|||
|
|
@ -728,7 +728,7 @@ void GeometrySet::gather_attributes_for_propagation(
|
|||
return;
|
||||
}
|
||||
}
|
||||
if (meta_data.data_type == CD_PROP_STRING) {
|
||||
if (meta_data.data_type == AttrType::String) {
|
||||
/* Propagating string attributes is not supported yet. */
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,10 +76,7 @@ static AttributeAccessorFunctions get_grease_pencil_accessor_functions()
|
|||
const int domain_size = get_domain_size(owner, AttrDomain::Layer);
|
||||
return attribute_to_reader(attribute, AttrDomain::Layer, domain_size);
|
||||
};
|
||||
const std::optional<eCustomDataType> cd_type = attr_type_to_custom_data_type(
|
||||
attribute.data_type());
|
||||
BLI_assert(cd_type.has_value());
|
||||
AttributeIter iter(attribute.name(), attribute.domain(), *cd_type, get_fn);
|
||||
AttributeIter iter(attribute.name(), attribute.domain(), attribute.data_type(), get_fn);
|
||||
iter.is_builtin = builtin_attributes().contains(attribute.name());
|
||||
iter.accessor = &accessor;
|
||||
fn(iter);
|
||||
|
|
@ -124,13 +121,11 @@ static AttributeAccessorFunctions get_grease_pencil_accessor_functions()
|
|||
fn.add = [](void *owner,
|
||||
const StringRef name,
|
||||
const AttrDomain domain,
|
||||
const eCustomDataType data_type,
|
||||
const bke::AttrType type,
|
||||
const AttributeInit &initializer) {
|
||||
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(owner);
|
||||
const int domain_size = get_domain_size(owner, domain);
|
||||
AttributeStorage &storage = grease_pencil.attribute_storage.wrap();
|
||||
const std::optional<AttrType> type = custom_data_type_to_attr_type(data_type);
|
||||
BLI_assert(type.has_value());
|
||||
if (const AttrBuiltinInfo *info = builtin_attributes().lookup_ptr(name)) {
|
||||
if (info->domain != domain || info->type != type) {
|
||||
return false;
|
||||
|
|
@ -139,8 +134,8 @@ static AttributeAccessorFunctions get_grease_pencil_accessor_functions()
|
|||
if (storage.lookup(name)) {
|
||||
return false;
|
||||
}
|
||||
Attribute::DataVariant data = attribute_init_to_data(*type, domain_size, initializer);
|
||||
storage.add(name, domain, *type, std::move(data));
|
||||
Attribute::DataVariant data = attribute_init_to_data(type, domain_size, initializer);
|
||||
storage.add(name, domain, type, std::move(data));
|
||||
return true;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -69,9 +69,7 @@ static constexpr AttributeAccessorFunctions get_instances_accessor_functions()
|
|||
if (!info) {
|
||||
return std::nullopt;
|
||||
}
|
||||
const std::optional<eCustomDataType> cd_type = attr_type_to_custom_data_type(info->type);
|
||||
BLI_assert(cd_type.has_value());
|
||||
return AttributeDomainAndType{info->domain, *cd_type};
|
||||
return AttributeDomainAndType{info->domain, info->type};
|
||||
};
|
||||
fn.get_builtin_default = [](const void * /*owner*/, StringRef name) -> GPointer {
|
||||
const AttrBuiltinInfo &info = builtin_attributes().lookup(name);
|
||||
|
|
@ -104,10 +102,7 @@ static constexpr AttributeAccessorFunctions get_instances_accessor_functions()
|
|||
const auto get_fn = [&]() {
|
||||
return attribute_to_reader(attribute, AttrDomain::Instance, instances.instances_num());
|
||||
};
|
||||
const std::optional<eCustomDataType> cd_type = attr_type_to_custom_data_type(
|
||||
attribute.data_type());
|
||||
BLI_assert(cd_type.has_value());
|
||||
AttributeIter iter(attribute.name(), attribute.domain(), *cd_type, get_fn);
|
||||
AttributeIter iter(attribute.name(), attribute.domain(), attribute.data_type(), get_fn);
|
||||
iter.is_builtin = builtin_attributes().contains(attribute.name());
|
||||
iter.accessor = &accessor;
|
||||
fn(iter);
|
||||
|
|
@ -151,13 +146,11 @@ static constexpr AttributeAccessorFunctions get_instances_accessor_functions()
|
|||
fn.add = [](void *owner,
|
||||
const StringRef name,
|
||||
const AttrDomain domain,
|
||||
const eCustomDataType data_type,
|
||||
const AttrType type,
|
||||
const AttributeInit &initializer) {
|
||||
Instances &instances = *static_cast<Instances *>(owner);
|
||||
const int domain_size = instances.instances_num();
|
||||
AttributeStorage &storage = instances.attribute_storage();
|
||||
const std::optional<AttrType> type = custom_data_type_to_attr_type(data_type);
|
||||
BLI_assert(type.has_value());
|
||||
if (const AttrBuiltinInfo *info = builtin_attributes().lookup_ptr(name)) {
|
||||
if (info->domain != domain || info->type != type) {
|
||||
return false;
|
||||
|
|
@ -166,8 +159,8 @@ static constexpr AttributeAccessorFunctions get_instances_accessor_functions()
|
|||
if (storage.lookup(name)) {
|
||||
return false;
|
||||
}
|
||||
Attribute::DataVariant data = attribute_init_to_data(*type, domain_size, initializer);
|
||||
storage.add(name, domain, *type, std::move(data));
|
||||
Attribute::DataVariant data = attribute_init_to_data(type, domain_size, initializer);
|
||||
storage.add(name, domain, type, std::move(data));
|
||||
return true;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -540,12 +540,12 @@ namespace blender::bke {
|
|||
void mesh_ensure_default_color_attribute_on_add(Mesh &mesh,
|
||||
const StringRef id,
|
||||
AttrDomain domain,
|
||||
eCustomDataType data_type)
|
||||
bke::AttrType data_type)
|
||||
{
|
||||
if (bke::attribute_name_is_anonymous(id)) {
|
||||
return;
|
||||
}
|
||||
if (!(CD_TYPE_AS_MASK(data_type) & CD_MASK_COLOR_ALL) ||
|
||||
if (!(CD_TYPE_AS_MASK(*attr_type_to_custom_data_type(data_type)) & CD_MASK_COLOR_ALL) ||
|
||||
!(ATTR_DOMAIN_AS_MASK(domain) & ATTR_DOMAIN_MASK_COLOR))
|
||||
{
|
||||
return;
|
||||
|
|
@ -562,10 +562,10 @@ void mesh_ensure_required_data_layers(Mesh &mesh)
|
|||
AttributeInitConstruct attribute_init;
|
||||
|
||||
/* Try to create attributes if they do not exist. */
|
||||
attributes.add("position", AttrDomain::Point, CD_PROP_FLOAT3, attribute_init);
|
||||
attributes.add(".edge_verts", AttrDomain::Edge, CD_PROP_INT32_2D, attribute_init);
|
||||
attributes.add(".corner_vert", AttrDomain::Corner, CD_PROP_INT32, attribute_init);
|
||||
attributes.add(".corner_edge", AttrDomain::Corner, CD_PROP_INT32, attribute_init);
|
||||
attributes.add("position", AttrDomain::Point, bke::AttrType::Float3, attribute_init);
|
||||
attributes.add(".edge_verts", AttrDomain::Edge, bke::AttrType::Int32_2D, attribute_init);
|
||||
attributes.add(".corner_vert", AttrDomain::Corner, bke::AttrType::Int32, attribute_init);
|
||||
attributes.add(".corner_edge", AttrDomain::Corner, bke::AttrType::Int32, attribute_init);
|
||||
}
|
||||
|
||||
static bool meta_data_matches(const std::optional<bke::AttributeMetaData> meta_data,
|
||||
|
|
@ -578,7 +578,7 @@ static bool meta_data_matches(const std::optional<bke::AttributeMetaData> meta_d
|
|||
if (!(ATTR_DOMAIN_AS_MASK(meta_data->domain) & domains)) {
|
||||
return false;
|
||||
}
|
||||
if (!(CD_TYPE_AS_MASK(meta_data->data_type) & types)) {
|
||||
if (!(CD_TYPE_AS_MASK(*attr_type_to_custom_data_type(meta_data->data_type)) & types)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
@ -1526,7 +1526,7 @@ void mesh_transform(Mesh &mesh, const float4x4 &transform, bool do_shape_keys)
|
|||
if (const std::optional<AttributeMetaData> meta_data = attributes.lookup_meta_data(
|
||||
"custom_normal"))
|
||||
{
|
||||
if (meta_data->data_type == CD_PROP_FLOAT3) {
|
||||
if (meta_data->data_type == bke::AttrType::Float3) {
|
||||
bke::SpanAttributeWriter normals = attributes.lookup_for_write_span<float3>("custom_normal");
|
||||
transform_normals(normals.span, transform);
|
||||
normals.finish();
|
||||
|
|
|
|||
|
|
@ -816,7 +816,7 @@ class MeshVertexGroupsAttributeProvider final : public DynamicAttributesProvider
|
|||
return this->get_for_vertex_group_index(*mesh, dverts, group_index);
|
||||
};
|
||||
|
||||
AttributeIter iter{group->name, AttrDomain::Point, CD_PROP_FLOAT, get_fn};
|
||||
AttributeIter iter{group->name, AttrDomain::Point, bke::AttrType::Float, get_fn};
|
||||
fn(iter);
|
||||
if (iter.is_stopped()) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ void mesh_flip_faces(Mesh &mesh, const IndexMask &selection)
|
|||
|
||||
MutableAttributeAccessor attributes = mesh.attributes_for_write();
|
||||
attributes.foreach_attribute([&](const AttributeIter &iter) {
|
||||
if (iter.data_type == CD_PROP_STRING) {
|
||||
if (iter.data_type == bke::AttrType::String) {
|
||||
return;
|
||||
}
|
||||
if (iter.domain != AttrDomain::Corner) {
|
||||
|
|
|
|||
|
|
@ -496,7 +496,7 @@ static void gather_attributes(const Span<StringRef> ids,
|
|||
{
|
||||
for (const StringRef id : ids) {
|
||||
const GVArraySpan src = *src_attributes.lookup(id, domain);
|
||||
const eCustomDataType type = cpp_type_to_custom_data_type(src.type());
|
||||
const AttrType type = cpp_type_to_attribute_type(src.type());
|
||||
GSpanAttributeWriter dst = dst_attributes.lookup_or_add_for_write_only_span(id, domain, type);
|
||||
attribute_math::gather(src, index_map, dst.span);
|
||||
dst.finish();
|
||||
|
|
|
|||
|
|
@ -2717,7 +2717,7 @@ void BKE_sculpt_color_layer_create_if_needed(Object *object)
|
|||
AttributeOwner owner = AttributeOwner::from_id(&orig_me->id);
|
||||
const std::string unique_name = BKE_attribute_calc_unique_name(owner, "Color");
|
||||
if (!orig_me->attributes_for_write().add(
|
||||
unique_name, AttrDomain::Point, CD_PROP_COLOR, AttributeInitDefaultValue()))
|
||||
unique_name, AttrDomain::Point, AttrType::ColorFloat, AttributeInitDefaultValue()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,9 +64,7 @@ static constexpr AttributeAccessorFunctions get_pointcloud_accessor_functions()
|
|||
if (!info) {
|
||||
return std::nullopt;
|
||||
}
|
||||
const std::optional<eCustomDataType> cd_type = attr_type_to_custom_data_type(info->type);
|
||||
BLI_assert(cd_type.has_value());
|
||||
return AttributeDomainAndType{info->domain, *cd_type};
|
||||
return AttributeDomainAndType{info->domain, info->type};
|
||||
};
|
||||
fn.get_builtin_default = [](const void * /*owner*/, StringRef name) -> GPointer {
|
||||
const AttrBuiltinInfo &info = builtin_attributes().lookup(name);
|
||||
|
|
@ -99,10 +97,7 @@ static constexpr AttributeAccessorFunctions get_pointcloud_accessor_functions()
|
|||
const auto get_fn = [&]() {
|
||||
return attribute_to_reader(attribute, AttrDomain::Point, pointcloud.totpoint);
|
||||
};
|
||||
const std::optional<eCustomDataType> cd_type = attr_type_to_custom_data_type(
|
||||
attribute.data_type());
|
||||
BLI_assert(cd_type.has_value());
|
||||
AttributeIter iter(attribute.name(), attribute.domain(), *cd_type, get_fn);
|
||||
AttributeIter iter(attribute.name(), attribute.domain(), attribute.data_type(), get_fn);
|
||||
iter.is_builtin = builtin_attributes().contains(attribute.name());
|
||||
iter.accessor = &accessor;
|
||||
fn(iter);
|
||||
|
|
@ -146,13 +141,11 @@ static constexpr AttributeAccessorFunctions get_pointcloud_accessor_functions()
|
|||
fn.add = [](void *owner,
|
||||
const StringRef name,
|
||||
const AttrDomain domain,
|
||||
const eCustomDataType data_type,
|
||||
const bke::AttrType type,
|
||||
const AttributeInit &initializer) {
|
||||
PointCloud &pointcloud = *static_cast<PointCloud *>(owner);
|
||||
const int domain_size = pointcloud.totpoint;
|
||||
AttributeStorage &storage = pointcloud.attribute_storage.wrap();
|
||||
const std::optional<AttrType> type = custom_data_type_to_attr_type(data_type);
|
||||
BLI_assert(type.has_value());
|
||||
if (const AttrBuiltinInfo *info = builtin_attributes().lookup_ptr(name)) {
|
||||
if (info->domain != domain || info->type != type) {
|
||||
return false;
|
||||
|
|
@ -161,8 +154,8 @@ static constexpr AttributeAccessorFunctions get_pointcloud_accessor_functions()
|
|||
if (storage.lookup(name)) {
|
||||
return false;
|
||||
}
|
||||
Attribute::DataVariant data = attribute_init_to_data(*type, domain_size, initializer);
|
||||
storage.add(name, domain, *type, std::move(data));
|
||||
Attribute::DataVariant data = attribute_init_to_data(type, domain_size, initializer);
|
||||
storage.add(name, domain, type, std::move(data));
|
||||
return true;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ bool BKE_subsurf_modifier_use_custom_loop_normals(const SubsurfModifierData *smd
|
|||
const std::optional<AttributeMetaData> meta_data = mesh->attributes().lookup_meta_data(
|
||||
"custom_normal");
|
||||
return meta_data && meta_data->domain == AttrDomain::Corner &&
|
||||
meta_data->data_type == CD_PROP_INT16_2D;
|
||||
meta_data->data_type == AttrType::Int16_2D;
|
||||
}
|
||||
|
||||
bool BKE_subsurf_modifier_has_split_normals(const SubsurfModifierData *smd, const Mesh *mesh)
|
||||
|
|
|
|||
|
|
@ -31,6 +31,10 @@ struct ViewLayer;
|
|||
struct bContext;
|
||||
struct rcti;
|
||||
|
||||
namespace blender::bke {
|
||||
enum class AttrType : int16_t;
|
||||
}
|
||||
|
||||
void DRW_engines_register();
|
||||
void DRW_engines_free();
|
||||
|
||||
|
|
@ -190,7 +194,7 @@ namespace blender::draw {
|
|||
|
||||
void DRW_cdlayer_attr_aliases_add(GPUVertFormat *format,
|
||||
const char *base_name,
|
||||
int data_type,
|
||||
bke::AttrType data_type,
|
||||
blender::StringRef layer_name,
|
||||
bool is_active_render,
|
||||
bool is_active_layer);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "BKE_curves.hh"
|
||||
#include "BKE_customdata.hh"
|
||||
#include "BKE_geometry_set.hh"
|
||||
#include "DNA_curve_types.h"
|
||||
#include "DNA_pointcloud_types.h"
|
||||
|
|
@ -159,10 +158,9 @@ class AttributeViewer : Overlay {
|
|||
}
|
||||
}
|
||||
|
||||
static bool attribute_type_supports_viewer_overlay(const eCustomDataType data_type)
|
||||
static bool attribute_type_supports_viewer_overlay(const bke::AttrType data_type)
|
||||
{
|
||||
return CD_TYPE_AS_MASK(data_type) &
|
||||
(CD_MASK_PROP_ALL & ~(CD_MASK_PROP_QUATERNION | CD_MASK_PROP_FLOAT4X4));
|
||||
return !ELEM(data_type, bke::AttrType::Quaternion, bke::AttrType::Float4x4);
|
||||
}
|
||||
|
||||
void populate_for_geometry(const ObjectRef &ob_ref, const State &state, Manager &manager)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
namespace blender::draw {
|
||||
|
||||
GPUVertFormat init_format_for_attribute(const eCustomDataType data_type, const StringRef vbo_name)
|
||||
GPUVertFormat init_format_for_attribute(const bke::AttrType data_type, const StringRef vbo_name)
|
||||
{
|
||||
GPUVertFormat format{};
|
||||
bke::attribute_math::convert_to_static_type(data_type, [&](auto dummy) {
|
||||
|
|
|
|||
|
|
@ -12,14 +12,16 @@
|
|||
#include "BLI_math_vector_types.hh"
|
||||
#include "BLI_string_ref.hh"
|
||||
|
||||
#include "DNA_customdata_types.h" /* #eCustomDataType. */
|
||||
|
||||
#include "GPU_vertex_format.hh"
|
||||
|
||||
namespace blender::gpu {
|
||||
class VertBuf;
|
||||
}
|
||||
|
||||
namespace blender::bke {
|
||||
enum class AttrType : int16_t;
|
||||
}
|
||||
|
||||
/**
|
||||
* Component length of 3 is used for scalars because implicit conversion is done by OpenGL from a
|
||||
* scalar `s` will produce `float4(s, 0, 0, 1)`. However, following the Blender convention, it
|
||||
|
|
@ -141,7 +143,7 @@ template<> struct AttributeConverter<math::Quaternion> {
|
|||
}
|
||||
};
|
||||
|
||||
GPUVertFormat init_format_for_attribute(eCustomDataType data_type, StringRef vbo_name);
|
||||
GPUVertFormat init_format_for_attribute(bke::AttrType data_type, StringRef vbo_name);
|
||||
|
||||
void vertbuf_data_extract_direct(GSpan attribute, gpu::VertBuf &vbo);
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
#include "BLI_string.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BKE_attribute.hh"
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_mesh_wrapper.hh"
|
||||
#include "BKE_object.hh"
|
||||
|
|
@ -585,7 +586,7 @@ void DRW_batch_cache_free_old(Object *ob, int ctime)
|
|||
|
||||
void DRW_cdlayer_attr_aliases_add(GPUVertFormat *format,
|
||||
const char *base_name,
|
||||
const int data_type,
|
||||
const bke::AttrType data_type,
|
||||
const StringRef layer_name,
|
||||
bool is_active_render,
|
||||
bool is_active_layer)
|
||||
|
|
@ -603,7 +604,7 @@ void DRW_cdlayer_attr_aliases_add(GPUVertFormat *format,
|
|||
|
||||
/* Active render layer name. */
|
||||
if (is_active_render) {
|
||||
GPU_vertformat_alias_add(format, data_type == CD_PROP_FLOAT2 ? "a" : base_name);
|
||||
GPU_vertformat_alias_add(format, data_type == bke::AttrType::Float2 ? "a" : base_name);
|
||||
}
|
||||
|
||||
/* Active display layer name. */
|
||||
|
|
|
|||
|
|
@ -94,7 +94,9 @@ static bool use_normals_simplify(const Scene &scene, const MeshRenderData &mr)
|
|||
if (!meta_data) {
|
||||
return false;
|
||||
}
|
||||
if (meta_data->domain == bke::AttrDomain::Corner && meta_data->data_type == CD_PROP_INT16_2D) {
|
||||
if (meta_data->domain == bke::AttrDomain::Corner &&
|
||||
meta_data->data_type == bke::AttrType::Int16_2D)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -736,7 +736,7 @@ static std::optional<StringRef> get_first_uv_name(const bke::AttributeAccessor &
|
|||
{
|
||||
std::optional<StringRef> name;
|
||||
attributes.foreach_attribute([&](const bke::AttributeIter &iter) {
|
||||
if (iter.data_type == CD_PROP_FLOAT2) {
|
||||
if (iter.data_type == bke::AttrType::Float2) {
|
||||
name = iter.name;
|
||||
iter.stop();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -274,7 +274,7 @@ static std::optional<StringRef> get_first_uv_name(const bke::AttributeAccessor &
|
|||
{
|
||||
std::optional<StringRef> name;
|
||||
attributes.foreach_attribute([&](const bke::AttributeIter &iter) {
|
||||
if (iter.data_type == CD_PROP_FLOAT2) {
|
||||
if (iter.data_type == bke::AttrType::Float2) {
|
||||
name = iter.name;
|
||||
iter.stop();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
#include "DNA_object_types.h"
|
||||
|
||||
#include "BKE_attribute.hh"
|
||||
#include "BKE_attribute_legacy_convert.hh"
|
||||
#include "BKE_attribute_math.hh"
|
||||
#include "BKE_customdata.hh"
|
||||
#include "BKE_mesh.hh"
|
||||
|
|
@ -308,19 +309,19 @@ static const GPUVertFormat &face_set_format()
|
|||
|
||||
static GPUVertFormat attribute_format(const OrigMeshData &orig_mesh_data,
|
||||
const StringRef name,
|
||||
const eCustomDataType data_type)
|
||||
const bke::AttrType data_type)
|
||||
{
|
||||
GPUVertFormat format = init_format_for_attribute(data_type, "data");
|
||||
|
||||
bool is_render, is_active;
|
||||
const char *prefix = "a";
|
||||
|
||||
if (CD_TYPE_AS_MASK(data_type) & CD_MASK_COLOR_ALL) {
|
||||
if (CD_TYPE_AS_MASK(*bke::attr_type_to_custom_data_type(data_type))) {
|
||||
prefix = "c";
|
||||
is_active = orig_mesh_data.active_color == name;
|
||||
is_render = orig_mesh_data.default_color == name;
|
||||
}
|
||||
if (data_type == CD_PROP_FLOAT2) {
|
||||
if (data_type == bke::AttrType::Float2) {
|
||||
prefix = "u";
|
||||
is_active = orig_mesh_data.active_uv_map == name;
|
||||
is_render = orig_mesh_data.default_uv_map == name;
|
||||
|
|
@ -705,7 +706,7 @@ BLI_NOINLINE static void update_generic_attribute_mesh(const Object &object,
|
|||
if (!attr || attr.domain == bke::AttrDomain::Edge) {
|
||||
return;
|
||||
}
|
||||
const eCustomDataType data_type = bke::cpp_type_to_custom_data_type(attr.varray.type());
|
||||
const bke::AttrType data_type = bke::cpp_type_to_attribute_type(attr.varray.type());
|
||||
ensure_vbos_allocated_mesh(
|
||||
object, attribute_format(orig_mesh_data, name, data_type), node_mask, vbos);
|
||||
node_mask.foreach_index(GrainSize(1), [&](const int i) {
|
||||
|
|
@ -1056,7 +1057,7 @@ BLI_NOINLINE static void update_face_sets_bmesh(const Object &object,
|
|||
struct BMeshAttributeLookup {
|
||||
const int offset = -1;
|
||||
bke::AttrDomain domain;
|
||||
eCustomDataType type;
|
||||
bke::AttrType type;
|
||||
operator bool() const
|
||||
{
|
||||
return offset != -1;
|
||||
|
|
@ -1067,22 +1068,30 @@ static BMeshAttributeLookup lookup_bmesh_attribute(const BMesh &bm, const String
|
|||
{
|
||||
for (const CustomDataLayer &layer : Span(bm.vdata.layers, bm.vdata.totlayer)) {
|
||||
if (layer.name == name) {
|
||||
return {layer.offset, bke::AttrDomain::Point, eCustomDataType(layer.type)};
|
||||
return {layer.offset,
|
||||
bke::AttrDomain::Point,
|
||||
*bke::custom_data_type_to_attr_type(eCustomDataType(layer.type))};
|
||||
}
|
||||
}
|
||||
for (const CustomDataLayer &layer : Span(bm.edata.layers, bm.edata.totlayer)) {
|
||||
if (layer.name == name) {
|
||||
return {layer.offset, bke::AttrDomain::Edge, eCustomDataType(layer.type)};
|
||||
return {layer.offset,
|
||||
bke::AttrDomain::Edge,
|
||||
*bke::custom_data_type_to_attr_type(eCustomDataType(layer.type))};
|
||||
}
|
||||
}
|
||||
for (const CustomDataLayer &layer : Span(bm.pdata.layers, bm.pdata.totlayer)) {
|
||||
if (layer.name == name) {
|
||||
return {layer.offset, bke::AttrDomain::Face, eCustomDataType(layer.type)};
|
||||
return {layer.offset,
|
||||
bke::AttrDomain::Face,
|
||||
*bke::custom_data_type_to_attr_type(eCustomDataType(layer.type))};
|
||||
}
|
||||
}
|
||||
for (const CustomDataLayer &layer : Span(bm.ldata.layers, bm.ldata.totlayer)) {
|
||||
if (layer.name == name) {
|
||||
return {layer.offset, bke::AttrDomain::Corner, eCustomDataType(layer.type)};
|
||||
return {layer.offset,
|
||||
bke::AttrDomain::Corner,
|
||||
*bke::custom_data_type_to_attr_type(eCustomDataType(layer.type))};
|
||||
}
|
||||
}
|
||||
return {};
|
||||
|
|
@ -1739,11 +1748,12 @@ Span<gpu::VertBufPtr> DrawCacheImpl::ensure_attribute_data(const Object &object,
|
|||
}
|
||||
}
|
||||
else {
|
||||
ensure_vbos_allocated_grids(object,
|
||||
attribute_format(orig_mesh_data, "Dummy", CD_PROP_FLOAT3),
|
||||
use_flat_layout_,
|
||||
mask,
|
||||
vbos);
|
||||
ensure_vbos_allocated_grids(
|
||||
object,
|
||||
attribute_format(orig_mesh_data, "Dummy", bke::AttrType::Float3),
|
||||
use_flat_layout_,
|
||||
mask,
|
||||
vbos);
|
||||
mask.foreach_index(GrainSize(1),
|
||||
[&](const int i) { vbos[i]->data<float3>().fill(float3(0.0f)); });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include "draw_view.hh"
|
||||
|
||||
#include "BKE_attribute.hh"
|
||||
#include "BKE_attribute_legacy_convert.hh"
|
||||
#include "BKE_customdata.hh"
|
||||
#include "BKE_material.hh"
|
||||
#include "BKE_object.hh"
|
||||
|
|
@ -148,7 +149,8 @@ static bool bmesh_attribute_exists(const BMesh &bm,
|
|||
const StringRef name)
|
||||
{
|
||||
const CustomData *cdata = get_cdata(bm, meta_data.domain);
|
||||
return cdata && CustomData_get_offset_named(cdata, meta_data.data_type, name) != -1;
|
||||
return cdata && CustomData_get_offset_named(
|
||||
cdata, *bke::attr_type_to_custom_data_type(meta_data.data_type), name) != -1;
|
||||
}
|
||||
|
||||
Vector<SculptBatch> sculpt_batches_get(const Object *ob, SculptBatchFeature features)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include "BLI_string.h"
|
||||
|
||||
#include "BKE_attribute.hh"
|
||||
#include "BKE_attribute_legacy_convert.hh"
|
||||
#include "BKE_attribute_math.hh"
|
||||
#include "BKE_mesh.hh"
|
||||
|
||||
|
|
@ -29,7 +30,7 @@ namespace blender::draw {
|
|||
static void init_vbo_for_attribute(const MeshRenderData &mr,
|
||||
gpu::VertBuf &vbo,
|
||||
const StringRef name,
|
||||
const eCustomDataType type,
|
||||
const bke::AttrType type,
|
||||
bool build_on_device,
|
||||
uint32_t len)
|
||||
{
|
||||
|
|
@ -173,7 +174,7 @@ static void extract_data_bmesh_loop(const BMesh &bm, const int cd_offset, gpu::V
|
|||
struct BMeshAttributeLookup {
|
||||
const int offset = -1;
|
||||
bke::AttrDomain domain;
|
||||
eCustomDataType type;
|
||||
bke::AttrType type;
|
||||
operator bool() const
|
||||
{
|
||||
return offset != -1;
|
||||
|
|
@ -184,22 +185,30 @@ static BMeshAttributeLookup lookup_bmesh_attribute(const BMesh &bm, const String
|
|||
{
|
||||
for (const CustomDataLayer &layer : Span(bm.vdata.layers, bm.vdata.totlayer)) {
|
||||
if (layer.name == name) {
|
||||
return {layer.offset, bke::AttrDomain::Point, eCustomDataType(layer.type)};
|
||||
return {layer.offset,
|
||||
bke::AttrDomain::Point,
|
||||
*bke::custom_data_type_to_attr_type(eCustomDataType(layer.type))};
|
||||
}
|
||||
}
|
||||
for (const CustomDataLayer &layer : Span(bm.edata.layers, bm.edata.totlayer)) {
|
||||
if (layer.name == name) {
|
||||
return {layer.offset, bke::AttrDomain::Edge, eCustomDataType(layer.type)};
|
||||
return {layer.offset,
|
||||
bke::AttrDomain::Edge,
|
||||
*bke::custom_data_type_to_attr_type(eCustomDataType(layer.type))};
|
||||
}
|
||||
}
|
||||
for (const CustomDataLayer &layer : Span(bm.pdata.layers, bm.pdata.totlayer)) {
|
||||
if (layer.name == name) {
|
||||
return {layer.offset, bke::AttrDomain::Face, eCustomDataType(layer.type)};
|
||||
return {layer.offset,
|
||||
bke::AttrDomain::Face,
|
||||
*bke::custom_data_type_to_attr_type(eCustomDataType(layer.type))};
|
||||
}
|
||||
}
|
||||
for (const CustomDataLayer &layer : Span(bm.ldata.layers, bm.ldata.totlayer)) {
|
||||
if (layer.name == name) {
|
||||
return {layer.offset, bke::AttrDomain::Corner, eCustomDataType(layer.type)};
|
||||
return {layer.offset,
|
||||
bke::AttrDomain::Corner,
|
||||
*bke::custom_data_type_to_attr_type(eCustomDataType(layer.type))};
|
||||
}
|
||||
}
|
||||
return {};
|
||||
|
|
@ -267,7 +276,7 @@ gpu::VertBufPtr extract_attribute(const MeshRenderData &mr, const StringRef name
|
|||
if (!attr) {
|
||||
return {};
|
||||
}
|
||||
const eCustomDataType type = attr.type;
|
||||
const bke::AttrType type = attr.type;
|
||||
init_vbo_for_attribute(mr, *vbo, name, type, false, uint32_t(mr.corners_num));
|
||||
extract_attribute_data(mr, attr, *vbo);
|
||||
}
|
||||
|
|
@ -277,14 +286,14 @@ gpu::VertBufPtr extract_attribute(const MeshRenderData &mr, const StringRef name
|
|||
if (!attr) {
|
||||
return {};
|
||||
}
|
||||
const eCustomDataType type = bke::cpp_type_to_custom_data_type(attr.varray.type());
|
||||
const bke::AttrType type = bke::cpp_type_to_attribute_type(attr.varray.type());
|
||||
init_vbo_for_attribute(mr, *vbo, name, type, false, uint32_t(mr.corners_num));
|
||||
extract_attribute_data(mr, attr, *vbo);
|
||||
}
|
||||
return gpu::VertBufPtr(vbo);
|
||||
}
|
||||
|
||||
static gpu::VertBufPtr init_coarse_data(const eCustomDataType type, const int coarse_corners_num)
|
||||
static gpu::VertBufPtr init_coarse_data(const bke::AttrType type, const int coarse_corners_num)
|
||||
{
|
||||
gpu::VertBuf *vbo = GPU_vertbuf_calloc();
|
||||
GPUVertFormat coarse_format = draw::init_format_for_attribute(type, "data");
|
||||
|
|
@ -302,7 +311,7 @@ gpu::VertBufPtr extract_attribute_subdiv(const MeshRenderData &mr,
|
|||
|
||||
/* Prepare VBO for coarse data. The compute shader only expects floats. */
|
||||
gpu::VertBufPtr coarse_vbo;
|
||||
eCustomDataType type;
|
||||
bke::AttrType type;
|
||||
if (mr.extract_type == MeshExtractType::BMesh) {
|
||||
const BMeshAttributeLookup attr = lookup_bmesh_attribute(*mr.bm, name);
|
||||
if (!attr) {
|
||||
|
|
@ -318,7 +327,7 @@ gpu::VertBufPtr extract_attribute_subdiv(const MeshRenderData &mr,
|
|||
if (!attr) {
|
||||
return {};
|
||||
}
|
||||
type = bke::cpp_type_to_custom_data_type(attr.varray.type());
|
||||
type = bke::cpp_type_to_attribute_type(attr.varray.type());
|
||||
coarse_vbo = init_coarse_data(type, coarse_mesh->corners_num);
|
||||
extract_attribute_data(mr, attr, *coarse_vbo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,8 +97,8 @@ static wmOperatorStatus set_attribute_exec(bContext *C, wmOperator *op)
|
|||
const StringRef name = *BKE_attributes_active_name_get(active_owner);
|
||||
const bke::AttributeMetaData active_meta_data =
|
||||
*active_curves_id.geometry.wrap().attributes().lookup_meta_data(name);
|
||||
const eCustomDataType active_type = active_meta_data.data_type;
|
||||
const CPPType &type = *bke::custom_data_type_to_cpp_type(active_type);
|
||||
const bke::AttrType active_type = active_meta_data.data_type;
|
||||
const CPPType &type = bke::attribute_type_to_cpp_type(active_type);
|
||||
|
||||
BUFFER_FOR_CPP_TYPE_VALUE(type, buffer);
|
||||
BLI_SCOPED_DEFER([&]() { type.destruct(buffer); });
|
||||
|
|
@ -162,7 +162,7 @@ static wmOperatorStatus set_attribute_invoke(bContext *C, wmOperator *op, const
|
|||
const CPPType &type = attribute.varray.type();
|
||||
|
||||
PropertyRNA *prop = geometry::rna_property_for_type(*op->ptr,
|
||||
bke::cpp_type_to_custom_data_type(type));
|
||||
bke::cpp_type_to_attribute_type(type));
|
||||
if (RNA_property_is_set(op->ptr, prop)) {
|
||||
return WM_operator_props_popup(C, op, event);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -265,7 +265,7 @@ static bke::CurvesGeometry extrude_curves(const bke::CurvesGeometry &curves,
|
|||
dst_selections[selection_i] = ensure_selection_attribute(
|
||||
new_curves,
|
||||
bke::AttrDomain::Point,
|
||||
src_selection_array.type().is<bool>() ? CD_PROP_BOOL : CD_PROP_FLOAT,
|
||||
src_selection_array.type().is<bool>() ? bke::AttrType::Bool : bke::AttrType::Float,
|
||||
selection_name);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -809,7 +809,7 @@ static wmOperatorStatus curves_set_selection_domain_exec(bContext *C, wmOperator
|
|||
attributes.remove(selection_name);
|
||||
if (!attributes.add(selection_name,
|
||||
domain,
|
||||
bke::cpp_type_to_custom_data_type(type),
|
||||
bke::cpp_type_to_attribute_type(type),
|
||||
bke::AttributeInitMoveArray(dst)))
|
||||
{
|
||||
MEM_freeN(dst);
|
||||
|
|
@ -913,7 +913,7 @@ static wmOperatorStatus select_random_exec(bContext *C, wmOperator *op)
|
|||
|
||||
const bool was_anything_selected = has_anything_selected(curves);
|
||||
bke::GSpanAttributeWriter selection = ensure_selection_attribute(
|
||||
curves, selection_domain, CD_PROP_BOOL);
|
||||
curves, selection_domain, bke::AttrType::Bool);
|
||||
if (!was_anything_selected) {
|
||||
curves::fill_selection_true(selection.span);
|
||||
}
|
||||
|
|
@ -984,7 +984,7 @@ static wmOperatorStatus select_ends_exec(bContext *C, wmOperator *op)
|
|||
|
||||
const bool was_anything_selected = has_anything_selected(curves);
|
||||
bke::GSpanAttributeWriter selection = ensure_selection_attribute(
|
||||
curves, bke::AttrDomain::Point, CD_PROP_BOOL);
|
||||
curves, bke::AttrDomain::Point, bke::AttrType::Bool);
|
||||
if (!was_anything_selected) {
|
||||
fill_selection_true(selection.span);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ Span<float3> get_selection_attribute_positions(
|
|||
static Vector<bke::GSpanAttributeWriter> init_selection_writers(bke::CurvesGeometry &curves,
|
||||
bke::AttrDomain selection_domain)
|
||||
{
|
||||
const eCustomDataType create_type = CD_PROP_BOOL;
|
||||
const bke::AttrType create_type = bke::AttrType::Bool;
|
||||
Span<StringRef> selection_attribute_names = get_curves_selection_attribute_names(curves);
|
||||
Vector<bke::GSpanAttributeWriter> writers;
|
||||
for (const int i : selection_attribute_names.index_range()) {
|
||||
|
|
@ -278,7 +278,7 @@ void foreach_selectable_curve_range(const bke::CurvesGeometry &curves,
|
|||
|
||||
bke::GSpanAttributeWriter ensure_selection_attribute(bke::CurvesGeometry &curves,
|
||||
bke::AttrDomain selection_domain,
|
||||
eCustomDataType create_type,
|
||||
bke::AttrType create_type,
|
||||
StringRef attribute_name)
|
||||
{
|
||||
bke::MutableAttributeAccessor attributes = curves.attributes_for_write();
|
||||
|
|
@ -293,16 +293,16 @@ bke::GSpanAttributeWriter ensure_selection_attribute(bke::CurvesGeometry &curves
|
|||
}
|
||||
const int domain_size = attributes.domain_size(selection_domain);
|
||||
switch (create_type) {
|
||||
case CD_PROP_BOOL:
|
||||
case bke::AttrType::Bool:
|
||||
attributes.add(attribute_name,
|
||||
selection_domain,
|
||||
CD_PROP_BOOL,
|
||||
bke::AttrType::Bool,
|
||||
bke::AttributeInitVArray(VArray<bool>::ForSingle(true, domain_size)));
|
||||
break;
|
||||
case CD_PROP_FLOAT:
|
||||
case bke::AttrType::Float:
|
||||
attributes.add(attribute_name,
|
||||
selection_domain,
|
||||
CD_PROP_FLOAT,
|
||||
bke::AttrType::Float,
|
||||
bke::AttributeInitVArray(VArray<float>::ForSingle(1.0f, domain_size)));
|
||||
break;
|
||||
default:
|
||||
|
|
@ -584,7 +584,7 @@ void select_alternate(bke::CurvesGeometry &curves,
|
|||
|
||||
const OffsetIndices points_by_curve = curves.points_by_curve();
|
||||
bke::GSpanAttributeWriter selection = ensure_selection_attribute(
|
||||
curves, bke::AttrDomain::Point, CD_PROP_BOOL);
|
||||
curves, bke::AttrDomain::Point, bke::AttrType::Bool);
|
||||
const VArray<bool> cyclic = curves.cyclic();
|
||||
|
||||
MutableSpan<bool> selection_typed = selection.span.typed<bool>();
|
||||
|
|
@ -629,7 +629,7 @@ void select_adjacent(bke::CurvesGeometry &curves,
|
|||
{
|
||||
const OffsetIndices points_by_curve = curves.points_by_curve();
|
||||
bke::GSpanAttributeWriter selection = ensure_selection_attribute(
|
||||
curves, bke::AttrDomain::Point, CD_PROP_BOOL);
|
||||
curves, bke::AttrDomain::Point, bke::AttrType::Bool);
|
||||
const VArray<bool> cyclic = curves.cyclic();
|
||||
|
||||
if (deselect) {
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ static bool select_linked_pick(bContext &C, const int2 &mval, const SelectPick_P
|
|||
}
|
||||
else if (selection_domain == bke::AttrDomain::Curve) {
|
||||
bke::GSpanAttributeWriter selection = ensure_selection_attribute(
|
||||
closest_curves, bke::AttrDomain::Curve, CD_PROP_BOOL);
|
||||
closest_curves, bke::AttrDomain::Curve, bke::AttrType::Bool);
|
||||
apply_selection_operation_at_index(selection.span, closest.elem.index, params.sel_op);
|
||||
selection.finish();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,25 +51,25 @@
|
|||
|
||||
namespace blender::ed::geometry {
|
||||
|
||||
StringRefNull rna_property_name_for_type(const eCustomDataType type)
|
||||
StringRefNull rna_property_name_for_type(const bke::AttrType type)
|
||||
{
|
||||
switch (type) {
|
||||
case CD_PROP_FLOAT:
|
||||
case bke::AttrType::Float:
|
||||
return "value_float";
|
||||
case CD_PROP_FLOAT2:
|
||||
case bke::AttrType::Float2:
|
||||
return "value_float_vector_2d";
|
||||
case CD_PROP_FLOAT3:
|
||||
case bke::AttrType::Float3:
|
||||
return "value_float_vector_3d";
|
||||
case CD_PROP_COLOR:
|
||||
case CD_PROP_BYTE_COLOR:
|
||||
case bke::AttrType::ColorByte:
|
||||
case bke::AttrType::ColorFloat:
|
||||
return "value_color";
|
||||
case CD_PROP_BOOL:
|
||||
case bke::AttrType::Bool:
|
||||
return "value_bool";
|
||||
case CD_PROP_INT8:
|
||||
case CD_PROP_INT32:
|
||||
case bke::AttrType::Int8:
|
||||
case bke::AttrType::Int32:
|
||||
return "value_int";
|
||||
case CD_PROP_INT16_2D:
|
||||
case CD_PROP_INT32_2D:
|
||||
case bke::AttrType::Int16_2D:
|
||||
case bke::AttrType::Int32_2D:
|
||||
return "value_int_vector_2d";
|
||||
default:
|
||||
BLI_assert_unreachable();
|
||||
|
|
@ -77,7 +77,7 @@ StringRefNull rna_property_name_for_type(const eCustomDataType type)
|
|||
}
|
||||
}
|
||||
|
||||
PropertyRNA *rna_property_for_type(PointerRNA &ptr, const eCustomDataType type)
|
||||
PropertyRNA *rna_property_for_type(PointerRNA &ptr, const bke::AttrType type)
|
||||
{
|
||||
return RNA_struct_find_property(&ptr, rna_property_name_for_type(type).c_str());
|
||||
}
|
||||
|
|
@ -116,87 +116,87 @@ void register_rna_properties_for_attribute_types(StructRNA &srna)
|
|||
}
|
||||
|
||||
GPointer rna_property_for_attribute_type_retrieve_value(PointerRNA &ptr,
|
||||
const eCustomDataType type,
|
||||
const bke::AttrType type,
|
||||
void *buffer)
|
||||
{
|
||||
const StringRefNull prop_name = rna_property_name_for_type(type);
|
||||
switch (type) {
|
||||
case CD_PROP_FLOAT:
|
||||
case bke::AttrType::Float:
|
||||
*static_cast<float *>(buffer) = RNA_float_get(&ptr, prop_name.c_str());
|
||||
break;
|
||||
case CD_PROP_FLOAT2:
|
||||
case bke::AttrType::Float2:
|
||||
RNA_float_get_array(&ptr, prop_name.c_str(), static_cast<float *>(buffer));
|
||||
break;
|
||||
case CD_PROP_FLOAT3:
|
||||
case bke::AttrType::Float3:
|
||||
RNA_float_get_array(&ptr, prop_name.c_str(), static_cast<float *>(buffer));
|
||||
break;
|
||||
case CD_PROP_COLOR:
|
||||
case bke::AttrType::ColorFloat:
|
||||
RNA_float_get_array(&ptr, prop_name.c_str(), static_cast<float *>(buffer));
|
||||
break;
|
||||
case CD_PROP_BYTE_COLOR: {
|
||||
case bke::AttrType::ColorByte: {
|
||||
ColorGeometry4f value;
|
||||
RNA_float_get_array(&ptr, prop_name.c_str(), value);
|
||||
*static_cast<ColorGeometry4b *>(buffer) = value.encode();
|
||||
break;
|
||||
}
|
||||
case CD_PROP_BOOL:
|
||||
case bke::AttrType::Bool:
|
||||
*static_cast<bool *>(buffer) = RNA_boolean_get(&ptr, prop_name.c_str());
|
||||
break;
|
||||
case CD_PROP_INT8:
|
||||
case bke::AttrType::Int8:
|
||||
*static_cast<int8_t *>(buffer) = RNA_int_get(&ptr, prop_name.c_str());
|
||||
break;
|
||||
case CD_PROP_INT32:
|
||||
case bke::AttrType::Int32:
|
||||
*static_cast<int32_t *>(buffer) = RNA_int_get(&ptr, prop_name.c_str());
|
||||
break;
|
||||
case CD_PROP_INT16_2D: {
|
||||
case bke::AttrType::Int16_2D: {
|
||||
int2 value;
|
||||
RNA_int_get_array(&ptr, prop_name.c_str(), value);
|
||||
*static_cast<short2 *>(buffer) = short2(value);
|
||||
break;
|
||||
}
|
||||
case CD_PROP_INT32_2D:
|
||||
case bke::AttrType::Int32_2D:
|
||||
RNA_int_get_array(&ptr, prop_name.c_str(), static_cast<int *>(buffer));
|
||||
break;
|
||||
default:
|
||||
BLI_assert_unreachable();
|
||||
return {};
|
||||
}
|
||||
return GPointer(bke::custom_data_type_to_cpp_type(type), buffer);
|
||||
return GPointer(bke::attribute_type_to_cpp_type(type), buffer);
|
||||
}
|
||||
|
||||
void rna_property_for_attribute_type_set_value(PointerRNA &ptr,
|
||||
PropertyRNA &prop,
|
||||
const GPointer value)
|
||||
{
|
||||
switch (bke::cpp_type_to_custom_data_type(*value.type())) {
|
||||
case CD_PROP_FLOAT:
|
||||
switch (bke::cpp_type_to_attribute_type(*value.type())) {
|
||||
case bke::AttrType::Float:
|
||||
RNA_property_float_set(&ptr, &prop, *value.get<float>());
|
||||
break;
|
||||
case CD_PROP_FLOAT2:
|
||||
case bke::AttrType::Float2:
|
||||
RNA_property_float_set_array(&ptr, &prop, *value.get<float2>());
|
||||
break;
|
||||
case CD_PROP_FLOAT3:
|
||||
case bke::AttrType::Float3:
|
||||
RNA_property_float_set_array(&ptr, &prop, *value.get<float3>());
|
||||
break;
|
||||
case CD_PROP_BYTE_COLOR:
|
||||
case bke::AttrType::ColorByte:
|
||||
RNA_property_float_set_array(&ptr, &prop, value.get<ColorGeometry4b>()->decode());
|
||||
break;
|
||||
case CD_PROP_COLOR:
|
||||
case bke::AttrType::ColorFloat:
|
||||
RNA_property_float_set_array(&ptr, &prop, *value.get<ColorGeometry4f>());
|
||||
break;
|
||||
case CD_PROP_BOOL:
|
||||
case bke::AttrType::Bool:
|
||||
RNA_property_boolean_set(&ptr, &prop, *value.get<bool>());
|
||||
break;
|
||||
case CD_PROP_INT8:
|
||||
case bke::AttrType::Int8:
|
||||
RNA_property_int_set(&ptr, &prop, *value.get<int8_t>());
|
||||
break;
|
||||
case CD_PROP_INT32:
|
||||
case bke::AttrType::Int32:
|
||||
RNA_property_int_set(&ptr, &prop, *value.get<int32_t>());
|
||||
break;
|
||||
case CD_PROP_INT16_2D:
|
||||
case bke::AttrType::Int16_2D:
|
||||
RNA_property_int_set_array(&ptr, &prop, int2(*value.get<short2>()));
|
||||
break;
|
||||
case CD_PROP_INT32_2D:
|
||||
case bke::AttrType::Int32_2D:
|
||||
RNA_property_int_set_array(&ptr, &prop, *value.get<int2>());
|
||||
break;
|
||||
default:
|
||||
|
|
@ -220,7 +220,11 @@ bool attribute_set_poll(bContext &C, const ID &object_data)
|
|||
CTX_wm_operator_poll_msg_set(&C, "No active attribute");
|
||||
return false;
|
||||
}
|
||||
if (ELEM(meta_data->data_type, CD_PROP_STRING, CD_PROP_FLOAT4X4, CD_PROP_QUATERNION)) {
|
||||
if (ELEM(meta_data->data_type,
|
||||
bke::AttrType::String,
|
||||
bke::AttrType::Float4x4,
|
||||
bke::AttrType::Quaternion))
|
||||
{
|
||||
CTX_wm_operator_poll_msg_set(&C, "The active attribute has an unsupported type");
|
||||
return false;
|
||||
}
|
||||
|
|
@ -522,11 +526,11 @@ bool convert_attribute(AttributeOwner &owner,
|
|||
bke::MutableAttributeAccessor attributes,
|
||||
const StringRef name,
|
||||
const bke::AttrDomain dst_domain,
|
||||
const eCustomDataType dst_type,
|
||||
const bke::AttrType dst_type,
|
||||
ReportList *reports)
|
||||
{
|
||||
BLI_assert(attributes.contains(name));
|
||||
if (ELEM(dst_type, CD_PROP_STRING)) {
|
||||
if (ELEM(dst_type, bke::AttrType::String)) {
|
||||
if (reports) {
|
||||
BKE_report(reports, RPT_ERROR, "Cannot convert to the selected type");
|
||||
}
|
||||
|
|
@ -575,7 +579,7 @@ static wmOperatorStatus geometry_attribute_convert_exec(bContext *C, wmOperator
|
|||
attributes,
|
||||
name,
|
||||
bke::AttrDomain(RNA_enum_get(op->ptr, "domain")),
|
||||
eCustomDataType(RNA_enum_get(op->ptr, "data_type")),
|
||||
bke::AttrType(RNA_enum_get(op->ptr, "data_type")),
|
||||
op->reports))
|
||||
{
|
||||
return OPERATOR_CANCELLED;
|
||||
|
|
@ -616,7 +620,8 @@ static wmOperatorStatus geometry_attribute_convert_exec(bContext *C, wmOperator
|
|||
curves.attributes_for_write(),
|
||||
name,
|
||||
bke::AttrDomain(RNA_enum_get(op->ptr, "domain")),
|
||||
eCustomDataType(RNA_enum_get(op->ptr, "data_type")),
|
||||
*bke::custom_data_type_to_attr_type(
|
||||
eCustomDataType(RNA_enum_get(op->ptr, "data_type"))),
|
||||
op->reports))
|
||||
{
|
||||
return OPERATOR_CANCELLED;
|
||||
|
|
@ -630,7 +635,8 @@ static wmOperatorStatus geometry_attribute_convert_exec(bContext *C, wmOperator
|
|||
pointcloud.attributes_for_write(),
|
||||
name,
|
||||
bke::AttrDomain(RNA_enum_get(op->ptr, "domain")),
|
||||
eCustomDataType(RNA_enum_get(op->ptr, "data_type")),
|
||||
*bke::custom_data_type_to_attr_type(
|
||||
eCustomDataType(RNA_enum_get(op->ptr, "data_type"))),
|
||||
op->reports))
|
||||
{
|
||||
return OPERATOR_CANCELLED;
|
||||
|
|
@ -870,7 +876,7 @@ static wmOperatorStatus geometry_attribute_convert_invoke(bContext *C,
|
|||
}
|
||||
prop = RNA_struct_find_property(op->ptr, "data_type");
|
||||
if (!RNA_property_is_set(op->ptr, prop)) {
|
||||
RNA_property_enum_set(op->ptr, prop, meta_data.data_type);
|
||||
RNA_property_enum_set(op->ptr, prop, *bke::attr_type_to_custom_data_type(meta_data.data_type));
|
||||
}
|
||||
|
||||
return WM_operator_props_dialog_popup(
|
||||
|
|
@ -974,12 +980,13 @@ static wmOperatorStatus geometry_color_attribute_convert_exec(bContext *C, wmOpe
|
|||
Object *ob = object::context_object(C);
|
||||
Mesh *mesh = static_cast<Mesh *>(ob->data);
|
||||
AttributeOwner owner = AttributeOwner::from_id(&mesh->id);
|
||||
convert_attribute(owner,
|
||||
mesh->attributes_for_write(),
|
||||
mesh->active_color_attribute,
|
||||
bke::AttrDomain(RNA_enum_get(op->ptr, "domain")),
|
||||
eCustomDataType(RNA_enum_get(op->ptr, "data_type")),
|
||||
op->reports);
|
||||
convert_attribute(
|
||||
owner,
|
||||
mesh->attributes_for_write(),
|
||||
mesh->active_color_attribute,
|
||||
bke::AttrDomain(RNA_enum_get(op->ptr, "domain")),
|
||||
*bke::custom_data_type_to_attr_type(eCustomDataType(RNA_enum_get(op->ptr, "data_type"))),
|
||||
op->reports);
|
||||
DEG_id_tag_update(&mesh->id, ID_RECALC_GEOMETRY);
|
||||
WM_main_add_notifier(NC_GEOM | ND_DATA, &mesh->id);
|
||||
return OPERATOR_FINISHED;
|
||||
|
|
@ -1000,7 +1007,7 @@ static wmOperatorStatus geometry_color_attribute_convert_invoke(bContext *C,
|
|||
}
|
||||
prop = RNA_struct_find_property(op->ptr, "data_type");
|
||||
if (!RNA_property_is_set(op->ptr, prop)) {
|
||||
RNA_property_enum_set(op->ptr, prop, meta_data.data_type);
|
||||
RNA_property_enum_set(op->ptr, prop, *bke::attr_type_to_custom_data_type(meta_data.data_type));
|
||||
}
|
||||
|
||||
return WM_operator_props_dialog_popup(
|
||||
|
|
|
|||
|
|
@ -2693,7 +2693,7 @@ static wmOperatorStatus grease_pencil_paste_strokes_exec(bContext *C, wmOperator
|
|||
/* Make sure everything on the clipboard is selected, in the correct selection domain. */
|
||||
threading::parallel_for_each(clipboard.layers, [&](Clipboard::ClipboardLayer &layer) {
|
||||
bke::GSpanAttributeWriter selection = ed::curves::ensure_selection_attribute(
|
||||
layer.curves, selection_domain, CD_PROP_BOOL);
|
||||
layer.curves, selection_domain, bke::AttrType::Bool);
|
||||
selection.finish();
|
||||
});
|
||||
|
||||
|
|
@ -2713,7 +2713,7 @@ static wmOperatorStatus grease_pencil_paste_strokes_exec(bContext *C, wmOperator
|
|||
const Vector<MutableDrawingInfo> drawings = retrieve_editable_drawings(scene, grease_pencil);
|
||||
threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) {
|
||||
bke::GSpanAttributeWriter selection_in_target = ed::curves::ensure_selection_attribute(
|
||||
info.drawing.strokes_for_write(), selection_domain, CD_PROP_BOOL);
|
||||
info.drawing.strokes_for_write(), selection_domain, bke::AttrType::Bool);
|
||||
ed::curves::fill_selection_false(selection_in_target.span);
|
||||
selection_in_target.finish();
|
||||
});
|
||||
|
|
@ -2773,7 +2773,7 @@ static wmOperatorStatus grease_pencil_paste_strokes_exec(bContext *C, wmOperator
|
|||
const Vector<MutableDrawingInfo> drawings = retrieve_editable_drawings(scene, grease_pencil);
|
||||
threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) {
|
||||
bke::GSpanAttributeWriter selection_in_target = ed::curves::ensure_selection_attribute(
|
||||
info.drawing.strokes_for_write(), selection_domain, CD_PROP_BOOL);
|
||||
info.drawing.strokes_for_write(), selection_domain, bke::AttrType::Bool);
|
||||
ed::curves::fill_selection_false(selection_in_target.span);
|
||||
selection_in_target.finish();
|
||||
});
|
||||
|
|
@ -3056,7 +3056,7 @@ static bke::CurvesGeometry extrude_grease_pencil_curves(const bke::CurvesGeometr
|
|||
ed::curves::get_curves_selection_attribute_names(src))
|
||||
{
|
||||
bke::GSpanAttributeWriter selection = ed::curves::ensure_selection_attribute(
|
||||
dst, bke::AttrDomain::Point, CD_PROP_BOOL, selection_attribute_name);
|
||||
dst, bke::AttrDomain::Point, bke::AttrType::Bool, selection_attribute_name);
|
||||
selection.span.copy_from(dst_selected.as_span());
|
||||
selection.finish();
|
||||
}
|
||||
|
|
@ -4803,13 +4803,13 @@ static bke::AttributeStorage merge_attributes(const bke::AttributeAccessor &a,
|
|||
const bke::AttributeAccessor &b,
|
||||
const int dst_size)
|
||||
{
|
||||
Map<std::string, eCustomDataType> new_types;
|
||||
Map<std::string, bke::AttrType> new_types;
|
||||
const auto add_or_upgrade_types = [&](const bke::AttributeAccessor &attributes) {
|
||||
attributes.foreach_attribute([&](const bke::AttributeIter &iter) {
|
||||
new_types.add_or_modify(
|
||||
iter.name,
|
||||
[&](eCustomDataType *value) { *value = iter.data_type; },
|
||||
[&](eCustomDataType *value) {
|
||||
[&](bke::AttrType *value) { *value = iter.data_type; },
|
||||
[&](bke::AttrType *value) {
|
||||
*value = bke::attribute_data_type_highest_complexity({*value, iter.data_type});
|
||||
});
|
||||
});
|
||||
|
|
@ -4820,7 +4820,7 @@ static bke::AttributeStorage merge_attributes(const bke::AttributeAccessor &a,
|
|||
|
||||
bke::AttributeStorage new_storage;
|
||||
for (const auto &[name, type] : new_types.items()) {
|
||||
const CPPType &cpp_type = *bke::custom_data_type_to_cpp_type(type);
|
||||
const CPPType &cpp_type = bke::attribute_type_to_cpp_type(type);
|
||||
auto new_data = bke::Attribute::ArrayData::ForUninitialized(cpp_type, dst_size);
|
||||
|
||||
const GVArray data_a = *a.lookup_or_default(name, bke::AttrDomain::Layer, type);
|
||||
|
|
@ -4830,10 +4830,7 @@ static bke::AttributeStorage merge_attributes(const bke::AttributeAccessor &a,
|
|||
data_b.materialize_to_uninitialized(
|
||||
POINTER_OFFSET(new_data.data, cpp_type.size * domain_size_a));
|
||||
|
||||
new_storage.add(name,
|
||||
bke::AttrDomain::Layer,
|
||||
*bke::custom_data_type_to_attr_type(type),
|
||||
std::move(new_data));
|
||||
new_storage.add(name, bke::AttrDomain::Layer, type, std::move(new_data));
|
||||
}
|
||||
|
||||
return new_storage;
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ void reverse_points_of(bke::CurvesGeometry &dst_curves, const IndexRange points_
|
|||
if (iter.domain != bke::AttrDomain::Point) {
|
||||
return;
|
||||
}
|
||||
if (iter.data_type == CD_PROP_STRING) {
|
||||
if (iter.data_type == bke::AttrType::String) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -523,7 +523,7 @@ wmOperatorStatus grease_pencil_join_selection_exec(bContext *C, wmOperator *op)
|
|||
append_strokes_from(std::move(tmp_curves), dst_curves);
|
||||
|
||||
bke::GSpanAttributeWriter selection = ed::curves::ensure_selection_attribute(
|
||||
dst_curves, selection_domain, CD_PROP_BOOL);
|
||||
dst_curves, selection_domain, bke::AttrType::Bool);
|
||||
|
||||
if (selection_domain == bke::AttrDomain::Curve) {
|
||||
ed::curves::fill_selection_true(selection.span.take_back(tmp_curves.curves_num()));
|
||||
|
|
|
|||
|
|
@ -1159,7 +1159,7 @@ static void duplicate_layer_and_frames(GreasePencil &dst_grease_pencil,
|
|||
bke::GAttributeWriter writer = dst_attributes.lookup_or_add_for_write(
|
||||
iter.name, iter.domain, iter.data_type);
|
||||
if (writer) {
|
||||
const CPPType &cpptype = *bke::custom_data_type_to_cpp_type(iter.data_type);
|
||||
const CPPType &cpptype = bke::attribute_type_to_cpp_type(iter.data_type);
|
||||
BUFFER_FOR_CPP_TYPE_VALUE(cpptype, buffer);
|
||||
reader.varray.get(src_layer_index, buffer);
|
||||
writer.varray.set_by_copy(dst_layer_index, buffer);
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@ void merge_layers(const GreasePencil &src_grease_pencil,
|
|||
const bke::AttributeAccessor src_attributes = src_grease_pencil.attributes();
|
||||
bke::MutableAttributeAccessor dst_attributes = dst_grease_pencil.attributes_for_write();
|
||||
src_attributes.foreach_attribute([&](const blender::bke::AttributeIter &iter) {
|
||||
if (iter.data_type == CD_PROP_STRING) {
|
||||
if (iter.data_type == bke::AttrType::String) {
|
||||
return;
|
||||
}
|
||||
bke::GAttributeReader src_attribute = iter.get();
|
||||
|
|
|
|||
|
|
@ -119,9 +119,8 @@ bool apply_mask_as_selection(bke::CurvesGeometry &curves,
|
|||
return false;
|
||||
}
|
||||
|
||||
const eCustomDataType create_type = CD_PROP_BOOL;
|
||||
bke::GSpanAttributeWriter writer = ed::curves::ensure_selection_attribute(
|
||||
curves, selection_domain, create_type, attribute_name);
|
||||
curves, selection_domain, bke::AttrType::Bool, attribute_name);
|
||||
|
||||
selection_mask.foreach_index(grain_size, [&](const int64_t element_i) {
|
||||
ed::curves::apply_selection_operation_at_index(writer.span, element_i, sel_op);
|
||||
|
|
@ -162,9 +161,8 @@ bool apply_mask_as_segment_selection(bke::CurvesGeometry &curves,
|
|||
curves, changed_curve_mask, screen_space_positions, tree_data, tree_data_range);
|
||||
|
||||
const OffsetIndices<int> segments_by_curve = OffsetIndices<int>(segment_data.segment_offsets);
|
||||
const eCustomDataType create_type = CD_PROP_BOOL;
|
||||
bke::GSpanAttributeWriter attribute_writer = ed::curves::ensure_selection_attribute(
|
||||
curves, bke::AttrDomain::Point, create_type, attribute_name);
|
||||
curves, bke::AttrDomain::Point, bke::AttrType::Bool, attribute_name);
|
||||
|
||||
/* Find all segments that have changed points and fill them. */
|
||||
Array<bool> changed_points(curves.points_num());
|
||||
|
|
@ -647,7 +645,7 @@ static void select_similar_by_value(Scene *scene,
|
|||
threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) {
|
||||
bke::CurvesGeometry &curves = info.drawing.strokes_for_write();
|
||||
bke::GSpanAttributeWriter selection_writer = ed::curves::ensure_selection_attribute(
|
||||
curves, selection_domain, CD_PROP_BOOL);
|
||||
curves, selection_domain, bke::AttrType::Bool);
|
||||
MutableSpan<bool> selection = selection_writer.span.typed<bool>();
|
||||
const VArraySpan<T> values = *curves.attributes().lookup_or_default<T>(
|
||||
attribute_id, selection_domain, default_value);
|
||||
|
|
@ -895,7 +893,7 @@ bool ensure_selection_domain(ToolSettings *ts, Object *object)
|
|||
attributes.remove(".selection");
|
||||
if (!attributes.add(".selection",
|
||||
domain,
|
||||
bke::cpp_type_to_custom_data_type(type),
|
||||
bke::cpp_type_to_attribute_type(type),
|
||||
bke::AttributeInitMoveArray(dst)))
|
||||
{
|
||||
MEM_freeN(dst);
|
||||
|
|
@ -991,7 +989,7 @@ static wmOperatorStatus grease_pencil_material_select_exec(bContext *C, wmOperat
|
|||
return;
|
||||
}
|
||||
bke::GSpanAttributeWriter selection = ed::curves::ensure_selection_attribute(
|
||||
curves, domain, CD_PROP_BOOL);
|
||||
curves, domain, bke::AttrType::Bool);
|
||||
|
||||
switch (domain) {
|
||||
case bke::AttrDomain::Curve: {
|
||||
|
|
|
|||
|
|
@ -1964,7 +1964,7 @@ void apply_eval_grease_pencil_data(const GreasePencil &eval_grease_pencil,
|
|||
if (attribute_name_is_anonymous(iter.name)) {
|
||||
return;
|
||||
}
|
||||
if (iter.data_type == CD_PROP_STRING) {
|
||||
if (iter.data_type == bke::AttrType::String) {
|
||||
return;
|
||||
}
|
||||
const GVArraySpan src = *iter.get(AttrDomain::Layer);
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ IndexMask retrieve_all_selected_points(const bke::CurvesGeometry &curves, IndexM
|
|||
*/
|
||||
bke::GSpanAttributeWriter ensure_selection_attribute(bke::CurvesGeometry &curves,
|
||||
bke::AttrDomain selection_domain,
|
||||
eCustomDataType create_type,
|
||||
bke::AttrType create_type,
|
||||
StringRef attribute_name = ".selection");
|
||||
|
||||
void foreach_selection_attribute_writer(
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@
|
|||
#include "BLI_generic_pointer.hh"
|
||||
#include "BLI_string_ref.hh"
|
||||
|
||||
#include "DNA_customdata_types.h"
|
||||
|
||||
#include "BKE_screen.hh"
|
||||
|
||||
struct ReportList;
|
||||
|
|
@ -23,6 +21,7 @@ struct PropertyRNA;
|
|||
class AttributeOwner;
|
||||
namespace blender::bke {
|
||||
enum class AttrDomain : int8_t;
|
||||
enum class AttrType : int16_t;
|
||||
class MutableAttributeAccessor;
|
||||
} // namespace blender::bke
|
||||
namespace blender::nodes::geo_eval_log {
|
||||
|
|
@ -38,11 +37,11 @@ namespace blender::ed::geometry {
|
|||
* retrieve/set their values.
|
||||
* \{ */
|
||||
|
||||
StringRefNull rna_property_name_for_type(eCustomDataType type);
|
||||
PropertyRNA *rna_property_for_type(PointerRNA &ptr, const eCustomDataType type);
|
||||
StringRefNull rna_property_name_for_type(bke::AttrType type);
|
||||
PropertyRNA *rna_property_for_type(PointerRNA &ptr, const bke::AttrType type);
|
||||
void register_rna_properties_for_attribute_types(StructRNA &srna);
|
||||
GPointer rna_property_for_attribute_type_retrieve_value(PointerRNA &ptr,
|
||||
const eCustomDataType type,
|
||||
const bke::AttrType type,
|
||||
void *buffer);
|
||||
void rna_property_for_attribute_type_set_value(PointerRNA &ptr, PropertyRNA &prop, GPointer value);
|
||||
bool attribute_set_poll(bContext &C, const ID &object_data);
|
||||
|
|
@ -61,7 +60,7 @@ bool convert_attribute(AttributeOwner &owner,
|
|||
bke::MutableAttributeAccessor attributes,
|
||||
StringRef name,
|
||||
bke::AttrDomain dst_domain,
|
||||
eCustomDataType dst_type,
|
||||
bke::AttrType dst_type,
|
||||
ReportList *reports);
|
||||
|
||||
struct GeoOperatorLog {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
#include "BLI_math_vector_types.hh"
|
||||
#include "BLI_vector_set.hh"
|
||||
|
||||
#include "DNA_customdata_types.h"
|
||||
#include "DNA_windowmanager_enums.h"
|
||||
|
||||
struct ARegion;
|
||||
|
|
@ -28,6 +27,7 @@ struct wmKeyConfig;
|
|||
struct wmOperator;
|
||||
struct wmOperatorType;
|
||||
namespace blender::bke {
|
||||
enum class AttrType : int16_t;
|
||||
struct GSpanAttributeWriter;
|
||||
} // namespace blender::bke
|
||||
namespace blender {
|
||||
|
|
@ -78,7 +78,7 @@ void select_all(PointCloud &pointcloud, int action);
|
|||
* If the selection_id attribute doesn't exist, create it with the requested type (bool or float).
|
||||
*/
|
||||
bke::GSpanAttributeWriter ensure_selection_attribute(PointCloud &pointcloud,
|
||||
eCustomDataType create_type);
|
||||
bke::AttrType create_type);
|
||||
|
||||
bool select_box(PointCloud &pointcloud,
|
||||
const ARegion ®ion,
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
#include "BLT_translation.hh"
|
||||
|
||||
#include "BKE_attribute.hh"
|
||||
#include "BKE_attribute_legacy_convert.hh"
|
||||
|
||||
#include "NOD_geometry_nodes_log.hh"
|
||||
|
||||
|
|
@ -45,10 +46,11 @@ static StringRef attribute_domain_string(const bke::AttrDomain domain)
|
|||
|
||||
static bool attribute_search_item_add(uiSearchItems *items, const GeometryAttributeInfo &item)
|
||||
{
|
||||
std::string search_item_text = fmt::format("{} " UI_MENU_ARROW_SEP "{}" UI_SEP_CHAR_S "{}",
|
||||
attribute_domain_string(*item.domain),
|
||||
item.name,
|
||||
attribute_data_type_string(*item.data_type));
|
||||
std::string search_item_text = fmt::format(
|
||||
"{} " UI_MENU_ARROW_SEP "{}" UI_SEP_CHAR_S "{}",
|
||||
attribute_domain_string(*item.domain),
|
||||
item.name,
|
||||
attribute_data_type_string(*bke::attr_type_to_custom_data_type(*item.data_type)));
|
||||
return UI_search_item_add(
|
||||
items, search_item_text, (void *)&item, ICON_NONE, UI_BUT_HAS_SEP_CHAR, 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include "BLI_generic_pointer.hh"
|
||||
|
||||
#include "BKE_attribute.hh"
|
||||
#include "BKE_attribute_legacy_convert.hh"
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_editmesh.hh"
|
||||
#include "BKE_layer.hh"
|
||||
|
|
@ -142,8 +143,9 @@ static wmOperatorStatus mesh_set_attribute_exec(bContext *C, wmOperator *op)
|
|||
const StringRef name = *BKE_attributes_active_name_get(active_owner);
|
||||
CustomDataLayer *active_layer = BKE_attribute_search_for_write(
|
||||
active_owner, name, CD_MASK_PROP_ALL, ATTR_DOMAIN_MASK_ALL);
|
||||
const eCustomDataType active_type = eCustomDataType(active_layer->type);
|
||||
const CPPType &type = *bke::custom_data_type_to_cpp_type(active_type);
|
||||
const bke::AttrType active_type = *bke::custom_data_type_to_attr_type(
|
||||
eCustomDataType(active_layer->type));
|
||||
const CPPType &type = bke::attribute_type_to_cpp_type(active_type);
|
||||
|
||||
BUFFER_FOR_CPP_TYPE_VALUE(type, buffer);
|
||||
BLI_SCOPED_DEFER([&]() { type.destruct(buffer); });
|
||||
|
|
@ -217,7 +219,8 @@ static wmOperatorStatus mesh_set_attribute_invoke(bContext *C,
|
|||
const StringRef name = *BKE_attributes_active_name_get(owner);
|
||||
CustomDataLayer *layer = BKE_attribute_search_for_write(
|
||||
owner, name, CD_MASK_PROP_ALL, ATTR_DOMAIN_MASK_ALL);
|
||||
const eCustomDataType data_type = eCustomDataType(layer->type);
|
||||
const bke::AttrType data_type = *bke::custom_data_type_to_attr_type(
|
||||
eCustomDataType(layer->type));
|
||||
const bke::AttrDomain domain = BKE_attribute_domain(owner, layer);
|
||||
const BMElem *active_elem = BM_mesh_active_elem_get(bm);
|
||||
if (!active_elem) {
|
||||
|
|
@ -230,7 +233,7 @@ static wmOperatorStatus mesh_set_attribute_invoke(bContext *C,
|
|||
return WM_operator_props_popup(C, op, event);
|
||||
}
|
||||
|
||||
const CPPType &type = *bke::custom_data_type_to_cpp_type(data_type);
|
||||
const CPPType &type = bke::attribute_type_to_cpp_type(data_type);
|
||||
const GPointer active_value(type, POINTER_OFFSET(active_elem->head.data, layer->offset));
|
||||
|
||||
PropertyRNA *prop = geometry::rna_property_for_type(*op->ptr, data_type);
|
||||
|
|
@ -252,7 +255,7 @@ static void mesh_set_attribute_ui(bContext *C, wmOperator *op)
|
|||
const StringRef name = *BKE_attributes_active_name_get(owner);
|
||||
CustomDataLayer *layer = BKE_attribute_search_for_write(
|
||||
owner, name, CD_MASK_PROP_ALL, ATTR_DOMAIN_MASK_ALL);
|
||||
const eCustomDataType active_type = eCustomDataType(layer->type);
|
||||
const bke::AttrType active_type = bke::AttrType(layer->type);
|
||||
const StringRefNull prop_name = geometry::rna_property_name_for_type(active_type);
|
||||
layout->prop(op->ptr, prop_name, UI_ITEM_NONE, name, ICON_NONE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -428,7 +428,7 @@ bool ED_mesh_color_ensure(Mesh *mesh, const char *name)
|
|||
const std::string unique_name = BKE_attribute_calc_unique_name(owner, name);
|
||||
if (!mesh->attributes_for_write().add(unique_name,
|
||||
bke::AttrDomain::Corner,
|
||||
CD_PROP_BYTE_COLOR,
|
||||
bke::AttrType::ColorByte,
|
||||
bke::AttributeInitDefaultValue()))
|
||||
{
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -3251,7 +3251,7 @@ static void mesh_data_to_grease_pencil(const Mesh &mesh_eval,
|
|||
mesh_copied->attributes_for_write().add(
|
||||
unique_attribute_id,
|
||||
bke::AttrDomain::Point,
|
||||
CD_PROP_FLOAT3,
|
||||
bke::AttrType::Float3,
|
||||
bke::AttributeInitVArray(VArray<float3>::ForSpan(normals)));
|
||||
|
||||
const int edges_num = mesh_copied->edges_num;
|
||||
|
|
|
|||
|
|
@ -1078,7 +1078,7 @@ static void vgroup_grease_pencil_select_verts(const Scene &scene,
|
|||
}
|
||||
|
||||
GSpanAttributeWriter selection = ed::curves::ensure_selection_attribute(
|
||||
curves, selection_domain, CD_PROP_BOOL);
|
||||
curves, selection_domain, bke::AttrType::Bool);
|
||||
switch (selection_domain) {
|
||||
case AttrDomain::Point:
|
||||
threading::parallel_for(curves.points_range(), 4096, [&](const IndexRange range) {
|
||||
|
|
|
|||
|
|
@ -84,8 +84,8 @@ static wmOperatorStatus set_attribute_exec(bContext *C, wmOperator *op)
|
|||
AttributeOwner active_owner = AttributeOwner::from_id(&active_pointcloud.id);
|
||||
const StringRef name = *BKE_attributes_active_name_get(active_owner);
|
||||
const bke::AttributeMetaData meta_data = *active_pointcloud.attributes().lookup_meta_data(name);
|
||||
const eCustomDataType active_type = meta_data.data_type;
|
||||
const CPPType &type = *bke::custom_data_type_to_cpp_type(active_type);
|
||||
const bke::AttrType active_type = meta_data.data_type;
|
||||
const CPPType &type = bke::attribute_type_to_cpp_type(active_type);
|
||||
|
||||
BUFFER_FOR_CPP_TYPE_VALUE(type, buffer);
|
||||
BLI_SCOPED_DEFER([&]() { type.destruct(buffer); });
|
||||
|
|
@ -146,7 +146,7 @@ static wmOperatorStatus set_attribute_invoke(bContext *C, wmOperator *op, const
|
|||
const CPPType &type = attribute.varray.type();
|
||||
|
||||
PropertyRNA *prop = geometry::rna_property_for_type(*op->ptr,
|
||||
bke::cpp_type_to_custom_data_type(type));
|
||||
bke::cpp_type_to_attribute_type(type));
|
||||
if (RNA_property_is_set(op->ptr, prop)) {
|
||||
return WM_operator_props_popup(C, op, event);
|
||||
}
|
||||
|
|
@ -179,7 +179,7 @@ static void set_attribute_ui(bContext *C, wmOperator *op)
|
|||
AttributeOwner owner = AttributeOwner::from_id(&pointcloud.id);
|
||||
const StringRef name = *BKE_attributes_active_name_get(owner);
|
||||
const bke::AttributeMetaData meta_data = *pointcloud.attributes().lookup_meta_data(name);
|
||||
const eCustomDataType active_type = eCustomDataType(meta_data.data_type);
|
||||
const bke::AttrType active_type = bke::AttrType(meta_data.data_type);
|
||||
const StringRefNull prop_name = geometry::rna_property_name_for_type(active_type);
|
||||
layout->prop(op->ptr, prop_name, UI_ITEM_NONE, name, ICON_NONE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,7 +152,8 @@ static wmOperatorStatus select_random_exec(bContext *C, wmOperator *op)
|
|||
.complement(IndexRange(pointcloud->totpoint),
|
||||
memory);
|
||||
const bool was_anything_selected = has_anything_selected(*pointcloud);
|
||||
bke::GSpanAttributeWriter selection = ensure_selection_attribute(*pointcloud, CD_PROP_BOOL);
|
||||
bke::GSpanAttributeWriter selection = ensure_selection_attribute(*pointcloud,
|
||||
bke::AttrType::Bool);
|
||||
if (!was_anything_selected) {
|
||||
pointcloud::fill_selection_true(selection.span);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ bool has_anything_selected(const PointCloud &pointcloud)
|
|||
}
|
||||
|
||||
bke::GSpanAttributeWriter ensure_selection_attribute(PointCloud &pointcloud,
|
||||
eCustomDataType create_type)
|
||||
bke::AttrType create_type)
|
||||
{
|
||||
const bke::AttrDomain selection_domain = bke::AttrDomain::Point;
|
||||
const StringRef attribute_name = ".selection";
|
||||
|
|
@ -105,16 +105,16 @@ bke::GSpanAttributeWriter ensure_selection_attribute(PointCloud &pointcloud,
|
|||
}
|
||||
const int domain_size = pointcloud.totpoint;
|
||||
switch (create_type) {
|
||||
case CD_PROP_BOOL:
|
||||
case bke::AttrType::Bool:
|
||||
attributes.add(attribute_name,
|
||||
selection_domain,
|
||||
CD_PROP_BOOL,
|
||||
bke::AttrType::Bool,
|
||||
bke::AttributeInitVArray(VArray<bool>::ForSingle(true, domain_size)));
|
||||
break;
|
||||
case CD_PROP_FLOAT:
|
||||
case bke::AttrType::Float:
|
||||
attributes.add(attribute_name,
|
||||
selection_domain,
|
||||
CD_PROP_FLOAT,
|
||||
bke::AttrType::Float,
|
||||
bke::AttributeInitVArray(VArray<float>::ForSingle(1.0f, domain_size)));
|
||||
break;
|
||||
default:
|
||||
|
|
@ -176,7 +176,8 @@ static void select_all(PointCloud &pointcloud, const IndexMask &mask, int action
|
|||
}
|
||||
}
|
||||
|
||||
bke::GSpanAttributeWriter selection = ensure_selection_attribute(pointcloud, CD_PROP_BOOL);
|
||||
bke::GSpanAttributeWriter selection = ensure_selection_attribute(pointcloud,
|
||||
bke::AttrType::Bool);
|
||||
if (action == SEL_SELECT) {
|
||||
fill_selection_true(selection.span, mask);
|
||||
}
|
||||
|
|
@ -199,7 +200,8 @@ static bool apply_selection_operation(PointCloud &pointcloud,
|
|||
eSelectOp sel_op)
|
||||
{
|
||||
bool changed = false;
|
||||
bke::GSpanAttributeWriter selection = ensure_selection_attribute(pointcloud, CD_PROP_BOOL);
|
||||
bke::GSpanAttributeWriter selection = ensure_selection_attribute(pointcloud,
|
||||
bke::AttrType::Bool);
|
||||
if (sel_op == SEL_OP_SET) {
|
||||
fill_selection_false(selection.span, IndexRange(selection.span.size()));
|
||||
changed = true;
|
||||
|
|
|
|||
|
|
@ -784,7 +784,7 @@ static wmOperatorStatus select_grow_modal(bContext *C, wmOperator *op, const wmE
|
|||
attributes.add(
|
||||
".selection",
|
||||
bke::AttrDomain(curves_id.selection_domain),
|
||||
bke::cpp_type_to_custom_data_type(curve_op_data->original_selection.type()),
|
||||
bke::cpp_type_to_attribute_type(curve_op_data->original_selection.type()),
|
||||
bke::AttributeInitVArray(GVArray::ForSpan(curve_op_data->original_selection)));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ bke::SpanAttributeWriter<float> float_selection_ensure(Curves &curves_id)
|
|||
bke::MutableAttributeAccessor attributes = curves.attributes_for_write();
|
||||
|
||||
if (const auto meta_data = attributes.lookup_meta_data(".selection")) {
|
||||
if (meta_data->data_type == CD_PROP_BOOL) {
|
||||
if (meta_data->data_type == bke::AttrType::Bool) {
|
||||
const VArray<float> selection = *attributes.lookup<float>(".selection");
|
||||
float *dst = static_cast<float *>(
|
||||
MEM_malloc_arrayN(selection.size(), sizeof(float), __func__));
|
||||
|
|
@ -23,7 +23,7 @@ bke::SpanAttributeWriter<float> float_selection_ensure(Curves &curves_id)
|
|||
|
||||
attributes.remove(".selection");
|
||||
attributes.add(
|
||||
".selection", meta_data->domain, CD_PROP_FLOAT, bke::AttributeInitMoveArray(dst));
|
||||
".selection", meta_data->domain, bke::AttrType::Float, bke::AttributeInitMoveArray(dst));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
@ -31,7 +31,7 @@ bke::SpanAttributeWriter<float> float_selection_ensure(Curves &curves_id)
|
|||
const int64_t size = attributes.domain_size(domain);
|
||||
attributes.add(".selection",
|
||||
domain,
|
||||
CD_PROP_FLOAT,
|
||||
bke::AttrType::Float,
|
||||
bke::AttributeInitVArray(VArray<float>::ForSingle(1.0f, size)));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1511,7 +1511,7 @@ static void deselect_stroke(const bContext &C,
|
|||
scene->toolsettings);
|
||||
|
||||
bke::GSpanAttributeWriter selection = ed::curves::ensure_selection_attribute(
|
||||
curves, selection_domain, CD_PROP_BOOL);
|
||||
curves, selection_domain, bke::AttrType::Bool);
|
||||
|
||||
if (selection_domain == bke::AttrDomain::Curve) {
|
||||
ed::curves::fill_selection_false(selection.span.slice(IndexRange::from_single(active_curve)));
|
||||
|
|
|
|||
|
|
@ -922,13 +922,13 @@ void PAINT_OT_vertex_paint_toggle(wmOperatorType *ot)
|
|||
*/
|
||||
|
||||
template<typename Func>
|
||||
static void to_static_color_type(const eCustomDataType type, const Func &func)
|
||||
static void to_static_color_type(const bke::AttrType type, const Func &func)
|
||||
{
|
||||
switch (type) {
|
||||
case CD_PROP_COLOR:
|
||||
case bke::AttrType::ColorFloat:
|
||||
func(ColorGeometry4f());
|
||||
break;
|
||||
case CD_PROP_BYTE_COLOR:
|
||||
case bke::AttrType::ColorByte:
|
||||
func(ColorGeometry4b());
|
||||
break;
|
||||
default:
|
||||
|
|
@ -940,7 +940,7 @@ static void to_static_color_type(const eCustomDataType type, const Func &func)
|
|||
struct VPaintData : public PaintModeData {
|
||||
ViewContext vc;
|
||||
AttrDomain domain;
|
||||
eCustomDataType type;
|
||||
bke::AttrType type;
|
||||
|
||||
NormalAnglePrecalc normal_angle_precalc;
|
||||
|
||||
|
|
@ -982,7 +982,7 @@ static std::unique_ptr<VPaintData> vpaint_init_vpaint(bContext *C,
|
|||
Object &ob,
|
||||
Mesh &mesh,
|
||||
const AttrDomain domain,
|
||||
const eCustomDataType type,
|
||||
const bke::AttrType type,
|
||||
const Brush &brush)
|
||||
{
|
||||
std::unique_ptr<VPaintData> vpd = std::make_unique<VPaintData>();
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ static bool vertex_paint_from_weight(Object &ob)
|
|||
const GVArray vertex_group = *attributes.lookup(
|
||||
deform_group->name,
|
||||
bke::AttrDomain::Point,
|
||||
bke::cpp_type_to_custom_data_type(color_attribute.varray.type()));
|
||||
bke::cpp_type_to_attribute_type(color_attribute.varray.type()));
|
||||
if (!vertex_group) {
|
||||
BLI_assert_unreachable();
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -5187,7 +5187,7 @@ void flush_update_done(const bContext *C, Object &ob, const UpdateType update_ty
|
|||
static void replace_attribute(const bke::AttributeAccessor src_attributes,
|
||||
const StringRef name,
|
||||
const bke::AttrDomain domain,
|
||||
const eCustomDataType data_type,
|
||||
const bke::AttrType data_type,
|
||||
bke::MutableAttributeAccessor dst_attributes)
|
||||
{
|
||||
dst_attributes.remove(name);
|
||||
|
|
@ -5353,7 +5353,7 @@ void store_mesh_from_eval(const wmOperator &op,
|
|||
replace_attribute(new_mesh->attributes(),
|
||||
".sculpt_mask",
|
||||
bke::AttrDomain::Point,
|
||||
CD_PROP_FLOAT,
|
||||
bke::AttrType::Float,
|
||||
mesh.attributes_for_write());
|
||||
pbvh.tag_masks_changed(leaf_nodes);
|
||||
BKE_mesh_copy_parameters(&mesh, new_mesh);
|
||||
|
|
@ -5366,7 +5366,7 @@ void store_mesh_from_eval(const wmOperator &op,
|
|||
replace_attribute(new_mesh->attributes(),
|
||||
".sculpt_face_set",
|
||||
bke::AttrDomain::Face,
|
||||
CD_PROP_INT32,
|
||||
bke::AttrType::Int32,
|
||||
mesh.attributes_for_write());
|
||||
pbvh.tag_face_sets_changed(leaf_nodes);
|
||||
BKE_mesh_copy_parameters(&mesh, new_mesh);
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "BKE_attribute.hh"
|
||||
#include "BKE_attribute_legacy_convert.hh"
|
||||
#include "BKE_ccg.hh"
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_customdata.hh"
|
||||
|
|
@ -1671,13 +1672,13 @@ static void save_active_attribute(Object &object, SculptAttrRef *attr)
|
|||
return;
|
||||
}
|
||||
if (!(ATTR_DOMAIN_AS_MASK(meta_data->domain) & ATTR_DOMAIN_MASK_COLOR) ||
|
||||
!(CD_TYPE_AS_MASK(meta_data->data_type) & CD_MASK_COLOR_ALL))
|
||||
!(ELEM(meta_data->data_type, bke::AttrType::ColorFloat, bke::AttrType::ColorByte)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
attr->domain = meta_data->domain;
|
||||
STRNCPY(attr->name, name);
|
||||
attr->type = meta_data->data_type;
|
||||
attr->type = *bke::attr_type_to_custom_data_type(meta_data->data_type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1880,7 +1881,7 @@ static void set_active_layer(bContext *C, const SculptAttrRef *attr)
|
|||
mesh->attributes_for_write(),
|
||||
attr->name,
|
||||
attr->domain,
|
||||
eCustomDataType(attr->type),
|
||||
*bke::custom_data_type_to_attr_type(attr->type),
|
||||
nullptr))
|
||||
{
|
||||
layer = BKE_attribute_find(owner, attr->name, attr->type, attr->domain);
|
||||
|
|
@ -1890,8 +1891,10 @@ static void set_active_layer(bContext *C, const SculptAttrRef *attr)
|
|||
|
||||
if (!layer) {
|
||||
/* Memfile undo killed the layer; re-create it. */
|
||||
mesh->attributes_for_write().add(
|
||||
attr->name, attr->domain, attr->type, bke::AttributeInitDefaultValue());
|
||||
mesh->attributes_for_write().add(attr->name,
|
||||
attr->domain,
|
||||
*bke::custom_data_type_to_attr_type(attr->type),
|
||||
bke::AttributeInitDefaultValue());
|
||||
layer = BKE_attribute_find(owner, attr->name, attr->type, attr->domain);
|
||||
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include "DNA_node_types.h"
|
||||
#include "DNA_space_types.h"
|
||||
|
||||
#include "BKE_attribute_legacy_convert.hh"
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_main_invariants.hh"
|
||||
#include "BKE_node_legacy_types.hh"
|
||||
|
|
@ -199,7 +200,8 @@ static void attribute_search_exec_fn(bContext *C, void *data_v, void *item_v)
|
|||
if (node->type_legacy == GEO_NODE_INPUT_NAMED_ATTRIBUTE && item->data_type.has_value()) {
|
||||
NodeGeometryInputNamedAttribute &storage = *static_cast<NodeGeometryInputNamedAttribute *>(
|
||||
node->storage);
|
||||
const eCustomDataType new_type = data_type_in_attribute_input_node(*item->data_type);
|
||||
const eCustomDataType new_type = data_type_in_attribute_input_node(
|
||||
*bke::attr_type_to_custom_data_type(*item->data_type));
|
||||
if (new_type != storage.data_type) {
|
||||
storage.data_type = new_type;
|
||||
/* Make the output socket with the new type on the attribute input node active. */
|
||||
|
|
|
|||
|
|
@ -3140,8 +3140,8 @@ static bool pointcloud_select_pick(bContext &C, const int2 mval, const SelectPic
|
|||
continue;
|
||||
}
|
||||
|
||||
bke::GSpanAttributeWriter selection = pointcloud::ensure_selection_attribute(pointcloud,
|
||||
CD_PROP_BOOL);
|
||||
bke::GSpanAttributeWriter selection = pointcloud::ensure_selection_attribute(
|
||||
pointcloud, bke::AttrType::Bool);
|
||||
pointcloud::fill_selection_false(selection.span, IndexMask(pointcloud.totpoint));
|
||||
selection.finish();
|
||||
|
||||
|
|
@ -3158,8 +3158,8 @@ static bool pointcloud_select_pick(bContext &C, const int2 mval, const SelectPic
|
|||
return deselected;
|
||||
}
|
||||
|
||||
bke::GSpanAttributeWriter selection = pointcloud::ensure_selection_attribute(*closest.pointcloud,
|
||||
CD_PROP_BOOL);
|
||||
bke::GSpanAttributeWriter selection = pointcloud::ensure_selection_attribute(
|
||||
*closest.pointcloud, bke::AttrType::Bool);
|
||||
curves::apply_selection_operation_at_index(selection.span, closest.elem.index, params.sel_op);
|
||||
selection.finish();
|
||||
|
||||
|
|
@ -3283,7 +3283,7 @@ static bool ed_curves_select_pick(bContext &C, const int mval[2], const SelectPi
|
|||
bke::GSpanAttributeWriter selection = ed::curves::ensure_selection_attribute(
|
||||
closest.curves_id->geometry.wrap(),
|
||||
bke::AttrDomain::Point,
|
||||
CD_PROP_BOOL,
|
||||
bke::AttrType::Bool,
|
||||
closest.selection_attribute_name);
|
||||
ed::curves::apply_selection_operation_at_index(
|
||||
selection.span, closest.elem.index, params.sel_op);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ using bke::AttrDomain;
|
|||
|
||||
struct PropagationAttribute {
|
||||
StringRef name;
|
||||
eCustomDataType cd_type;
|
||||
bke::AttrType data_type;
|
||||
AttrDomain domain;
|
||||
GVArray data;
|
||||
};
|
||||
|
|
@ -36,7 +36,7 @@ Array<Mesh *> extract_mesh_vertices(const Mesh &mesh,
|
|||
|
||||
Vector<PropagationAttribute> propagation_attributes;
|
||||
src_attributes.foreach_attribute([&](const bke::AttributeIter &iter) {
|
||||
if (iter.data_type == CD_PROP_STRING) {
|
||||
if (iter.data_type == bke::AttrType::String) {
|
||||
return;
|
||||
}
|
||||
if (attribute_filter.allow_skip(iter.name)) {
|
||||
|
|
@ -57,7 +57,7 @@ Array<Mesh *> extract_mesh_vertices(const Mesh &mesh,
|
|||
|
||||
for (const PropagationAttribute &src_attribute : propagation_attributes) {
|
||||
bke::GSpanAttributeWriter dst = element_attributes.lookup_or_add_for_write_only_span(
|
||||
src_attribute.name, AttrDomain::Point, src_attribute.cd_type);
|
||||
src_attribute.name, AttrDomain::Point, src_attribute.data_type);
|
||||
if (!dst) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -83,7 +83,7 @@ Array<Mesh *> extract_mesh_edges(const Mesh &mesh,
|
|||
|
||||
Vector<PropagationAttribute> propagation_attributes;
|
||||
src_attributes.foreach_attribute([&](const bke::AttributeIter &iter) {
|
||||
if (iter.data_type == CD_PROP_STRING) {
|
||||
if (iter.data_type == bke::AttrType::String) {
|
||||
return;
|
||||
}
|
||||
if (iter.name == ".edge_verts") {
|
||||
|
|
@ -126,7 +126,7 @@ Array<Mesh *> extract_mesh_edges(const Mesh &mesh,
|
|||
bke::MutableAttributeAccessor element_attributes = element->attributes_for_write();
|
||||
for (const PropagationAttribute &src_attribute : propagation_attributes) {
|
||||
bke::GSpanAttributeWriter dst = element_attributes.lookup_or_add_for_write_only_span(
|
||||
src_attribute.name, src_attribute.domain, src_attribute.cd_type);
|
||||
src_attribute.name, src_attribute.domain, src_attribute.data_type);
|
||||
if (!dst) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -160,7 +160,7 @@ Array<Mesh *> extract_mesh_faces(const Mesh &mesh,
|
|||
|
||||
Vector<PropagationAttribute> propagation_attributes;
|
||||
src_attributes.foreach_attribute([&](const bke::AttributeIter &iter) {
|
||||
if (iter.data_type == CD_PROP_STRING) {
|
||||
if (iter.data_type == bke::AttrType::String) {
|
||||
return;
|
||||
}
|
||||
if (ELEM(iter.name, ".edge_verts", ".corner_edge", ".corner_vert")) {
|
||||
|
|
@ -201,7 +201,7 @@ Array<Mesh *> extract_mesh_faces(const Mesh &mesh,
|
|||
bke::MutableAttributeAccessor element_attributes = element->attributes_for_write();
|
||||
for (const PropagationAttribute &src_attribute : propagation_attributes) {
|
||||
bke::GSpanAttributeWriter dst = element_attributes.lookup_or_add_for_write_only_span(
|
||||
src_attribute.name, src_attribute.domain, src_attribute.cd_type);
|
||||
src_attribute.name, src_attribute.domain, src_attribute.data_type);
|
||||
if (!dst) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,11 +80,11 @@ static AttributesForInterpolation retrieve_attribute_spans(const Span<StringRef>
|
|||
const bke::AttributeAccessor src_to_attributes = src_to_curves.attributes();
|
||||
bke::MutableAttributeAccessor dst_attributes = dst_curves.attributes_for_write();
|
||||
for (const int i : ids.index_range()) {
|
||||
eCustomDataType data_type;
|
||||
bke::AttrType data_type;
|
||||
|
||||
const GVArray src_from_attribute = *src_from_attributes.lookup(ids[i], domain);
|
||||
if (src_from_attribute) {
|
||||
data_type = bke::cpp_type_to_custom_data_type(src_from_attribute.type());
|
||||
data_type = bke::cpp_type_to_attribute_type(src_from_attribute.type());
|
||||
|
||||
const GVArray src_to_attribute = *src_to_attributes.lookup(ids[i], domain, data_type);
|
||||
|
||||
|
|
@ -96,7 +96,7 @@ static AttributesForInterpolation retrieve_attribute_spans(const Span<StringRef>
|
|||
/* Attribute should exist on at least one of the geometries. */
|
||||
BLI_assert(src_to_attribute);
|
||||
|
||||
data_type = bke::cpp_type_to_custom_data_type(src_to_attribute.type());
|
||||
data_type = bke::cpp_type_to_attribute_type(src_to_attribute.type());
|
||||
|
||||
result.src_from.append(GVArraySpan{});
|
||||
result.src_to.append(src_to_attribute);
|
||||
|
|
@ -121,7 +121,7 @@ static AttributesForInterpolation gather_point_attributes_to_interpolate(
|
|||
if (iter.domain != bke::AttrDomain::Point) {
|
||||
return;
|
||||
}
|
||||
if (iter.data_type == CD_PROP_STRING) {
|
||||
if (iter.data_type == bke::AttrType::String) {
|
||||
return;
|
||||
}
|
||||
if (!interpolate_attribute_to_curves(iter.name, dst_curves.curve_type_counts())) {
|
||||
|
|
@ -156,7 +156,7 @@ static AttributesForInterpolation gather_curve_attributes_to_interpolate(
|
|||
if (iter.domain != bke::AttrDomain::Curve) {
|
||||
return;
|
||||
}
|
||||
if (iter.data_type == CD_PROP_STRING) {
|
||||
if (iter.data_type == bke::AttrType::String) {
|
||||
return;
|
||||
}
|
||||
if (bke::attribute_name_is_anonymous(iter.name)) {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ static Map<StringRef, AttributeDomainAndType> get_final_attribute_info(
|
|||
if (ignored_attributes.contains(iter.name)) {
|
||||
return;
|
||||
}
|
||||
if (iter.data_type == CD_PROP_STRING) {
|
||||
if (iter.data_type == bke::AttrType::String) {
|
||||
return;
|
||||
}
|
||||
info.add_or_modify(
|
||||
|
|
@ -47,12 +47,11 @@ static Map<StringRef, AttributeDomainAndType> get_final_attribute_info(
|
|||
|
||||
static void fill_new_attribute(const Span<const GeometryComponent *> src_components,
|
||||
const StringRef attribute_id,
|
||||
const eCustomDataType data_type,
|
||||
const bke::AttrType data_type,
|
||||
const bke::AttrDomain domain,
|
||||
GMutableSpan dst_span)
|
||||
{
|
||||
const CPPType *cpp_type = bke::custom_data_type_to_cpp_type(data_type);
|
||||
BLI_assert(cpp_type != nullptr);
|
||||
const CPPType &cpp_type = bke::attribute_type_to_cpp_type(data_type);
|
||||
|
||||
int offset = 0;
|
||||
for (const GeometryComponent *component : src_components) {
|
||||
|
|
@ -66,7 +65,7 @@ static void fill_new_attribute(const Span<const GeometryComponent *> src_compone
|
|||
GVArraySpan src_span{read_attribute};
|
||||
const void *src_buffer = src_span.data();
|
||||
void *dst_buffer = dst_span[offset];
|
||||
cpp_type->copy_assign_n(src_buffer, dst_buffer, domain_num);
|
||||
cpp_type.copy_assign_n(src_buffer, dst_buffer, domain_num);
|
||||
|
||||
offset += domain_num;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ static void reorder_and_flip_attributes_group_to_group(
|
|||
if (iter.domain != domain) {
|
||||
return;
|
||||
}
|
||||
if (iter.data_type == CD_PROP_STRING) {
|
||||
if (iter.data_type == bke::AttrType::String) {
|
||||
return;
|
||||
}
|
||||
const GVArray src = *iter.get(domain);
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ GreasePencil *merge_layers(const GreasePencil &src_grease_pencil,
|
|||
const bke::AttributeAccessor src_attributes = src_grease_pencil.attributes();
|
||||
bke::MutableAttributeAccessor new_attributes = new_grease_pencil->attributes_for_write();
|
||||
src_attributes.foreach_attribute([&](const bke::AttributeIter &iter) {
|
||||
if (iter.data_type == CD_PROP_STRING) {
|
||||
if (iter.data_type == bke::AttrType::String) {
|
||||
return;
|
||||
}
|
||||
if (attribute_filter.allow_skip(iter.name)) {
|
||||
|
|
|
|||
|
|
@ -177,20 +177,20 @@ static void dump_mesh(const Mesh *mesh, const std::string &name)
|
|||
const char *domain = (di >= 0 && di < ATTR_DOMAIN_NUM) ? domain_names[di] : "?";
|
||||
std::string label = std::string(domain) + ": " + iter.name;
|
||||
switch (iter.data_type) {
|
||||
case CD_PROP_FLOAT: {
|
||||
case bke::AttrType::Float: {
|
||||
VArraySpan<float> floatspan(*attrs.lookup<float>(iter.name));
|
||||
dump_span(floatspan, label);
|
||||
} break;
|
||||
case CD_PROP_INT32:
|
||||
case CD_PROP_BOOL: {
|
||||
case bke::AttrType::Int32:
|
||||
case bke::AttrType::Bool: {
|
||||
const VArraySpan<int> intspan(*attrs.lookup<int>(iter.name));
|
||||
dump_span(intspan, label);
|
||||
} break;
|
||||
case CD_PROP_FLOAT3: {
|
||||
case bke::AttrType::Float3: {
|
||||
const VArraySpan<float3> float3span(*attrs.lookup<float3>(iter.name));
|
||||
dump_span(float3span, label);
|
||||
} break;
|
||||
case CD_PROP_FLOAT2: {
|
||||
case bke::AttrType::Float2: {
|
||||
const VArraySpan<float2> float2span(*attrs.lookup<float2>(iter.name));
|
||||
dump_span(float2span, label);
|
||||
} break;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ static void propagate_vert_attributes(Mesh &mesh, const Span<int> new_to_old_ver
|
|||
if (meta_data.domain != bke::AttrDomain::Point) {
|
||||
continue;
|
||||
}
|
||||
if (meta_data.data_type == CD_PROP_STRING) {
|
||||
if (meta_data.data_type == bke::AttrType::String) {
|
||||
continue;
|
||||
}
|
||||
bke::GSpanAttributeWriter attribute = attributes.lookup_for_write_span(id);
|
||||
|
|
@ -75,7 +75,7 @@ static void propagate_edge_attributes(Mesh &mesh, const Span<int> new_to_old_edg
|
|||
if (meta_data.domain != bke::AttrDomain::Edge) {
|
||||
continue;
|
||||
}
|
||||
if (meta_data.data_type == CD_PROP_STRING) {
|
||||
if (meta_data.data_type == bke::AttrType::String) {
|
||||
continue;
|
||||
}
|
||||
if (id == ".edge_verts") {
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ BLI_NOINLINE bke::CurvesGeometry create_curve_from_vert_indices(
|
|||
if (iter.domain == bke::AttrDomain::Point) {
|
||||
return;
|
||||
}
|
||||
if (iter.data_type == CD_PROP_STRING) {
|
||||
if (iter.data_type == bke::AttrType::String) {
|
||||
return;
|
||||
}
|
||||
if (attribute_filter_with_skip.allow_skip(iter.name)) {
|
||||
|
|
@ -303,7 +303,7 @@ bke::CurvesGeometry mesh_faces_to_curves_convert(const Mesh &mesh,
|
|||
if (iter.domain != bke::AttrDomain::Edge) {
|
||||
return;
|
||||
}
|
||||
if (iter.data_type == CD_PROP_STRING) {
|
||||
if (iter.data_type == bke::AttrType::String) {
|
||||
return;
|
||||
}
|
||||
if (attribute_filter_with_skip.allow_skip(iter.name)) {
|
||||
|
|
|
|||
|
|
@ -88,8 +88,8 @@ static void mix_attributes(bke::MutableAttributeAccessor attributes_a,
|
|||
if (domain != mix_domain) {
|
||||
continue;
|
||||
}
|
||||
const eCustomDataType type = bke::cpp_type_to_custom_data_type(attribute_a.varray.type());
|
||||
if (ELEM(type, CD_PROP_STRING, CD_PROP_BOOL)) {
|
||||
const bke::AttrType type = bke::cpp_type_to_attribute_type(attribute_a.varray.type());
|
||||
if (ELEM(type, bke::AttrType::String, bke::AttrType::Bool)) {
|
||||
/* String attributes can't be mixed, and there's no point in mixing boolean attributes. */
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -226,7 +226,8 @@ static bke::AttrDomain normal_domain_to_domain(bke::MeshNormalDomain domain)
|
|||
return bke::AttrDomain::Point;
|
||||
}
|
||||
|
||||
constexpr bke::AttributeMetaData CORNER_FAN_META_DATA{bke::AttrDomain::Corner, CD_PROP_INT16_2D};
|
||||
constexpr bke::AttributeMetaData CORNER_FAN_META_DATA{bke::AttrDomain::Corner,
|
||||
bke::AttrType::Int16_2D};
|
||||
|
||||
/** Tracks the storage format for the resulting mesh based on the combination of input meshes. */
|
||||
struct MeshNormalInfo {
|
||||
|
|
@ -273,7 +274,7 @@ struct MeshNormalInfo {
|
|||
this->add_no_custom_normals(mesh.normals_domain());
|
||||
return;
|
||||
}
|
||||
if (custom_normal->data_type == CD_PROP_FLOAT3) {
|
||||
if (custom_normal->data_type == bke::AttrType::Float3) {
|
||||
if (custom_normal->domain == bke::AttrDomain::Edge) {
|
||||
/* Skip invalid storage on the edge domain. */
|
||||
this->add_no_custom_normals(mesh.normals_domain());
|
||||
|
|
@ -595,10 +596,10 @@ static Vector<std::pair<int, GSpan>> prepare_attribute_fallbacks(
|
|||
return;
|
||||
}
|
||||
GSpan span = attribute.varray.get_internal_span();
|
||||
const eCustomDataType expected_type = ordered_attributes.kinds[attribute_index].data_type;
|
||||
const bke::AttrType expected_type = ordered_attributes.kinds[attribute_index].data_type;
|
||||
if (iter.data_type != expected_type) {
|
||||
const CPPType &from_type = span.type();
|
||||
const CPPType &to_type = *bke::custom_data_type_to_cpp_type(expected_type);
|
||||
const CPPType &to_type = bke::attribute_type_to_cpp_type(expected_type);
|
||||
const bke::DataTypeConversions &conversions = bke::get_implicit_type_conversions();
|
||||
if (!conversions.is_convertible(from_type, to_type)) {
|
||||
/* Ignore the attribute because it can not be converted to the desired type. */
|
||||
|
|
@ -995,7 +996,7 @@ static Map<StringRef, AttributeDomainAndType> gather_attributes_to_propagate(
|
|||
return;
|
||||
}
|
||||
}
|
||||
if (iter.data_type == CD_PROP_STRING) {
|
||||
if (iter.data_type == bke::AttrType::String) {
|
||||
/* Propagating string attributes is not supported yet. */
|
||||
return;
|
||||
}
|
||||
|
|
@ -1081,7 +1082,7 @@ static void execute_instances_tasks(
|
|||
for (const int attribute_index : all_instances_attributes.index_range()) {
|
||||
const bke::AttrDomain domain = bke::AttrDomain::Instance;
|
||||
const StringRef id = all_instances_attributes.ids[attribute_index];
|
||||
const eCustomDataType type = all_instances_attributes.kinds[attribute_index].data_type;
|
||||
const bke::AttrType type = all_instances_attributes.kinds[attribute_index].data_type;
|
||||
dst_instances->attributes_for_write()
|
||||
.lookup_or_add_for_write_only_span(id, domain, type)
|
||||
.finish();
|
||||
|
|
@ -1105,9 +1106,8 @@ static void execute_instances_tasks(
|
|||
const IndexRange dst_range = offsets[component_index];
|
||||
for (const int attribute_index : all_instances_attributes.index_range()) {
|
||||
const StringRef id = all_instances_attributes.ids[attribute_index];
|
||||
const eCustomDataType type = all_instances_attributes.kinds[attribute_index].data_type;
|
||||
const CPPType *cpp_type = bke::custom_data_type_to_cpp_type(type);
|
||||
BLI_assert(cpp_type != nullptr);
|
||||
const bke::AttrType type = all_instances_attributes.kinds[attribute_index].data_type;
|
||||
const CPPType &cpp_type = bke::attribute_type_to_cpp_type(type);
|
||||
bke::GSpanAttributeWriter write_attribute =
|
||||
dst_instances->attributes_for_write().lookup_for_write_span(id);
|
||||
GMutableSpan dst_span = write_attribute.span;
|
||||
|
|
@ -1117,10 +1117,10 @@ static void execute_instances_tasks(
|
|||
attribute_ptr = attribute_fallback_array[attribute_index];
|
||||
}
|
||||
else {
|
||||
attribute_ptr = cpp_type->default_value();
|
||||
attribute_ptr = cpp_type.default_value();
|
||||
}
|
||||
|
||||
cpp_type->fill_assign_n(attribute_ptr, dst_span.slice(dst_range).data(), dst_range.size());
|
||||
cpp_type.fill_assign_n(attribute_ptr, dst_span.slice(dst_range).data(), dst_range.size());
|
||||
write_attribute.finish();
|
||||
}
|
||||
|
||||
|
|
@ -1210,7 +1210,7 @@ static AllPointCloudsInfo preprocess_pointclouds(const bke::GeometrySet &geometr
|
|||
pointcloud_info.attributes.reinitialize(info.attributes.size());
|
||||
for (const int attribute_index : info.attributes.index_range()) {
|
||||
const StringRef attribute_id = info.attributes.ids[attribute_index];
|
||||
const eCustomDataType data_type = info.attributes.kinds[attribute_index].data_type;
|
||||
const bke::AttrType data_type = info.attributes.kinds[attribute_index].data_type;
|
||||
const bke::AttrDomain domain = info.attributes.kinds[attribute_index].domain;
|
||||
if (attributes.contains(attribute_id)) {
|
||||
GVArray attribute = *attributes.lookup_or_default(attribute_id, domain, data_type);
|
||||
|
|
@ -1282,8 +1282,8 @@ static void add_instance_attributes_to_single_geometry(
|
|||
continue;
|
||||
}
|
||||
const bke::AttrDomain domain = ordered_attributes.kinds[attribute_index].domain;
|
||||
const eCustomDataType data_type = ordered_attributes.kinds[attribute_index].data_type;
|
||||
const CPPType &cpp_type = *bke::custom_data_type_to_cpp_type(data_type);
|
||||
const bke::AttrType data_type = ordered_attributes.kinds[attribute_index].data_type;
|
||||
const CPPType &cpp_type = bke::attribute_type_to_cpp_type(data_type);
|
||||
GVArray gvaray(GVArray::ForSingle(cpp_type, attributes.domain_size(domain), value));
|
||||
attributes.add(ordered_attributes.ids[attribute_index],
|
||||
domain,
|
||||
|
|
@ -1347,7 +1347,7 @@ static void execute_realize_pointcloud_tasks(const RealizeInstancesOptions &opti
|
|||
Vector<GSpanAttributeWriter> dst_attribute_writers;
|
||||
for (const int attribute_index : ordered_attributes.index_range()) {
|
||||
const StringRef attribute_id = ordered_attributes.ids[attribute_index];
|
||||
const eCustomDataType data_type = ordered_attributes.kinds[attribute_index].data_type;
|
||||
const bke::AttrType data_type = ordered_attributes.kinds[attribute_index].data_type;
|
||||
dst_attribute_writers.append(dst_attributes.lookup_or_add_for_write_only_span(
|
||||
attribute_id, bke::AttrDomain::Point, data_type));
|
||||
}
|
||||
|
|
@ -1480,7 +1480,7 @@ static AllMeshesInfo preprocess_meshes(const bke::GeometrySet &geometry_set,
|
|||
mesh_info.attributes.reinitialize(info.attributes.size());
|
||||
for (const int attribute_index : info.attributes.index_range()) {
|
||||
const StringRef attribute_id = info.attributes.ids[attribute_index];
|
||||
const eCustomDataType data_type = info.attributes.kinds[attribute_index].data_type;
|
||||
const bke::AttrType data_type = info.attributes.kinds[attribute_index].data_type;
|
||||
const bke::AttrDomain domain = info.attributes.kinds[attribute_index].domain;
|
||||
if (attributes.contains(attribute_id)) {
|
||||
GVArray attribute = *attributes.lookup_or_default(attribute_id, domain, data_type);
|
||||
|
|
@ -1693,7 +1693,7 @@ static void copy_vertex_group_names(Mesh &dst_mesh,
|
|||
continue;
|
||||
}
|
||||
const bke::AttributeDomainAndType kind = ordered_attributes.kinds[attribute_index];
|
||||
if (kind.domain != bke::AttrDomain::Point || kind.data_type != CD_PROP_FLOAT) {
|
||||
if (kind.domain != bke::AttrDomain::Point || kind.data_type != bke::AttrType::Float) {
|
||||
/* Prefer using the highest priority domain and type from all input meshes. */
|
||||
continue;
|
||||
}
|
||||
|
|
@ -1783,13 +1783,13 @@ static void execute_realize_mesh_tasks(const RealizeInstancesOptions &options,
|
|||
}
|
||||
case MeshNormalInfo::Output::CornerFan: {
|
||||
custom_normals = dst_attributes.lookup_or_add_for_write_only_span(
|
||||
"custom_normal", bke::AttrDomain::Corner, CD_PROP_INT16_2D);
|
||||
"custom_normal", bke::AttrDomain::Corner, bke::AttrType::Int16_2D);
|
||||
break;
|
||||
}
|
||||
case MeshNormalInfo::Output::Free: {
|
||||
const bke::AttrDomain domain = *all_meshes_info.custom_normal_info.result_domain;
|
||||
custom_normals = dst_attributes.lookup_or_add_for_write_only_span(
|
||||
"custom_normal", domain, CD_PROP_FLOAT3);
|
||||
"custom_normal", domain, bke::AttrType::Float3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1799,7 +1799,7 @@ static void execute_realize_mesh_tasks(const RealizeInstancesOptions &options,
|
|||
for (const int attribute_index : ordered_attributes.index_range()) {
|
||||
const StringRef attribute_id = ordered_attributes.ids[attribute_index];
|
||||
const bke::AttrDomain domain = ordered_attributes.kinds[attribute_index].domain;
|
||||
const eCustomDataType data_type = ordered_attributes.kinds[attribute_index].data_type;
|
||||
const bke::AttrType data_type = ordered_attributes.kinds[attribute_index].data_type;
|
||||
dst_attribute_writers.append(
|
||||
dst_attributes.lookup_or_add_for_write_only_span(attribute_id, domain, data_type));
|
||||
}
|
||||
|
|
@ -1922,7 +1922,7 @@ static AllCurvesInfo preprocess_curves(const bke::GeometrySet &geometry_set,
|
|||
for (const int attribute_index : info.attributes.index_range()) {
|
||||
const bke::AttrDomain domain = info.attributes.kinds[attribute_index].domain;
|
||||
const StringRef attribute_id = info.attributes.ids[attribute_index];
|
||||
const eCustomDataType data_type = info.attributes.kinds[attribute_index].data_type;
|
||||
const bke::AttrType data_type = info.attributes.kinds[attribute_index].data_type;
|
||||
if (attributes.contains(attribute_id)) {
|
||||
GVArray attribute = *attributes.lookup_or_default(attribute_id, domain, data_type);
|
||||
curve_info.attributes[attribute_index].emplace(std::move(attribute));
|
||||
|
|
@ -2127,7 +2127,7 @@ static void execute_realize_curve_tasks(const RealizeInstancesOptions &options,
|
|||
for (const int attribute_index : ordered_attributes.index_range()) {
|
||||
const StringRef attribute_id = ordered_attributes.ids[attribute_index];
|
||||
const bke::AttrDomain domain = ordered_attributes.kinds[attribute_index].domain;
|
||||
const eCustomDataType data_type = ordered_attributes.kinds[attribute_index].data_type;
|
||||
const bke::AttrType data_type = ordered_attributes.kinds[attribute_index].data_type;
|
||||
dst_attribute_writers.append(
|
||||
dst_attributes.lookup_or_add_for_write_only_span(attribute_id, domain, data_type));
|
||||
}
|
||||
|
|
@ -2247,7 +2247,7 @@ static AllGreasePencilsInfo preprocess_grease_pencils(
|
|||
grease_pencil_info.attributes.reinitialize(info.attributes.size());
|
||||
for (const int attribute_index : info.attributes.index_range()) {
|
||||
const StringRef attribute_id = info.attributes.ids[attribute_index];
|
||||
const eCustomDataType data_type = info.attributes.kinds[attribute_index].data_type;
|
||||
const bke::AttrType data_type = info.attributes.kinds[attribute_index].data_type;
|
||||
const bke::AttrDomain domain = info.attributes.kinds[attribute_index].domain;
|
||||
if (attributes.contains(attribute_id)) {
|
||||
GVArray attribute = *attributes.lookup_or_default(attribute_id, domain, data_type);
|
||||
|
|
@ -2378,7 +2378,7 @@ static void execute_realize_grease_pencil_tasks(
|
|||
Vector<GSpanAttributeWriter> dst_attribute_writers;
|
||||
for (const int attribute_index : ordered_attributes.index_range()) {
|
||||
const StringRef attribute_id = ordered_attributes.ids[attribute_index];
|
||||
const eCustomDataType data_type = ordered_attributes.kinds[attribute_index].data_type;
|
||||
const bke::AttrType data_type = ordered_attributes.kinds[attribute_index].data_type;
|
||||
dst_attribute_writers.append(dst_attributes.lookup_or_add_for_write_only_span(
|
||||
attribute_id, bke::AttrDomain::Layer, data_type));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ static void reorder_attributes_group_to_group(const bke::AttributeAccessor src_a
|
|||
if (iter.domain != domain) {
|
||||
return;
|
||||
}
|
||||
if (iter.data_type == CD_PROP_STRING) {
|
||||
if (iter.data_type == bke::AttrType::String) {
|
||||
return;
|
||||
}
|
||||
if (attribute_filter.allow_skip(iter.name)) {
|
||||
|
|
|
|||
|
|
@ -112,8 +112,7 @@ static void retrieve_attribute_spans(const Span<StringRef> ids,
|
|||
bke::AttrDomain::Point);
|
||||
src.append(src_attribute.varray);
|
||||
|
||||
const eCustomDataType data_type = bke::cpp_type_to_custom_data_type(
|
||||
src_attribute.varray.type());
|
||||
const bke::AttrType data_type = bke::cpp_type_to_attribute_type(src_attribute.varray.type());
|
||||
bke::GSpanAttributeWriter dst_attribute =
|
||||
dst_curves.attributes_for_write().lookup_or_add_for_write_only_span(
|
||||
ids[i], bke::AttrDomain::Point, data_type);
|
||||
|
|
@ -152,7 +151,7 @@ static void gather_point_attributes_to_interpolate(
|
|||
if (iter.domain != bke::AttrDomain::Point) {
|
||||
return;
|
||||
}
|
||||
if (iter.data_type == CD_PROP_STRING) {
|
||||
if (iter.data_type == bke::AttrType::String) {
|
||||
return;
|
||||
}
|
||||
if (!interpolate_attribute_to_curves(iter.name, dst_curves.curve_type_counts())) {
|
||||
|
|
@ -186,14 +185,14 @@ static void gather_point_attributes_to_interpolate(
|
|||
if (output_ids.tangent_id) {
|
||||
result.src_evaluated_tangents = src_curves.evaluated_tangents();
|
||||
bke::GSpanAttributeWriter dst_attribute = dst_attributes.lookup_or_add_for_write_only_span(
|
||||
*output_ids.tangent_id, bke::AttrDomain::Point, CD_PROP_FLOAT3);
|
||||
*output_ids.tangent_id, bke::AttrDomain::Point, bke::AttrType::Float3);
|
||||
result.dst_tangents = dst_attribute.span.typed<float3>();
|
||||
result.dst_attributes.append(std::move(dst_attribute));
|
||||
}
|
||||
if (output_ids.normal_id) {
|
||||
result.src_evaluated_normals = src_curves.evaluated_normals();
|
||||
bke::GSpanAttributeWriter dst_attribute = dst_attributes.lookup_or_add_for_write_only_span(
|
||||
*output_ids.normal_id, bke::AttrDomain::Point, CD_PROP_FLOAT3);
|
||||
*output_ids.normal_id, bke::AttrDomain::Point, bke::AttrType::Float3);
|
||||
result.dst_normals = dst_attribute.span.typed<float3>();
|
||||
result.dst_attributes.append(std::move(dst_attribute));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -347,7 +347,7 @@ PointCloud *import_csv_as_pointcloud(const CSVImportParams &import_params)
|
|||
continue;
|
||||
}
|
||||
const auto *data = new ImplicitSharedValue<GArray<>>(std::move(*attribute));
|
||||
const eCustomDataType type = bke::cpp_type_to_custom_data_type(attribute->type());
|
||||
const bke::AttrType type = bke::cpp_type_to_attribute_type(attribute->type());
|
||||
const ColumnInfo &column_info = columns_info[column_i];
|
||||
attributes.add(column_info.name,
|
||||
bke::AttrDomain::Point,
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ static void load_custom_attributes(const Mesh *mesh,
|
|||
return;
|
||||
}
|
||||
switch (iter.data_type) {
|
||||
case CD_PROP_FLOAT: {
|
||||
case bke::AttrType::Float: {
|
||||
float *attr = find_or_add_attribute(iter.name, size, vertex_offset, r_attributes);
|
||||
auto typed = attribute.typed<float>();
|
||||
for (const int64_t i : ply_to_vertex.index_range()) {
|
||||
|
|
@ -202,7 +202,7 @@ static void load_custom_attributes(const Mesh *mesh,
|
|||
}
|
||||
break;
|
||||
}
|
||||
case CD_PROP_INT8: {
|
||||
case bke::AttrType::Int8: {
|
||||
float *attr = find_or_add_attribute(iter.name, size, vertex_offset, r_attributes);
|
||||
auto typed = attribute.typed<int8_t>();
|
||||
for (const int64_t i : ply_to_vertex.index_range()) {
|
||||
|
|
@ -210,7 +210,7 @@ static void load_custom_attributes(const Mesh *mesh,
|
|||
}
|
||||
break;
|
||||
}
|
||||
case CD_PROP_INT32: {
|
||||
case bke::AttrType::Int32: {
|
||||
float *attr = find_or_add_attribute(iter.name, size, vertex_offset, r_attributes);
|
||||
auto typed = attribute.typed<int32_t>();
|
||||
for (const int64_t i : ply_to_vertex.index_range()) {
|
||||
|
|
@ -218,7 +218,7 @@ static void load_custom_attributes(const Mesh *mesh,
|
|||
}
|
||||
break;
|
||||
}
|
||||
case CD_PROP_INT16_2D: {
|
||||
case bke::AttrType::Int16_2D: {
|
||||
float *attr_x = find_or_add_attribute(iter.name + "_x", size, vertex_offset, r_attributes);
|
||||
float *attr_y = find_or_add_attribute(iter.name + "_y", size, vertex_offset, r_attributes);
|
||||
auto typed = attribute.typed<short2>();
|
||||
|
|
@ -229,7 +229,7 @@ static void load_custom_attributes(const Mesh *mesh,
|
|||
}
|
||||
break;
|
||||
}
|
||||
case CD_PROP_INT32_2D: {
|
||||
case bke::AttrType::Int32_2D: {
|
||||
float *attr_x = find_or_add_attribute(iter.name + "_x", size, vertex_offset, r_attributes);
|
||||
float *attr_y = find_or_add_attribute(iter.name + "_y", size, vertex_offset, r_attributes);
|
||||
auto typed = attribute.typed<int2>();
|
||||
|
|
@ -240,7 +240,7 @@ static void load_custom_attributes(const Mesh *mesh,
|
|||
}
|
||||
break;
|
||||
}
|
||||
case CD_PROP_FLOAT2: {
|
||||
case bke::AttrType::Float2: {
|
||||
float *attr_x = find_or_add_attribute(iter.name + "_x", size, vertex_offset, r_attributes);
|
||||
float *attr_y = find_or_add_attribute(iter.name + "_y", size, vertex_offset, r_attributes);
|
||||
auto typed = attribute.typed<float2>();
|
||||
|
|
@ -251,7 +251,7 @@ static void load_custom_attributes(const Mesh *mesh,
|
|||
}
|
||||
break;
|
||||
}
|
||||
case CD_PROP_FLOAT3: {
|
||||
case bke::AttrType::Float3: {
|
||||
float *attr_x = find_or_add_attribute(iter.name + "_x", size, vertex_offset, r_attributes);
|
||||
float *attr_y = find_or_add_attribute(iter.name + "_y", size, vertex_offset, r_attributes);
|
||||
float *attr_z = find_or_add_attribute(iter.name + "_z", size, vertex_offset, r_attributes);
|
||||
|
|
@ -264,7 +264,7 @@ static void load_custom_attributes(const Mesh *mesh,
|
|||
}
|
||||
break;
|
||||
}
|
||||
case CD_PROP_BYTE_COLOR: {
|
||||
case bke::AttrType::ColorByte: {
|
||||
float *attr_r = find_or_add_attribute(iter.name + "_r", size, vertex_offset, r_attributes);
|
||||
float *attr_g = find_or_add_attribute(iter.name + "_g", size, vertex_offset, r_attributes);
|
||||
float *attr_b = find_or_add_attribute(iter.name + "_b", size, vertex_offset, r_attributes);
|
||||
|
|
@ -279,7 +279,7 @@ static void load_custom_attributes(const Mesh *mesh,
|
|||
}
|
||||
break;
|
||||
}
|
||||
case CD_PROP_COLOR: {
|
||||
case bke::AttrType::ColorFloat: {
|
||||
float *attr_r = find_or_add_attribute(iter.name + "_r", size, vertex_offset, r_attributes);
|
||||
float *attr_g = find_or_add_attribute(iter.name + "_g", size, vertex_offset, r_attributes);
|
||||
float *attr_b = find_or_add_attribute(iter.name + "_b", size, vertex_offset, r_attributes);
|
||||
|
|
@ -294,7 +294,7 @@ static void load_custom_attributes(const Mesh *mesh,
|
|||
}
|
||||
break;
|
||||
}
|
||||
case CD_PROP_BOOL: {
|
||||
case bke::AttrType::Bool: {
|
||||
float *attr = find_or_add_attribute(iter.name, size, vertex_offset, r_attributes);
|
||||
auto typed = attribute.typed<bool>();
|
||||
for (const int64_t i : ply_to_vertex.index_range()) {
|
||||
|
|
@ -302,7 +302,7 @@ static void load_custom_attributes(const Mesh *mesh,
|
|||
}
|
||||
break;
|
||||
}
|
||||
case CD_PROP_QUATERNION: {
|
||||
case bke::AttrType::Quaternion: {
|
||||
float *attr_x = find_or_add_attribute(iter.name + "_x", size, vertex_offset, r_attributes);
|
||||
float *attr_y = find_or_add_attribute(iter.name + "_y", size, vertex_offset, r_attributes);
|
||||
float *attr_z = find_or_add_attribute(iter.name + "_z", size, vertex_offset, r_attributes);
|
||||
|
|
|
|||
|
|
@ -19,74 +19,74 @@
|
|||
|
||||
namespace blender::io::usd {
|
||||
|
||||
std::optional<pxr::SdfValueTypeName> convert_blender_type_to_usd(
|
||||
const eCustomDataType blender_type, bool use_color3f_type)
|
||||
std::optional<pxr::SdfValueTypeName> convert_blender_type_to_usd(const bke::AttrType blender_type,
|
||||
bool use_color3f_type)
|
||||
{
|
||||
switch (blender_type) {
|
||||
case CD_PROP_FLOAT:
|
||||
case bke::AttrType::Float:
|
||||
return pxr::SdfValueTypeNames->FloatArray;
|
||||
case CD_PROP_INT8:
|
||||
case bke::AttrType::Int8:
|
||||
return pxr::SdfValueTypeNames->UCharArray;
|
||||
case CD_PROP_INT32:
|
||||
case bke::AttrType::Int32:
|
||||
return pxr::SdfValueTypeNames->IntArray;
|
||||
case CD_PROP_FLOAT2:
|
||||
case bke::AttrType::Float2:
|
||||
return pxr::SdfValueTypeNames->Float2Array;
|
||||
case CD_PROP_FLOAT3:
|
||||
case bke::AttrType::Float3:
|
||||
return pxr::SdfValueTypeNames->Float3Array;
|
||||
case CD_PROP_STRING:
|
||||
case bke::AttrType::String:
|
||||
return pxr::SdfValueTypeNames->StringArray;
|
||||
case CD_PROP_BOOL:
|
||||
case bke::AttrType::Bool:
|
||||
return pxr::SdfValueTypeNames->BoolArray;
|
||||
case CD_PROP_COLOR:
|
||||
case CD_PROP_BYTE_COLOR:
|
||||
case bke::AttrType::ColorFloat:
|
||||
case bke::AttrType::ColorByte:
|
||||
return use_color3f_type ? pxr::SdfValueTypeNames->Color3fArray :
|
||||
pxr::SdfValueTypeNames->Color4fArray;
|
||||
case CD_PROP_QUATERNION:
|
||||
case bke::AttrType::Quaternion:
|
||||
return pxr::SdfValueTypeNames->QuatfArray;
|
||||
default:
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<eCustomDataType> convert_usd_type_to_blender(const pxr::SdfValueTypeName usd_type)
|
||||
std::optional<bke::AttrType> convert_usd_type_to_blender(const pxr::SdfValueTypeName usd_type)
|
||||
{
|
||||
static const Map<pxr::SdfValueTypeName, eCustomDataType> type_map = []() {
|
||||
Map<pxr::SdfValueTypeName, eCustomDataType> map;
|
||||
map.add_new(pxr::SdfValueTypeNames->FloatArray, CD_PROP_FLOAT);
|
||||
map.add_new(pxr::SdfValueTypeNames->Double, CD_PROP_FLOAT);
|
||||
map.add_new(pxr::SdfValueTypeNames->UCharArray, CD_PROP_INT8);
|
||||
map.add_new(pxr::SdfValueTypeNames->IntArray, CD_PROP_INT32);
|
||||
map.add_new(pxr::SdfValueTypeNames->Float2Array, CD_PROP_FLOAT2);
|
||||
map.add_new(pxr::SdfValueTypeNames->TexCoord2dArray, CD_PROP_FLOAT2);
|
||||
map.add_new(pxr::SdfValueTypeNames->TexCoord2fArray, CD_PROP_FLOAT2);
|
||||
map.add_new(pxr::SdfValueTypeNames->TexCoord2hArray, CD_PROP_FLOAT2);
|
||||
map.add_new(pxr::SdfValueTypeNames->TexCoord3dArray, CD_PROP_FLOAT2);
|
||||
map.add_new(pxr::SdfValueTypeNames->TexCoord3fArray, CD_PROP_FLOAT2);
|
||||
map.add_new(pxr::SdfValueTypeNames->TexCoord3hArray, CD_PROP_FLOAT2);
|
||||
map.add_new(pxr::SdfValueTypeNames->Float3Array, CD_PROP_FLOAT3);
|
||||
map.add_new(pxr::SdfValueTypeNames->Point3fArray, CD_PROP_FLOAT3);
|
||||
map.add_new(pxr::SdfValueTypeNames->Point3dArray, CD_PROP_FLOAT3);
|
||||
map.add_new(pxr::SdfValueTypeNames->Point3hArray, CD_PROP_FLOAT3);
|
||||
map.add_new(pxr::SdfValueTypeNames->Normal3fArray, CD_PROP_FLOAT3);
|
||||
map.add_new(pxr::SdfValueTypeNames->Normal3dArray, CD_PROP_FLOAT3);
|
||||
map.add_new(pxr::SdfValueTypeNames->Normal3hArray, CD_PROP_FLOAT3);
|
||||
map.add_new(pxr::SdfValueTypeNames->Vector3fArray, CD_PROP_FLOAT3);
|
||||
map.add_new(pxr::SdfValueTypeNames->Vector3hArray, CD_PROP_FLOAT3);
|
||||
map.add_new(pxr::SdfValueTypeNames->Vector3dArray, CD_PROP_FLOAT3);
|
||||
map.add_new(pxr::SdfValueTypeNames->Color3fArray, CD_PROP_COLOR);
|
||||
map.add_new(pxr::SdfValueTypeNames->Color3hArray, CD_PROP_COLOR);
|
||||
map.add_new(pxr::SdfValueTypeNames->Color3dArray, CD_PROP_COLOR);
|
||||
map.add_new(pxr::SdfValueTypeNames->Color4fArray, CD_PROP_COLOR);
|
||||
map.add_new(pxr::SdfValueTypeNames->Color4hArray, CD_PROP_COLOR);
|
||||
map.add_new(pxr::SdfValueTypeNames->Color4dArray, CD_PROP_COLOR);
|
||||
map.add_new(pxr::SdfValueTypeNames->BoolArray, CD_PROP_BOOL);
|
||||
map.add_new(pxr::SdfValueTypeNames->QuatfArray, CD_PROP_QUATERNION);
|
||||
map.add_new(pxr::SdfValueTypeNames->QuatdArray, CD_PROP_QUATERNION);
|
||||
map.add_new(pxr::SdfValueTypeNames->QuathArray, CD_PROP_QUATERNION);
|
||||
static const Map<pxr::SdfValueTypeName, bke::AttrType> type_map = []() {
|
||||
Map<pxr::SdfValueTypeName, bke::AttrType> map;
|
||||
map.add_new(pxr::SdfValueTypeNames->FloatArray, bke::AttrType::Float);
|
||||
map.add_new(pxr::SdfValueTypeNames->Double, bke::AttrType::Float);
|
||||
map.add_new(pxr::SdfValueTypeNames->UCharArray, bke::AttrType::Int8);
|
||||
map.add_new(pxr::SdfValueTypeNames->IntArray, bke::AttrType::Int32);
|
||||
map.add_new(pxr::SdfValueTypeNames->Float2Array, bke::AttrType::Float2);
|
||||
map.add_new(pxr::SdfValueTypeNames->TexCoord2dArray, bke::AttrType::Float2);
|
||||
map.add_new(pxr::SdfValueTypeNames->TexCoord2fArray, bke::AttrType::Float2);
|
||||
map.add_new(pxr::SdfValueTypeNames->TexCoord2hArray, bke::AttrType::Float2);
|
||||
map.add_new(pxr::SdfValueTypeNames->TexCoord3dArray, bke::AttrType::Float2);
|
||||
map.add_new(pxr::SdfValueTypeNames->TexCoord3fArray, bke::AttrType::Float2);
|
||||
map.add_new(pxr::SdfValueTypeNames->TexCoord3hArray, bke::AttrType::Float2);
|
||||
map.add_new(pxr::SdfValueTypeNames->Float3Array, bke::AttrType::Float3);
|
||||
map.add_new(pxr::SdfValueTypeNames->Point3fArray, bke::AttrType::Float3);
|
||||
map.add_new(pxr::SdfValueTypeNames->Point3dArray, bke::AttrType::Float3);
|
||||
map.add_new(pxr::SdfValueTypeNames->Point3hArray, bke::AttrType::Float3);
|
||||
map.add_new(pxr::SdfValueTypeNames->Normal3fArray, bke::AttrType::Float3);
|
||||
map.add_new(pxr::SdfValueTypeNames->Normal3dArray, bke::AttrType::Float3);
|
||||
map.add_new(pxr::SdfValueTypeNames->Normal3hArray, bke::AttrType::Float3);
|
||||
map.add_new(pxr::SdfValueTypeNames->Vector3fArray, bke::AttrType::Float3);
|
||||
map.add_new(pxr::SdfValueTypeNames->Vector3hArray, bke::AttrType::Float3);
|
||||
map.add_new(pxr::SdfValueTypeNames->Vector3dArray, bke::AttrType::Float3);
|
||||
map.add_new(pxr::SdfValueTypeNames->Color3fArray, bke::AttrType::ColorFloat);
|
||||
map.add_new(pxr::SdfValueTypeNames->Color3hArray, bke::AttrType::ColorFloat);
|
||||
map.add_new(pxr::SdfValueTypeNames->Color3dArray, bke::AttrType::ColorFloat);
|
||||
map.add_new(pxr::SdfValueTypeNames->Color4fArray, bke::AttrType::ColorFloat);
|
||||
map.add_new(pxr::SdfValueTypeNames->Color4hArray, bke::AttrType::ColorFloat);
|
||||
map.add_new(pxr::SdfValueTypeNames->Color4dArray, bke::AttrType::ColorFloat);
|
||||
map.add_new(pxr::SdfValueTypeNames->BoolArray, bke::AttrType::Bool);
|
||||
map.add_new(pxr::SdfValueTypeNames->QuatfArray, bke::AttrType::Quaternion);
|
||||
map.add_new(pxr::SdfValueTypeNames->QuatdArray, bke::AttrType::Quaternion);
|
||||
map.add_new(pxr::SdfValueTypeNames->QuathArray, bke::AttrType::Quaternion);
|
||||
return map;
|
||||
}();
|
||||
|
||||
const eCustomDataType *value = type_map.lookup_ptr(usd_type);
|
||||
const bke::AttrType *value = type_map.lookup_ptr(usd_type);
|
||||
if (value == nullptr) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
|
@ -96,7 +96,7 @@ std::optional<eCustomDataType> convert_usd_type_to_blender(const pxr::SdfValueTy
|
|||
|
||||
void copy_primvar_to_blender_attribute(const pxr::UsdGeomPrimvar &primvar,
|
||||
const pxr::UsdTimeCode timecode,
|
||||
const eCustomDataType data_type,
|
||||
const bke::AttrType data_type,
|
||||
const bke::AttrDomain domain,
|
||||
const OffsetIndices<int> face_indices,
|
||||
bke::MutableAttributeAccessor attributes)
|
||||
|
|
@ -107,27 +107,27 @@ void copy_primvar_to_blender_attribute(const pxr::UsdGeomPrimvar &primvar,
|
|||
pv_name.GetText(), domain, data_type);
|
||||
|
||||
switch (data_type) {
|
||||
case CD_PROP_FLOAT:
|
||||
case bke::AttrType::Float:
|
||||
copy_primvar_to_blender_buffer<float>(
|
||||
primvar, timecode, face_indices, attribute.span.typed<float>());
|
||||
break;
|
||||
case CD_PROP_INT8:
|
||||
case bke::AttrType::Int8:
|
||||
copy_primvar_to_blender_buffer<uchar>(
|
||||
primvar, timecode, face_indices, attribute.span.typed<int8_t>());
|
||||
break;
|
||||
case CD_PROP_INT32:
|
||||
case bke::AttrType::Int32:
|
||||
copy_primvar_to_blender_buffer<int32_t>(
|
||||
primvar, timecode, face_indices, attribute.span.typed<int>());
|
||||
break;
|
||||
case CD_PROP_FLOAT2:
|
||||
case bke::AttrType::Float2:
|
||||
copy_primvar_to_blender_buffer<pxr::GfVec2f>(
|
||||
primvar, timecode, face_indices, attribute.span.typed<float2>());
|
||||
break;
|
||||
case CD_PROP_FLOAT3:
|
||||
case bke::AttrType::Float3:
|
||||
copy_primvar_to_blender_buffer<pxr::GfVec3f>(
|
||||
primvar, timecode, face_indices, attribute.span.typed<float3>());
|
||||
break;
|
||||
case CD_PROP_COLOR: {
|
||||
case bke::AttrType::ColorFloat: {
|
||||
const pxr::SdfValueTypeName pv_type = primvar.GetTypeName();
|
||||
if (ELEM(pv_type,
|
||||
pxr::SdfValueTypeNames->Color3fArray,
|
||||
|
|
@ -142,11 +142,11 @@ void copy_primvar_to_blender_attribute(const pxr::UsdGeomPrimvar &primvar,
|
|||
primvar, timecode, face_indices, attribute.span.typed<ColorGeometry4f>());
|
||||
}
|
||||
} break;
|
||||
case CD_PROP_BOOL:
|
||||
case bke::AttrType::Bool:
|
||||
copy_primvar_to_blender_buffer<bool>(
|
||||
primvar, timecode, face_indices, attribute.span.typed<bool>());
|
||||
break;
|
||||
case CD_PROP_QUATERNION:
|
||||
case bke::AttrType::Quaternion:
|
||||
copy_primvar_to_blender_buffer<pxr::GfQuatf>(
|
||||
primvar, timecode, face_indices, attribute.span.typed<math::Quaternion>());
|
||||
break;
|
||||
|
|
@ -159,37 +159,37 @@ void copy_primvar_to_blender_attribute(const pxr::UsdGeomPrimvar &primvar,
|
|||
}
|
||||
|
||||
void copy_blender_attribute_to_primvar(const GVArray &attribute,
|
||||
const eCustomDataType data_type,
|
||||
const bke::AttrType data_type,
|
||||
const pxr::UsdTimeCode timecode,
|
||||
const pxr::UsdGeomPrimvar &primvar,
|
||||
pxr::UsdUtilsSparseValueWriter &value_writer)
|
||||
{
|
||||
switch (data_type) {
|
||||
case CD_PROP_FLOAT:
|
||||
case bke::AttrType::Float:
|
||||
copy_blender_buffer_to_primvar<float, float>(
|
||||
attribute.typed<float>(), timecode, primvar, value_writer);
|
||||
break;
|
||||
case CD_PROP_INT8:
|
||||
case bke::AttrType::Int8:
|
||||
copy_blender_buffer_to_primvar<int8_t, uchar>(
|
||||
attribute.typed<int8_t>(), timecode, primvar, value_writer);
|
||||
break;
|
||||
case CD_PROP_INT32:
|
||||
case bke::AttrType::Int32:
|
||||
copy_blender_buffer_to_primvar<int, int32_t>(
|
||||
attribute.typed<int>(), timecode, primvar, value_writer);
|
||||
break;
|
||||
case CD_PROP_FLOAT2:
|
||||
case bke::AttrType::Float2:
|
||||
copy_blender_buffer_to_primvar<float2, pxr::GfVec2f>(
|
||||
attribute.typed<float2>(), timecode, primvar, value_writer);
|
||||
break;
|
||||
case CD_PROP_FLOAT3:
|
||||
case bke::AttrType::Float3:
|
||||
copy_blender_buffer_to_primvar<float3, pxr::GfVec3f>(
|
||||
attribute.typed<float3>(), timecode, primvar, value_writer);
|
||||
break;
|
||||
case CD_PROP_BOOL:
|
||||
case bke::AttrType::Bool:
|
||||
copy_blender_buffer_to_primvar<bool, bool>(
|
||||
attribute.typed<bool>(), timecode, primvar, value_writer);
|
||||
break;
|
||||
case CD_PROP_COLOR:
|
||||
case bke::AttrType::ColorFloat:
|
||||
if (primvar.GetTypeName() == pxr::SdfValueTypeNames->Color3fArray) {
|
||||
copy_blender_buffer_to_primvar<ColorGeometry4f, pxr::GfVec3f>(
|
||||
attribute.typed<ColorGeometry4f>(), timecode, primvar, value_writer);
|
||||
|
|
@ -199,7 +199,7 @@ void copy_blender_attribute_to_primvar(const GVArray &attribute,
|
|||
attribute.typed<ColorGeometry4f>(), timecode, primvar, value_writer);
|
||||
}
|
||||
break;
|
||||
case CD_PROP_BYTE_COLOR:
|
||||
case bke::AttrType::ColorByte:
|
||||
if (primvar.GetTypeName() == pxr::SdfValueTypeNames->Color3fArray) {
|
||||
copy_blender_buffer_to_primvar<ColorGeometry4b, pxr::GfVec3f>(
|
||||
attribute.typed<ColorGeometry4b>(), timecode, primvar, value_writer);
|
||||
|
|
@ -209,7 +209,7 @@ void copy_blender_attribute_to_primvar(const GVArray &attribute,
|
|||
attribute.typed<ColorGeometry4b>(), timecode, primvar, value_writer);
|
||||
}
|
||||
break;
|
||||
case CD_PROP_QUATERNION:
|
||||
case bke::AttrType::Quaternion:
|
||||
copy_blender_buffer_to_primvar<math::Quaternion, pxr::GfQuatf>(
|
||||
attribute.typed<math::Quaternion>(), timecode, primvar, value_writer);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -112,10 +112,10 @@ template<class T> struct is_vt_array<pxr::VtArray<T>> : std::true_type {};
|
|||
|
||||
} // namespace detail
|
||||
|
||||
std::optional<pxr::SdfValueTypeName> convert_blender_type_to_usd(
|
||||
const eCustomDataType blender_type, bool use_color3f_type = false);
|
||||
std::optional<pxr::SdfValueTypeName> convert_blender_type_to_usd(const bke::AttrType blender_type,
|
||||
bool use_color3f_type = false);
|
||||
|
||||
std::optional<eCustomDataType> convert_usd_type_to_blender(const pxr::SdfValueTypeName usd_type);
|
||||
std::optional<bke::AttrType> convert_usd_type_to_blender(const pxr::SdfValueTypeName usd_type);
|
||||
|
||||
/**
|
||||
* Set the USD attribute to the provided value at the given time. The value will be written
|
||||
|
|
@ -188,7 +188,7 @@ void copy_blender_buffer_to_primvar(const VArray<BlenderT> &buffer,
|
|||
}
|
||||
|
||||
void copy_blender_attribute_to_primvar(const GVArray &attribute,
|
||||
const eCustomDataType data_type,
|
||||
const bke::AttrType data_type,
|
||||
const pxr::UsdTimeCode timecode,
|
||||
const pxr::UsdGeomPrimvar &primvar,
|
||||
pxr::UsdUtilsSparseValueWriter &value_writer);
|
||||
|
|
@ -269,7 +269,7 @@ void copy_primvar_to_blender_buffer(const pxr::UsdGeomPrimvar &primvar,
|
|||
|
||||
void copy_primvar_to_blender_attribute(const pxr::UsdGeomPrimvar &primvar,
|
||||
const pxr::UsdTimeCode timecode,
|
||||
const eCustomDataType data_type,
|
||||
const bke::AttrType data_type,
|
||||
const bke::AttrDomain domain,
|
||||
const OffsetIndices<int> face_indices,
|
||||
bke::MutableAttributeAccessor attributes);
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ void read_generic_mesh_primvar(Mesh *mesh,
|
|||
const pxr::TfToken pv_name = pxr::UsdGeomPrimvar::StripPrimvarsName(primvar.GetPrimvarName());
|
||||
|
||||
const std::optional<bke::AttrDomain> domain = convert_usd_varying_to_blender(pv_interp);
|
||||
const std::optional<eCustomDataType> type = convert_usd_type_to_blender(pv_type);
|
||||
const std::optional<bke::AttrType> type = convert_usd_type_to_blender(pv_type);
|
||||
|
||||
if (!domain.has_value() || !type.has_value()) {
|
||||
CLOG_WARN(&LOG,
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ void USDCurvesReader::read_custom_data(bke::CurvesGeometry &curves,
|
|||
|
||||
const pxr::TfToken pv_interp = pv.GetInterpolation();
|
||||
const std::optional<bke::AttrDomain> domain = convert_usd_interp_to_blender(pv_interp);
|
||||
const std::optional<eCustomDataType> type = convert_usd_type_to_blender(pv_type);
|
||||
const std::optional<bke::AttrType> type = convert_usd_type_to_blender(pv_type);
|
||||
|
||||
if (!domain.has_value() || !type.has_value()) {
|
||||
const pxr::TfToken pv_name = pxr::UsdGeomPrimvar::StripPrimvarsName(pv.GetPrimvarName());
|
||||
|
|
|
|||
|
|
@ -771,7 +771,7 @@ void USDMeshReader::read_custom_data(const ImportSettings *settings,
|
|||
}
|
||||
|
||||
/* Read Color primvars. */
|
||||
if (convert_usd_type_to_blender(type) == CD_PROP_COLOR) {
|
||||
if (convert_usd_type_to_blender(type) == bke::AttrType::ColorFloat) {
|
||||
if ((settings->read_flag & MOD_MESHSEQ_READ_COLOR) != 0) {
|
||||
/* Set the active color name to 'displayColor', if a color primvar
|
||||
* with this name exists. Otherwise, use the name of the first
|
||||
|
|
@ -789,7 +789,7 @@ void USDMeshReader::read_custom_data(const ImportSettings *settings,
|
|||
pxr::UsdGeomTokens->vertex,
|
||||
pxr::UsdGeomTokens->faceVarying,
|
||||
pxr::UsdGeomTokens->varying) &&
|
||||
convert_usd_type_to_blender(type) == CD_PROP_FLOAT2)
|
||||
convert_usd_type_to_blender(type) == bke::AttrType::Float2)
|
||||
{
|
||||
if ((settings->read_flag & MOD_MESHSEQ_READ_UV) != 0) {
|
||||
/* Set the active uv set name to 'st', if a uv set primvar
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ void USDPointsReader::read_custom_data(PointCloud *pointcloud, const double moti
|
|||
}
|
||||
|
||||
const bke::AttrDomain domain = bke::AttrDomain::Point;
|
||||
const std::optional<eCustomDataType> type = convert_usd_type_to_blender(pv_type);
|
||||
const std::optional<bke::AttrType> type = convert_usd_type_to_blender(pv_type);
|
||||
if (!type.has_value()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -211,8 +211,8 @@ void USDShapeReader::apply_primvars_to_mesh(Mesh *mesh, const double motionSampl
|
|||
continue;
|
||||
}
|
||||
|
||||
const std::optional<eCustomDataType> type = convert_usd_type_to_blender(pv_type);
|
||||
if (type == CD_PROP_COLOR) {
|
||||
const std::optional<bke::AttrType> type = convert_usd_type_to_blender(pv_type);
|
||||
if (type == bke::AttrType::String) {
|
||||
/* Set the active color name to 'displayColor', if a color primvar
|
||||
* with this name exists. Otherwise, use the name of the first
|
||||
* color primvar we find for the active color. */
|
||||
|
|
|
|||
|
|
@ -429,7 +429,7 @@ void USDCurvesWriter::write_generic_data(const bke::CurvesGeometry &curves,
|
|||
"Attribute '%s' (Blender domain %d, type %d) cannot be converted to USD",
|
||||
attr.name.c_str(),
|
||||
int8_t(attr.domain),
|
||||
attr.data_type);
|
||||
int(attr.data_type));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -501,7 +501,7 @@ void USDCurvesWriter::write_custom_data(const bke::CurvesGeometry &curves,
|
|||
}
|
||||
|
||||
/* Spline UV data */
|
||||
if (iter.domain == bke::AttrDomain::Curve && iter.data_type == CD_PROP_FLOAT2) {
|
||||
if (iter.domain == bke::AttrDomain::Curve && iter.data_type == bke::AttrType::Float2) {
|
||||
if (usd_export_context_.export_params.export_uvmaps) {
|
||||
this->write_uv_data(iter, usd_curves);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ void USDGenericMeshWriter::write_custom_data(const Object *obj,
|
|||
}
|
||||
|
||||
/* UV Data. */
|
||||
if (iter.domain == bke::AttrDomain::Corner && iter.data_type == CD_PROP_FLOAT2) {
|
||||
if (iter.domain == bke::AttrDomain::Corner && iter.data_type == bke::AttrType::Float2) {
|
||||
if (usd_export_context_.export_params.export_uvmaps) {
|
||||
this->write_uv_data(usd_mesh, iter, active_uvmap_name);
|
||||
}
|
||||
|
|
@ -237,7 +237,7 @@ void USDGenericMeshWriter::write_generic_data(const Mesh *mesh,
|
|||
BKE_id_name(mesh->id),
|
||||
attr.name.c_str(),
|
||||
int8_t(attr.domain),
|
||||
attr.data_type);
|
||||
int(attr.data_type));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -571,7 +571,7 @@ void USDPointInstancerWriter::write_attribute_data(const bke::AttributeIter &att
|
|||
"Attribute '%s' (Blender domain %d, type %d) cannot be converted to USD",
|
||||
attr.name.c_str(),
|
||||
int(attr.domain),
|
||||
attr.data_type);
|
||||
int(attr.data_type));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ void USDPointsWriter::write_generic_data(const bke::AttributeIter &attr,
|
|||
"Attribute '%s' (Blender domain %d, type %d) cannot be converted to USD",
|
||||
attr.name.c_str(),
|
||||
int(attr.domain),
|
||||
attr.data_type);
|
||||
int(attr.data_type));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ static std::string ensure_weight_attribute_meta_data(Mesh &mesh,
|
|||
r_attr_converted = false;
|
||||
return name;
|
||||
}
|
||||
if (meta_data->domain == domain && meta_data->data_type == CD_PROP_FLOAT) {
|
||||
if (meta_data->domain == domain && meta_data->data_type == bke::AttrType::Float) {
|
||||
r_attr_converted = false;
|
||||
return name;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ static void modify_curves(ModifierData &md,
|
|||
}
|
||||
|
||||
ImplicitSharingPtrAndData old_positions_data = save_shared_attribute(
|
||||
curves.attributes().lookup("position", CD_PROP_FLOAT3));
|
||||
curves.attributes().lookup("position", bke::AttrType::Float3));
|
||||
Span<float3> old_positions = {static_cast<const float3 *>(old_positions_data.data),
|
||||
curves.points_num()};
|
||||
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ struct GeometryAttributeInfo {
|
|||
std::string name;
|
||||
/** Can be empty when #name does not actually exist on a geometry yet. */
|
||||
std::optional<bke::AttrDomain> domain;
|
||||
std::optional<eCustomDataType> data_type;
|
||||
std::optional<bke::AttrType> data_type;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ static void copy_curve_domain_attributes(const AttributeAccessor curve_attribute
|
|||
if (attribute_filter.allow_skip(iter.name)) {
|
||||
return;
|
||||
}
|
||||
if (iter.data_type == CD_PROP_STRING) {
|
||||
if (iter.data_type == bke::AttrType::String) {
|
||||
return;
|
||||
}
|
||||
point_attributes.add(iter.name,
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ static GreasePencil *curve_instances_to_grease_pencil_layers(
|
|||
if (iter.is_builtin && !grease_pencil_attributes.is_builtin(iter.name)) {
|
||||
return;
|
||||
}
|
||||
if (iter.data_type == CD_PROP_STRING) {
|
||||
if (iter.data_type == bke::AttrType::String) {
|
||||
return;
|
||||
}
|
||||
if (ELEM(iter.name, "opacity")) {
|
||||
|
|
|
|||
|
|
@ -297,7 +297,7 @@ BLI_NOINLINE static void propagate_existing_attributes(
|
|||
|
||||
for (MapItem<StringRef, AttributeDomainAndType> entry : attributes.items()) {
|
||||
const StringRef attribute_id = entry.key;
|
||||
const eCustomDataType output_data_type = entry.value.data_type;
|
||||
const bke::AttrType output_data_type = entry.value.data_type;
|
||||
|
||||
GAttributeReader src = mesh_attributes.lookup(attribute_id);
|
||||
if (!src) {
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ static void transfer_attributes(
|
|||
/* Edges and Face Corners. */
|
||||
out_domain = src.domain;
|
||||
}
|
||||
const eCustomDataType data_type = bke::cpp_type_to_custom_data_type(src.varray.type());
|
||||
const bke::AttrType data_type = bke::cpp_type_to_attribute_type(src.varray.type());
|
||||
GSpanAttributeWriter dst = dst_attributes.lookup_or_add_for_write_only_span(
|
||||
id, out_domain, data_type);
|
||||
if (!dst) {
|
||||
|
|
|
|||
|
|
@ -136,14 +136,14 @@ static void copy_stable_id_point(const OffsetIndices<int> offsets,
|
|||
if (!src_attribute) {
|
||||
return;
|
||||
}
|
||||
GSpanAttributeWriter dst_attribute = dst_attributes.lookup_or_add_for_write_only_span(
|
||||
"id", AttrDomain::Point, CD_PROP_INT32);
|
||||
SpanAttributeWriter dst_attribute = dst_attributes.lookup_or_add_for_write_only_span<int>(
|
||||
"id", AttrDomain::Point);
|
||||
if (!dst_attribute) {
|
||||
return;
|
||||
}
|
||||
|
||||
VArraySpan<int> src{src_attribute.varray.typed<int>()};
|
||||
MutableSpan<int> dst = dst_attribute.span.typed<int>();
|
||||
MutableSpan<int> dst = dst_attribute.span;
|
||||
threaded_id_offset_copy(offsets, src, dst);
|
||||
dst_attribute.finish();
|
||||
}
|
||||
|
|
@ -215,15 +215,15 @@ static void copy_stable_id_curves(const bke::CurvesGeometry &src_curves,
|
|||
if (!src_attribute) {
|
||||
return;
|
||||
}
|
||||
GSpanAttributeWriter dst_attribute =
|
||||
dst_curves.attributes_for_write().lookup_or_add_for_write_only_span(
|
||||
"id", AttrDomain::Point, CD_PROP_INT32);
|
||||
SpanAttributeWriter dst_attribute =
|
||||
dst_curves.attributes_for_write().lookup_or_add_for_write_only_span<int>("id",
|
||||
AttrDomain::Point);
|
||||
if (!dst_attribute) {
|
||||
return;
|
||||
}
|
||||
|
||||
VArraySpan<int> src{src_attribute.varray.typed<int>()};
|
||||
MutableSpan<int> dst = dst_attribute.span.typed<int>();
|
||||
MutableSpan<int> dst = dst_attribute.span;
|
||||
|
||||
const OffsetIndices src_points_by_curve = src_curves.points_by_curve();
|
||||
const OffsetIndices dst_points_by_curve = dst_curves.points_by_curve();
|
||||
|
|
@ -423,14 +423,14 @@ static void copy_stable_id_faces(const Mesh &mesh,
|
|||
if (!src_attribute) {
|
||||
return;
|
||||
}
|
||||
GSpanAttributeWriter dst_attribute = dst_attributes.lookup_or_add_for_write_only_span(
|
||||
"id", AttrDomain::Point, CD_PROP_INT32);
|
||||
SpanAttributeWriter dst_attribute = dst_attributes.lookup_or_add_for_write_only_span<int>(
|
||||
"id", AttrDomain::Point);
|
||||
if (!dst_attribute) {
|
||||
return;
|
||||
}
|
||||
|
||||
VArraySpan<int> src{src_attribute.varray.typed<int>()};
|
||||
MutableSpan<int> dst = dst_attribute.span.typed<int>();
|
||||
MutableSpan<int> dst = dst_attribute.span;
|
||||
|
||||
const OffsetIndices faces = mesh.faces();
|
||||
int loop_index = 0;
|
||||
|
|
@ -614,8 +614,8 @@ static void copy_stable_id_edges(const Mesh &mesh,
|
|||
if (!src_attribute) {
|
||||
return;
|
||||
}
|
||||
GSpanAttributeWriter dst_attribute = dst_attributes.lookup_or_add_for_write_only_span(
|
||||
"id", AttrDomain::Point, CD_PROP_INT32);
|
||||
SpanAttributeWriter dst_attribute = dst_attributes.lookup_or_add_for_write_only_span<int>(
|
||||
"id", AttrDomain::Point);
|
||||
if (!dst_attribute) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -623,7 +623,7 @@ static void copy_stable_id_edges(const Mesh &mesh,
|
|||
const Span<int2> edges = mesh.edges();
|
||||
|
||||
VArraySpan<int> src{src_attribute.varray.typed<int>()};
|
||||
MutableSpan<int> dst = dst_attribute.span.typed<int>();
|
||||
MutableSpan<int> dst = dst_attribute.span;
|
||||
selection.foreach_index(GrainSize(1024), [&](const int64_t index, const int64_t i_selection) {
|
||||
const IndexRange edge_range = offsets[i_selection];
|
||||
if (edge_range.is_empty()) {
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ static void expand_mesh(Mesh &mesh,
|
|||
if (edge_expand != 0) {
|
||||
if (mesh.edges_num == 0) {
|
||||
mesh.attributes_for_write().add(
|
||||
".edge_verts", AttrDomain::Edge, CD_PROP_INT32_2D, bke::AttributeInitConstruct());
|
||||
".edge_verts", AttrDomain::Edge, bke::AttrType::Int32_2D, bke::AttributeInitConstruct());
|
||||
}
|
||||
const int old_edges_num = mesh.edges_num;
|
||||
mesh.edges_num += edge_expand;
|
||||
|
|
@ -166,9 +166,9 @@ static void expand_mesh(Mesh &mesh,
|
|||
if (loop_expand != 0) {
|
||||
if (mesh.corners_num == 0) {
|
||||
mesh.attributes_for_write().add(
|
||||
".corner_vert", AttrDomain::Corner, CD_PROP_INT32, bke::AttributeInitConstruct());
|
||||
".corner_vert", AttrDomain::Corner, bke::AttrType::Int32, bke::AttributeInitConstruct());
|
||||
mesh.attributes_for_write().add(
|
||||
".corner_edge", AttrDomain::Corner, CD_PROP_INT32, bke::AttributeInitConstruct());
|
||||
".corner_edge", AttrDomain::Corner, bke::AttrType::Int32, bke::AttributeInitConstruct());
|
||||
}
|
||||
const int old_loops_num = mesh.corners_num;
|
||||
mesh.corners_num += loop_expand;
|
||||
|
|
@ -272,7 +272,7 @@ static IDsByDomain attribute_ids_by_domain(const AttributeAccessor attributes,
|
|||
{
|
||||
IDsByDomain ids_by_domain;
|
||||
attributes.foreach_attribute([&](const bke::AttributeIter &iter) {
|
||||
if (iter.data_type == CD_PROP_STRING) {
|
||||
if (iter.data_type == bke::AttrType::String) {
|
||||
return;
|
||||
}
|
||||
if (skip.contains(iter.name)) {
|
||||
|
|
@ -289,7 +289,7 @@ static bool is_empty_domain(const AttributeAccessor attributes,
|
|||
{
|
||||
bool is_empty = true;
|
||||
attributes.foreach_attribute([&](const bke::AttributeIter &iter) {
|
||||
if (iter.data_type == CD_PROP_STRING) {
|
||||
if (iter.data_type == bke::AttrType::String) {
|
||||
return;
|
||||
}
|
||||
if (iter.domain != domain) {
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue