Browse Source

More actor harvesting fixes.

Apparently, I forgot about the `requires_actor` property. Oops! That has
been corrected along with an oversight in the PythonFileMod nodes.
pull/161/head
Adam Johnson 5 years ago
parent
commit
7e2cd66ffd
Signed by: Hoikas
GPG Key ID: 0B6515D6FF6F271E
  1. 4
      korman/nodes/node_avatar.py
  2. 14
      korman/nodes/node_conditions.py
  3. 10
      korman/nodes/node_core.py
  4. 4
      korman/nodes/node_logic.py
  5. 12
      korman/nodes/node_messages.py
  6. 19
      korman/nodes/node_python.py
  7. 6
      korman/properties/modifiers/logic.py
  8. 5
      korman/properties/modifiers/region.py

4
korman/nodes/node_avatar.py

@ -67,3 +67,7 @@ class PlasmaSittingBehaviorNode(PlasmaNodeBase, bpy.types.Node):
sitmod.addNotifyKey(i.get_key(exporter, so)) sitmod.addNotifyKey(i.get_key(exporter, so))
else: else:
exporter.report.warn("'{}' Node '{}' doesn't expose a key. It won't be triggered by '{}'!".format(i.bl_idname, i.name, self.name), indent=3) exporter.report.warn("'{}' Node '{}' doesn't expose a key. It won't be triggered by '{}'!".format(i.bl_idname, i.name, self.name), indent=3)
@property
def requires_actor(self):
return True

14
korman/nodes/node_conditions.py

