Skip to content

Commit

Permalink
Merge pull request #4864 from nortikin/curve_mapper_clipping
Browse files Browse the repository at this point in the history
"Curve mapper": respect "use clipping" option.
  • Loading branch information
portnov authored Jan 8, 2023
2 parents 759595a + be481cc commit 7f9602f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
21 changes: 20 additions & 1 deletion docs/nodes/number/curve_mapper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------

Expand Down Expand Up @@ -66,4 +74,15 @@ Example of the Curve output usage:
* Curves-> :doc:`Naturally Parametrized Curve </nodes/curve/length_rebuild>`
* Surface-> :doc:`Revolution Surface </nodes/surface/revolution_surface>`
* Surface-> :doc:`Evaluate Surface </nodes/surface/evaluate_surface>`
* Viz-> :doc:`Viewer Draw </nodes/viz/viewer_draw_mk4>`
* Viz-> :doc:`Viewer Draw </nodes/viz/viewer_draw_mk4>`

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

2 changes: 2 additions & 0 deletions docs/old/nodes/dimensions_svg.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
:orphan:

Dimensions SVG
==============

Expand Down
9 changes: 8 additions & 1 deletion utils/sv_manual_curves_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 7f9602f

Please sign in to comment.