|
|
@ -85,7 +85,7 @@ class PlasmaResponderNode(PlasmaNodeVariableInput, bpy.types.Node): |
|
|
|
# Convert the Responder states |
|
|
|
# Convert the Responder states |
|
|
|
stateMgr = ResponderStateMgr(self, responder) |
|
|
|
stateMgr = ResponderStateMgr(self, responder) |
|
|
|
for stateNode in self.find_outputs("states", "PlasmaResponderStateNode"): |
|
|
|
for stateNode in self.find_outputs("states", "PlasmaResponderStateNode"): |
|
|
|
stateNode.convert_state(exporter, stateMgr) |
|
|
|
stateNode.convert_state(exporter, tree, so, stateMgr) |
|
|
|
stateMgr.save() |
|
|
|
stateMgr.save() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -111,7 +111,7 @@ class PlasmaResponderStateNode(PlasmaNodeVariableInput, bpy.types.Node): |
|
|
|
# Now draw a prop |
|
|
|
# Now draw a prop |
|
|
|
layout.prop(self, "default_state") |
|
|
|
layout.prop(self, "default_state") |
|
|
|
|
|
|
|
|
|
|
|
def convert_state(self, exporter, stateMgr): |
|
|
|
def convert_state(self, exporter, tree, so, stateMgr): |
|
|
|
idx, state = stateMgr.get_state(self) |
|
|
|
idx, state = stateMgr.get_state(self) |
|
|
|
|
|
|
|
|
|
|
|
# No sanity checking here. Hopefully nothing crazy has happened in the UI. |
|
|
|
# No sanity checking here. Hopefully nothing crazy has happened in the UI. |
|
|
@ -131,22 +131,15 @@ class PlasmaResponderStateNode(PlasmaNodeVariableInput, bpy.types.Node): |
|
|
|
self.commands = [] |
|
|
|
self.commands = [] |
|
|
|
self.waits = {} |
|
|
|
self.waits = {} |
|
|
|
|
|
|
|
|
|
|
|
def add_command(self, node): |
|
|
|
def add_command(self, node, waitOn): |
|
|
|
cmd = type("ResponderCommand", (), {"msg": None, "waitOn": -1}) |
|
|
|
cmd = type("ResponderCommand", (), {"msg": None, "waitOn": waitOn}) |
|
|
|
self.commands.append((node, cmd)) |
|
|
|
self.commands.append((node, cmd)) |
|
|
|
return (len(self.commands) - 1, cmd) |
|
|
|
return (len(self.commands) - 1, cmd) |
|
|
|
|
|
|
|
|
|
|
|
def add_wait(self, parentCmd): |
|
|
|
def add_wait(self, parentIdx): |
|
|
|
try: |
|
|
|
|
|
|
|
idx = self.commands.index(parentCmd) |
|
|
|
|
|
|
|
except ValueError: |
|
|
|
|
|
|
|
# The parent command didn't export for some reason... Probably no message. |
|
|
|
|
|
|
|
# So, wait on nothing! |
|
|
|
|
|
|
|
return -1 |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
wait = len(self.waits) |
|
|
|
wait = len(self.waits) |
|
|
|
self.waits[wait] = idx |
|
|
|
self.waits[wait] = parentIdx |
|
|
|
return idx |
|
|
|
return wait |
|
|
|
|
|
|
|
|
|
|
|
def save(self, state): |
|
|
|
def save(self, state): |
|
|
|
for node, cmd in self.commands: |
|
|
|
for node, cmd in self.commands: |
|
|
@ -161,7 +154,7 @@ class PlasmaResponderStateNode(PlasmaNodeVariableInput, bpy.types.Node): |
|
|
|
for i in self.find_outputs("cmds", "PlasmaResponderCommandNode"): |
|
|
|
for i in self.find_outputs("cmds", "PlasmaResponderCommandNode"): |
|
|
|
# slight optimization--commands attached to states can't wait on other commands |
|
|
|
# slight optimization--commands attached to states can't wait on other commands |
|
|
|
# namely because it's impossible to wait on a command that doesn't exist... |
|
|
|
# namely because it's impossible to wait on a command that doesn't exist... |
|
|
|
i.convert_command(exporter, stateMgr.responder, commands, True) |
|
|
|
i.convert_command(exporter, tree, so, stateMgr.responder, commands) |
|
|
|
commands.save(state) |
|
|
|
commands.save(state) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -179,36 +172,31 @@ class PlasmaResponderCommandNode(PlasmaNodeBase, bpy.types.Node): |
|
|
|
self.outputs.new("PlasmaMessageSocket", "Message", "msg") |
|
|
|
self.outputs.new("PlasmaMessageSocket", "Message", "msg") |
|
|
|
self.outputs.new("PlasmaRespCommandSocket", "Trigger", "trigger") |
|
|
|
self.outputs.new("PlasmaRespCommandSocket", "Trigger", "trigger") |
|
|
|
|
|
|
|
|
|
|
|
def convert_command(self, exporter, responder, commandMgr, forceNoWait=False): |
|
|
|
def convert_command(self, exporter, tree, so, responder, commandMgr, waitOn=-1): |
|
|
|
# If this command has no message, there is no need to export it... |
|
|
|
# If this command has no message, there is no need to export it... |
|
|
|
msgNode = self.find_output("msg") |
|
|
|
msgNode = self.find_output("msg") |
|
|
|
if msgNode is not None: |
|
|
|
if msgNode is not None: |
|
|
|
idx, command = commandMgr.add_command(self) |
|
|
|
idx, command = commandMgr.add_command(self, waitOn) |
|
|
|
|
|
|
|
|
|
|
|
# If the thingthatdoneit is another command, we need to register a wait. |
|
|
|
# If we have child commands, we need to make sure that we support chaining this message as a callback |
|
|
|
# We could hack and assume the parent is idx-1, but that won't work if the parent has many |
|
|
|
# If not, we'll export our children and tell them to not actually wait on us. |
|
|
|
# child commands. Le whoops! |
|
|
|
haveChildren = self.find_output("trigger", "PlasmaResponderCommandNode") is not None |
|
|
|
if not forceNoWait: |
|
|
|
if haveChildren and msgNode.has_callbacks: |
|
|
|
parentCmd = self.find_input("whodoneit", "PlasmaResponderCommandNode") |
|
|
|
childWaitOn = commandMgr.add_wait(idx) |
|
|
|
if parentCmd is not None: |
|
|
|
else: |
|
|
|
command.waitOn = commandMgr.add_wait(parentCmd) |
|
|
|
childWaitOn = -1 |
|
|
|
|
|
|
|
|
|
|
|
# Finally, convert our message... |
|
|
|
# Finally, convert our message... |
|
|
|
msg = msgNode.convert_message(exporter) |
|
|
|
msg = msgNode.convert_message(exporter, tree, so, responder.key, childWaitOn) |
|
|
|
self._finalize_message(exporter, responder, msg) |
|
|
|
self._finalize_message(exporter, responder, msg) |
|
|
|
|
|
|
|
|
|
|
|
# If we have child commands, we need to make sure that we support chaining this message as a callback |
|
|
|
|
|
|
|
# If not, we'll export our children and tell them to not actually wait on us. |
|
|
|
|
|
|
|
haveChildren = self.find_output("trigger", "PlasmaResponderCommandNode") is not None |
|
|
|
|
|
|
|
if haveChildren: |
|
|
|
|
|
|
|
nowait = not self._add_msg_callback(exporter, responder, msg) |
|
|
|
|
|
|
|
command.msg = msg |
|
|
|
command.msg = msg |
|
|
|
else: |
|
|
|
else: |
|
|
|
nowait = True |
|
|
|
childWaitOn = -1 |
|
|
|
|
|
|
|
|
|
|
|
# Export any child commands |
|
|
|
# Export any child commands |
|
|
|
for i in self.find_outputs("trigger", "PlasmaResponderCommandNode"): |
|
|
|
for i in self.find_outputs("trigger", "PlasmaResponderCommandNode"): |
|
|
|
i.convert_command(exporter, responder, commandMgr, nowait) |
|
|
|
i.convert_command(exporter, tree, so, responder, commandMgr, childWaitOn) |
|
|
|
|
|
|
|
|
|
|
|
_bcast_flags = { |
|
|
|
_bcast_flags = { |
|
|
|
plArmatureEffectStateMsg: (plMessage.kPropagateToModifiers | plMessage.kNetPropagate), |
|
|
|
plArmatureEffectStateMsg: (plMessage.kPropagateToModifiers | plMessage.kNetPropagate), |
|
|
@ -223,12 +211,6 @@ class PlasmaResponderCommandNode(PlasmaNodeBase, bpy.types.Node): |
|
|
|
msg.BCastFlags = self._bcast_flags[_cls] |
|
|
|
msg.BCastFlags = self._bcast_flags[_cls] |
|
|
|
msg.BCastFlags |= plMessage.kLocalPropagate |
|
|
|
msg.BCastFlags |= plMessage.kLocalPropagate |
|
|
|
|
|
|
|
|
|
|
|
def _add_msg_callback(self, exporter, responder, msg): |
|
|
|
|
|
|
|
"""Prepares a given message to be a callback to the responder""" |
|
|
|
|
|
|
|
# We do not support callback messages ATM |
|
|
|
|
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PlasmaRespCommandSocket(PlasmaNodeSocketBase, bpy.types.NodeSocket): |
|
|
|
class PlasmaRespCommandSocket(PlasmaNodeSocketBase, bpy.types.NodeSocket): |
|
|
|
bl_color = (0.451, 0.0, 0.263, 1.0) |
|
|
|
bl_color = (0.451, 0.0, 0.263, 1.0) |
|
|
|
|
|
|
|
|
|
|
|