This commit is contained in:
Moritz Brückner 2021-07-03 19:45:35 +02:00
parent 4387d774cc
commit b2153dbcd2
7 changed files with 39 additions and 38 deletions

View file

@ -8,15 +8,15 @@ class MathExpressionNode(ArmLogicTreeNode):
arm_version = 1
min_inputs = 2
max_inputs = 10
@staticmethod
def get_variable_name(index):
return {
0: 'a',
1: 'b',
2: 'c',
3: 'd',
4: 'e',
0: 'a',
1: 'b',
2: 'c',
3: 'd',
4: 'e',
5: 'x',
6: 'y',
7: 'h',
@ -27,7 +27,7 @@ class MathExpressionNode(ArmLogicTreeNode):
@staticmethod
def get_clear_exp(value):
return re.sub(r'[\-\+\*\/\(\)\^\%abcdexyhik0123456789. ]', '', value).strip()
@staticmethod
def get_invalid_characters(value):
value = value.replace(' ', '')
@ -70,7 +70,7 @@ class MathExpressionNode(ArmLogicTreeNode):
return False
return True
@staticmethod
@staticmethod
def matches(line, opendelim='(', closedelim=')'):
stack = []
for m in re.finditer(r'[{}{}]'.format(opendelim, closedelim), line):
@ -92,7 +92,7 @@ class MathExpressionNode(ArmLogicTreeNode):
if len(stack) > 0:
for pos in stack:
yield (False, 0, 0, 0)
@staticmethod
def isPartCorrect(s):
if len(s.replace('p', '').replace(' ', '').split()) == 0:
@ -151,7 +151,7 @@ class MathExpressionNode(ArmLogicTreeNode):
elif not self.isCorrect(self, value.replace(' ', '')):
val_error = True
self.set_exp_error(val_error)
def get_exp(self):
return self.get('property0', 'a + b')
@ -187,4 +187,4 @@ class MathExpressionNode(ArmLogicTreeNode):
op = column.operator('arm.node_remove_input', text='', icon='X', emboss=True)
op.node_index = str(id(self))
if len(self.inputs) == 2:
column.enabled = False
column.enabled = False

View file

@ -84,7 +84,7 @@ class QuaternionMathNode(ArmLogicTreeNode):
self.inputs.remove(self.inputs.values()[-1])
if (select_prev == 'DotProduct') or (select_prev == 'ToAxisAngle') or (select_prev == 'Module'):
self.outputs.remove(self.outputs.values()[-1])
# Many arguments: Add, Subtract, DotProduct, Multiply, MultiplyFloat
if (self.get_count_in(select_current) == 0):
if (select_current == "MultiplyFloats"):
@ -95,7 +95,7 @@ class QuaternionMathNode(ArmLogicTreeNode):
self.add_input('NodeSocketVector', 'Quaternion ' + str(len(self.inputs)))
if (select_current == 'DotProduct'):
self.add_output('NodeSocketFloat', 'Scalar')
# 3 arguments: Lerp, Slerp, FromAxisAngle, FromEuler
if (self.get_count_in(select_current) == 3):
if (select_current == 'Lerp') or (select_current == 'Slerp'):
@ -111,7 +111,7 @@ class QuaternionMathNode(ArmLogicTreeNode):
self.add_input('NodeSocketFloat', 'X')
self.add_input('NodeSocketFloat', 'Y')
self.add_input('NodeSocketFloat', 'Z')
# 2 arguments: FromTo, FromMat, FromRotationMat, ToAxisAngle
if (self.get_count_in(select_current) == 2):
if (select_current == 'FromTo'):

View file

@ -13,11 +13,11 @@ class SetDebugConsoleSettings(ArmLogicTreeNode):
('right', 'Anchor Right', 'Anchor the debug console in the top right')],
name='', default='right')
def init(self, context):
super(SetDebugConsoleSettings, self).init(context)
def init(self, context):
super(SetDebugConsoleSettings, self).init(context)
self.add_input('ArmNodeSocketAction', 'In')
self.add_input('NodeSocketBool', 'Visible')
self.add_input('NodeSocketFloat', 'Scale')
self.add_input('NodeSocketBool', 'Visible')
self.add_input('NodeSocketFloat', 'Scale')
self.inputs[-1].default_value = 1.0
self.add_output('ArmNodeSocketAction', 'Out')

View file

