From 44ed91958c9b0e4829b17cf2deb27b14c87bbccc Mon Sep 17 00:00:00 2001 From: Franz Beaune Date: Wed, 18 Jan 2017 08:38:10 +0100 Subject: [PATCH 1/4] Tweak unit tests --- .../meta/tests/test_beziercurve.cpp | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/appleseed/foundation/meta/tests/test_beziercurve.cpp b/src/appleseed/foundation/meta/tests/test_beziercurve.cpp index 48ae205df2..9bd0d8c559 100644 --- a/src/appleseed/foundation/meta/tests/test_beziercurve.cpp +++ b/src/appleseed/foundation/meta/tests/test_beziercurve.cpp @@ -68,8 +68,8 @@ TEST_SUITE(Foundation_Math_BezierCurveIntersector) typedef RayInfo RayInfoType; typedef BezierCurveIntersector BezierCurveIntersectorType; - const size_t ImageWidth = 500; - const size_t ImageHeight = 500; + const size_t ImageWidth = 512; + const size_t ImageHeight = 512; const ValueType RcpImageWidth = ValueType(1.0) / ImageWidth; const ValueType RcpImageHeight = ValueType(1.0) / ImageHeight; @@ -82,7 +82,7 @@ TEST_SUITE(Foundation_Math_BezierCurveIntersector) { Color3f color(0.0f); - // Compute the coordinates of the center of the pixel. + // Compute the normalized coordinates of the center of the pixel in [-1,1]^2. const ValueType pix_x = (ValueType(2.0) * x + ValueType(1.0)) * RcpImageWidth - ValueType(1.0); const ValueType pix_y = ValueType(1.0) - (ValueType(2.0) * y + ValueType(1.0)) * RcpImageHeight; @@ -283,7 +283,7 @@ TEST_SUITE(Foundation_Math_BezierCurveIntersector) // Check continuity across connected Bezier curves. // - TEST_CASE(RenderMultipleBezier1Curves) + TEST_CASE(RenderTwoConnectedBezier1Curves) { const Vector3f ControlPoints1[] = { Vector3f(-0.5f, -0.5f, 0.0f), Vector3f(0.0f, 0.0f, 0.0f) }; const Vector3f ControlPoints2[] = { Vector3f(0.0f, 0.0f, 0.0f), Vector3f(0.5f, 0.5f, 0.0f) }; @@ -293,10 +293,10 @@ TEST_SUITE(Foundation_Math_BezierCurveIntersector) BezierCurve1f(ControlPoints2, 0.06f) }; - render_curves_to_image(Curves, countof(Curves), "unit tests/outputs/test_beziercurveintersector_multiplebezier1curves.png", false); + render_curves_to_image(Curves, countof(Curves), "unit tests/outputs/test_beziercurveintersector_twoconnectedbezier1curves.png", false); } - TEST_CASE(RenderMultipleBezier1Curves_VariableWidth) + TEST_CASE(RenderTwoConnectedBezier1Curves_VariableWidth) { const Vector3f ControlPoints1[] = { Vector3f(-0.5f, -0.5f, 0.0f), Vector3f(0.0f, 0.0f, 0.0f) }; const Vector3f ControlPoints2[] = { Vector3f(0.0f, 0.0f, 0.0f), Vector3f(0.5f, 0.5f, 0.0f) }; @@ -308,10 +308,10 @@ TEST_SUITE(Foundation_Math_BezierCurveIntersector) BezierCurve1f(ControlPoints2, Widths2) }; - render_curves_to_image(Curves, countof(Curves), "unit tests/outputs/test_beziercurveintersector_multiplebezier1curves_variablewidth.png", false); + render_curves_to_image(Curves, countof(Curves), "unit tests/outputs/test_beziercurveintersector_twoconnectedbezier1curves_variablewidth.png", false); } - TEST_CASE(RenderMultipleBezier2Curves) + TEST_CASE(RenderTwoConnectedBezier2Curves) { const Vector3f ControlPoints1[] = { Vector3f(-0.7f, 0.0f, 0.0f), Vector3f(-0.4f, 0.5f, 0.0f), Vector3f(0.0f, 0.0f, 0.0f) }; const Vector3f ControlPoints2[] = { Vector3f(0.0f, 0.0f, 0.0f), Vector3f(0.4f, -0.5f, 0.0f), Vector3f(0.7f, 0.0f, 0.0f) }; @@ -321,10 +321,10 @@ TEST_SUITE(Foundation_Math_BezierCurveIntersector) BezierCurve2f(ControlPoints2, 0.06f) }; - render_curves_to_image(Curves, countof(Curves), "unit tests/outputs/test_beziercurveintersector_multiplebezier2curves.png", false); + render_curves_to_image(Curves, countof(Curves), "unit tests/outputs/test_beziercurveintersector_twoconnectedbezier2curves.png", false); } - TEST_CASE(RenderMultipleBezier2Curves_VariableWidth) + TEST_CASE(RenderTwoConnectedBezier2Curves_VariableWidth) { const Vector3f ControlPoints1[] = { Vector3f(-0.7f, 0.0f, 0.0f), Vector3f(-0.4f, 0.5f, 0.0f), Vector3f(0.0f, 0.0f, 0.0f) }; const Vector3f ControlPoints2[] = { Vector3f(0.0f, 0.0f, 0.0f), Vector3f(0.4f, -0.5f, 0.0f), Vector3f(0.7f, 0.0f, 0.0f) }; @@ -335,10 +335,10 @@ TEST_SUITE(Foundation_Math_BezierCurveIntersector) BezierCurve2f(ControlPoints2, Widths) }; - render_curves_to_image(Curves, countof(Curves), "unit tests/outputs/test_beziercurveintersector_multiplebezier2curves_variablewidth.png", false); + render_curves_to_image(Curves, countof(Curves), "unit tests/outputs/test_beziercurveintersector_twoconnectedbezier2curves_variablewidth.png", false); } - TEST_CASE(RenderMultipleBezier3Curves) + TEST_CASE(RenderTwoConnectedBezier3Curves) { const Vector3f ControlPoints1[] = { Vector3f(-0.7f, 0.0f, 0.0f), Vector3f(-0.2f, 0.5f, 0.0f), Vector3f(-0.5f, -0.5f, 0.0f), Vector3f(0.0f, 0.0f, 0.0f) }; const Vector3f ControlPoints2[] = { Vector3f(0.0f, 0.0f, 0.0f), Vector3f(0.5f, 0.5f, 0.0f), Vector3f(0.2f, -0.5f, 0.0f), Vector3f(0.7f, 0.0f, 0.0f) }; @@ -348,10 +348,10 @@ TEST_SUITE(Foundation_Math_BezierCurveIntersector) BezierCurve3f(ControlPoints2, 0.06f) }; - render_curves_to_image(Curves, countof(Curves), "unit tests/outputs/test_beziercurveintersector_multiplebezier3curves.png", false); + render_curves_to_image(Curves, countof(Curves), "unit tests/outputs/test_beziercurveintersector_twoconnectedbezier3curves.png", false); } - TEST_CASE(RenderMultipleBezier3Curves_VariableWidth) + TEST_CASE(RenderTwoConnectedBezier3Curves_VariableWidth) { const Vector3f ControlPoints1[] = { Vector3f(-0.7f, 0.0f, 0.0f), Vector3f(-0.2f, 0.5f, 0.0f), Vector3f(-0.5f, -0.5f, 0.0f), Vector3f(0.0f, 0.0f, 0.0f) }; const Vector3f ControlPoints2[] = { Vector3f(0.0f, 0.0f, 0.0f), Vector3f(0.5f, 0.5f, 0.0f), Vector3f(0.2f, -0.5f, 0.0f), Vector3f(0.7f, 0.0f, 0.0f) }; From a5b604ba0bb3ac73d1a4c06e67b66e057e28f9f3 Mon Sep 17 00:00:00 2001 From: Franz Beaune Date: Wed, 18 Jan 2017 08:38:46 +0100 Subject: [PATCH 2/4] Add test drawing multiple connected Bezier curves --- .../meta/tests/test_beziercurve.cpp | 43 ++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/appleseed/foundation/meta/tests/test_beziercurve.cpp b/src/appleseed/foundation/meta/tests/test_beziercurve.cpp index 9bd0d8c559..5a43b73a1e 100644 --- a/src/appleseed/foundation/meta/tests/test_beziercurve.cpp +++ b/src/appleseed/foundation/meta/tests/test_beziercurve.cpp @@ -42,6 +42,7 @@ // Standard headers. #include #include +#include using namespace foundation; using namespace std; @@ -362,7 +363,47 @@ TEST_SUITE(Foundation_Math_BezierCurveIntersector) BezierCurve3f(ControlPoints2, Widths) }; - render_curves_to_image(Curves, countof(Curves), "unit tests/outputs/test_beziercurveintersector_multiplebezier3curves_variablewidth.png", false); + render_curves_to_image(Curves, countof(Curves), "unit tests/outputs/test_beziercurveintersector_twoconnectedbezier3curves_variablewidth.png", false); + } + + TEST_CASE(RenderMultipleBezier3Curves) + { + const Vector3f ControlPoints[] = + { + Vector3f(-0.827751f, -0.269373f, 0.0f), + Vector3f(-0.614035f, 0.557196f, 0.0f), + Vector3f(-0.298246f, -0.505535f, 0.0f), + Vector3f(-0.094099f, 0.586716f, 0.0f), + Vector3f( 0.199362f, -0.173432f, 0.0f), + Vector3f( 0.416268f, 0.704797f, 0.0f), + Vector3f( 0.642743f, -0.682657f, 0.0f), + Vector3f( 0.897927f, 0.468635f, 0.0f) + }; + + // + // Create a new set of control points by adding midpoints between every other pairs + // of control points. See http://stackoverflow.com/a/3516110/393756 for details. + // + + vector new_points; + + for (size_t i = 0; i < countof(ControlPoints); ++i) + { + new_points.push_back(ControlPoints[i]); + + if (i > 0 && i % 2 == 0 && i + 1 < countof(ControlPoints)) + { + // Add a midpoint. + new_points.push_back(0.5f * (ControlPoints[i] + ControlPoints[i + 1])); + } + } + + vector curves; + + for (size_t i = 0, e = new_points.size(); i + 3 < e; i += 3) + curves.push_back(BezierCurve3f(&new_points[i], 0.05f)); + + render_curves_to_image(&curves[0], curves.size(), "unit tests/outputs/test_beziercurveintersector_multiplebezier3curves.png", false); } From e96aae0b135ca0d22e6d9b31b48188a2f8352c7f Mon Sep 17 00:00:00 2001 From: Franz Beaune Date: Wed, 18 Jan 2017 10:13:06 +0100 Subject: [PATCH 3/4] Code tweak --- src/appleseed/renderer/modeling/display/display.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/appleseed/renderer/modeling/display/display.cpp b/src/appleseed/renderer/modeling/display/display.cpp index 94d6fddb86..bbe52d0ab2 100644 --- a/src/appleseed/renderer/modeling/display/display.cpp +++ b/src/appleseed/renderer/modeling/display/display.cpp @@ -113,7 +113,7 @@ bool Display::open(const Project& project) } catch (const ExceptionDictionaryKeyNotFound&) { - RENDERER_LOG_ERROR("%s", "cannot open display: missing plugin_name parameter."); + RENDERER_LOG_ERROR("cannot open display: missing \"plugin_name\" parameter."); return false; } From 1119d63cd77134a4454609a6e74d39bcf0ae1fd4 Mon Sep 17 00:00:00 2001 From: Franz Beaune Date: Thu, 19 Jan 2017 11:49:40 +0100 Subject: [PATCH 4/4] Fix typo in label --- src/appleseed/renderer/modeling/bsdf/glassbsdf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/appleseed/renderer/modeling/bsdf/glassbsdf.cpp b/src/appleseed/renderer/modeling/bsdf/glassbsdf.cpp index c1053420c7..60bb294afa 100644 --- a/src/appleseed/renderer/modeling/bsdf/glassbsdf.cpp +++ b/src/appleseed/renderer/modeling/bsdf/glassbsdf.cpp @@ -726,7 +726,7 @@ DictionaryArray GlassBSDFFactory::get_input_metadata() const metadata.push_back( Dictionary() .insert("name", "volume_transmittance") - .insert("label", "Volume Transmittace") + .insert("label", "Volume Transmittance") .insert("type", "colormap") .insert("entity_types", Dictionary()