-
Notifications
You must be signed in to change notification settings - Fork 316
/
LN_vector_clamp.py
41 lines (32 loc) · 1.44 KB
/
LN_vector_clamp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from arm.logicnode.arm_nodes import *
class VectorClampToSizeNode(ArmLogicTreeNode):
"""Clamp the vector's value inside the given range and return the result as a new vector.
@option Clamping Mode: Whether to clamp the length of the vector
or the value of each individual component.
"""
bl_idname = 'LNVectorClampToSizeNode'
bl_label = 'Vector Clamp'
arm_section = 'vector'
arm_version = 2
property0: HaxeEnumProperty(
'property0',
name='Clamping Mode', default='length',
description='Whether to clamp the length of the vector or the value of each individual component',
items=[
('length', 'Length', 'Clamp the length (magnitude) of the vector'),
('components', 'Components', 'Clamp the individual components of the vector'),
]
)
def draw_buttons(self, context, layout):
col = layout.column()
col.label(text="Clamping Mode:")
col.prop(self, 'property0', expand=True)
def arm_init(self, context):
self.add_input('ArmVectorSocket', 'Vector In', default_value=[0.0, 0.0, 0.0])
self.add_input('ArmFloatSocket', 'Min')
self.add_input('ArmFloatSocket', 'Max')
self.add_output('ArmVectorSocket', 'Vector Out')
def get_replacement_node(self, node_tree: bpy.types.NodeTree):
if self.arm_version not in (0, 1):
raise LookupError()
return NodeReplacement.Identity(self)