[Bf-blender-cvs] [ef636af49e8] functions-experimental-refactor: move network generation to separate file
Jacques Lucke
noreply at git.blender.org
Fri Nov 1 20:31:47 CET 2019
Commit: ef636af49e88b1367426b0d177e8214a806ce55e
Author: Jacques Lucke
Date: Fri Nov 1 20:31:13 2019 +0100
Branches: functions-experimental-refactor
https://developer.blender.org/rBef636af49e88b1367426b0d177e8214a806ce55e
move network generation to separate file
===================================================================
M source/blender/functions2/CMakeLists.txt
A source/blender/functions2/FN_vtree_multi_function_network_generation.h
A source/blender/functions2/intern/vtree_multi_function_network/generate.cc
M source/blender/modifiers/intern/MOD_functiondeform_cxx.cc
===================================================================
diff --git a/source/blender/functions2/CMakeLists.txt b/source/blender/functions2/CMakeLists.txt
index f48cd582851..10bdca0e31a 100644
--- a/source/blender/functions2/CMakeLists.txt
+++ b/source/blender/functions2/CMakeLists.txt
@@ -25,6 +25,7 @@ set(SRC
intern/multi_functions/lists.cc
intern/multi_functions/mixed.cc
intern/multi_functions/network.cc
+ intern/vtree_multi_function_network/generate.cc
intern/cpp_type.cc
intern/cpp_types.cc
intern/generic_tuple.cc
@@ -42,6 +43,7 @@ set(SRC
FN_multi_function.h
FN_multi_functions.h
FN_vtree_multi_function_network_builder.h
+ FN_vtree_multi_function_network_generation.h
FN_vtree_multi_function_network.h
intern/multi_functions/lists.h
diff --git a/source/blender/functions2/FN_vtree_multi_function_network_generation.h b/source/blender/functions2/FN_vtree_multi_function_network_generation.h
new file mode 100644
index 00000000000..93c54883827
--- /dev/null
+++ b/source/blender/functions2/FN_vtree_multi_function_network_generation.h
@@ -0,0 +1,16 @@
+#ifndef __FN_VTREE_MULTI_FUNCTION_NETWORK_GENERATION_H__
+#define __FN_VTREE_MULTI_FUNCTION_NETWORK_GENERATION_H__
+
+#include "FN_vtree_multi_function_network.h"
+#include "BLI_owned_resources.h"
+
+namespace FN {
+
+using BLI::OwnedResources;
+
+std::unique_ptr<VTreeMFNetwork> generate_vtree_multi_function_network(const VirtualNodeTree &vtree,
+ OwnedResources &resources);
+
+} // namespace FN
+
+#endif /* __FN_VTREE_MULTI_FUNCTION_NETWORK_GENERATION_H__ */
diff --git a/source/blender/modifiers/intern/MOD_functiondeform_cxx.cc b/source/blender/functions2/intern/vtree_multi_function_network/generate.cc
similarity index 87%
copy from source/blender/modifiers/intern/MOD_functiondeform_cxx.cc
copy to source/blender/functions2/intern/vtree_multi_function_network/generate.cc
index 8901f739c6a..797a4119f4b 100644
--- a/source/blender/modifiers/intern/MOD_functiondeform_cxx.cc
+++ b/source/blender/functions2/intern/vtree_multi_function_network/generate.cc
@@ -1,70 +1,14 @@
-#include "DNA_modifier_types.h"
-
-#include "BKE_virtual_node_tree_cxx.h"
-
-#include "FN_multi_functions.h"
-#include "FN_multi_function_network.h"
-#include "FN_vtree_multi_function_network.h"
#include "FN_vtree_multi_function_network_builder.h"
+#include "FN_vtree_multi_function_network_generation.h"
+#include "FN_multi_functions.h"
#include "BLI_math_cxx.h"
#include "BLI_string_map.h"
-#include "BLI_owned_resources.h"
-#include "BLI_stack_cxx.h"
-#include "BLI_timeit.h"
-
-#include "DEG_depsgraph_query.h"
-
-using BKE::VirtualLink;
-using BKE::VirtualNode;
-using BKE::VirtualNodeTree;
-using BKE::VirtualSocket;
-using BLI::Array;
-using BLI::ArrayRef;
+
+namespace FN {
+
using BLI::float3;
-using BLI::IndexRange;
-using BLI::Map;
-using BLI::OwnedResources;
-using BLI::Stack;
using BLI::StringMap;
-using BLI::StringRef;
-using BLI::TemporaryVector;
-using BLI::Vector;
-using FN::CPPType;
-using FN::GenericArrayRef;
-using FN::GenericMutableArrayRef;
-using FN::GenericVectorArray;
-using FN::GenericVirtualListListRef;
-using FN::GenericVirtualListRef;
-using FN::MFBuilderDummyNode;
-using FN::MFBuilderFunctionNode;
-using FN::MFBuilderInputSocket;
-using FN::MFBuilderNode;
-using FN::MFBuilderOutputSocket;
-using FN::MFBuilderSocket;
-using FN::MFContext;
-using FN::MFDataType;
-using FN::MFDummyNode;
-using FN::MFFunctionNode;
-using FN::MFInputSocket;
-using FN::MFMask;
-using FN::MFNetwork;
-using FN::MFNetworkBuilder;
-using FN::MFNode;
-using FN::MFOutputSocket;
-using FN::MFParams;
-using FN::MFParamsBuilder;
-using FN::MFParamType;
-using FN::MFSignature;
-using FN::MFSignatureBuilder;
-using FN::MFSocket;
-using FN::MultiFunction;
-using FN::VTreeMFNetwork;
-using FN::VTreeMFNetworkBuilder;
-
-extern "C" {
-void MOD_functiondeform_do(FunctionDeformModifierData *fdmd, float (*vertexCos)[3], int numVerts);
-}
static MFDataType get_type_by_socket(const VirtualSocket &vsocket)
{
@@ -586,20 +530,9 @@ static bool insert_unlinked_inputs(VTreeMFNetworkBuilder &builder, OwnedResource
return true;
}
-void MOD_functiondeform_do(FunctionDeformModifierData *fdmd, float (*vertexCos)[3], int numVerts)
+std::unique_ptr<VTreeMFNetwork> generate_vtree_multi_function_network(const VirtualNodeTree &vtree,
+ OwnedResources &resources)
{
- if (fdmd->function_tree == nullptr) {
- return;
- }
-
- bNodeTree *tree = (bNodeTree *)DEG_get_original_id((ID *)fdmd->function_tree);
- VirtualNodeTree vtree;
- vtree.add_all_of_tree(tree);
- vtree.freeze_and_index();
-
- const VirtualNode &input_vnode = *vtree.nodes_with_idname("fn_FunctionInputNode")[0];
- const VirtualNode &output_vnode = *vtree.nodes_with_idname("fn_FunctionOutputNode")[0];
-
Vector<MFDataType> type_by_vsocket{vtree.socket_count()};
for (const VirtualNode *vnode : vtree.nodes()) {
for (const VirtualSocket *vsocket : vnode->inputs()) {
@@ -612,7 +545,6 @@ void MOD_functiondeform_do(FunctionDeformModifierData *fdmd, float (*vertexCos)[
}
}
- OwnedResources resources;
VTreeMFNetworkBuilder builder(vtree, std::move(type_by_vsocket));
if (!insert_nodes(builder, resources)) {
BLI_assert(false);
@@ -625,27 +557,7 @@ void MOD_functiondeform_do(FunctionDeformModifierData *fdmd, float (*vertexCos)[
}
auto vtree_network = builder.build();
-
- Vector<const MFOutputSocket *> function_inputs = {
- &vtree_network->lookup_socket(input_vnode.output(0)).as_output(),
- &vtree_network->lookup_socket(input_vnode.output(1)).as_output(),
- &vtree_network->lookup_socket(input_vnode.output(2)).as_output()};
-
- Vector<const MFInputSocket *> function_outputs = {
- &vtree_network->lookup_socket(output_vnode.input(0)).as_input()};
-
- FN::MF_EvaluateNetwork function{function_inputs, function_outputs};
-
- MFParamsBuilder params(function, numVerts);
- params.add_readonly_single_input(ArrayRef<float3>((float3 *)vertexCos, numVerts));
- params.add_readonly_single_input(&fdmd->control1);
- params.add_readonly_single_input(&fdmd->control2);
-
- TemporaryVector<float3> output_vectors(numVerts);
- params.add_single_output<float3>(output_vectors);
-
- MFContext context;
- function.call(IndexRange(numVerts).as_array_ref(), params.build(), context);
-
- memcpy(vertexCos, output_vectors.begin(), output_vectors.size() * sizeof(float3));
+ return vtree_network;
}
+
+} // namespace FN
diff --git a/source/blender/modifiers/intern/MOD_functiondeform_cxx.cc b/source/blender/modifiers/intern/MOD_functiondeform_cxx.cc
index 8901f739c6a..d9daafbe585 100644
--- a/source/blender/modifiers/intern/MOD_functiondeform_cxx.cc
+++ b/source/blender/modifiers/intern/MOD_functiondeform_cxx.cc
@@ -1,591 +1,28 @@
#include "DNA_modifier_types.h"
-#include "BKE_virtual_node_tree_cxx.h"
-
+#include "FN_vtree_multi_function_network_generation.h"
#include "FN_multi_functions.h"
-#include "FN_multi_function_network.h"
-#include "FN_vtree_multi_function_network.h"
-#include "FN_vtree_multi_function_network_builder.h"
#include "BLI_math_cxx.h"
-#include "BLI_string_map.h"
-#include "BLI_owned_resources.h"
-#include "BLI_stack_cxx.h"
-#include "BLI_timeit.h"
#include "DEG_depsgraph_query.h"
-using BKE::VirtualLink;
using BKE::VirtualNode;
using BKE::VirtualNodeTree;
-using BKE::VirtualSocket;
-using BLI::Array;
using BLI::ArrayRef;
using BLI::float3;
using BLI::IndexRange;
-using BLI::Map;
-using BLI::OwnedResources;
-using BLI::Stack;
-using BLI::StringMap;
-using BLI::StringRef;
using BLI::TemporaryVector;
using BLI::Vector;
-using FN::CPPType;
-using FN::GenericArrayRef;
-using FN::GenericMutableArrayRef;
-using FN::GenericVectorArray;
-using FN::GenericVirtualListListRef;
-using FN::GenericVirtualListRef;
-using FN::MFBuilderDummyNode;
-using FN::MFBuilderFunctionNode;
-using FN::MFBuilderInputSocket;
-using FN::MFBuilderNode;
-using FN::MFBuilderOutputSocket;
-using FN::MFBuilderSocket;
using FN::MFContext;
-using FN::MFDataType;
-using FN::MFDummyNode;
-using FN::MFFunctionNode;
using FN::MFInputSocket;
-using FN::MFMask;
-using FN::MFNetwork;
-using FN::MFNetworkBuilder;
-using FN::MFNode;
using FN::MFOutputSocket;
-using FN::MFParams;
using FN::MFParamsBuilder;
-using FN::MFParamType;
-using FN::MFSignature;
-using FN::MFSignatureBuilder;
-using FN::MFSocket;
-using FN::MultiFunction;
-using FN::VTreeMFNetwork;
-using FN::VTreeMFNetworkBuilder;
extern "C" {
void MOD_functiondeform_do(FunctionDeformModifierData *fdmd, float (*vertexCos)[3], int numVerts);
}
-static MFDataType get_type_by_socket(const VirtualSocket &vsocket)
-{
- StringRef idname = vsocket.idname();
-
- if (idname == "fn_FloatSocket") {
- return MFDataType::ForSingle<float>();
- }
- else if (idname == "fn_VectorSocket") {
- return MFDataType::ForSingle<float3>();
- }
- else if (idname == "fn_IntegerSocket") {
- return MFDataType::ForSingle<int32_t>();
- }
- else if (idname == "fn_BooleanSocket") {
- return MFDataType::ForSingle<bool>();
- }
- else if (idname == "fn_ObjectSocket") {
- return MFDataType::ForSingle<Object *>();
- }
- else if (idname == "fn_TextSocket") {
- return MFDataType::ForSingle<std::string>();
- }
- else if (idname == "fn_FloatListSocket") {
- return MFDataType::ForVector<float>();
- }
- else if (idname == "fn_VectorListSocket") {
- return MFDataType::ForVector<float3>();
- }
- else if (idname == "fn_IntegerListSocket") {
- return MFDataType::ForVector<int32_t>();
- }
- else if (idname == "fn_BooleanListSocket") {
- return MFDataType::ForVector<bool>();
- }
- else if (idname == "fn_ObjectListSocket") {
- return MFDataType::ForVector<Object *>();
- }
- else if (idname == "fn_TextListSocket") {
- return MFDataType::ForVector<std::string>();
- }
-
- return MFDataType();
-}
-
-static const CPPType &get_cpp_type_by_name(StringRef name)
-{
- if (name == "Float") {
- return FN::GET_TYPE<float>();
- }
- else if (name == "Vector") {
- return FN::GET_TYPE<float3>();
- }
- else if (name == "Integer") {
- return FN::GET_TYPE<int32_t>();
- }
- else if (nam
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list