Motion transfer setup #1
51
execute.py
51
execute.py
@ -1,14 +1,14 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
import bpy
|
||||
from . import nodes
|
||||
is_first_load = "nodes" not in locals()
|
||||
from . import nodes
|
||||
|
||||
if not is_first_load:
|
||||
import sys
|
||||
|
||||
nodes = sys.modules[nodes.__name__]
|
||||
|
||||
import bpy
|
||||
|
||||
_skip_next_autorun = False
|
||||
|
||||
@ -50,6 +50,7 @@ def execute_tree(
|
||||
# The running of this tree will trigger another depsgraph update, which
|
||||
# should not trigger yet another execution.
|
||||
global _skip_next_autorun
|
||||
|
||||
try:
|
||||
tree.run_event(depsgraph, mode)
|
||||
except Exception:
|
||||
@ -66,10 +67,28 @@ def _on_depsgraph_update_post(
|
||||
scene: bpy.types.Scene, depsgraph: bpy.types.Depsgraph
|
||||
) -> None:
|
||||
global _skip_next_autorun
|
||||
|
||||
if _skip_next_autorun:
|
||||
_skip_next_autorun = False
|
||||
return
|
||||
|
||||
run_node_tree(scene, depsgraph)
|
||||
|
||||
|
||||
@bpy.app.handlers.persistent # type: ignore
|
||||
def _on_frame_changed_post(
|
||||
scene: bpy.types.Scene, depsgraph: bpy.types.Depsgraph
|
||||
) -> None:
|
||||
global _skip_next_autorun
|
||||
if not _skip_next_autorun:
|
||||
_skip_next_autorun = True
|
||||
cgtinker marked this conversation as resolved
|
||||
|
||||
run_node_tree(scene, depsgraph)
|
||||
|
||||
|
||||
def run_node_tree(
|
||||
scene: bpy.types.Scene, depsgraph: bpy.types.Depsgraph
|
||||
) -> None:
|
||||
for tree in bpy.data.node_groups:
|
||||
if tree.bl_idname != "PowerShipNodeTree":
|
||||
continue
|
||||
@ -97,34 +116,6 @@ def _choose_auto_mode(context: bpy.types.Context) -> str:
|
||||
return "FORWARD"
|
||||
|
||||
|
||||
@bpy.app.handlers.persistent # type: ignore
|
||||
def _on_frame_changed_post(
|
||||
scene: bpy.types.Scene, depsgraph: bpy.types.Depsgraph
|
||||
) -> None:
|
||||
global _skip_next_autorun
|
||||
if _skip_next_autorun:
|
||||
_skip_next_autorun = True
|
||||
|
||||
# updating on frame change to allow
|
||||
# keyframed animation influencing the rig
|
||||
for tree in bpy.data.node_groups:
|
||||
if tree.bl_idname != "PowerShipNodeTree":
|
||||
continue
|
||||
|
||||
if not tree.autorun:
|
||||
return
|
||||
|
||||
powership_mode = scene.powership_mode
|
||||
|
||||
if powership_mode == "AUTO":
|
||||
if bpy.context.object and bpy.context.object.mode == "POSE":
|
||||
powership_mode = "BACKWARD"
|
||||
else:
|
||||
powership_mode = "FORWARD"
|
||||
|
||||
execute_tree(tree, depsgraph, powership_mode)
|
||||
|
||||
|
||||
classes = (
|
||||
# Operators:
|
||||
PowerShip_OT_execute_tree,
|
||||
|
Loading…
Reference in New Issue
Block a user
Since
_skip_next_autorun
is a boolean, theif
condition can be removed.