Update leenkx/blender/lnx/nodes_logic.py
This commit is contained in:
parent
e34ed0794f
commit
a20d6b581c
@ -344,6 +344,8 @@ class LNX_PT_NodeDevelopment(bpy.types.Panel):
|
|||||||
|
|
||||||
layout.separator()
|
layout.separator()
|
||||||
layout.operator('lnx.node_replace_all')
|
layout.operator('lnx.node_replace_all')
|
||||||
|
layout.operator('lnx.recalculate_rotations')
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _draw_row(col: bpy.types.UILayout, text: str, val: Any):
|
def _draw_row(col: bpy.types.UILayout, text: str, val: Any):
|
||||||
@ -366,6 +368,40 @@ class LNX_OT_ReplaceNodesOperator(bpy.types.Operator):
|
|||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
return context.space_data is not None and context.space_data.type == 'NODE_EDITOR'
|
return context.space_data is not None and context.space_data.type == 'NODE_EDITOR'
|
||||||
|
|
||||||
|
class LNX_OT_RecalculateRotations(bpy.types.Operator):
|
||||||
|
"""Recalculates internal rotation values for all rotation sockets in the tree"""
|
||||||
|
bl_idname = "lnx.recalculate_rotations"
|
||||||
|
bl_label = "Recalculate Rotations"
|
||||||
|
bl_description = "Forces recalculation of internal quaternion values for all LnxRotationSockets in the active tree using their current settings. Useful for fixing old files."
|
||||||
|
bl_options = {'REGISTER', 'UNDO'}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
return (context.space_data is not None and
|
||||||
|
context.space_data.type == 'NODE_EDITOR' and
|
||||||
|
context.space_data.tree_type == 'LnxLogicTreeType' and
|
||||||
|
context.space_data.edit_tree is not None)
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
tree = context.space_data.edit_tree
|
||||||
|
if not tree:
|
||||||
|
self.report({'WARNING'}, "No active Logic Node tree found")
|
||||||
|
return {'CANCELLED'}
|
||||||
|
recalculated_count = 0
|
||||||
|
for node in tree.nodes:
|
||||||
|
for socket in list(node.inputs) + list(node.outputs):
|
||||||
|
if hasattr(socket, 'do_update_raw') and callable(socket.do_update_raw):
|
||||||
|
try:
|
||||||
|
socket.do_update_raw(context)
|
||||||
|
recalculated_count += 1
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error recalculating socket '{socket.name}' on node '{node.name}': {e}")
|
||||||
|
|
||||||
|
self.report({'INFO'}, f"Recalculated {recalculated_count} rotation sockets in tree '{tree.name}'")
|
||||||
|
tree.update_tag()
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
class LNX_UL_InterfaceSockets(bpy.types.UIList):
|
class LNX_UL_InterfaceSockets(bpy.types.UIList):
|
||||||
"""UI List of input and output sockets"""
|
"""UI List of input and output sockets"""
|
||||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
|
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
|
||||||
@ -421,6 +457,7 @@ __REG_CLASSES = (
|
|||||||
LnxOpenNodePythonSource,
|
LnxOpenNodePythonSource,
|
||||||
LnxOpenNodeWikiEntry,
|
LnxOpenNodeWikiEntry,
|
||||||
LNX_OT_ReplaceNodesOperator,
|
LNX_OT_ReplaceNodesOperator,
|
||||||
|
LNX_OT_RecalculateRotations,
|
||||||
LNX_MT_NodeAddOverride,
|
LNX_MT_NodeAddOverride,
|
||||||
LNX_OT_AddNodeOverride,
|
LNX_OT_AddNodeOverride,
|
||||||
LNX_UL_InterfaceSockets,
|
LNX_UL_InterfaceSockets,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user