def returnData(self):
     if len(self.links) == 0:
         print_debug("Returning data:", str(self.standard_data))
         return [self.standard_data]
     else:
         node_output = self.links[0].from_socket
         return node_output.getData()
    def returnData(self):
        if len(self.links) == 0:

            vec = mathutils.Vector([self.vec1_0, self.vec1_1, self.vec1_2])
            print_debug("Returning Data:", self.name, "/", vec)
            return [vec]
        else:
            node_output = self.links[0].from_socket
            return node_output.getData()
 def update(self):
     print_debug("UPDATING TREE:", self.name)
     if not self.init:
         print_debug("INITIALIZING TREE:", self.name)
         for node in self.nodes:
             node.corrupted = True
             node.update()
             node.displayWarning = True
         self.init = True
    def getData(self):

        if self.node.corrupted:
            self.node.recalculate()

        heap = DataHeap()

        data = heap.loadData(self.as_pointer())

        print_debug("Data:", str(data))

        if data == None:
            print_debug("No data:", str(self), "/", self.as_pointer())
            self.node.corrupted = True
            return self.getData()

        return data
    def floodObsolete(self, context):

        #mark as outdated:
        self.corrupted = True
        print_debug(self.name + " has been marked obsolete.")
        # propagate flood

        outputs = []

        for output in self.outputs:
            if len(output.links) != 0:
                for link in output.links:
                    print_debug("   -> " + self.name + " is flooding " +
                                link.to_node.name)
                    test = link.to_node.floodObsolete(context)
                    if not test == None:
                        if not test in outputs:
                            outputs.extend(test)

        return outputs
    def callObsolete(self, context):
        print_debug("CALLING OBSOLETE:", self.name)
        pings = self.floodObsolete(context)

        print_debug(self.name, "is reaching out to outputs...")

        if not pings == []:

            pings = list(set(pings))

            print_debug(pings)

            for node in self.id_data.nodes:
                if node.as_pointer() in pings:
                    print_debug(node.name)
                    try:
                        node.triggerData(context)
                    except:
                        pass
    def update(self):
        print_debug("UPDATING:", self.name)
        print_debug("   -> self:", self.name)

        self.updateNode("")
    def free(self):
        print_debug("Removing node: ", self.name)

        for output in self.outputs:
            output.clearData()
    def generate(self):

        for area in bpy.context.screen.areas:
            if area.type == 'VIEW_3D':

                override = bpy.context.copy()
                override['area'] = area
                bpy.ops.view3d.snap_cursor_to_center(override)
                break

        print_debug("")
        print_debug("GENERATING")
        print_debug("-------------------")
        #utils_GLO.dumpNodelist(self.id_data)

        utils_OBJ.clear_selection()

        curLayer = utils_OBJ.enableLayers()

        #change color to red to show this node is working on something
        self.color = (1, .3, .3)

        #collect data from inputs
        if len(self.inputs[0].links) != 0:

            scene = bpy.context.scene
            obs = self.inputs[0].returnData()

            if obs == [] or obs == None:
                #garbage collection
                utils_OBJ.collectGarbage()

                #change color back to normal
                self.color = (.6, .6, .6)
                utils_OBJ.disableLayers(curLayer)
                print_debug("")
                print_debug("GENERATING DONE (no objects)")
                print_debug("-------------------")
                print_debug("")
                return True

            for ob in obs:
                scene.objects.link(ob)

            ctx = bpy.context.copy()

            # one of the objects to join
            obs[0].name = self.building_name
            obs[0].layers = self.getObjectLayerList(self.create_in_layer_g)
            ctx['active_object'] = obs[0]

            if len(obs) == 1:

                #garbage collection
                utils_OBJ.collectGarbage()

                #change color back to normal
                self.color = (.6, .6, .6)
                utils_OBJ.disableLayers(curLayer)
                print_debug("")
                print_debug("GENERATING DONE(1 object)")
                print_debug("-------------------")
                print_debug("")
                return True

            ctx['selected_objects'] = obs

            # we need the scene bases as well for joining
            ctx['selected_editable_bases'] = [
                scene.object_bases[ob.name] for ob in obs
            ]

            bpy.ops.object.join(ctx)

        #garbage collection
        utils_OBJ.collectGarbage()

        #change color back to normal
        self.color = (.6, .6, .6)

        utils_OBJ.disableLayers(curLayer)

        print_debug("")
        print_debug("GENERATING DONE")
        print_debug("-------------------")
        print_debug("")
        self.displayWarning = False
    def update(self):
        print_debug("UPDATING:", self.name)
        print_debug("   -> self:", self.name)

        self.checkInputs("")