[Bf-blender-cvs] [de0933f] object_nodes: Replaced EvalData for node evaluation with graph inputs.

Lukas Tönne noreply at git.blender.org
Tue Dec 8 14:52:30 CET 2015


Commit: de0933f0aa0b4499068a5247f6da14ce04334dd7
Author: Lukas Tönne
Date:   Tue Dec 8 14:48:22 2015 +0100
Branches: object_nodes
https://developer.blender.org/rBde0933f0aa0b4499068a5247f6da14ce04334dd7

Replaced EvalData for node evaluation with graph inputs.

Warning: this disabled the iteration input for mesh arrays. To make it
work again the mesh array kernel needs to overwrite the input argument.

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

M	release/scripts/nodes/common_nodes.py
M	release/scripts/nodes/forcefield_nodes.py
M	release/scripts/nodes/geometry_nodes.py
M	source/blender/blenvm/bvm/bvm_eval.cc
M	source/blender/blenvm/bvm/bvm_eval.h
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
M	source/blender/blenvm/intern/bvm_api.cc

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

diff --git a/release/scripts/nodes/common_nodes.py b/release/scripts/nodes/common_nodes.py
index 0570db1..6c86e99 100644
--- a/release/scripts/nodes/common_nodes.py
+++ b/release/scripts/nodes/common_nodes.py
@@ -82,8 +82,7 @@ class IterationNode(CommonNodeBase, ObjectNode):
         self.outputs.new('NodeSocketInt', "N")
 
     def compile(self, compiler):
-        node = compiler.add_node("ITERATION", self.name)
-        compiler.map_output(0, node.outputs[0])
+        compiler.map_output(0, compiler.graph_input("iteration"))
 
 class MathNode(CommonNodeBase, ObjectNode):
     '''Math '''
diff --git a/release/scripts/nodes/forcefield_nodes.py b/release/scripts/nodes/forcefield_nodes.py
index 1e3cb61..fd6a6f6 100644
--- a/release/scripts/nodes/forcefield_nodes.py
+++ b/release/scripts/nodes/forcefield_nodes.py
@@ -81,10 +81,8 @@ class PointDataNode(ForceNodeBase, ObjectNode):
         self.outputs.new('NodeSocketVector', "Velocity")
 
     def compile(self, compiler):
-        node = compiler.add_node("POINT_POSITION", self.name+"P")
-        compiler.map_output(0, node.outputs[0])
-        node = compiler.add_node("POINT_VELOCITY", self.name+"V")
-        compiler.map_output(1, node.outputs[0])
+        compiler.map_output(0, compiler.graph_input("effector.position"))
+        compiler.map_output(1, compiler.graph_input("effector.velocity"))
 
 
 class ForceClosestPointNode(ForceNodeBase, ObjectNode):
@@ -101,9 +99,8 @@ class ForceClosestPointNode(ForceNodeBase, ObjectNode):
 
     def compile(self, compiler):
         node = compiler.add_node("EFFECTOR_CLOSEST_POINT", self.name+"N")
-        obnode = compiler.add_node("EFFECTOR_OBJECT", self.name+"O")
         
-        compiler.link(obnode.outputs[0], node.inputs["object"])
+        compiler.link(compiler.graph_input("effector.object"), node.inputs["object"])
 
         compiler.map_input(0, node.inputs["vector"])
         compiler.map_output(0, node.outputs["position"])
diff --git a/release/scripts/nodes/geometry_nodes.py b/release/scripts/nodes/geometry_nodes.py
index b7291bf..4c9e342 100644
--- a/release/scripts/nodes/geometry_nodes.py
+++ b/release/scripts/nodes/geometry_nodes.py
@@ -80,6 +80,7 @@ class GeometryMeshLoadNode(GeometryNodeBase, ObjectNode):
 
     def compile(self, compiler):
         node = compiler.add_node("MESH_LOAD", self.name)
+        compiler.link(compiler.graph_input("modifier.base_mesh"), node.inputs[0])
         compiler.map_output(0, node.outputs[0])
 
 
diff --git a/source/blender/blenvm/bvm/bvm_eval.cc b/source/blender/blenvm/bvm/bvm_eval.cc
index cacec12..201e4dd 100644
--- a/source/blender/blenvm/bvm/bvm_eval.cc
+++ b/source/blender/blenvm/bvm/bvm_eval.cc
@@ -156,16 +156,6 @@ static void eval_op_release_mesh_ptr(float *stack, StackIndex offset)
 	stack_store_mesh_ptr(stack, offset, p);
 }
 