@ -144,13 +144,13 @@ class PlasmaClickableNode(idprops.IDPropObjectMixin, PlasmaNodeBase, bpy.types.N
else: else:
return (None, parent_so) return (None, parent_so)
def harvest_actors(self, bo): def harvest_actors(self):
actors = set() if self.clickable_object:
if self.clickable_object is not None: yield self.clickable_object.name
actors.add(self.clickable_object.name)
else: @property
actors.add(bo.name) def requires_actor(self):
return actors return self.clickable_object is None
@classmethod @classmethod
def _idprop_mapping(cls): def _idprop_mapping(cls):

10
korman/nodes/node_core.py

@ -220,7 +220,7 @@ class PlasmaNodeBase:
"""Generates valid sockets on this node type that can be linked to a specific node's socket.""" """Generates valid sockets on this node type that can be linked to a specific node's socket."""
return [] return []
def harvest_actors(self, bo): def harvest_actors(self):
return set() return set()
def link_input(self, node, out_key, in_key): def link_input(self, node, out_key, in_key):
@ -466,12 +466,12 @@ class PlasmaNodeTree(bpy.types.NodeTree):
return node return node
return None return None
def harvest_actors(self, bo): def harvest_actors(self):
actors = set() actors = set()
for node in self.nodes: for node in self.nodes:
harvest_method = getattr(node, "harvest_actors", None) harvest_method = getattr(node, "harvest_actors", None)
if harvest_method is not None: if harvest_method is not None:
actors.update(harvest_method(bo)) actors.update(harvest_method())
elif not isinstance(node, PlasmaNodeBase): elif not isinstance(node, PlasmaNodeBase):
raise ExportError("Plasma Node Tree '{}' Node '{}': is not a valid node for this tree".format(self.id_data.name, node.name)) raise ExportError("Plasma Node Tree '{}' Node '{}': is not a valid node for this tree".format(self.id_data.name, node.name))
return actors return actors
@ -480,6 +480,10 @@ class PlasmaNodeTree(bpy.types.NodeTree):
def poll(cls, context): def poll(cls, context):
return (context.scene.render.engine == "PLASMA_GAME") return (context.scene.render.engine == "PLASMA_GAME")
@property
def requires_actor(self):
return any((node.requires_actor for node in self.nodes))
# Welcome to HAXland! # Welcome to HAXland!
# Blender 2.79 is great in that it allows us to have ID Datablock pointer properties everywhere. # Blender 2.79 is great in that it allows us to have ID Datablock pointer properties everywhere.

4
korman/nodes/node_logic.py

@ -84,8 +84,8 @@ class PlasmaExcludeRegionNode(idprops.IDPropObjectMixin, PlasmaNodeBase, bpy.typ
self.raise_error("Region must be set") self.raise_error("Region must be set")
return self._find_create_key(plExcludeRegionModifier, exporter, bl=self.region_object) return self._find_create_key(plExcludeRegionModifier, exporter, bl=self.region_object)
def harvest_actors(self, bo): def harvest_actors(self):
return [i.safepoint.name for i in self.find_input_sockets("safe_points") if i.safepoint is not None] return (i.safepoint.name for i in self.find_input_sockets("safe_points") if i.safepoint is not None)
def export(self, exporter, bo, parent_so): def export(self, exporter, bo, parent_so):
excludergn = self.get_key(exporter, parent_so).object excludergn = self.get_key(exporter, parent_so).object

12
korman/nodes/node_messages.py

@ -561,18 +561,18 @@ class PlasmaOneShotMsgNode(idprops.IDPropObjectMixin, PlasmaMessageWithCallbacks
else: else:
return self._find_create_key(plOneShotMod, exporter, so=so) return self._find_create_key(plOneShotMod, exporter, so=so)
def harvest_actors(self, bo): def harvest_actors(self):
actors = set()
if self.pos_object: if self.pos_object:
actors.add(self.pos_object.name) yield self.pos_object.name
else:
actors.add(bo.name)
return actors
@property @property
def has_callbacks(self): def has_callbacks(self):
return bool(self.marker) return bool(self.marker)
@property
def requires_actor(self):
return self.pos_object is None
@classmethod @classmethod
def _idprop_mapping(cls): def _idprop_mapping(cls):
return {"pos_object": "pos"} return {"pos_object": "pos"}

19
korman/nodes/node_python.py

@ -394,14 +394,13 @@ class PlasmaPythonFileNode(PlasmaVersionedNode, bpy.types.Node):
"socket_name": attrib["name"], "socket_name": attrib["name"],
"socket_text": attrib["name"] } "socket_text": attrib["name"] }
def harvest_actors(self, bo): def harvest_actors(self):
actors = set() for i in self.inputs:
actors.add(bo.name) if not i.is_linked or i.attribute_type not in {"ptAttribSceneobject", "ptAttribSceneobjectList"}:
continue
so_nodes = (i.links[0].from_node for i in self.inputs node = i.links[0].from_node
if i.is_linked and i.attribute_type in {"ptAttribSceneobject", "ptAttribSceneobjectList"}) if node.target_object is not None:
actors.update((i.target_object for i in so_nodes if i.target_object is not None)) yield node.target_object.name
return actors
@property @property
def key_name(self): def key_name(self):
@ -422,6 +421,10 @@ class PlasmaPythonFileNode(PlasmaVersionedNode, bpy.types.Node):
if not is_init and new_pos != old_pos: if not is_init and new_pos != old_pos:
self.inputs.move(old_pos, new_pos) self.inputs.move(old_pos, new_pos)
@property
def requires_actor(self):
return True
@contextmanager @contextmanager
def NoUpdate(self): def NoUpdate(self):
self.no_update = True self.no_update = True

6
korman/properties/modifiers/logic.py

@ -66,9 +66,13 @@ class PlasmaAdvancedLogic(PlasmaModifierProperties):
actors = set() actors = set()
for i in self.logic_groups: for i in self.logic_groups:
if i.node_tree is not None: if i.node_tree is not None:
actors.update(i.node_tree.harvest_actors(self.id_data)) actors.update(i.node_tree.harvest_actors())
return actors return actors
@property
def requires_actor(self):
return any((i.node_tree.requires_actor for i in self.logic_groups if i.node_tree))
class PlasmaSpawnPoint(PlasmaModifierProperties): class PlasmaSpawnPoint(PlasmaModifierProperties):
pl_id = "spawnpoint" pl_id = "spawnpoint"

5
korman/properties/modifiers/region.py

@ -120,10 +120,13 @@ class PlasmaCameraRegion(PlasmaModifierProperties):
raise ExportError("Camera Modifier '{}' does not specify a valid camera object".format(self.id_data.name)) raise ExportError("Camera Modifier '{}' does not specify a valid camera object".format(self.id_data.name))
actors.update(self.camera_object.data.plasma_camera.settings.harvest_actors()) actors.update(self.camera_object.data.plasma_camera.settings.harvest_actors())
else: else:
actors.add(self.id_data.name)
actors.update(self.auto_camera.harvest_actors()) actors.update(self.auto_camera.harvest_actors())
return actors return actors
@property
def requires_actor(self):
return self.camera_type == "auto_follow"
class PlasmaFootstepRegion(PlasmaModifierProperties, PlasmaModifierLogicWiz): class PlasmaFootstepRegion(PlasmaModifierProperties, PlasmaModifierLogicWiz):
pl_id = "footstep" pl_id = "footstep"

Loading…
Cancel
Save