diff options
author | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2022-03-13 21:50:35 +0300 |
---|---|---|
committer | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2022-03-13 21:50:35 +0300 |
commit | c0ef2a5cf56590c7b01502d8d6c5a18067afc028 (patch) | |
tree | f04018116f9c412cea30bb6cc14c6a0357568e33 /source/blender/io/alembic/intern/abc_customdata.h | |
parent | 5a0efc9c8b5ad991109c97d52d476d8c071a78ac (diff) |
Start replacing write_custom_data with the attribute exporter.temp-abc-features
Diffstat (limited to 'source/blender/io/alembic/intern/abc_customdata.h')
-rw-r--r-- | source/blender/io/alembic/intern/abc_customdata.h | 85 |
1 files changed, 83 insertions, 2 deletions
diff --git a/source/blender/io/alembic/intern/abc_customdata.h b/source/blender/io/alembic/intern/abc_customdata.h index 3b162364de8..b5dbb023100 100644 --- a/source/blender/io/alembic/intern/abc_customdata.h +++ b/source/blender/io/alembic/intern/abc_customdata.h @@ -13,7 +13,10 @@ #include "BKE_attribute.h" +#include "BLI_color.hh" #include "BLI_listbase_wrapper.hh" +#include "BLI_math_vec_types.hh" +#include "BLI_span.hh" struct CacheAttributeMapping; struct CustomData; @@ -23,6 +26,7 @@ struct MLoopUV; struct MPoly; struct MVert; struct Mesh; +struct MCol; using Alembic::Abc::ICompoundProperty; using Alembic::Abc::OCompoundProperty; @@ -111,13 +115,90 @@ struct CDStreamConfig { * For now the active layer is used, maybe needs a better way to choose this. */ const char *get_uv_sample(UVSample &sample, const CDStreamConfig &config, CustomData *data); -void write_generated_coordinates(const OCompoundProperty &prop, CDStreamConfig &config); - void write_custom_data(const OCompoundProperty &prop, CDStreamConfig &config, CustomData *data, int data_type); +/* Need special handling for: + * - creases (vertex/edge) + * - velocity + * - generated coordinate + * - UVs + * - vertex colors + */ +class GenericAttributeExporter { + ID *m_id; + int64_t cd_mask = CD_MASK_ALL; + + public: + GenericAttributeExporter(ID *id, int64_t cd_mask_) : m_id(id), cd_mask(cd_mask_) + { + } + + void export_attributes(); + + protected: + virtual void export_attribute(blender::Span<bool> span, + const std::string &name, + AttributeDomain domain) = 0; + + virtual void export_attribute(blender::Span<char> span, + const std::string &name, + AttributeDomain domain) = 0; + + virtual void export_attribute(blender::Span<int> span, + const std::string &name, + AttributeDomain domain) = 0; + + virtual void export_attribute(blender::Span<float> span, + const std::string &name, + AttributeDomain domain) = 0; + + virtual void export_attribute(blender::Span<float2> span, + const std::string &name, + AttributeDomain domain) = 0; + + virtual void export_attribute(blender::Span<float3> span, + const std::string &name, + AttributeDomain domain) = 0; + + virtual void export_attribute(blender::Span<ColorGeometry4f> span, + const std::string &name, + AttributeDomain domain) = 0; + + virtual void export_attribute(blender::Span<MLoopUV> span, + const std::string &name, + AttributeDomain domain) = 0; + + virtual void export_attribute(blender::Span<MCol> span, + const std::string &name, + AttributeDomain domain) = 0; + + template<typename BlenderDataType> + void export_customdata_layer(CustomDataLayer *layer, DomainInfo info, AttributeDomain domain) + { + BlenderDataType *data = static_cast<BlenderDataType *>(layer->data); + int64_t size = static_cast<int64_t>(info.length); + blender::Span<BlenderDataType> data_span(data, size); + this->export_attribute(data_span, layer->name, domain); + } + + void export_generated_coordinates(CustomDataLayer *layer, + DomainInfo info, + AttributeDomain domain); + + void export_attribute_for_domain(DomainInfo info, AttributeDomain domain); +}; + +GenericAttributeExporter *make_attribute_exporter(ID *id, + int64_t cd_mask, + OCompoundProperty &prop); + +void set_timesample_index(GenericAttributeExporter *exporter, int timesample_index); + +void delete_attribute_exporter(GenericAttributeExporter *exporter); + class AttributeSelector { /* Name of the velocity attribute, it is ignored since we deal with separately. */ std::string velocity_attribute = ""; |