Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Curve mapper": respect "use clipping" option. #4864

Merged
merged 4 commits into from
Jan 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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