Blender  V3.3
abc_customdata.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2016 Kévin Dietrich. All rights reserved. */
3 #pragma once
4 
9 #include <Alembic/Abc/All.h>
10 #include <Alembic/AbcGeom/All.h>
11 
12 #include <map>
13 
14 struct CustomData;
15 struct MLoop;
16 struct MLoopUV;
17 struct MPoly;
18 struct MVert;
19 struct Mesh;
20 
21 using Alembic::Abc::ICompoundProperty;
22 using Alembic::Abc::OCompoundProperty;
23 namespace blender::io::alembic {
24 
25 struct UVSample {
26  std::vector<Imath::V2f> uvs;
27  std::vector<uint32_t> indices;
28 };
29 
32  int totloop;
33 
35  int totpoly;
36 
38  int totvert;
39 
41 
43 
44  bool pack_uvs;
45 
46  /* TODO(kevin): might need a better way to handle adding and/or updating
47  * custom data such that it updates the custom data holder and its pointers properly. */
49  void *(*add_customdata_cb)(Mesh *mesh, const char *name, int data_type);
50 
51  double weight;
52  Alembic::Abc::chrono_t time;
55  Alembic::AbcGeom::index_t index;
56  Alembic::AbcGeom::index_t ceil_index;
57 
58  const char **modifier_error_message;
59 
60  /* Alembic needs Blender to keep references to C++ objects (the destructors finalize the writing
61  * to ABC). The following fields are all used to keep these references. */
62 
63  /* Mapping from UV map name to its ABC property, for the 2nd and subsequent UV maps; the primary
64  * UV map is kept alive by the Alembic mesh sample itself. */
65  std::map<std::string, Alembic::AbcGeom::OV2fGeomParam> abc_uv_maps;
66 
67  /* ORCO coordinates, aka Generated Coordinates. */
68  Alembic::AbcGeom::OV3fGeomParam abc_orco;
69 
70  /* Mapping from vertex color layer name to its Alembic color data. */
71  std::map<std::string, Alembic::AbcGeom::OC4fGeomParam> abc_vertex_colors;
72 
74  : mloop(NULL),
75  totloop(0),
76  mpoly(NULL),
77  totpoly(0),
78  totvert(0),
79  pack_uvs(false),
80  mesh(NULL),
82  weight(0.0),
83  time(0.0),
84  index(0),
85  ceil_index(0),
87  {
88  }
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. */
95 const char *get_uv_sample(UVSample &sample, const CDStreamConfig &config, CustomData *data);
96 
97 void write_generated_coordinates(const OCompoundProperty &prop, CDStreamConfig &config);
98 
99 void read_generated_coordinates(const ICompoundProperty &prop,
100  const CDStreamConfig &config,
101  const Alembic::Abc::ISampleSelector &iss);
102 
103 void write_custom_data(const OCompoundProperty &prop,
104  CDStreamConfig &config,
105  CustomData *data,
106  int data_type);
107 
108 void read_custom_data(const std::string &iobject_full_name,
109  const ICompoundProperty &prop,
110  const CDStreamConfig &config,
111  const Alembic::Abc::ISampleSelector &iss);
112 
113 typedef enum {
117 } AbcUvScope;
118 
127 AbcUvScope get_uv_scope(const Alembic::AbcGeom::GeometryScope scope,
128  const CDStreamConfig &config,
129  const Alembic::AbcGeom::UInt32ArraySamplePtr &indices);
130 
131 } // namespace blender::io::alembic
ccl_gpu_kernel_postfix int ccl_global int * indices
AbcUvScope get_uv_scope(const Alembic::AbcGeom::GeometryScope scope, const CDStreamConfig &config, const Alembic::AbcGeom::UInt32ArraySamplePtr &indices)
const char * get_uv_sample(UVSample &sample, const CDStreamConfig &config, CustomData *data)
void write_custom_data(const OCompoundProperty &prop, CDStreamConfig &config, CustomData *data, int data_type)
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)
Alembic::AbcGeom::index_t index
Alembic::AbcGeom::index_t ceil_index
std::map< std::string, Alembic::AbcGeom::OC4fGeomParam > abc_vertex_colors
void *(* add_customdata_cb)(Mesh *mesh, const char *name, int data_type)
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