Commit: af7ec7ac5636043c9c1b62095bfe0c6db77bd4dd
Author: Lukas Tönne
Date: Wed Jun 18 17:37:57 2014 +0200
https://developer.blender.org/rBaf7ec7ac5636043c9c1b62095bfe0c6db77bd4dd
Wrapper for std::bind, which will allow us to catch operation arguments
and replace them by their respective result data types.
This is just a proof of concept, it will be used later to construct a
intermediate callback, which then performs the actual binding at
scheduling time, when all the input data of an operation is actually
available.
It uses a nifty recursion trick based on the tuple index and std::get
to apply a tuple as an argument pack in std::bind. The
bind_operation_tuple function appends tuple elements to the ArgsTail
pack one by one until N==0, at which point a template specialization is
used to issue the final std::bind call.
===================================================================
M source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
M source/blender/depsgraph/intern/depsgraph_type_defines.cpp
M source/blender/depsgraph/intern/stubs.h
===================================================================
diff --git a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
index d85a6fb..5f73c42 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
@@ -282,6 +282,53 @@ IDDepsNode *DepsgraphNodeBuilder::build_object(Scene
*scene, Object *ob)
return ob_node;
}
+#include <cstddef> // for std::size_t
+#include <tuple>
+#include <type_traits>
+
+typedef function<void ()> EvalFunc;
+//typedef function<EvalFunc ()> BindFunc;
+
+namespace detail {
+
+using std::forward;
+using std::tuple;
+using std::tuple_size;
+using std::get;
+using std::size_t;
+
+template <size_t N>
+struct bind_tuple_impl {
+ template <typename Func, typename... Args, typename... ArgsTail>
+ static EvalFunc bind_operation_tuple(Func &&func, tuple<Args...>
&&args, ArgsTail... tail)
+ {
+ typedef decltype(get<N-1>(args)) T;
+ T &&head = get<N-1>(args);
+
+ return
bind_tuple_impl<N-1>::bind_operation_tuple(forward<Func>(func),
forward<tuple<Args...>>(args), forward<T>(head), tail...);
+ }
+};
+
+template <>
+struct bind_tuple_impl<0> {
+ template <typename Func, typename... Args, typename... ArgsTail>
+ static EvalFunc bind_operation_tuple(Func &&func, tuple<Args...>
&&args, ArgsTail... tail)
+ {
+ return std::bind(func, tail...);
+ }
+};
+
+} /* namespace detail */
+
+template <typename Func, typename... Args>
+static EvalFunc bind_operation(Func func, Args... args)
+{
+ typedef std::tuple_size<std::tuple<Args...>> args_size;
+
+ return
detail::bind_tuple_impl<args_size::value>::bind_operation_tuple(func,
std::tuple<Args...>(args...));
+}
+
+
ComponentDepsNode *DepsgraphNodeBuilder::build_object_transform(Object *ob,
IDDepsNode *ob_node)
{
/* component to hold all transform operations */
@@ -289,7 +336,7 @@ ComponentDepsNode
*DepsgraphNodeBuilder::build_object_transform(Object *ob, IDDe
/* init operation */
add_operation_node(trans_node,
- DEPSOP_TYPE_INIT,
bind(BKE_object_eval_local_transform, ob),
+ DEPSOP_TYPE_INIT,
bind_operation(BKE_object_eval_local_transform, ob, 3, 6, 12),
deg_op_name_object_local_transform);
/* return component created */
diff --git a/source/blender/depsgraph/intern/depsgraph_type_defines.cpp
b/source/blender/depsgraph/intern/depsgraph_type_defines.cpp
index ffee038..3d3bca0 100644
--- a/source/blender/depsgraph/intern/depsgraph_type_defines.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_type_defines.cpp
@@ -80,7 +80,7 @@ void BKE_rigidbody_rebuild_sim(Scene *scene) {}
void BKE_rigidbody_eval_simulation(Scene *scene) {}
void BKE_rigidbody_object_sync_transforms(Scene *scene, Object *ob) {}
-void BKE_object_eval_local_transform(Object *ob) {}
+void BKE_object_eval_local_transform(Object *ob, int a, int b, int c) {
printf("BKE_object_eval_local_transform on %s (%d, %d, %d)\n", ob->id.name, a,
b, c); }
void BKE_object_eval_parent(Object *ob) {}
void BKE_object_eval_modifier(Object *ob, ModifierData *md) {}
diff --git a/source/blender/depsgraph/intern/stubs.h
b/source/blender/depsgraph/intern/stubs.h
index be5b526..829f68e 100644
--- a/source/blender/depsgraph/intern/stubs.h
+++ b/source/blender/depsgraph/intern/stubs.h
@@ -42,7 +42,7 @@ void BKE_rigidbody_rebuild_sim(Scene *scene); //
BKE_rigidbody_rebuild_sim
void BKE_rigidbody_eval_simulation(Scene *scene); //
BKE_rigidbody_do_simulation
void BKE_rigidbody_object_sync_transforms(Scene *scene, Object *ob); //
BKE_rigidbody_sync_transforms
-void BKE_object_eval_local_transform(Object *ob);
+void BKE_object_eval_local_transform(Object *ob, int a, int b, int c);
void BKE_object_eval_parent(Object *ob);
void BKE_object_eval_modifier(Object *ob, ModifierData *md);
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs