Blender V5.3
abc_customdata.h
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#pragma once
5
9
11
12#include <Alembic/Abc/ICompoundProperty.h>
13#include <Alembic/Abc/ISampleSelector.h>
14#include <Alembic/Abc/OCompoundProperty.h>
15#include <Alembic/Abc/TypedArraySample.h>
16#include <Alembic/AbcCoreAbstract/Foundation.h>
17#include <Alembic/AbcGeom/GeometryScope.h>
18#include <Alembic/AbcGeom/OGeomParam.h>
19
20#include "BKE_attribute.hh"
21
22#include <cstdint>
23#include <map>
24#include <string>
25#include <vector>
26
27namespace blender {
28
29struct CustomData;
30struct Mesh;
31
32using Alembic::Abc::ICompoundProperty;
33using Alembic::Abc::OCompoundProperty;
34using Alembic::Abc::UInt32ArraySamplePtr;
35using Alembic::Abc::V2fArraySamplePtr;
36using Alembic::Abc::V3fArraySamplePtr;
37
38namespace io::alembic {
39
40struct UVSample {
41 std::vector<Imath::V2f> uvs;
42 std::vector<uint32_t> indices;
43};
44
50
52 int *corner_verts = nullptr;
53 int totloop = 0;
54
55 int *face_offsets = nullptr;
56 int faces_num = 0;
57
58 float3 *positions = nullptr;
59 int totvert = 0;
60
62
63 bool pack_uvs = false;
64
65 /* TODO(kevin): might need a better way to handle adding and/or updating
66 * custom data such that it updates the custom data holder and its pointers properly. */
67 Mesh *mesh = nullptr;
68
69 Alembic::Abc::chrono_t time = 0.0;
71
72 const char **modifier_error_message = nullptr;
73
74 /* Alembic needs Blender to keep references to C++ objects (the destructors finalize the writing
75 * to ABC). The following fields are all used to keep these references. */
76
77 /* Mapping from UV map name to its ABC property, for the 2nd and subsequent UV maps; the primary
78 * UV map is kept alive by the Alembic mesh sample itself. */
79 std::map<std::string, Alembic::AbcGeom::OV2fGeomParam> abc_uv_maps;
80
81 /* ORCO coordinates, aka Generated Coordinates. */
82 Alembic::AbcGeom::OV3fGeomParam abc_orco;
83
85 V2fArraySamplePtr uvs;
86 UInt32ArraySamplePtr uvs_indices;
87
88 CDStreamConfig() = default;
89};
90
91/* Get the UVs for the main UV property on a OSchema.
92 * Returns the name of the UV layer.
93 *
94 * For now the active layer is used, maybe needs a better way to choose this. */
95const char *get_uv_sample(UVSample &sample, const CDStreamConfig &config, const Mesh &mesh);
96
97void write_generated_coordinates(const OCompoundProperty &prop, CDStreamConfig &config);
98
99void read_velocity(const V3fArraySamplePtr &velocities,
100 const CDStreamConfig &config,
101 const float velocity_scale);
102
103void read_generated_coordinates(const ICompoundProperty &prop,
104 const CDStreamConfig &config,
105 const Alembic::Abc::ISampleSelector &iss);
106
107void write_uv_maps(const OCompoundProperty &prop, CDStreamConfig &config, const Mesh &mesh);
108
109void read_custom_data(const std::string &iobject_full_name,
110 const ICompoundProperty &prop,
111 const CDStreamConfig &config,
112 const Alembic::Abc::ISampleSelector &iss);
113
122AbcUvScope get_uv_scope(const Alembic::AbcGeom::GeometryScope scope,
123 const CDStreamConfig &config,
124 const Alembic::AbcGeom::UInt32ArraySamplePtr &indices);
125
132 const ICompoundProperty &user_props,
133 const Alembic::AbcGeom::ISampleSelector &sample_sel);
134
135} // namespace io::alembic
136} // namespace blender
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)
void read_velocity(const V3fArraySamplePtr &velocities, const CDStreamConfig &config, const float velocity_scale)
void read_custom_data(const std::string &iobject_full_name, const ICompoundProperty &prop, const CDStreamConfig &config, const Alembic::Abc::ISampleSelector &iss)
void read_generated_coordinates(const ICompoundProperty &prop, const CDStreamConfig &config, const Alembic::Abc::ISampleSelector &iss)
void write_generated_coordinates(const OCompoundProperty &prop, CDStreamConfig &config)
const char * get_uv_sample(UVSample &sample, const CDStreamConfig &config, const Mesh &mesh)
void read_active_and_default_color_attributes(Mesh &mesh, const ICompoundProperty &user_props, const Alembic::AbcGeom::ISampleSelector &sample_sel)
BMesh Iterators.
VecBase< float, 3 > float3
bke::SpanAttributeWriter< float2 > uv_map
Alembic::AbcGeom::OV3fGeomParam abc_orco
std::map< std::string, Alembic::AbcGeom::OV2fGeomParam > abc_uv_maps
std::vector< Imath::V2f > uvs
std::vector< uint32_t > indices