Blender V5.3
abc_customdata.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2016 Kévin Dietrich. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "abc_customdata.h"
10#include "BLI_color_types.hh"
11#include "abc_axis_conversion.h"
12#include "abc_util.h"
13
14#include <Alembic/Abc/ICompoundProperty.h>
15#include <Alembic/Abc/ISampleSelector.h>
16#include <Alembic/Abc/OCompoundProperty.h>
17#include <Alembic/Abc/TypedArraySample.h>
18#include <Alembic/AbcCoreAbstract/PropertyHeader.h>
19#include <Alembic/AbcGeom/GeometryScope.h>
20#include <Alembic/AbcGeom/IGeomParam.h>
21#include <Alembic/AbcGeom/OGeomParam.h>
22
24#include "DNA_mesh_types.h"
25#include "DNA_meshdata_types.h"
26
27#include "BLI_math_base_c.hh"
28#include "BLI_math_vector_c.hh"
30#include "BLI_utildefines.hh"
31
32#include "BKE_attribute.h"
33#include "BKE_attribute.hh"
34#include "BKE_customdata.hh"
35#include "BKE_mesh.hh"
36
37#include "IO_validate.hh"
38
39namespace blender {
40
41/* NOTE: for now only UVs and Vertex Colors are supported for streaming.
42 * Although Alembic only allows for a single UV layer per {I|O}Schema, and does
43 * not have a vertex color concept, there is a convention between DCCs to write
44 * such data in a way that lets other DCC know what they are for. See comments
45 * in the write code for the conventions. */
46
47using Alembic::AbcGeom::kFacevaryingScope;
48using Alembic::AbcGeom::kVaryingScope;
49using Alembic::AbcGeom::kVertexScope;
50
51using Alembic::Abc::C4fArraySample;
52using Alembic::Abc::UInt32ArraySample;
53using Alembic::Abc::V2fArraySample;
54
55using Alembic::AbcGeom::OC4fGeomParam;
56using Alembic::AbcGeom::OV2fGeomParam;
57using Alembic::AbcGeom::OV3fGeomParam;
58namespace io::alembic {
59
60static void get_uvs(const CDStreamConfig &config,
61 std::vector<Imath::V2f> &uvs,
62 std::vector<uint32_t> &uvidx,
63 const Span<float2> uv_map_array)
64{
65 const OffsetIndices faces = config.mesh->faces();
66 int *corner_verts = config.corner_verts;
67
68 if (!config.pack_uvs) {
69 int count = 0;
70 uvidx.resize(config.totloop);
71 uvs.resize(config.totloop);
72
73 /* Iterate in reverse order to match exported polygons. */
74 for (const int i : faces.index_range()) {
75 const IndexRange face = faces[i];
76 const float2 *loopuv = uv_map_array.data() + face.start() + face.size();
77
78 for (int j = 0; j < face.size(); j++, count++) {
79 loopuv--;
80
81 uvidx[count] = count;
82 uvs[count][0] = (*loopuv)[0];
83 uvs[count][1] = (*loopuv)[1];
84 }
85 }
86 }
87 else {
88 /* Mapping for indexed UVs, deduplicating UV coordinates at vertices. */
89 std::vector<std::vector<uint32_t>> idx_map(config.totvert);
90 int idx_count = 0;
91
92 for (const int i : faces.index_range()) {
93 const IndexRange face = faces[i];
94 int *face_verts = corner_verts + face.start() + face.size();
95 const float2 *loopuv = uv_map_array.data() + face.start() + face.size();
96
97 for (int j = 0; j < face.size(); j++) {
98 face_verts--;
99 loopuv--;
100
101 Imath::V2f uv((*loopuv)[0], (*loopuv)[1]);
102 bool found_same = false;
103
104 /* Find UV already in uvs array. */
105 for (uint32_t uv_idx : idx_map[*face_verts]) {
106 if (uvs[uv_idx] == uv) {
107 found_same = true;
108 uvidx.push_back(uv_idx);
109 break;
110 }
111 }
112
113 /* UV doesn't exists for this vertex, add it. */
114 if (!found_same) {
115 uint32_t uv_idx = idx_count++;
116 idx_map[*face_verts].push_back(uv_idx);
117 uvidx.push_back(uv_idx);
118 uvs.push_back(uv);
119 }
120 }
121 }
122 }
123}
124
125const char *get_uv_sample(UVSample &sample, const CDStreamConfig &config, const Mesh &mesh)
126{
127 const StringRefNull name = mesh.active_uv_map_name();
128 if (name.is_empty()) {
129 return "";
130 }
131 const VArraySpan uv_map = *mesh.attributes().lookup<float2>(name, bke::AttrDomain::Corner);
132 if (uv_map.is_empty()) {
133 return "";
134 }
135
136 get_uvs(config, sample.uvs, sample.indices, uv_map);
137
138 return name.c_str();
139}
140
141/* Convention to write UVs:
142 * - V2fGeomParam on the arbGeomParam
143 * - set scope as face varying
144 * - (optional due to its behavior) tag as UV using Alembic::AbcGeom::SetIsUV
145 */
146static void write_uv(const OCompoundProperty &prop,
147 CDStreamConfig &config,
148 const Span<float2> data,
149 const std::string &uv_map_name)
150{
151 std::vector<uint32_t> indices;
152 std::vector<Imath::V2f> uvs;
153
154 get_uvs(config, uvs, indices, data);
155
156 if (indices.empty() || uvs.empty()) {
157 return;
158 }
159
160 OV2fGeomParam param = config.abc_uv_maps[uv_map_name];
161
162 if (!param.valid()) {
163 param = OV2fGeomParam(prop, uv_map_name, true, kFacevaryingScope, 1);
164 }
165 OV2fGeomParam::Sample sample(V2fArraySample(&uvs.front(), uvs.size()),
166 UInt32ArraySample(&indices.front(), indices.size()),
167 kFacevaryingScope);
168 param.set(sample);
169 param.setTimeSampling(config.timesample_index);
170
171 config.abc_uv_maps[uv_map_name] = param;
172}
173
174void write_generated_coordinates(const OCompoundProperty &prop, CDStreamConfig &config)
175{
176 Mesh *mesh = config.mesh;
177 const void *customdata = CustomData_get_layer(&mesh->vert_data, CD_ORCO);
178 if (customdata == nullptr) {
179 /* Data not available, so don't even bother creating an Alembic property for it. */
180 return;
181 }
182 const float (*orcodata)[3] = static_cast<const float (*)[3]>(customdata);
183
184 /* Convert 3D vertices from float[3] z=up to V3f y=up. */
185 std::vector<Imath::V3f> coords(config.totvert);
186 float orco_yup[3];
187 for (int vertex_idx = 0; vertex_idx < config.totvert; vertex_idx++) {
188 copy_yup_from_zup(orco_yup, orcodata[vertex_idx]);
189 coords[vertex_idx].setValue(orco_yup[0], orco_yup[1], orco_yup[2]);
190 }
191
192 /* ORCOs are always stored in the normalized 0..1 range in Blender, but Alembic stores them
193 * unnormalized, so we need to unnormalize (invert transform) them. */
195 mesh, reinterpret_cast<float (*)[3]>(coords.data()), mesh->verts_num, true);
196
197 if (!config.abc_orco.valid()) {
198 /* Create the Alembic property and keep a reference so future frames can reuse it. */
199 config.abc_orco = OV3fGeomParam(prop, propNameOriginalCoordinates, false, kVertexScope, 1);
200 }
201
202 OV3fGeomParam::Sample sample(coords, kVertexScope);
203 config.abc_orco.set(sample);
204}
205
206void write_uv_maps(const OCompoundProperty &prop, CDStreamConfig &config, const Mesh &mesh)
207{
208 const bke::AttributeAccessor attributes = mesh.attributes();
209 const StringRef active_uv_name = mesh.active_uv_map_name();
210 for (const StringRefNull name : mesh.uv_map_names()) {
211 if (name == active_uv_name) {
212 /* Already exported. */
213 continue;
214 }
215 const VArraySpan uv_map = *attributes.lookup<float2>(name, bke::AttrDomain::Corner);
216 write_uv(prop, config, uv_map, get_valid_abc_name(name.c_str()));
217 }
218}
219
220/* ************************************************************************** */
221
222using Alembic::Abc::C3fArraySamplePtr;
223using Alembic::Abc::C4fArraySamplePtr;
224using Alembic::Abc::PropertyHeader;
225using Alembic::Abc::UInt32ArraySamplePtr;
226
227using Alembic::AbcGeom::IC3fGeomParam;
228using Alembic::AbcGeom::IC4fGeomParam;
229using Alembic::AbcGeom::IV2fGeomParam;
230using Alembic::AbcGeom::IV3fGeomParam;
231
232static void read_uvs(const CDStreamConfig &config,
233 MutableSpan<float2> uv_map,
234 const AbcUvScope uv_scope,
235 const Alembic::AbcGeom::V2fArraySamplePtr &uvs,
236 const UInt32ArraySamplePtr &indices)
237{
238 const OffsetIndices faces = config.mesh->faces();
239 const int *corner_verts = config.corner_verts;
240 const int64_t indices_size = int64_t(indices->size());
241 const int64_t uvs_size = int64_t(uvs->size());
242
243 BLI_assert(uv_scope != ABC_UV_SCOPE_NONE);
244 const bool do_uvs_per_loop = (uv_scope == ABC_UV_SCOPE_LOOP);
245
246 for (const int64_t i : faces.index_range()) {
247 const IndexRange face = faces[i];
248 const int64_t rev_loop_offset = face.start() + face.size() - 1;
249
250 for (int64_t f = 0; f < face.size(); f++) {
251 const int64_t rev_loop_index = rev_loop_offset - f;
252 const int64_t loop_index = do_uvs_per_loop ? face.start() + f : corner_verts[rev_loop_index];
253 if (!validate::index_in_range(loop_index, indices_size)) {
254 continue;
255 }
256 const int64_t uv_index = (*indices)[loop_index];
257 if (!validate::index_in_range(uv_index, uvs_size)) {
258 continue;
259 }
260 const Imath::V2f &uv = (*uvs)[uv_index];
261
262 float2 &loopuv = uv_map[rev_loop_index];
263 loopuv[0] = uv[0];
264 loopuv[1] = uv[1];
265 }
266 }
267}
268
270 const int64_t array_size,
271 const std::string &iobject_full_name,
272 const PropertyHeader &prop_header,
273 bool &r_is_out_of_bounds,
274 bool &r_bounds_warning_given)
275{
276 if (validate::index_in_range(color_index, array_size)) {
277 return color_index;
278 }
279
280 if (!r_bounds_warning_given) {
281 std::cerr << "Alembic: color index out of bounds "
282 "reading face colors for object "
283 << iobject_full_name << ", property " << prop_header.getName() << std::endl;
284 r_bounds_warning_given = true;
285 }
286 r_is_out_of_bounds = true;
287 return 0;
288}
289
290static void read_custom_data_mcols(const std::string &iobject_full_name,
291 const ICompoundProperty &arbGeomParams,
292 const PropertyHeader &prop_header,
293 const CDStreamConfig &config,
294 const Alembic::Abc::ISampleSelector &iss)
295{
296 C3fArraySamplePtr c3f_ptr = C3fArraySamplePtr();
297 C4fArraySamplePtr c4f_ptr = C4fArraySamplePtr();
298 Alembic::Abc::UInt32ArraySamplePtr indices;
299 bool use_c3f_ptr;
300 bool is_facevarying;
301
302 /* Find the correct interpretation of the data */
303 if (IC3fGeomParam::matches(prop_header)) {
304 IC3fGeomParam color_param(arbGeomParams, prop_header.getName());
305 IC3fGeomParam::Sample sample;
306 BLI_assert(STREQ("rgb", color_param.getInterpretation()));
307
308 color_param.getIndexed(sample, iss);
309 is_facevarying = sample.getScope() == kFacevaryingScope &&
310 config.totloop == sample.getIndices()->size();
311
312 c3f_ptr = sample.getVals();
313 indices = sample.getIndices();
314 use_c3f_ptr = true;
315 }
316 else if (IC4fGeomParam::matches(prop_header)) {
317 IC4fGeomParam color_param(arbGeomParams, prop_header.getName());
318 IC4fGeomParam::Sample sample;
319 BLI_assert(STREQ("rgba", color_param.getInterpretation()));
320
321 color_param.getIndexed(sample, iss);
322 is_facevarying = sample.getScope() == kFacevaryingScope &&
323 config.totloop == sample.getIndices()->size();
324
325 c4f_ptr = sample.getVals();
326 indices = sample.getIndices();
327 use_c3f_ptr = false;
328 }
329 else {
330 /* this won't happen due to the checks in read_custom_data() */
331 return;
332 }
333 BLI_assert(c3f_ptr || c4f_ptr);
334
335 /* Read the vertex colors */
336 bke::MutableAttributeAccessor attributes = config.mesh->attributes_for_write();
338 prop_header.getName(), bke::AttrDomain::Corner);
339 const OffsetIndices faces = config.mesh->faces();
340 const int *corner_verts = config.corner_verts;
341
342 int64_t face_index = 0;
343 int64_t color_index;
344 bool bounds_warning_given = false;
345
346 /* The colors can go through two layers of indexing. Often the 'indices'
347 * array doesn't do anything (i.e. indices[n] = n), but when it does, it's
348 * important. Blender 2.79 writes indices incorrectly (see #53745), which
349 * is why we have to check for indices->size() > 0 */
350 bool use_dual_indexing = is_facevarying && indices->size() > 0;
351
352 for (const int64_t i : faces.index_range()) {
353 const IndexRange face = faces[i];
354 int64_t corner = face.start() + face.size();
355
356 for (int64_t j = 0; j < face.size(); j++, face_index++) {
357 corner--;
358
359 color_index = is_facevarying ? face_index : corner_verts[corner];
360 if (use_dual_indexing) {
361 color_index = (*indices)[color_index];
362 }
363 if (use_c3f_ptr) {
364 bool is_mcols_out_of_bounds = false;
365 color_index = mcols_out_of_bounds_check(color_index,
366 c3f_ptr->size(),
367 iobject_full_name,
368 prop_header,
369 is_mcols_out_of_bounds,
370 bounds_warning_given);
371 if (is_mcols_out_of_bounds) {
372 continue;
373 }
374 const Imath::C3f &color = (*c3f_ptr)[color_index];
375 attr.span[corner].r = unit_float_to_uchar_clamp(color[0]);
376 attr.span[corner].g = unit_float_to_uchar_clamp(color[1]);
377 attr.span[corner].b = unit_float_to_uchar_clamp(color[2]);
378 attr.span[corner].a = 255;
379 }
380 else {
381 bool is_mcols_out_of_bounds = false;
382 color_index = mcols_out_of_bounds_check(color_index,
383 c4f_ptr->size(),
384 iobject_full_name,
385 prop_header,
386 is_mcols_out_of_bounds,
387 bounds_warning_given);
388 if (is_mcols_out_of_bounds) {
389 continue;
390 }
391 const Imath::C4f &color = (*c4f_ptr)[color_index];
392 attr.span[corner].r = unit_float_to_uchar_clamp(color[0]);
393 attr.span[corner].g = unit_float_to_uchar_clamp(color[1]);
394 attr.span[corner].b = unit_float_to_uchar_clamp(color[2]);
395 attr.span[corner].a = unit_float_to_uchar_clamp(color[3]);
396 }
397 }
398 }
399
400 attr.finish();
401}
402
403static void read_custom_data_uvs(const ICompoundProperty &prop,
404 const PropertyHeader &prop_header,
405 const CDStreamConfig &config,
406 const Alembic::Abc::ISampleSelector &iss)
407{
408 IV2fGeomParam uv_param(prop, prop_header.getName());
409
410 if (!uv_param.isIndexed()) {
411 return;
412 }
413
414 IV2fGeomParam::Sample sample;
415 uv_param.getIndexed(sample, iss);
416
417 UInt32ArraySamplePtr uvs_indices = sample.getIndices();
418
419 const AbcUvScope uv_scope = get_uv_scope(uv_param.getScope(), config, uvs_indices);
420
421 if (uv_scope == ABC_UV_SCOPE_NONE) {
422 return;
423 }
424
425 bke::MutableAttributeAccessor attributes = config.mesh->attributes_for_write();
427 prop_header.getName(), bke::AttrDomain::Corner);
428
429 read_uvs(config, uv_map.span, uv_scope, sample.getVals(), uvs_indices);
430
431 uv_map.finish();
432}
433
434void read_velocity(const V3fArraySamplePtr &velocities,
435 const CDStreamConfig &config,
436 const float velocity_scale)
437{
438 if (velocities->size() != config.mesh->verts_num) {
439 /* Files containing videogrammetry data may be malformed and export velocity data on missing
440 * frames (most likely by copying the last valid data). */
441 return;
442 }
443 const int64_t num_velocity_vectors = config.mesh->verts_num;
444
445 bke::MutableAttributeAccessor attributes = config.mesh->attributes_for_write();
447 "velocity", bke::AttrDomain::Point);
448 MutableSpan<float3> velocity = attr.span;
449 for (int64_t i = 0; i < num_velocity_vectors; i++) {
450 const Imath::V3f &vel_in = (*velocities)[i];
451 copy_zup_from_yup(velocity[i], vel_in.getValue());
452 mul_v3_fl(velocity[i], velocity_scale);
453 }
454 attr.finish();
455}
456
457void read_generated_coordinates(const ICompoundProperty &prop,
458 const CDStreamConfig &config,
459 const Alembic::Abc::ISampleSelector &iss)
460{
461 if (!prop.valid() || prop.getPropertyHeader(propNameOriginalCoordinates) == nullptr) {
462 /* The ORCO property isn't there, so don't bother trying to process it. */
463 return;
464 }
465
466 IV3fGeomParam param(prop, propNameOriginalCoordinates);
467 if (!param.valid() || param.isIndexed()) {
468 /* Invalid or indexed coordinates aren't supported. */
469 return;
470 }
471 if (param.getScope() != kVertexScope) {
472 /* These are original vertex coordinates, so must be vertex-scoped. */
473 return;
474 }
475
476 IV3fGeomParam::Sample sample = param.getExpandedValue(iss);
477 Alembic::AbcGeom::V3fArraySamplePtr abc_orco = sample.getVals();
478 const size_t totvert = abc_orco.get()->size();
479 Mesh *mesh = config.mesh;
480
481 if (totvert != mesh->verts_num) {
482 /* Either the data is somehow corrupted, or we have a dynamic simulation where only the ORCOs
483 * for the first frame were exported. */
484 return;
485 }
486
487 void *cd_data;
488 if (CustomData_has_layer(&mesh->vert_data, CD_ORCO)) {
489 cd_data = CustomData_get_layer_for_write(&mesh->vert_data, CD_ORCO, mesh->verts_num);
490 }
491 else {
492 cd_data = CustomData_add_layer(&mesh->vert_data, CD_ORCO, CD_CONSTRUCT, totvert);
493 }
494
495 float (*orcodata)[3] = static_cast<float (*)[3]>(cd_data);
496 for (int vertex_idx = 0; vertex_idx < totvert; ++vertex_idx) {
497 const Imath::V3f &abc_coords = (*abc_orco)[vertex_idx];
498 copy_zup_from_yup(orcodata[vertex_idx], abc_coords.getValue());
499 }
500
501 /* ORCOs are always stored in the normalized 0..1 range in Blender, but Alembic stores them
502 * unnormalized, so we need to normalize them. */
503 BKE_mesh_orco_verts_transform(mesh, orcodata, mesh->verts_num, false);
504}
505
506void read_custom_data(const std::string &iobject_full_name,
507 const ICompoundProperty &prop,
508 const CDStreamConfig &config,
509 const Alembic::Abc::ISampleSelector &iss)
510{
511 if (!prop.valid()) {
512 return;
513 }
514
515 int num_uvs = 0;
516
517 const size_t num_props = prop.getNumProperties();
518
519 for (size_t i = 0; i < num_props; i++) {
520 const Alembic::Abc::PropertyHeader &prop_header = prop.getPropertyHeader(i);
521
522 /* Read UVs according to convention. */
523 if (IV2fGeomParam::matches(prop_header) && Alembic::AbcGeom::isUV(prop_header)) {
524 if (++num_uvs > MAX_MTFACE) {
525 continue;
526 }
527
528 read_custom_data_uvs(prop, prop_header, config, iss);
529 continue;
530 }
531
532 /* Read vertex colors according to convention. */
533 if (IC3fGeomParam::matches(prop_header) || IC4fGeomParam::matches(prop_header)) {
534 read_custom_data_mcols(iobject_full_name, prop, prop_header, config, iss);
535 continue;
536 }
537 }
538}
539
540AbcUvScope get_uv_scope(const Alembic::AbcGeom::GeometryScope scope,
541 const CDStreamConfig &config,
542 const Alembic::AbcGeom::UInt32ArraySamplePtr &indices)
543{
544 if (scope == kFacevaryingScope && indices->size() == config.totloop) {
545 return ABC_UV_SCOPE_LOOP;
546 }
547
548 /* kVaryingScope is sometimes used for vertex scopes as the values vary across the vertices. To
549 * be sure, one has to check the size of the data against the number of vertices, as it could
550 * also be a varying attribute across the faces (i.e. one value per face). */
551 if (ELEM(scope, kVaryingScope, kVertexScope) && indices->size() == config.totvert) {
552 return ABC_UV_SCOPE_VERTEX;
553 }
554
555 return ABC_UV_SCOPE_NONE;
556}
557
558static std::string get_string_property(const ICompoundProperty &prop,
559 const StringRefNull name,
560 const Alembic::AbcGeom::ISampleSelector &sample_sel)
561{
562 if (!prop.valid()) {
563 return "";
564 }
565 const PropertyHeader *header = prop.getPropertyHeader(name);
566 if (header && header->isScalar() && Alembic::AbcGeom::IStringProperty::matches(*header)) {
567 Alembic::AbcGeom::IStringProperty active_color_attribute(prop, header->getName());
568 return active_color_attribute.getValue(sample_sel);
569 }
570 return "";
571}
572
574 const ICompoundProperty &user_props,
575 const Alembic::AbcGeom::ISampleSelector &sample_sel)
576{
577 std::string active_color_attribute = get_string_property(
578 user_props, ABC_ACTIVE_COLOR_ATTRIBUTE_PROPNAME, sample_sel);
579 std::string default_color_attribute = get_string_property(
580 user_props, ABC_DEFAULT_COLOR_ATTRIBUTE_PROPNAME, sample_sel);
581
582 StringRefNull first_color_attribute;
583 StringRefNull final_active_color_attribute;
584 StringRefNull final_default_color_attribute;
585
586 mesh.attributes().foreach_attribute([&](const bke::AttributeIter &iter) {
588 return;
589 }
590
592 {
593 return;
594 }
595
596 if (first_color_attribute.is_empty()) {
597 first_color_attribute = iter.name;
598 }
599
600 if (iter.name == active_color_attribute) {
601 final_active_color_attribute = active_color_attribute;
602 }
603 if (iter.name == default_color_attribute) {
604 final_default_color_attribute = default_color_attribute;
605 }
606 });
607
608 if (final_active_color_attribute.is_empty()) {
609 final_active_color_attribute = first_color_attribute;
610 }
611 if (final_default_color_attribute.is_empty()) {
612 final_default_color_attribute = first_color_attribute;
613 }
614
615 if (!final_default_color_attribute.is_empty()) {
616 BKE_id_attributes_default_color_set(&mesh.id, final_default_color_attribute);
617 }
618 if (!final_active_color_attribute.is_empty()) {
619 BKE_id_attributes_active_color_set(&mesh.id, final_active_color_attribute);
620 }
621}
622
623} // namespace io::alembic
624} // namespace blender
Generic geometry attributes built on CustomData.
CustomData interface, see also DNA_customdata_types.h.
#define ELEM(...)
#define STREQ(a, b)
#define MAX_MTFACE
constexpr int64_t size() const
constexpr int64_t start() const
constexpr const T * data() const
Definition BLI_span.hh:219
constexpr const char * c_str() const
GAttributeReader lookup(const StringRef name) const
GSpanAttributeWriter lookup_or_add_for_write_span(StringRef name, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
constexpr bool is_empty() const
constexpr bool is_empty() const
void write_uv_maps(const OCompoundProperty &prop, CDStreamConfig &config, const Mesh &mesh)
AbcUvScope get_uv_scope(const Alembic::AbcGeom::GeometryScope scope, const CDStreamConfig &config, const Alembic::AbcGeom::UInt32ArraySamplePtr &indices)
BLI_INLINE void copy_yup_from_zup(float yup[3], const float zup[3])
void read_velocity(const V3fArraySamplePtr &velocities, const CDStreamConfig &config, const float velocity_scale)
std::string get_valid_abc_name(const char *name)
Definition abc_util.cc:36
static void read_custom_data_mcols(const std::string &iobject_full_name, const ICompoundProperty &arbGeomParams, const PropertyHeader &prop_header, const CDStreamConfig &config, const Alembic::Abc::ISampleSelector &iss)
static void read_uvs(const CDStreamConfig &config, MutableSpan< float2 > uv_map, const AbcUvScope uv_scope, const Alembic::AbcGeom::V2fArraySamplePtr &uvs, const UInt32ArraySamplePtr &indices)
BLI_INLINE void copy_zup_from_yup(float zup[3], const float yup[3])
void read_custom_data(const std::string &iobject_full_name, const ICompoundProperty &prop, const CDStreamConfig &config, const Alembic::Abc::ISampleSelector &iss)
static std::string get_string_property(const ICompoundProperty &prop, const StringRefNull name, const Alembic::AbcGeom::ISampleSelector &sample_sel)
static void read_custom_data_uvs(const ICompoundProperty &prop, const PropertyHeader &prop_header, const CDStreamConfig &config, const Alembic::Abc::ISampleSelector &iss)
void read_generated_coordinates(const ICompoundProperty &prop, const CDStreamConfig &config, const Alembic::Abc::ISampleSelector &iss)
static void get_uvs(const CDStreamConfig &config, std::vector< Imath::V2f > &uvs, std::vector< uint32_t > &uvidx, const Span< float2 > uv_map_array)
void write_generated_coordinates(const OCompoundProperty &prop, CDStreamConfig &config)
const char * get_uv_sample(UVSample &sample, const CDStreamConfig &config, const Mesh &mesh)
static void write_uv(const OCompoundProperty &prop, CDStreamConfig &config, const Span< float2 > data, const std::string &uv_map_name)
static int64_t mcols_out_of_bounds_check(const int64_t color_index, const int64_t array_size, const std::string &iobject_full_name, const PropertyHeader &prop_header, bool &r_is_out_of_bounds, bool &r_bounds_warning_given)
void read_active_and_default_color_attributes(Mesh &mesh, const ICompoundProperty &user_props, const Alembic::AbcGeom::ISampleSelector &sample_sel)
bool index_in_range(const int64_t index, const int64_t size)
BMesh Iterators.
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
__int64 int64_t
Definition BKE_text.h:90
MINLINE unsigned char unit_float_to_uchar_clamp(float val)
void BKE_id_attributes_default_color_set(struct ID *id, std::optional< StringRef > name)
bool CustomData_has_layer(const CustomData *data, eCustomDataType type)
MINLINE void mul_v3_fl(float r[3], float f)
unsigned int uint32_t
Definition BKE_text.h:81
VecBase< float, 2 > float2
BMesh const char void * data
const void * CustomData_get_layer(const CustomData *data, eCustomDataType type)
void BKE_mesh_orco_verts_transform(Mesh *mesh, MutableSpan< float3 > orco, bool invert)
void BKE_id_attributes_active_color_set(struct ID *id, std::optional< StringRef > name)
void * CustomData_get_layer_for_write(CustomData *data, eCustomDataType type, int totelem)
VecBase< float, 3 > float3
ColorSceneLinearByteEncoded4b< eAlpha::Premultiplied > ColorGeometry4b
void * CustomData_add_layer(CustomData *data, eCustomDataType type, eCDAllocType alloctype, int totelem)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
Alembic::AbcGeom::OV3fGeomParam abc_orco
std::map< std::string, Alembic::AbcGeom::OV2fGeomParam > abc_uv_maps