From 90dc71a478c3ce18d88ef2aa6cf9a2efa93fd1dc Mon Sep 17 00:00:00 2001 From: Francois Beaune Date: Tue, 29 Jul 2014 23:31:54 +0200 Subject: [PATCH] support per-control point width in temporary curve file format. --- .../renderer/modeling/object/curveobject.cpp | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/appleseed/renderer/modeling/object/curveobject.cpp b/src/appleseed/renderer/modeling/object/curveobject.cpp index dd51a5eb5a..7c1ffcf83d 100644 --- a/src/appleseed/renderer/modeling/object/curveobject.cpp +++ b/src/appleseed/renderer/modeling/object/curveobject.cpp @@ -167,8 +167,6 @@ struct CurveObject::Impl void load_curve_file(const char* filepath) { - const double CurveWidth = 0.009; - ifstream input; input.open(filepath); @@ -185,7 +183,16 @@ struct CurveObject::Impl size_t control_point_count; input >> control_point_count; + if (control_point_count != 4) + { + RENDERER_LOG_ERROR( + "while loading curve file %s: only curves with 4 control points are currently supported.", + filepath); + return; + } + vector points(control_point_count); + vector widths(control_point_count); m_curves.reserve(curve_count); @@ -193,15 +200,16 @@ struct CurveObject::Impl { for (size_t p = 0; p < control_point_count; ++p) { - Vector3d point; - input >> point.x >> point.y >> point.z; - points[p] = point; + input >> points[p].x >> points[p].y >> points[p].z; + input >> widths[p]; } - const BezierCurve3d curve(&points[0], CurveWidth); + const BezierCurve3d curve(&points[0], &widths[0]); m_curves.push_back(curve); } + input.close(); + stopwatch.measure(); RENDERER_LOG_INFO( @@ -209,8 +217,6 @@ struct CurveObject::Impl filepath, pretty_uint(curve_count).c_str(), pretty_time(stopwatch.get_seconds()).c_str()); - - input.close(); } else {