[Bf-blender-cvs] [0dbafd1] object_nodes: Added object nodes for looking up an object and transform from global data.

Lukas Tönne noreply at git.blender.org
Fri Jun 24 16:19:55 CEST 2016


Commit: 0dbafd1fe566766b6226c65a6511a01eb269ad16
Author: Lukas Tönne
Date:   Fri Jun 24 16:19:23 2016 +0200
Branches: object_nodes
https://developer.blender.org/rB0dbafd1fe566766b6226c65a6511a01eb269ad16

Added object nodes for looking up an object and transform from global data.

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

M	release/scripts/nodes/geometry_nodes.py
M	source/blender/blenvm/CMakeLists.txt
M	source/blender/blenvm/compile/node_graph.cc
A	source/blender/blenvm/modules/mod_object.h
M	source/blender/blenvm/modules/modules.h
M	source/blender/blenvm/util/util_opcode.h

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

diff --git a/release/scripts/nodes/geometry_nodes.py b/release/scripts/nodes/geometry_nodes.py
index 9c3b5ad..aa93f1b 100644
--- a/release/scripts/nodes/geometry_nodes.py
+++ b/release/scripts/nodes/geometry_nodes.py
@@ -159,9 +159,9 @@ class GeometryMeshLoadNode(GeometryNodeBase, ObjectNode):
         compiler.map_output(0, node.outputs[0])
 
 
-class GeometryObjectFinalMeshNode(GeometryNodeBase, ObjectNode):
+class GeometryMeshLoadObjectNode(GeometryNodeBase, ObjectNode):
     '''Load the final mesh of an object'''
-    bl_idname = 'GeometryObjectFinalMeshNode'
+    bl_idname = 'GeometryMeshLoadObjectNode'
     bl_label = 'Object Mesh'
 
     bl_id_property_type = 'OBJECT'
@@ -184,7 +184,7 @@ class GeometryObjectFinalMeshNode(GeometryNodeBase, ObjectNode):
             return
         ob, tfm, itfm = compile_modifier_inputs(compiler, self.id)
 
-        node = compiler.add_node("OBJECT_FINAL_MESH")
+        node = compiler.add_node("MESH_LOAD_OBJECT")
         compiler.link(ob, node.inputs[0])
         compiler.map_output(0, node.outputs[0])
 