-static void eval_op_point_position(const EvalData *data, float *stack, StackIndex offset)
-{
-	stack_store_float3(stack, offset, data->effector.position);
-}
-
-static void eval_op_point_velocity(const EvalData *data, float *stack, StackIndex offset)
-{
-	stack_store_float3(stack, offset, data->effector.velocity);
-}
-
 static void eval_op_mix_rgb(float *stack, int mode, StackIndex offset_col_a, StackIndex offset_col_b, StackIndex offset_fac, StackIndex offset_r)
 {
 	float4 a = stack_load_float4(stack, offset_col_a);
@@ -177,21 +167,6 @@ static void eval_op_mix_rgb(float *stack, int mode, StackIndex offset_col_a, Sta
 	stack_store_float4(stack, offset_r, a);
 }
 
-static void eval_op_iteration(const EvalData *data, float *stack, StackIndex offset)
-{
-	stack_store_int(stack, offset, data->iteration);
-}
-
-static void eval_op_tex_coord(const EvalData *data, float *stack, StackIndex offset)
-{
-	stack_store_float3(stack, offset, data->texture.co);
-}
-
-static void eval_op_effector_object(const EvalData *data, float *stack, StackIndex offset)
-{
-	stack_store_pointer(stack, offset, data->effector.object);
-}
-
 static void eval_op_effector_transform(const EvalGlobals *globals, float *stack, int object_index, StackIndex offset_tfm)
 {
 	Object *ob = globals->objects[object_index];
@@ -239,7 +214,7 @@ static void eval_op_effector_closest_point(float *stack, StackIndex offset_objec
 	}
 }
 
-void EvalContext::eval_instructions(const EvalGlobals *globals, const EvalData *data, const Function *fn, int entry_point, float *stack) const
+void EvalContext::eval_instructions(const EvalGlobals *globals, const Function *fn, int entry_point, float *stack) const
 {
 	EvalKernelData kd;
 	kd.context = this;
@@ -347,16 +322,6 @@ void EvalContext::eval_instructions(const EvalGlobals *globals, const EvalData *
 				eval_op_release_mesh_ptr(stack, offset);
 				break;
 			}
-			case OP_POINT_POSITION: {
-				StackIndex offset = fn->read_stack_index(&instr);
-				eval_op_point_position(data, stack, offset);
-				break;
-			}
-			case OP_POINT_VELOCITY: {
-				StackIndex offset = fn->read_stack_index(&instr);
-				eval_op_point_velocity(data, stack, offset);
-				break;
-			}
 			case OP_ADD_FLOAT: {
 				StackIndex offset_a = fn->read_stack_index(&instr);
 				StackIndex offset_b = fn->read_stack_index(&instr);
@@ -700,17 +665,6 @@ void EvalContext::eval_instructions(const EvalGlobals *globals, const EvalData *
 				break;
 			}
 				
-			case OP_ITERATION: {
-				StackIndex offset = fn->read_stack_index(&instr);
-				eval_op_iteration(data, stack, offset);
-				break;
-			}
-			
-			case OP_TEX_COORD: {
-				StackIndex offset = fn->read_stack_index(&instr);
-				eval_op_tex_coord(data, stack, offset);
-				break;
-			}
 			case OP_TEX_PROC_VORONOI: {
 				int distance_metric = fn->read_int(&instr);
 				int color_type = fn->read_int(&instr);
@@ -748,11 +702,6 @@ void EvalContext::eval_instructions(const EvalGlobals *globals, const EvalData *
 				break;
 			}
 			
-			case OP_EFFECTOR_OBJECT: {
-				StackIndex offset = fn->read_stack_index(&instr);
-				eval_op_effector_object(data, stack, offset);
-				break;
-			}
 			case OP_EFFECTOR_TRANSFORM: {
 				int object_index = fn->read_int(&instr);
 				StackIndex offset_tfm = fn->read_stack_index(&instr);
@@ -770,8 +719,9 @@ void EvalContext::eval_instructions(const EvalGlobals *globals, const EvalData *
 				break;
 			}
 			case OP_MESH_LOAD: {
+				StackIndex offset_base_mesh = fn->read_stack_index(&instr);
 				StackIndex offset_mesh = fn->read_stack_index(&instr);
-				eval_op_mesh_load(data, stack, offset_mesh);
+				eval_op_mesh_load(stack, offset_base_mesh, offset_mesh);
 				break;
 			}
 			case OP_MESH_COMBINE: {
@@ -787,7 +737,7 @@ void EvalContext::eval_instructions(const EvalGlobals *globals, const EvalData *
 				int fn_transform = fn->read_jump_address(&instr);
 				StackIndex offset_transform = fn->read_stack_index(&instr);
 				StackIndex offset_mesh_out = fn->read_stack_index(&instr);
-				eval_op_mesh_array(globals, data, &kd, stack,
+				eval_op_mesh_array(globals, &kd, stack,
 				                   offset_mesh_in, offset_mesh_out, offset_count, fn_transform, offset_transform);
 				break;
 			}
@@ -800,7 +750,7 @@ void EvalContext::eval_instructions(const EvalGlobals *globals, const EvalData *
 	}
 }
 
-void EvalContext::eval_function(const EvalGlobals *globals, const EvalData *data, const Function *fn, const void *arguments[], void *results[]) const
+void EvalContext::eval_function(const EvalGlobals *globals, const Function *fn, const void *arguments[], void *results[]) const
 {
 	float stack[BVM_STACK_SIZE] = {0};
 	
@@ -814,7 +764,7 @@ void EvalContext::eval_function(const EvalGlobals *globals, const EvalData *data
 		}
 	}
 	
-	eval_instructions(globals, data, fn, fn->entry_point(), stack);
+	eval_instructions(globals, fn, fn->entry_point(), stack);
 	
 	/* read out return values */
 	for (int i = 0; i < fn->num_return_values(); ++i) {
@@ -825,9 +775,9 @@ void EvalContext::eval_function(const EvalGlobals *globals, const EvalData *data
 	}
 }
 
-void EvalContext::eval_expression(const EvalGlobals *globals, const EvalData *data, const Function *fn, int entry_point, float *stack) const
+void EvalContext::eval_expression(const EvalGlobals *globals, const Function *fn, int entry_point, float *stack) const
 {
-	eval_instructions(globals, data, fn, entry_point, stack);
+	eval_instructions(globals, fn, entry_point, stack);
 }
 
 } /* namespace bvm */
diff --git a/source/blender/blenvm/bvm/bvm_eval.h b/source/blender/blenvm/bvm/bvm_eval.h
index c30bc3d..04fe0b1 100644
--- a/source/blender/blenvm/bvm/bvm_eval.h
+++ b/source/blender/blenvm/bvm/bvm_eval.h
@@ -128,11 +128,11 @@ struct EvalContext {
 	EvalContext();
 	~EvalContext();
 	
-	void eval_function(const EvalGlobals *globals, const EvalData *data, const Function *fn, const void *arguments[], void *results[]) const;
-	void eval_expression(const EvalGlobals *globals, const EvalData *data, const Function *fn, int entry_point, float *stack) const;
+	void eval_function(const EvalGlobals *globals, const Function *fn, const void *arguments[], void *results[]) const;
+	void eval_expression(const EvalGlobals *globals, const Function *fn, int entry_point, float *stack) const;
 	
 protected:
-	void eval_instructions(const EvalGlobals *globals, const EvalData *data, const Function *fn, int entry_point, float *stack) const;
+	void eval_instructions(const EvalGlobals *globals, const Function *fn, int entry_point, float *stack) const;
 
 	MEM_CXX_CLASS_ALLOC_FUNCS("BVM:EvalContext")
 };
diff --git a/source/blender/blenvm/bvm/bvm_eval_mesh.h b/source/blender/blenvm/bvm/bvm_eval_mesh.h
index 45caf39..90fef12 100644
--- a/source/blender/blenvm/bvm/bvm_eval_mesh.h
+++ b/source/blender/blenvm/bvm/bvm_eval_mesh.h
@@ -40,10 +40,17 @@ extern "C" {
 
 namespace bvm {
 
-static void eval_op_mesh_load(const EvalData *data, float *stack, StackIndex offset)
+static void eval_op_mesh_load(float *stack, StackIndex offset_base_mesh, StackIndex offset_mesh)
 {
-	DerivedMesh *dm = CDDM_from_mesh(data->modifier.base_mesh);
-	stack_store_mesh(stack, offset, dm);
+	PointerRNA ptr = stack_load_pointer(stack, offset_base_mesh);
+	DerivedMesh *dm;
+	if (ptr.data && RNA_struct_is_a(&RNA_Mesh, ptr.type)) {
+		dm = CDDM_from_mesh((Mesh *)ptr.data);
+	}
+	else {
+		dm = CDDM_new(0, 0, 0, 0, 0);
+	}
+	stack_store

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list