Blender V4.3
abc_reader_object.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4#pragma once
5
10#include <Alembic/Abc/IObject.h>
11#include <Alembic/Abc/ISampleSelector.h>
12#include <Alembic/AbcCoreAbstract/Foundation.h>
13#include <Alembic/AbcCoreAbstract/ObjectHeader.h>
14#include <Alembic/AbcGeom/IXform.h>
15
16#include <string>
17#include <vector>
18
19struct CacheFile;
20struct Main;
21struct Mesh;
22struct Object;
23
24namespace blender::bke {
25struct GeometrySet;
26}
27
28using Alembic::AbcCoreAbstract::chrono_t;
29
30namespace blender::io::alembic {
31
34 float conversion_mat[4][4];
35
38 float scale;
41
42 /* Min and max frame detected from file sequences. */
45
46 /* From MeshSeqCacheModifierData.read_flag */
48
49 /* From CacheFile and MeshSeqCacheModifierData */
50 std::string velocity_name;
52
55
57
75};
76
77template<typename Schema> static bool has_animations(Schema &schema, ImportSettings *settings)
78{
79 return settings->is_sequence || !schema.isConstant();
80}
81
83 protected:
84 std::string m_name;
85 std::string m_object_name;
86 std::string m_data_name;
88 Alembic::Abc::IObject m_iobject;
89
90 /* XXX - TODO(kevindietrich) : this references stack memory... */
92 /* This is initialized from the ImportSettings above on construction. It will need to be removed
93 * once we fix the stack memory reference situation. */
95
96 chrono_t m_min_time;
97 chrono_t m_max_time;
98
99 /* Use reference counting since the same reader may be used by multiple
100 * modifiers and/or constraints. */
102
104
105 public:
107
108 public:
109 explicit AbcObjectReader(const Alembic::Abc::IObject &object, ImportSettings &settings);
110
111 virtual ~AbcObjectReader() = default;
112
113 const Alembic::Abc::IObject &iobject() const;
114
115 typedef std::vector<AbcObjectReader *> ptr_vector;
116
121 virtual Alembic::AbcGeom::IXform xform();
122
123 Object *object() const;
124 void object(Object *ob);
125
126 const std::string &name() const
127 {
128 return m_name;
129 }
130 const std::string &object_name() const
131 {
132 return m_object_name;
133 }
134 const std::string &data_name() const
135 {
136 return m_data_name;
137 }
138 bool inherits_xform() const
139 {
140 return m_inherits_xform;
141 }
142
143 virtual bool valid() const = 0;
144 virtual bool accepts_object_type(const Alembic::AbcCoreAbstract::ObjectHeader &alembic_header,
145 const Object *const ob,
146 const char **r_err_str) const = 0;
147
148 virtual void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel) = 0;
149
150 virtual void read_geometry(bke::GeometrySet &geometry_set,
151 const Alembic::Abc::ISampleSelector &sample_sel,
152 int read_flag,
153 const char *velocity_name,
154 float velocity_scale,
155 const char **r_err_str);
156
157 virtual bool topology_changed(const Mesh *existing_mesh,
158 const Alembic::Abc::ISampleSelector &sample_sel);
159
161 void setupObjectTransform(chrono_t time);
162
163 void addCacheModifier();
164
165 chrono_t minTime() const;
166 chrono_t maxTime() const;
167
168 int refcount() const;
169 void incref();
170 void decref();
171
172 void read_matrix(float r_mat[4][4], chrono_t time, float scale, bool &is_constant);
173
174 protected:
177};
178
179Imath::M44d get_matrix(const Alembic::AbcGeom::IXformSchema &schema, chrono_t time);
180
181} // namespace blender::io::alembic
const std::string & object_name() const
AbcObjectReader(const Alembic::Abc::IObject &object, ImportSettings &settings)
void read_matrix(float r_mat[4][4], chrono_t time, float scale, bool &is_constant)
const Alembic::Abc::IObject & iobject() const
virtual bool accepts_object_type(const Alembic::AbcCoreAbstract::ObjectHeader &alembic_header, const Object *const ob, const char **r_err_str) const =0
virtual bool topology_changed(const Mesh *existing_mesh, const Alembic::Abc::ISampleSelector &sample_sel)
virtual Alembic::AbcGeom::IXform xform()
const std::string & data_name() const
virtual void read_geometry(bke::GeometrySet &geometry_set, const Alembic::Abc::ISampleSelector &sample_sel, int read_flag, const char *velocity_name, float velocity_scale, const char **r_err_str)
virtual void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel)=0
std::vector< AbcObjectReader * > ptr_vector
#define NULL
Imath::M44d get_matrix(const IXformSchema &schema, const chrono_t time)
bool has_animations(Alembic::AbcGeom::IPolyMeshSchema &schema, ImportSettings *settings)