@ -1,12 +1,12 @@
from arm.logicnode.arm_nodes import *
class AddRigidBodyNode(ArmLogicTreeNode):
"""Adds a rigid body to an object if not already present.
"""Adds a rigid body to an object if not already present.
@option Advanced: Shows optional advanced options for rigid body.
@option Shape: Shape of the rigid body including Box, Sphere, Capsule, Cone, Cylinder, Convex Hull and Mesh
@input Object: Object to which rigid body is added.
@input Mass: Mass of the rigid body. Must be > 0.
@ -14,9 +14,9 @@ class AddRigidBodyNode(ArmLogicTreeNode):
@input Active: Rigid body actively participates in the physics world and will be affected by collisions
@input Animated: Rigid body follows animation and will affect other active non-animated rigid bodies.
@input Trigger: Rigid body behaves as a trigger and detects collision. However, rigd body does not contribute to or receive collissions.
@input Trigger: Rigid body behaves as a trigger and detects collision. However, rigd body does not contribute to or receive collissions.
@input Friction: Surface friction of the rigid body. Minimum value = 0, Preferred max value = 1.
@input Bounciness: How elastic is the surface of the rigid body. Minimum value = 0, Preferred max value = 1.
@ -34,7 +34,7 @@ class AddRigidBodyNode(ArmLogicTreeNode):
@input Use Deactivation: Deactive this rigid body when below the Linear and Angular velocity threshold. Enable to improve performance.
@input Linear Velocity Threshold: Velocity below which decativation occurs if enabled.
@input Angular Velocity Threshold: Velocity below which decativation occurs if enabled.
@input Collision Group: A set of rigid bodies that can interact with each other
@ -43,9 +43,9 @@ class AddRigidBodyNode(ArmLogicTreeNode):
@output Rigid body: Object to which rigid body was added.
@output Out: activated after rigid body is added.
@output Out: activated after rigid body is added.
"""
bl_idname = 'LNAddRigidBodyNode'
bl_label = 'Add Rigid Body'
arm_version = 1
@ -80,7 +80,7 @@ class AddRigidBodyNode(ArmLogicTreeNode):
def init(self, context):
super(AddRigidBodyNode, self).init(context)
self.add_input('ArmNodeSocketAction', 'In')
self.add_input('ArmNodeSocketObject', 'Object')
self.add_input('NodeSocketFloat', 'Mass', 1.0)

View file

@ -3,11 +3,11 @@ from arm.logicnode.arm_nodes import *
class AddPhysicsConstraintNode(ArmLogicTreeNode):
"""
Add a physics constraint to constrain two rigid bodies if not already present.
@option Fixed: No fredom of movement. Relative positions and rotations of rigid bodies are fixed
@option Point: Both rigid bodies are constrained at the pivot object.
@option Hinge: Constrained objects can move only along angular Z axis of the pivot object.
@option Slider: Constrained objects can move only along linear X axis of the pivot object.
@ -57,15 +57,15 @@ class AddPhysicsConstraintNode(ArmLogicTreeNode):
@staticmethod
def get_count_in(type_name):
return {
'Fixed': 0,
'Point': 1,
'Hinge': 2,
'Fixed': 0,
'Point': 1,
'Hinge': 2,
'Slider': 3,
'Piston': 4,
'Piston': 4,
'Generic Spring': 5
}.get(type_name, 0)
def get_enum(self):
def get_enum(self):
return self.get('property0', 0)
def set_enum(self, value):
@ -133,7 +133,7 @@ class AddPhysicsConstraintNode(ArmLogicTreeNode):
('Piston', 'Piston', 'Piston'),
('Generic Spring', 'Generic Spring', 'Generic Spring')],
name='Type', default='Fixed', set=set_enum, get=get_enum)
def __init__(self):
array_nodes[str(id(self))] = self
@ -150,7 +150,7 @@ class AddPhysicsConstraintNode(ArmLogicTreeNode):
def draw_buttons(self, context, layout):
layout.prop(self, 'property0')
#GenericSpring:
if (self.get_count_in(self.property0) == 5):
grid0 = layout.grid_flow(row_major=True, columns=1, align=True)

View file

@ -1,5 +1,6 @@
from arm.logicnode.arm_nodes import *
class PhysicsConstraintNode(ArmLogicTreeNode):
"""
Custom physics constraint to add to `Add Physics Constarint` node.
@ -46,7 +47,7 @@ class PhysicsConstraintNode(ArmLogicTreeNode):
default=False,
update=update_spring
)
def __init__(self):
array_nodes[str(id(self))] = self

View file

@ -28,7 +28,7 @@ class RotateObjectNode(ArmLogicTreeNode):
self.inputs[2].name = "Axis"
self.inputs[3].name = "Angle"
else:
raise ValueError('No nodesocket labels for current input mode: check self-consistancy of action_set_rotation.py')
raise ValueError('No nodesocket labels for current input mode: check self-consistancy of LN_rotate_object.py')
def draw_buttons(self, context, layout):
# this block is here to ensure backwards compatibility and warn the user.