From 25aa07015d285fc51857ce2c760711dc6254060a Mon Sep 17 00:00:00 2001 From: Ilya Portnov Date: Sun, 8 Jan 2023 20:26:47 +0500 Subject: [PATCH 1/4] "Curve mapper": respect "use clipping" option. Earlier we used https://docs.blender.org/api/current/bpy.types.CurveMapping.html#bpy.types.CurveMapping.evaluate method to calculate the resulting value of mapper, in hope that it respects clipping settings automatically. However, it appears to do not. As a result, if the curve goes, for example, beyond [0;1] by Y, the result of the curve mapper could go negative even though "use clipping" option in the curve widget is enabled. This change adds explicit clipping to evaluate function. If someone happened to adapt previous behaviour, they can just untick the "use clipping" checkbox in the curve widget settings. --- utils/sv_manual_curves_utils.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/utils/sv_manual_curves_utils.py b/utils/sv_manual_curves_utils.py index c02803ea7f..7bad176baf 100644 --- a/utils/sv_manual_curves_utils.py +++ b/utils/sv_manual_curves_utils.py @@ -88,7 +88,14 @@ def get_valid_evaluate_function(group_name, node_name): try: node.mapping.evaluate(curve, 0.0) except: node.mapping.initialize() - evaluate = lambda val: node.mapping.evaluate(curve, val) + def evaluate(val): + res = node.mapping.evaluate(curve, val) + if node.mapping.use_clip: + if res < node.mapping.clip_min_y: + res = node.mapping.clip_min_y + if res > node.mapping.clip_max_y: + res = node.mapping.clip_max_y + return res return evaluate def get_rgb_curve(group_name, node_name): From 79e835ca494c9190457738a752b8798a4628fcde Mon Sep 17 00:00:00 2001 From: Ilya Portnov Date: Sun, 8 Jan 2023 20:40:15 +0500 Subject: [PATCH 2/4] Update documentation. --- docs/nodes/number/curve_mapper.rst | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/nodes/number/curve_mapper.rst b/docs/nodes/number/curve_mapper.rst index 952bc95d2e..0b50aa8cb1 100644 --- a/docs/nodes/number/curve_mapper.rst +++ b/docs/nodes/number/curve_mapper.rst @@ -9,6 +9,14 @@ Functionality This node map all the incoming values using the curve you define manually through the interface. +Note: the curve defined by the widget may give results in any range, from minus +infinity to plus infinity. However, by default, the "use clipping" checkbox in +curve widget's settings is enabled; the node respects that checkbox. It means, +that if, for example, **Min Y** and **Max Y** parameters in the curve editor +widget are set to 0.0 and 1.0, then, even if the curve goes beyond that range, +the node results will be always within 0.0 - 1.0 range. If you do not need such +clipping, you can disable it in curve widget settings. + Disclaimer ---------- @@ -66,4 +74,4 @@ Example of the Curve output usage: * Curves-> :doc:`Naturally Parametrized Curve ` * Surface-> :doc:`Revolution Surface ` * Surface-> :doc:`Evaluate Surface ` -* Viz-> :doc:`Viewer Draw ` \ No newline at end of file +* Viz-> :doc:`Viewer Draw ` From 434f2eb821ebe25dc0fbecd2d3aea99d26679878 Mon Sep 17 00:00:00 2001 From: Ilya Portnov Date: Sun, 8 Jan 2023 20:44:14 +0500 Subject: [PATCH 3/4] Add examples to documentation. --- docs/nodes/number/curve_mapper.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/nodes/number/curve_mapper.rst b/docs/nodes/number/curve_mapper.rst index 0b50aa8cb1..640b840fb5 100644 --- a/docs/nodes/number/curve_mapper.rst +++ b/docs/nodes/number/curve_mapper.rst @@ -75,3 +75,14 @@ Example of the Curve output usage: * Surface-> :doc:`Revolution Surface ` * Surface-> :doc:`Evaluate Surface ` * Viz-> :doc:`Viewer Draw ` + +An example of what the node can do if you disable the "use clipping" option: + +.. image:: https://user-images.githubusercontent.com/284644/211205670-277fcbd4-c0fb-4645-a058-c78716156bd5.png + :target: https://user-images.githubusercontent.com/284644/211205670-277fcbd4-c0fb-4645-a058-c78716156bd5.png + +The same curve with enabled clipping: + +.. image:: https://user-images.githubusercontent.com/284644/211205669-998e582e-18f9-4141-bed8-4182f5356d94.png + :target: https://user-images.githubusercontent.com/284644/211205669-998e582e-18f9-4141-bed8-4182f5356d94.png + From be481ccd4f6f6e4cd0d30df6aae4ffe23398392b Mon Sep 17 00:00:00 2001 From: Ilya Portnov Date: Sun, 8 Jan 2023 21:12:26 +0500 Subject: [PATCH 4/4] Fix dimensions_svg.rst. --- docs/old/nodes/dimensions_svg.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/old/nodes/dimensions_svg.rst b/docs/old/nodes/dimensions_svg.rst index 1a6a46a0ab..299f63a680 100644 --- a/docs/old/nodes/dimensions_svg.rst +++ b/docs/old/nodes/dimensions_svg.rst @@ -1,3 +1,5 @@ +:orphan: + Dimensions SVG ==============