[Bf-blender-cvs] [5de0556] object_nodes: Simple integration of object nodes into the modifier stack evaluation.

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


Commit: 5de05567f9ad3c429fa834d40d87c0b7d8238f16
Author: Lukas Tönne
Date:   Thu Nov 12 16:57:24 2015 +0100
Branches: object_nodes
https://developer.blender.org/rB5de05567f9ad3c429fa834d40d87c0b7d8238f16

Simple integration of object nodes into the modifier stack evaluation.

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

M	source/blender/blenkernel/intern/DerivedMesh.c
M	source/blender/blenvm/BVM_api.h
M	source/blender/blenvm/compile/bvm_codegen.cc
M	source/blender/blenvm/compile/bvm_codegen.h
M	source/blender/blenvm/intern/bvm_api.cc

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

diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 3c83fbe..af54e22 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -40,6 +40,7 @@
 #include "DNA_material_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
+#include "DNA_node_types.h"
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h"
 
@@ -73,6 +74,8 @@ static DerivedMesh *navmesh_dm_createNavMeshForVisualization(DerivedMesh *dm);
 
 #include "BLI_sys_types.h" /* for intptr_t support */
 
+#include "BVM_api.h"
+
 #include "GPU_buffers.h"
 #include "GPU_extensions.h"
 #include "GPU_glew.h"
@@ -1699,6 +1702,27 @@ static void dm_ensure_display_normals(DerivedMesh *dm)
 	}
 }
 
+/* XXX this should replace modifier stack eventually */
+static DerivedMesh *mesh_calc_modifier_nodes(Scene *scene, Object *ob, bNodeTree *ntree)
+{
+	Mesh *me = ob->data;
+	DerivedMesh *dm = CDDM_from_mesh(me);
+	
+	struct BVMEvalGlobals *globals = BVM_globals_create();
+	
+	struct BVMSchedule *sched = BVM_gen_modifier_function(globals, ob, ntree, NULL);
+	
+	{
+		struct BVMEvalContext *context = BVM_context_create();
+		BVM_eval_modifier(context, sched);
+		BVM_context_free(context);
+	}
+	
+	BVM_globals_free(globals);
+	
+	return dm;
+}
+
 /**
  * new value for useDeform -1  (hack for the gameengine):
  *
@@ -1759,6 +1783,14 @@ static void mesh_calc_modifiers(
 	if (useDeform)
 		deform_app_flags |= MOD_APPLY_USECACHE;
 
+	if (ob->nodetree) {
+		DerivedMesh *dm = mesh_calc_modifier_nodes(scene, ob, ob->nodetree);
+		*r_final = dm;
+		if (r_deform)
+			*r_deform = CDDM_copy(dm);
+		return;
+	}
+
 	if (!skipVirtualArmature) {
 		firstmd = modifiers_getVirtualModifierList(ob, &virtualModifierData);
 	}
diff --git a/source/blender/blenvm/BVM_api.h b/source/blender/blenvm/BVM_api.h
index c8afdfb..c0e285b 100644
--- a/source/blender/blenvm/BVM_api.h
+++ b/source/blender/blenvm/BVM_api.h
@@ -41,7 +41,6 @@ extern "C" {
 #endif
 
 struct BVMFunction;
-struct BVMFunction;
 struct BVMModule;
 
 void BVM_init(void);
@@ -122,6 +121,14 @@ void BVM_texture_cache_clear(void);
 
 /* ------------------------------------------------------------------------- */
 
+struct BVMFunction *BVM_gen_modifier_function(const struct BVMEvalGlobals *globals,
+                                              struct Object *ob, struct bNodeTree *btree,
+                                              FILE *debug_file);
+
+void BVM_eval_modifier(struct BVMEvalContext *context, struct BVMFunction *fn);
+
+/* ------------------------------------------------------------------------- */
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/blenvm/compile/bvm_codegen.cc b/source/blender/blenvm/compile/bvm_codegen.cc
index 46b910d..af9fba6 100644
--- a/source/blender/blenvm/compile/bvm_codegen.cc
+++ b/source/blender/blenvm/compile/bvm_codegen.cc
@@ -34,6 +34,7 @@
 
 #include "bvm_codegen.h"
 #include "bvm_eval.h"
+#include "bvm_function.h"
 #include "bvm_nodegraph.h"
 
 namespace bvm {
diff --git a/source/blender/blenvm/compile/bvm_codegen.h b/source/blender/blenvm/compile/bvm_codegen.h
index 6346d10..d4e36d6 100644
--- a/source/blender/blenvm/compile/bvm_codegen.h
+++ b/source/blender/blenvm/compile/bvm_codegen.h
@@ -44,7 +44,6 @@ struct Function;
 struct NodeGraph;
 struct NodeInstance;
 struct TypeDesc;
-struct ReturnValue;
 
 struct BVMCompiler {
 	typedef std::vector<int> StackUsers;
diff --git a/source/blender/blenvm/intern/bvm_api.cc b/source/blender/blenvm/intern/bvm_api.cc
index 9f8ad36..cae9973 100644
--- a/source/blender/blenvm/intern/bvm_api.cc
+++ b/source/blender/blenvm/intern/bvm_api.cc
@@ -54,6 +54,7 @@ extern "C" {
 #include "bvm_eval.h"
 #include "bvm_function.h"
 #include "bvm_nodegraph.h"
+
 #include "bvm_util_map.h"
 #include "bvm_util_thread.h"
 
@@ -839,6 +840,29 @@ void BVM_texture_cache_clear(void)
 	bvm_tex_cache.clear();
 }
 
-#undef _GRAPH
+/* ------------------------------------------------------------------------- */
+
+struct BVMFunction *BVM_gen_modifier_function(const struct BVMEvalGlobals *globals,
+                                              struct Object *ob, struct bNodeTree *btree,
+                                              FILE *debug_file)
+{
+	using namespace bvm;
+	
+	NodeGraph graph;
+	CompileContext comp(_GLOBALS(globals));
+//	parse_modifier_nodes(&comp, btree, &graph);
+	
+	if (debug_file) {
+		graph.dump_graphviz(debug_file, "Modifier Schedule Graph");
+	}
+	
+	BVMCompiler compiler;
+	Function *fn = compiler.codegen_function(graph);
+	
+	return (BVMFunction *)fn;
+}
 
-#undef _EXPR
+void BVM_eval_modifier(struct BVMEvalContext *context, struct BVMFunction *fn)
+{
+	
+}




More information about the Bf-blender-cvs mailing list