mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
Nodes: Defaults for Integer Math node depend on operation
When adding an Integer Math node, the inputs are initialized to 1 or 0 depending on the operation. Defaults: 1st and 2nd inputs set to 1: - Multiply - Divide - Divide Round - Divide Floor - Divide Ceil - Floored Modulo - Modulo 1st input to 1, 2nd to 0: - Multiply Add Pull Request: https://projects.blender.org/blender/blender/pulls/156823
This commit is contained in:
parent
777082b391
commit
9eab44d630
2 changed files with 25 additions and 2 deletions
|
|
@ -13,7 +13,8 @@ __all__ = (
|
|||
"add_repeat_zone",
|
||||
"add_simulation_zone",
|
||||
"draw_node_group_add_menu",
|
||||
"set_math_node_default_props"
|
||||
"set_math_node_default_props",
|
||||
"set_int_math_node_default_props",
|
||||
)
|
||||
|
||||
import bpy
|
||||
|
|
@ -140,6 +141,23 @@ def set_math_node_default_props(enum_identifier, props):
|
|||
set_socket_default_value(props.settings, "Value_002", "0.0")
|
||||
|
||||
|
||||
def set_int_math_node_default_props(enum_identifier, props):
|
||||
if enum_identifier in (
|
||||
'MULTIPLY',
|
||||
'DIVIDE',
|
||||
'DIVIDE_ROUND',
|
||||
'DIVIDE_FLOOR',
|
||||
'DIVIDE_CEIL',
|
||||
'FLOORED_MODULO',
|
||||
'MODULO'):
|
||||
set_socket_default_value(props.settings, "Value", "1")
|
||||
set_socket_default_value(props.settings, "Value_001", "1")
|
||||
|
||||
elif enum_identifier == 'MULTIPLY_ADD':
|
||||
set_socket_default_value(props.settings, "Value", "1")
|
||||
set_socket_default_value(props.settings, "Value_001", "0")
|
||||
|
||||
|
||||
class NodeMenu(Menu):
|
||||
"""A base-class defining the shared methods for AddNodeMenu and SwapNodeMenu."""
|
||||
draw_assets: bool
|
||||
|
|
|
|||
|
|
@ -851,7 +851,12 @@ class NODE_MT_gn_utilities_math_base(node_add_menu.NodeMenu):
|
|||
context, layout, "FunctionNodeBitMath", "operation", search_weight=-1.0,
|
||||
)
|
||||
self.node_operator_with_searchable_enum(context, layout, "FunctionNodeBooleanMath", "operation")
|
||||
self.node_operator_with_searchable_enum(context, layout, "FunctionNodeIntegerMath", "operation")
|
||||
self.node_operator_with_searchable_enum(
|
||||
context,
|
||||
layout,
|
||||
"FunctionNodeIntegerMath",
|
||||
"operation",
|
||||
defaults_callback=node_add_menu.set_int_math_node_default_props)
|
||||
self.node_operator(layout, "ShaderNodeClamp")
|
||||
self.node_operator(layout, "FunctionNodeCompare")
|
||||
self.node_operator(layout, "ShaderNodeFloatCurve")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue