[Bf-blender-cvs] [0937f5b] object_nodes: Another geometry node for loading another objects 'final derived' mesh.

Lukas Tönne noreply at git.blender.org
Tue Jan 12 14:50:42 CET 2016


Commit: 0937f5baa3d5ffa674fbd4567dc3e76cf90b7ead
Author: Lukas Tönne
Date:   Tue Jan 12 14:48:10 2016 +0100
Branches: object_nodes
https://developer.blender.org/rB0937f5baa3d5ffa674fbd4567dc3e76cf90b7ead

Another geometry node for loading another objects 'final derived' mesh.

Modifiers should be able to work on meshes directly as much as possible,
without direct reference to an object. The space transform should
ultimately be passed along with the DM (TODO, currently requires explicit
inputs).

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

M	release/scripts/nodes/geometry_nodes.py
M	source/blender/blenvm/bvm/bvm_eval.cc
M	source/blender/blenvm/bvm/bvm_eval_mesh.h
M	source/blender/blenvm/bvm/bvm_opcode.h
M	source/blender/blenvm/compile/bvm_nodegraph.cc

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

diff --git a/release/scripts/nodes/geometry_nodes.py b/release/scripts/nodes/geometry_nodes.py
index ccd8df0..5122a1c 100644
--- a/release/scripts/nodes/geometry_nodes.py
+++ b/release/scripts/nodes/geometry_nodes.py
@@ -159,6 +159,36 @@ class GeometryMeshLoadNode(GeometryNodeBase, ObjectNode):
         compiler.map_output(0, node.outputs[0])
 
 
+class GeometryObjectFinalMeshNode(GeometryNodeBase, ObjectNode):
+    '''Load the final mesh of an object'''
+    bl_idname = 'GeometryObjectFinalMeshNode'
+    bl_label = 'Object Mesh'
+
+    bl_id_property_type = 'OBJECT'
+    def bl_id_property_poll(self, ob):
+        return ob.type == 'MESH'
+
+    def draw_buttons(self, context, layout):
+        layout.template_ID(self, "id")
+
+    def eval_dependencies(self, depsnode):
+        ob = self.id
+        if ob:
+            depsnode.add_object_relation(ob, 'GEOMETRY')
+
+    def init(self, context):
+        self.outputs.new('GeometrySocket', "")
+
+    def compile(self, compiler):
+        if self.id is None:
+            return
+        ob, tfm, itfm = compile_modifier_inputs(compiler, self.id)
+
+        node = compiler.add_node("OBJECT_FINAL_MESH")
+        compiler.link(ob, node.inputs[0])
+        compiler.map_output(0, node.outputs[0])
+
+
 class GeometryMeshCombineNode(GeometryNodeBase, ObjectNode, DynamicSocketListNode):
     '''Combine multiple meshes into one'''
     bl_idname = 'GeometryMeshCombineNode'
@@ -402,6 +432,7 @@ def register():
         GeometryNodeCategory("GEO_INPUT", "Input", items=[
             NodeItem("ObjectIterationNode"),
             NodeItem("GeometryMeshLoadNode"),
+            NodeItem("GeometryObjectFinalMeshNode"),
             NodeItem(ginput.bl_idname),
             NodeItem("GeometryElementInfoNode"),
             NodeItem("ObjectValueFloatNode"),
diff --git a/source/blender/blenvm/bvm/bvm_eval.cc b/source/blender/blenvm/bvm/bvm_eval.cc
index 0a7e8c5..5f08fbf 100644
--- a/source/blender/blenvm/bvm/bvm_eval.cc
+++ b/source/blender/blenvm/bvm/bvm_eval.cc
@@ -977,6 +977,12 @@ void EvalContext::eval_instructions(const EvalGlobals *globals, const Function *
 				eval_op_object_transform(stack, offset_object, offset_transform);
 				break;
 			}
+			case OP_OBJECT_FINAL_MESH: {
+				StackIndex offset_object = fn->read_stack_index(&instr);
+				StackIndex offset_mesh = fn->read_stack_index(&instr);
+				eval_op_object_final_mesh(stack, offset_object, offset_mesh);
+				break;
+			}
 			
 			case OP_EFFECTOR_TRANSFORM: {
 				int object_index = fn->read_int(&instr);
diff --git a/source/blender/blenvm/bvm/bvm_eval_mesh.h b/source/blender/blenvm/bvm/bvm_eval_mesh.h
index a087b2f..79bb34a 100644
--- a/source/blender/blenvm/bvm/bvm_eval_mesh.h
+++ b/source/blender/blenvm/bvm/bvm_eval_mesh.h
@@ -59,6 +59,23 @@ static void eval_op_mesh_load(float *stack, StackIndex offset_base_mesh, StackIn
 	stack_store_mesh(stack, offset_mesh, dm);
 }
 
+static void eval_op_object_final_mesh(float *stack,
+                                      StackIndex offset_object,
+                                      StackIndex offset_mesh)
+{
+	PointerRNA ptr = stack_load_pointer(stack, offset_object);
+	
+	DerivedMesh *result = NULL;
+	if (ptr.data && RNA_struct_is_a(&RNA_Object, ptr.type)) {
+		Object *ob = (Object *)ptr.data;
+		result = ob->derivedFinal;
+	}
+	if (!result)
+		result = CDDM_new(0, 0, 0, 0, 0);
+	
+	stack_store_mesh(stack, offset_mesh, result);
+}
+
 static void dm_insert(
         DerivedMesh *result, DerivedMesh *dm,
         int ofs_verts, int ofs_edges, int ofs_loops, int ofs_polys)
diff --git a/source/blender/blenvm/bvm/bvm_opcode.h b/source/blender/blenvm/bvm/bvm_opcode.h
index 0795bd2..2e861e2 100644
--- a/source/blender/blenvm/bvm/bvm_opcode.h
+++ b/source/blender/blenvm/bvm/bvm_opcode.h
@@ -138,6 +138,7 @@ namespace bvm {
 	\
 	DEF_OPCODE(OBJECT_LOOKUP) \
 	DEF_OPCODE(OBJECT_TRANSFORM) \
+	DEF_OPCODE(OBJECT_FINAL_MESH) \
 	\
 	DEF_OPCODE(EFFECTOR_TRANSFORM) \
 	DEF_OPCODE(EFFECTOR_CLOSEST_POINT) \
diff --git a/source/blender/blenvm/compile/bvm_nodegraph.cc b/source/blender/blenvm/compile/bvm_nodegraph.cc
index 8b69204..01f2332 100644
--- a/source/blender/blenvm/compile/bvm_nodegraph.cc
+++ b/source/blender/blenvm/compile/bvm_nodegraph.cc
@@ -1251,6 +1251,7 @@ OpCode get_opcode_from_node_type(const string &node)
 	
 	NODETYPE(OBJECT_LOOKUP);
 	NODETYPE(OBJECT_TRANSFORM);
+	NODETYPE(OBJECT_FINAL_MESH);
 	
 	NODETYPE(EFFECTOR_TRANSFORM);
 	NODETYPE(EFFECTOR_CLOSEST_POINT);
@@ -1658,6 +1659,10 @@ static void register_opcode_node_types()
 	nt->add_input("object", TYPE_POINTER, PointerRNA_NULL);
 	nt->add_output("transform", TYPE_MATRIX44);
 	
+	nt = NodeGraph::add_function_node_type("OBJECT_FINAL_MESH");
+	nt->add_input("object", TYPE_POINTER, PointerRNA_NULL);
+	nt->add_output("mesh", TYPE_MESH);
+	
 	nt = NodeGraph::add_function_node_type("EFFECTOR_TRANSFORM");
 	nt->add_input("object", TYPE_INT, 0, INPUT_CONSTANT);
 	nt->add_output("transform", TYPE_MATRIX44);




More information about the Bf-blender-cvs mailing list