[Bf-blender-cvs] [0cd3fef] object_nodes: A basic Object node tree pointer property for use as component nodes.

Lukas Tönne noreply at git.blender.org
Tue Nov 24 09:42:28 CET 2015


Commit: 0cd3fef3019dbf8fa5dbb67f01000cf7cc1cbc77
Author: Lukas Tönne
Date:   Fri Jul 17 02:40:25 2015 +0200
Branches: object_nodes
https://developer.blender.org/rB0cd3fef3019dbf8fa5dbb67f01000cf7cc1cbc77

A basic Object node tree pointer property for use as component nodes.

===================================================================

M	release/scripts/startup/bl_operators/__init__.py
A	release/scripts/startup/bl_operators/object_nodes.py
M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	source/blender/blenloader/intern/readfile.c
M	source/blender/depsgraph/intern/depsgraph_build_nodes.cc
M	source/blender/depsgraph/intern/depsgraph_build_relations.cc
M	source/blender/editors/animation/anim_filter.c
M	source/blender/editors/space_node/node_draw.c
M	source/blender/makesdna/DNA_object_types.h
M	source/blender/makesrna/intern/rna_object.c

===================================================================

diff --git a/release/scripts/startup/bl_operators/__init__.py b/release/scripts/startup/bl_operators/__init__.py
index 35c7a55..9051d6f 100644
--- a/release/scripts/startup/bl_operators/__init__.py
+++ b/release/scripts/startup/bl_operators/__init__.py
@@ -35,6 +35,7 @@ _modules = [
     "node",
     "object_align",
     "object",
+    "object_nodes",
     "object_randomize_transform",
     "object_quick_effects",
     "presets",
diff --git a/release/scripts/startup/bl_operators/object_nodes.py b/release/scripts/startup/bl_operators/object_nodes.py
new file mode 100644
index 0000000..6952014
--- /dev/null
+++ b/release/scripts/startup/bl_operators/object_nodes.py
@@ -0,0 +1,45 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8-80 compliant>
+
+import bpy
+from bpy.types import Operator
+from bpy.props import *
+
+from bpy.types import NodeTree, Node, NodeSocket
+class ObjectNodeTree(NodeTree):
+    '''Object component nodes'''
+    bl_idname = 'ObjectNodeTree'
+    bl_label = 'Object Nodes'
+    bl_icon = 'OBJECT_DATA'
+
+
+class ObjectNodesNew(Operator):
+    """Create new object node tree"""
+    bl_idname = "object_nodes.new"
+    bl_label = "New"
+    bl_options = {'REGISTER', 'UNDO'}
+
+    name = StringProperty(
+            name="Name",
+            )
+
+    def execute(self, context):
+    	return bpy.ops.node.new_node_tree(type='ObjectNodeTree', name="NodeTree")
+    	#return {'FINISHED'}
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index de8617e..467eedd 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -37,6 +37,10 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
 
         ob = context.object
 
+        layout.template_ID(ob, "node_tree", new="object_nodes.new")
+
+        layout.separator()
+
         layout.operator_menu_enum("object.modifier_add", "type")
 
         for md in ob.modifiers:
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 55cadae..2fc4095 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -4839,6 +4839,9 @@ static void lib_link_object(FileData *fd, Main *main)
 			lib_link_particlesystems(fd, ob, &ob->id, &ob->particlesystem);
 			lib_link_modifiers(fd, ob);
 
+			if (ob->nodetree)
+				ob->nodetree = newlibadr(fd, ob->id.lib, ob->nodetree);
+
 			if (ob->rigidbody_constraint) {
 				ob->rigidbody_constraint->ob1 = newlibadr(fd, ob->id.lib, ob->rigidbody_constraint->ob1);
 				ob->rigidbody_constraint->ob2 = newlibadr(fd, ob->id.lib, ob->rigidbody_constraint->ob2);
@@ -9039,6 +9042,9 @@ static void expand_object(FileData *fd, Main *mainvar, Object *ob)
 		modifiers_foreachIDLink(ob, expand_object_expandModifiers, (void *)&data);
 	}
 	
+	if (ob->nodetree)
+		expand_nodetree(fd, mainvar, ob->nodetree);
+	
 	expand_pose(fd, mainvar, ob->pose);
 	expand_doit(fd, mainvar, ob->poselib);
 	expand_constraints(fd, mainvar, &ob->constraints);
diff --git a/source/blender/depsgraph/intern/depsgraph_build_nodes.cc b/source/blender/depsgraph/intern/depsgraph_build_nodes.cc
index 4463df6..5d72cfc 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_nodes.cc
+++ b/source/blender/depsgraph/intern/depsgraph_build_nodes.cc
@@ -446,6 +446,9 @@ void DepsgraphNodeBuilder::build_object(Scene *scene, Base *base, Object *ob)
 	 */
 	build_animdata(&ob->id);
 
+	/* component nodes */
+	build_nodetree(NULL, ob->nodetree);
+
 	/* particle systems */
 	if (ob->particlesystem.first) {
 		build_particles(scene, ob);
diff --git a/source/blender/depsgraph/intern/depsgraph_build_relations.cc b/source/blender/depsgraph/intern/depsgraph_build_relations.cc
index 649105a..1576296 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_relations.cc
+++ b/source/blender/depsgraph/intern/depsgraph_build_relations.cc
@@ -434,6 +434,8 @@ void DepsgraphRelationBuilder::build_object(Main *bmain, Scene *scene, Object *o
 		}
 	}
 
+	build_nodetree((ID *)ob, ob->nodetree);
+
 	/* particle systems */
 	if (ob->particlesystem.first) {
 		build_particles(scene, ob);
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index 8853422..9d6f041 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -2393,6 +2393,10 @@ static size_t animdata_filter_dopesheet_ob(bAnimContext *ac, ListBase *anim_data
 			tmp_items += animdata_filter_ds_modifiers(ac, &tmp_data, ads, ob, filter_mode);
 		}
 		
+		if ((ob->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE)) {
+			tmp_items += animdata_filter_ds_nodetree(ac, &tmp_data, ads, (ID *)ob, ob->nodetree, filter_mode);
+		}
+		
 		/* materials */
 		if ((ob->totcol) && !(ads->filterflag & ADS_FILTER_NOMAT)) {
 			tmp_items += animdata_filter_ds_materials(ac, &tmp_data, ads, ob, filter_mode);
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index 283457d..acd0166 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -32,6 +32,7 @@
 #include "DNA_lamp_types.h"
 #include "DNA_node_types.h"
 #include "DNA_material_types.h"
+#include "DNA_object_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_space_types.h"
 #include "DNA_texture_types.h"
@@ -100,6 +101,8 @@ static bNodeTree *node_tree_from_ID(ID *id)
 		switch (idtype) {
 			case ID_NT:
 				return (bNodeTree *)id;
+			case ID_OB:
+				return ((Object *)id)->nodetree;
 			case ID_MA:
 				return ((Material *)id)->nodetree;
 			case ID_LA:
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index faae78a..7a1bef1 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -266,6 +266,7 @@ typedef struct Object {
 	struct PartDeflect *pd;		/* particle deflector/attractor/collision data */
 	struct SoftBody *soft;		/* if exists, saved in file */
 	struct Group *dup_group;	/* object duplicator for group */
+	struct bNodeTree *nodetree;	/* component nodes */
 
 	char  body_type;			/* for now used to temporarily holds the type of collision object */
 	char  shapeflag;			/* flag for pinning */
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 54f1798..72bd4d6 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -2500,6 +2500,13 @@ static void rna_def_object(BlenderRNA *brna)
 /*	RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "constraints__add", "constraints__remove"); */
 	rna_def_object_constraints(brna, prop);
 
+	/* component nodes */
+	prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
+	RNA_def_property_pointer_sdna(prop, NULL, "nodetree");
+	RNA_def_property_flag(prop, PROP_EDITABLE);
+	RNA_def_property_ui_text(prop, "Node Tree", "Node tree for object components");
+	RNA_def_property_update(prop, 0, "rna_Object_internal_update_data");
+
 	/* game engine */
 	prop = RNA_def_property(srna, "game", PROP_POINTER, PROP_NONE);
 	RNA_def_property_flag(prop, PROP_NEVER_NULL);




More information about the Bf-blender-cvs mailing list