Alembic export: fixed curve type and order.
[blender.git] / source / blender / alembic / intern / abc_curves.cc
index 7e5ea3b1853467650e10f319d42cb0243c51000f..58b8d7e05cd03838b8095c07f13954a282d0a5d9 100644 (file)
@@ -95,14 +95,14 @@ void AbcCurveWriter::do_write()
        for (; nurbs; nurbs = nurbs->next) {
                if (nurbs->bp) {
                        curve_basis = Alembic::AbcGeom::kNoBasis;
-                       curve_type = Alembic::AbcGeom::kLinear;
+                       curve_type = Alembic::AbcGeom::kVariableOrder;
 
                        const int totpoint = nurbs->pntsu * nurbs->pntsv;
 
                        const BPoint *point = nurbs->bp;
 
                        for (int i = 0; i < totpoint; ++i, ++point) {
-                               copy_zup_yup(temp_vert.getValue(), point->vec);
+                               copy_yup_from_zup(temp_vert.getValue(), point->vec);
                                verts.push_back(temp_vert);
                                weights.push_back(point->vec[3]);
                                widths.push_back(point->radius);
@@ -118,7 +118,7 @@ void AbcCurveWriter::do_write()
 
                        /* TODO(kevin): store info about handles, Alembic doesn't have this. */
                        for (int i = 0; i < totpoint; ++i, ++bezier) {
-                               copy_zup_yup(temp_vert.getValue(), bezier->vec[1]);
+                               copy_yup_from_zup(temp_vert.getValue(), bezier->vec[1]);
                                verts.push_back(temp_vert);
                                widths.push_back(bezier->radius);
                        }
@@ -160,7 +160,7 @@ void AbcCurveWriter::do_write()
                        }
                }
 
-               orders.push_back(nurbs->orderu + 1);
+               orders.push_back(nurbs->orderu);
                vert_counts.push_back(verts.size());
        }
 
@@ -205,6 +205,7 @@ void AbcCurveReader::readObjectData(Main *bmain, float time)
 
        cu->flag |= CU_DEFORM_FILL | CU_3D;
        cu->actvert = CU_ACT_NONE;
+       cu->resolu = 1;
 
        m_object = BKE_object_add_only_object(bmain, OB_CURVE, m_object_name.c_str());
        m_object->data = cu;
@@ -250,13 +251,18 @@ void read_curve_sample(Curve *cu, const ICurvesSchema &schema, const float time)
                nu->pntsv = 1;
                nu->flag |= CU_SMOOTH;
 
-               nu->orderu = num_verts;
-
-               if (smp.getType() == Alembic::AbcGeom::kCubic) {
-                       nu->orderu = 3;
-               }
-               else if (orders && orders->size() > i) {
-                       nu->orderu = static_cast<short>((*orders)[i] - 1);
+               switch (smp.getType()) {
+                       case Alembic::AbcGeom::kCubic:
+                               nu->orderu = 4;
+                               break;
+                       case Alembic::AbcGeom::kVariableOrder:
+                               if (orders && orders->size() > i) {
+                                       nu->orderu = static_cast<short>((*orders)[i]);
+                               }
+                               break;
+                       case Alembic::AbcGeom::kLinear:
+                       default:
+                               nu->orderu = 2;
                }
 
                if (periodicity == Alembic::AbcGeom::kNonPeriodic) {
@@ -322,7 +328,7 @@ void read_curve_sample(Curve *cu, const ICurvesSchema &schema, const float time)
                                weight = (*weights)[idx];
                        }
 
-                       copy_yup_zup(bp->vec, pos.getValue());
+                       copy_zup_from_yup(bp->vec, pos.getValue());
                        bp->vec[3] = weight;
                        bp->f1 = SELECT;
                        bp->radius = radius;
@@ -361,7 +367,7 @@ void read_curve_sample(Curve *cu, const ICurvesSchema &schema, const float time)
  * object directly and create a new DerivedMesh from that. Also we might need to
  * create new or delete existing NURBS in the curve.
  */
-DerivedMesh *AbcCurveReader::read_derivedmesh(DerivedMesh */*dm*/, const float time, int /*read_flag*/)
+DerivedMesh *AbcCurveReader::read_derivedmesh(DerivedMesh * /*dm*/, const float time, int /*read_flag*/, const char ** /*err_str*/)
 {
        ISampleSelector sample_sel(time);
        const ICurvesSchema::Sample sample = m_curves_schema.getValue(sample_sel);
@@ -389,7 +395,7 @@ DerivedMesh *AbcCurveReader::read_derivedmesh(DerivedMesh */*dm*/, const float t
 
                                for (int i = 0; i < totpoint; ++i, ++point, ++vertex_idx) {
                                        const Imath::V3f &pos = (*positions)[vertex_idx];
-                                       copy_yup_zup(point->vec, pos.getValue());
+                                       copy_zup_from_yup(point->vec, pos.getValue());
                                }
                        }
                        else if (nurbs->bezt) {
@@ -397,7 +403,7 @@ DerivedMesh *AbcCurveReader::read_derivedmesh(DerivedMesh */*dm*/, const float t
 
                                for (int i = 0; i < totpoint; ++i, ++bezier, ++vertex_idx) {
                                        const Imath::V3f &pos = (*positions)[vertex_idx];
-                                       copy_yup_zup(bezier->vec[1], pos.getValue());
+                                       copy_zup_from_yup(bezier->vec[1], pos.getValue());
                                }
                        }
                }