31using Alembic::AbcGeom::OCompoundProperty;
32using Alembic::AbcGeom::OCurves;
33using Alembic::AbcGeom::OCurvesSchema;
34using Alembic::AbcGeom::OInt16Property;
35using Alembic::AbcGeom::ON3fGeomParam;
36using Alembic::AbcGeom::OV2fGeomParam;
55 abc_curve_schema_ = abc_curve_.getSchema();
62 switch (context->object->type) {
64 Curve *curves_id =
static_cast<Curve *
>(context->object->data);
65 resolution_u = curves_id->
resolu;
69 Curves *curves_id =
static_cast<Curves *
>(context->object->data);
76 OCompoundProperty user_props = abc_curve_schema_.getUserProperties();
78 user_prop_resolu.set(resolution_u);
94 std::unique_ptr<
Curves, std::function<void(
Curves *)>> converted_curves;
96 switch (context.object->type) {
98 const Curve *legacy_curve =
static_cast<Curve *
>(context.object->data);
99 converted_curves = std::unique_ptr<
Curves, std::function<void(
Curves *)>>(
101 curves_id = converted_curves.get();
105 curves_id =
static_cast<Curves *
>(context.object->data);
119 const std::array<int, CURVE_TYPES_NUM> &curve_type_counts = curves.
curve_type_counts();
120 const int number_of_curve_types = std::count_if(curve_type_counts.begin(),
121 curve_type_counts.end(),
122 [](
const int count) { return count > 0; });
123 if (number_of_curve_types > 1) {
124 CLOG_WARN(&
LOG,
"Cannot export mixed curve types in the same Curves object");
129 CLOG_WARN(&
LOG,
"Cannot export mixed cyclic and non-cyclic curves in the same Curves object");
134 Alembic::AbcGeom::BasisType curve_basis = Alembic::AbcGeom::kNoBasis;
135 Alembic::AbcGeom::CurveType curve_type = Alembic::AbcGeom::kLinear;
136 Alembic::AbcGeom::CurvePeriodicity periodicity =
is_cyclic ? Alembic::AbcGeom::kPeriodic :
137 Alembic::AbcGeom::kNonPeriodic;
139 switch (blender_curve_type) {
141 curve_basis = Alembic::AbcGeom::kNoBasis;
142 curve_type = Alembic::AbcGeom::kLinear;
145 curve_basis = Alembic::AbcGeom::kCatmullromBasis;
146 curve_type = Alembic::AbcGeom::kLinear;
149 curve_basis = Alembic::AbcGeom::kBezierBasis;
150 curve_type = Alembic::AbcGeom::kCubic;
153 curve_basis = Alembic::AbcGeom::kBsplineBasis;
154 curve_type = Alembic::AbcGeom::kVariableOrder;
158 std::vector<Imath::V3f>
verts;
159 std::vector<int32_t> vert_counts;
160 std::vector<float> widths;
161 std::vector<float> weights;
162 std::vector<float> knots;
163 std::vector<uint8_t> orders;
177 const IndexRange points = points_by_curve[i_curve];
178 const size_t current_vert_count =
verts.size();
180 const int start_point_index = points.
first();
181 const int last_point_index = points.
last();
189 for (
const int i_point : points.
drop_back(1)) {
191 widths.push_back(radii[i_point] * 2.0f);
200 widths.push_back(radii[last_point_index] * 2.0f);
209 vert_counts[i_curve] =
verts.size() - current_vert_count;
217 widths[i_point] = radii[i_point] * 2.0f;
222 std::copy_n(nurbs_weights.
data(), weights.size(), weights.data());
226 orders[i_curve] = nurbs_orders[i_curve];
233 Alembic::AbcGeom::OFloatGeomParam::Sample width_sample;
234 width_sample.setVals(widths);
241 OV2fGeomParam::Sample(),
242 ON3fGeomParam::Sample(),
250 abc_curve_schema_.set(
sample);
260 switch (object_eval->
type) {
263 if (mesh_eval !=
nullptr) {
Low-level operations for curves.
void BKE_id_free(Main *bmain, void *idv)
Mesh * BKE_mesh_new_nomain_from_curve(const Object *ob)
General operations, lookup, etc. for blender objects.
Mesh * BKE_object_get_evaluated_mesh(const Object *object_eval)
#define BLI_assert_unreachable()
#define CLOG_WARN(clg_ref,...)
#define CLOG_INFO(clg_ref, level,...)
Object is a sort of wrapper for general info.
ATTR_WARN_UNUSED_RESULT const BMVert * v
constexpr int64_t first() const
constexpr IndexRange drop_back(int64_t n) const
constexpr int64_t last(const int64_t n=0) const
constexpr const T * data() const
OffsetIndices< int > points_by_curve() const
IndexRange curves_range() const
const std::array< int, CURVE_TYPES_NUM > & curve_type_counts() const
VArray< float > radius() const
Span< float > nurbs_weights() const
Span< float3 > handle_positions_left() const
VArray< int > resolution() const
IndexRange points_range() const
Span< float3 > positions() const
Span< float3 > handle_positions_right() const
VArray< int8_t > curve_types() const
VArray< bool > cyclic() const
VArray< int8_t > nurbs_orders() const
ABCAbstractWriter(const ABCWriterConstructorArgs &args)
Alembic::Abc::OCompoundProperty abc_schema_prop_for_custom_props(T abc_schema)
uint32_t timesample_index_
Imath::Box3d bounding_box_
const ABCWriterConstructorArgs args_
virtual void update_bounding_box(Object *object)
Mesh * get_export_mesh(Object *object_eval, bool &r_needsfree) override
ABCCurveMeshWriter(const ABCWriterConstructorArgs &args)
Alembic::Abc::OObject get_alembic_object() const override
ABCCurveWriter(const ABCWriterConstructorArgs &args)
void create_alembic_objects(const HierarchyContext *context) override
void do_write(HierarchyContext &context) override
Alembic::Abc::OCompoundProperty abc_prop_for_custom_props() override
ABCGenericMeshWriter(const ABCWriterConstructorArgs &args)
IndexRange index_range() const
static bool is_cyclic(const Nurb *nu)
BooleanMix booleans_mix_calc(const VArray< bool > &varray, IndexRange range_to_check)
Curves * curve_legacy_to_curves(const Curve &curve_legacy)
Mesh * curve_to_wire_mesh(const CurvesGeometry &curve, const bke::AttributeFilter &attribute_filter={})
BLI_INLINE void copy_yup_from_zup(float yup[3], const float zup[3])
static Imath::V3f to_yup_V3f(float3 v)
const std::string ABC_CURVE_RESOLUTION_U_PROPNAME
void copy_group_sizes(OffsetIndices< int > offsets, const IndexMask &mask, MutableSpan< int > sizes)
VecBase< float, 3 > float3