[Bf-blender-cvs] [2012ea2e9dc] functions: add id handle lookups to function modifiers
Jacques Lucke
noreply at git.blender.org
Wed Dec 4 14:28:20 CET 2019
Commit: 2012ea2e9dc37ab5545f518759a1fdc8f534a1d4
Author: Jacques Lucke
Date: Wed Dec 4 13:49:24 2019 +0100
Branches: functions
https://developer.blender.org/rB2012ea2e9dc37ab5545f518759a1fdc8f534a1d4
add id handle lookups to function modifiers
===================================================================
M source/blender/functions/CMakeLists.txt
A source/blender/functions/FN_multi_function_dependencies.h
M source/blender/modifiers/intern/MOD_functiondeform_cxx.cc
M source/blender/modifiers/intern/MOD_functionpoints_cxx.cc
M source/blender/simulations/bparticles/node_frontend.cpp
===================================================================
diff --git a/source/blender/functions/CMakeLists.txt b/source/blender/functions/CMakeLists.txt
index 3c23d7244c1..f4702536bbf 100644
--- a/source/blender/functions/CMakeLists.txt
+++ b/source/blender/functions/CMakeLists.txt
@@ -53,6 +53,7 @@ set(SRC
FN_multi_function_common_contexts.h
FN_multi_function_context.h
FN_multi_function_data_type.h
+ FN_multi_function_dependencies.h
FN_multi_function_mask.h
FN_multi_function_network.h
FN_multi_function_param_type.h
diff --git a/source/blender/functions/FN_multi_function_dependencies.h b/source/blender/functions/FN_multi_function_dependencies.h
new file mode 100644
index 00000000000..2bf786f723d
--- /dev/null
+++ b/source/blender/functions/FN_multi_function_dependencies.h
@@ -0,0 +1,49 @@
+#ifndef __FN_MULTI_FUNCTION_DEPENDENCIES_H__
+#define __FN_MULTI_FUNCTION_DEPENDENCIES_H__
+
+#include "BLI_set.h"
+
+#include "DNA_object_types.h"
+
+#include "BKE_inlined_node_tree.h"
+
+namespace FN {
+
+using BKE::InlinedNodeTree;
+using BKE::XGroupInput;
+using BKE::XInputSocket;
+using BLI::Set;
+
+inline Set<Object *> get_objects_used_by_inputs(const InlinedNodeTree &inlined_tree)
+{
+ Set<Object *> objects;
+ for (const XInputSocket *xsocket : inlined_tree.all_input_sockets()) {
+ if (xsocket->idname() == "fn_ObjectSocket") {
+ Object *object = (Object *)RNA_pointer_get(xsocket->rna(), "value").data;
+ if (object != nullptr) {
+ objects.add(object);
+ }
+ }
+ }
+ for (const XGroupInput *group_input : inlined_tree.all_group_inputs()) {
+ if (group_input->vsocket().idname() == "fn_ObjectSocket") {
+ Object *object = (Object *)RNA_pointer_get(group_input->vsocket().rna(), "value").data;
+ if (object != nullptr) {
+ objects.add(object);
+ }
+ }
+ }
+ return objects;
+}
+
+inline void add_objects_used_by_inputs(IDHandleLookup &id_handle_lookup,
+ const InlinedNodeTree &inlined_tree)
+{
+ for (Object *object : get_objects_used_by_inputs(inlined_tree)) {
+ id_handle_lookup.add(object->id);
+ }
+}
+
+} // namespace FN
+
+#endif /* __FN_MULTI_FUNCTION_DEPENDENCIES_H__ */
\ No newline at end of file
diff --git a/source/blender/modifiers/intern/MOD_functiondeform_cxx.cc b/source/blender/modifiers/intern/MOD_functiondeform_cxx.cc
index b88633c7872..2f8e3b7dcdb 100644
--- a/source/blender/modifiers/intern/MOD_functiondeform_cxx.cc
+++ b/source/blender/modifiers/intern/MOD_functiondeform_cxx.cc
@@ -3,6 +3,7 @@
#include "FN_inlined_tree_multi_function_network_generation.h"
#include "FN_multi_functions.h"
#include "FN_multi_function_common_contexts.h"
+#include "FN_multi_function_dependencies.h"
#include "BLI_math_cxx.h"
@@ -65,7 +66,10 @@ void MOD_functiondeform_do(FunctionDeformModifierData *fdmd,
FN::VertexPositionArray vertex_positions_context;
vertex_positions_context.positions = ArrayRef<float3>((float3 *)vertexCos, numVerts);
- MFContextBuilder context_builder;
+ BKE::IDHandleLookup id_handle_lookup;
+ FN::add_objects_used_by_inputs(id_handle_lookup, inlined_tree);
+
+ MFContextBuilder context_builder(&id_handle_lookup);
context_builder.add_element_context(time_context);
context_builder.add_element_context(
vertex_positions_context,
diff --git a/source/blender/modifiers/intern/MOD_functionpoints_cxx.cc b/source/blender/modifiers/intern/MOD_functionpoints_cxx.cc
index c610f33821b..4e0cef49a6d 100644
--- a/source/blender/modifiers/intern/MOD_functionpoints_cxx.cc
+++ b/source/blender/modifiers/intern/MOD_functionpoints_cxx.cc
@@ -10,6 +10,7 @@
#include "FN_inlined_tree_multi_function_network_generation.h"
#include "FN_multi_functions.h"
#include "FN_multi_function_common_contexts.h"
+#include "FN_multi_function_dependencies.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
@@ -56,7 +57,10 @@ Mesh *MOD_functionpoints_do(FunctionPointsModifierData *fpmd,
FN::SceneTimeContext time_context;
time_context.time = DEG_get_ctime(ctx->depsgraph);
- FN::MFContextBuilder context_builder;
+ BKE::IDHandleLookup id_handle_lookup;
+ FN::add_objects_used_by_inputs(id_handle_lookup, inlined_tree);
+
+ FN::MFContextBuilder context_builder(&id_handle_lookup);
context_builder.add_element_context(time_context);
function->call({0}, params_builder, context_builder);
diff --git a/source/blender/simulations/bparticles/node_frontend.cpp b/source/blender/simulations/bparticles/node_frontend.cpp
index 0357ac2851c..cb1f09d9e43 100644
--- a/source/blender/simulations/bparticles/node_frontend.cpp
+++ b/source/blender/simulations/bparticles/node_frontend.cpp
@@ -14,6 +14,7 @@
#include "FN_generic_tuple.h"
#include "FN_inlined_tree_multi_function_network_generation.h"
#include "FN_multi_function_common_contexts.h"
+#include "FN_multi_function_dependencies.h"
#include "node_frontend.hpp"
#include "integrator.hpp"
@@ -63,29 +64,6 @@ class InfluencesCollector {
StringMap<AttributesInfoBuilder *> &m_attributes;
};
-static Set<Object *> get_used_objects(const InlinedNodeTree &inlined_tree)
-{
- Set<Object *> objects;
- for (const XInputSocket *xsocket : inlined_tree.all_input_sockets()) {
- if (xsocket->idname() == "fn_ObjectSocket") {
- Object *object = (Object *)RNA_pointer_get(xsocket->rna(), "value").data;
- if (object != nullptr) {
- objects.add(object);
- }
- }
- }
- for (const XGroupInput *group_input : inlined_tree.all_group_inputs()) {
- if (group_input->vsocket().idname() == "fn_ObjectSocket") {
- Object *object = (Object *)RNA_pointer_get(group_input->vsocket().rna(), "value").data;
- if (object != nullptr) {
- objects.add(object);
- }
- }
- }
-
- return objects;
-}
-
class VTreeData {
private:
/* Keep this at the beginning, so that it is destructed last. */
@@ -97,10 +75,7 @@ class VTreeData {
public:
VTreeData(VTreeMFNetwork &inlined_tree_data) : m_inlined_tree_data_graph(inlined_tree_data)
{
- Set<Object *> objects = get_used_objects(inlined_tree_data.inlined_tree());
- for (Object *ob : objects) {
- m_id_handle_lookup.add(ob->id);
- }
+ FN::add_objects_used_by_inputs(m_id_handle_lookup, inlined_tree_data.inlined_tree());
}
const InlinedNodeTree &inlined_tree()
More information about the Bf-blender-cvs
mailing list