21using namespace Alembic::AbcGeom;
98 return {
v.x,
v.y,
v.z};
119 return {
v.r,
v.g,
v.b,
v.a};
129 static constexpr float float_scale = 1.0f / 255.0f;
130 return {
float(
v.r) * float_scale,
133 float(
v.a) * float_scale};
144 return {quat.
w,
v.x,
v.y,
v.z};
153 return std::string(
v.s,
size_t(
v.s_len));
171 return kUniformScope;
174 return kFacevaryingScope;
178 return kUnknownScope;
181template<
typename GeomParamType>
190 for (
size_t i = param.getNumSamples(); i < num_geom_samples; i++) {
191 typename GeomParamType::Sample
sample;
192 static typename GeomParamType::value_type address_for_array{};
193 sample.setVals({&address_for_array, 0ul});
200#define WRITE_EMPTY_SAMPLE(abc_type, map_name) \
201 for (auto &iter : this->map_name) { \
202 io::alembic::write_empty_samples(iter.second, num_geom_samples); \
205#undef WRITE_EMPTY_SAMPLE
208template<
typename BlenderDataType>
214 const GeometryScope scope,
215 const int timesample_index,
218 const size_t num_geom_samples)
221 using AlembicTraitType =
typename TypeConverter::AbcTraitType;
222 using AlembicType =
typename AlembicTraitType::value_type;
224 std::vector<AlembicType> values;
226 GeometryScope corrected_scope = scope;
229 corrected_scope = GeometryScope::kConstantScope;
230 values.push_back(TypeConverter::convert(buffer[0]));
233 values.resize(
static_cast<size_t>(buffer.
size()));
234 AlembicType *values_ptr = values.data();
235 if (scope == kFacevaryingScope) {
239 for (
int j = face.
size() - 1; j >= 0; j--) {
240 const int blender_index = face[j];
241 *values_ptr++ = TypeConverter::convert(buffer[blender_index]);
246 for (
int i = 0; i < buffer.
size(); i++) {
247 *values_ptr++ = TypeConverter::convert(buffer[i]);
252 using ParamType = OTypedGeomParam<AlembicTraitType>;
253 using SampleType =
typename ParamType::Sample;
256 const Alembic::Abc::PropertyHeader *prop_header = prop.getPropertyHeader(valid_name.
c_str());
257 if (prop_header && !ParamType::matches(*prop_header)) {
259 "On object '%s', cannot write attribute '%s' as the type has changed",
266 param_maps.ensure_param(prop, param, valid_name, corrected_scope);
267 param.setTimeSampling(timesample_index);
271 SampleType
sample(values, corrected_scope);
274 catch (
const Alembic::Util::Exception &ex) {
276 "On object '%s', error writing attribute '%s' : %s",
286 const int timesample_index,
289 const size_t num_geom_samples)
292 if (scope == kUnknownScope) {
294 "On object '%s', attribute '%s' (Blender domain %d, type %d) cannot be converted "
308 "On object '%s', attribute '%s' (Blender domain %d, type %d) cannot be exported "
309 "to Alembic as it is using a reserved name",
335 if constexpr (!std::is_same_v<BlenderT, float4>) {
336 create_geom_param_for_attribute(prop,
338 attribute.typed<BlenderT>(),
352 "On object '%s', attribute '%s' of type %d is not supported by Alembic",
355 int(attr.data_type));
#define CLOG_WARN(clg_ref,...)
#define WRITE_EMPTY_SAMPLE(abc_type, map_name)
#define ENUMERATE_EXPORTED_TYPES(X)
constexpr int64_t size() const
constexpr const char * c_str() const
GAttributeReader get() const
void write_empty_samples(const size_t num_geom_samples)
IndexRange index_range() const
void to_static_type(const CPPType &cpp_type, Fn &&fn)
static void create_geom_param_for_attribute(const Alembic::Abc::OCompoundProperty &prop, AttributeParamMaps ¶m_maps, const VArray< BlenderDataType > &buffer, const StringRefNull name, const StringRefNull valid_name, const GeometryScope scope, const int timesample_index, const OffsetIndices< int > faces, const StringRefNull object_name, const size_t num_geom_samples)
BLI_INLINE void copy_yup_from_zup(float yup[3], const float zup[3])
std::string get_valid_abc_name(const char *name)
void copy_m44_axis_swap(float dst_mat[4][4], float src_mat[4][4], AbcAxisSwapMode mode)
static void write_empty_samples(GeomParamType ¶m, const size_t num_geom_samples)
bool is_reserved_attribute_name(const StringRefNull name)
Imath::M44d convert_matrix_datatype(const float mat[4][4])
static GeometryScope get_scope_for_attribute_domain(bke::AttrDomain domain)
QuaternionBase< float > Quaternion
ATTR_WARN_UNUSED_RESULT const BMVert * v
MatBase< float, 4, 4 > float4x4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
VecBase< int16_t, 2 > short2
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
VecBase< float, 3 > float3
ColorSceneLinearByteEncoded4b< eAlpha::Premultiplied > ColorGeometry4b
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
Alembic::Abc::C4fTPTraits AbcTraitType
static Imath::C4f convert(ColorGeometry4b v)
static Imath::C4f convert(ColorGeometry4f v)
Alembic::Abc::C4fTPTraits AbcTraitType
Alembic::Abc::StringTPTraits AbcTraitType
static std::string convert(const MStringProperty &v)
static Alembic::Abc::bool_t convert(bool v)
Alembic::Abc::BooleanTPTraits AbcTraitType
Alembic::Abc::V2fTPTraits AbcTraitType
static Imath::V2f convert(float2 v)
static Imath::V3f convert(float3 v)
Alembic::Abc::V3fTPTraits AbcTraitType
static Imath::M44d convert(float4x4 v)
Alembic::Abc::M44dTPTraits AbcTraitType
Alembic::Abc::Float32TPTraits AbcTraitType
static float convert(float v)
Alembic::Abc::V2iTPTraits AbcTraitType
static Imath::V2i convert(int2 v)
static int8_t convert(int8_t v)
Alembic::Abc::Int8TPTraits AbcTraitType
Alembic::Abc::Int32TPTraits AbcTraitType
static int convert(int v)
Alembic::Abc::QuatfTPTraits AbcTraitType
static Imath::Quatf convert(math::Quaternion quat)
static Imath::V2s convert(short2 v)
Alembic::Abc::V2sTPTraits AbcTraitType
const VecBase< T, 3 > & imaginary_part() const