@@ -432,7 +432,7 @@ def register():
         GeometryNodeCategory("GEO_INPUT", "Input", items=[
             NodeItem("ObjectRangeNode"),
             NodeItem("GeometryMeshLoadNode"),
-            NodeItem("GeometryObjectFinalMeshNode"),
+            NodeItem("GeometryMeshLoadObjectNode"),
             NodeItem(ginput.bl_idname),
             NodeItem("GeometryElementInfoNode"),
             NodeItem("ObjectValueFloatNode"),
diff --git a/source/blender/blenvm/CMakeLists.txt b/source/blender/blenvm/CMakeLists.txt
index 76645c6..184a0ec 100644
--- a/source/blender/blenvm/CMakeLists.txt
+++ b/source/blender/blenvm/CMakeLists.txt
@@ -57,6 +57,7 @@ set(SRC
 	modules/mod_image.h
 	modules/mod_math.h
 	modules/mod_mesh.h
+	modules/mod_object.h
 	modules/mod_texture.h
 
 	util/util_array.h
diff --git a/source/blender/blenvm/compile/node_graph.cc b/source/blender/blenvm/compile/node_graph.cc
index ab751d9..e1ac5ef 100644
--- a/source/blender/blenvm/compile/node_graph.cc
+++ b/source/blender/blenvm/compile/node_graph.cc
@@ -1681,6 +1681,7 @@ static void register_opcode_node_types()
 	nt->add_output("intensity", "FLOAT");
 	
 	nt = NodeGraph::add_node_type("OBJECT_LOOKUP");
+	nt->set_use_globals(true);
 	nt->add_input("key", "INT", 0, INPUT_CONSTANT);
 	nt->add_output("object", "RNAPOINTER");
 	
@@ -1688,10 +1689,6 @@ static void register_opcode_node_types()
 	nt->add_input("object", "RNAPOINTER", PointerRNA_NULL);
 	nt->add_output("transform", "MATRIX44");
 	
-	nt = NodeGraph::add_node_type("OBJECT_FINAL_MESH");
-	nt->add_input("object", "RNAPOINTER", PointerRNA_NULL);
-	nt->add_output("mesh", "MESH");
-	
 	nt = NodeGraph::add_node_type("EFFECTOR_TRANSFORM");
 	nt->add_input("object", "INT", 0, INPUT_CONSTANT);
 	nt->add_output("transform", "MATRIX44");
@@ -1707,6 +1704,10 @@ static void register_opcode_node_types()
 	nt->add_input("base_mesh", "RNAPOINTER", PointerRNA_NULL);
 	nt->add_output("mesh", "MESH");
 	
+	nt = NodeGraph::add_node_type("MESH_LOAD_OBJECT");
+	nt->add_input("object", "RNAPOINTER", PointerRNA_NULL);
+	nt->add_output("mesh", "MESH");
+	
 	nt = NodeGraph::add_node_type("MESH_COMBINE");
 	nt->add_input("mesh_a", "MESH", __empty_mesh__);
 	nt->add_input("mesh_b", "MESH", __empty_mesh__);
diff --git a/source/blender/blenvm/modules/modules.h b/source/blender/blenvm/modules/mod_object.h
similarity index 57%
copy from source/blender/blenvm/modules/modules.h
copy to source/blender/blenvm/modules/mod_object.h
index 060635a..b0a7910 100644
--- a/source/blender/blenvm/modules/modules.h
+++ b/source/blender/blenvm/modules/mod_object.h
@@ -25,30 +25,39 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
-#ifndef __MODULES_H__
-#define __MODULES_H__
+#ifndef __MOD_OBJECT_H__
+#define __MOD_OBJECT_H__
 
-#include "mod_base.h"
-#include "mod_color.h"
-#include "mod_image.h"
-#include "mod_math.h"
-#include "mod_mesh.h"
-#include "mod_texture.h"
+extern "C" {
+#include "DNA_object_types.h"
 
-#include "util_string.h"
+#include "RNA_access.h"
+}
+
+#include "mod_defines.h"
+
+#include "util_eval_globals.h"
+#include "util_math.h"
 
-namespace blenvm {
+BVM_MOD_NAMESPACE_BEGIN
 
-inline string bvm_value_function_name(const string &node)
+bvm_extern void V__OBJECT_LOOKUP(const EvalGlobals &globals, PointerRNA &ob_ptr, int key)
 {
-	return "V__" + node;
+	ob_ptr = globals.lookup_object(key);
 }
+BVM_DECL_FUNCTION_VALUE(OBJECT_LOOKUP)
 
-inline string bvm_deriv_function_name(const string &node)
+bvm_extern void V__OBJECT_TRANSFORM(matrix44 &tfm, const PointerRNA &ob_ptr)
 {
-	return "D__" + node;
+	if (ob_ptr.data && RNA_struct_is_a(&RNA_Object, ob_ptr.type)) {
+		Object *ob = (Object *)ob_ptr.data;
+		copy_m4_m4(tfm.c_data(), ob->obmat);
+	}
+	else
+		tfm = matrix44::identity();
 }
+BVM_DECL_FUNCTION_VALUE(OBJECT_TRANSFORM)
 
-} /* namespace blenvm */
+BVM_MOD_NAMESPACE_END
 
-#endif /* __MODULES_H__ */
+#endif /* __MOD_OBJECT_H__ */
diff --git a/source/blender/blenvm/modules/modules.h b/source/blender/blenvm/modules/modules.h
index 060635a..2065a06 100644
--- a/source/blender/blenvm/modules/modules.h
+++ b/source/blender/blenvm/modules/modules.h
@@ -33,6 +33,7 @@
 #include "mod_image.h"
 #include "mod_math.h"
 #include "mod_mesh.h"
+#include "mod_object.h"
 #include "mod_texture.h"
 
 #include "util_string.h"
diff --git a/source/blender/blenvm/util/util_opcode.h b/source/blender/blenvm/util/util_opcode.h
index ef9bc8e..bb29b8f 100644
--- a/source/blender/blenvm/util/util_opcode.h
+++ b/source/blender/blenvm/util/util_opcode.h
@@ -161,7 +161,9 @@ namespace blenvm {
 #define BVM_DEFINE_OPCODES_OBJECT \
 	DEF_OPCODE(OBJECT_LOOKUP) \
 	DEF_OPCODE(OBJECT_TRANSFORM) \
-	\
+	
+/*************************************/
+#define BVM_DEFINE_OPCODES_EFFECTOR \
 	DEF_OPCODE(EFFECTOR_TRANSFORM) \
 	DEF_OPCODE(EFFECTOR_CLOSEST_POINT) \
 	
@@ -200,6 +202,7 @@ namespace blenvm {
 	BVM_DEFINE_OPCODES_COLOR \
 	BVM_DEFINE_OPCODES_CURVE \
 	BVM_DEFINE_OPCODES_DUPLI \
+	BVM_DEFINE_OPCODES_EFFECTOR \
 	BVM_DEFINE_OPCODES_IMAGE \
 	BVM_DEFINE_OPCODES_ITERATOR \
 	BVM_DEFINE_OPCODES_MATH \
@@ -216,6 +219,7 @@ namespace blenvm {
 	BVM_DEFINE_OPCODES_IMAGE \
 	BVM_DEFINE_OPCODES_MATH \
 	BVM_DEFINE_OPCODES_MESH \
+	BVM_DEFINE_OPCODES_OBJECT \
 	BVM_DEFINE_OPCODES_TEXTURE \




More information about the Bf-blender-cvs mailing list