[Bf-blender-cvs] [416d6a17dcf] functions-experimental-refactor: first created and executed multi function graph
Jacques Lucke
noreply at git.blender.org
Thu Oct 17 17:53:23 CEST 2019
Commit: 416d6a17dcfee535d501815dbd87f3d2c14c5add
Author: Jacques Lucke
Date: Thu Oct 17 17:53:04 2019 +0200
Branches: functions-experimental-refactor
https://developer.blender.org/rB416d6a17dcfee535d501815dbd87f3d2c14c5add
first created and executed multi function graph
===================================================================
M source/blender/blenkernel/BKE_generic_array_ref.h
M source/blender/blenkernel/BKE_multi_function.h
M source/blender/blenkernel/BKE_multi_function_network.h
M source/blender/blenkernel/BKE_tuple.h
M source/blender/blenkernel/intern/multi_function_network.cc
M source/blender/blenkernel/intern/tuple.cc
M source/blender/modifiers/intern/MOD_functiondeform_cxx.cc
===================================================================
diff --git a/source/blender/blenkernel/BKE_generic_array_ref.h b/source/blender/blenkernel/BKE_generic_array_ref.h
index 99c3369b43a..b18ba151dd8 100644
--- a/source/blender/blenkernel/BKE_generic_array_ref.h
+++ b/source/blender/blenkernel/BKE_generic_array_ref.h
@@ -141,6 +141,16 @@ class GenericMutableArrayRef {
{
}
+ void destruct_all()
+ {
+ if (m_type->trivially_destructible()) {
+ return;
+ }
+ for (uint i = 0; i < m_size; i++) {
+ m_type->destruct((*this)[i]);
+ }
+ }
+
const CPPType &type() const
{
return *m_type;
diff --git a/source/blender/blenkernel/BKE_multi_function.h b/source/blender/blenkernel/BKE_multi_function.h
index 4647f1b485a..bea715de6f6 100644
--- a/source/blender/blenkernel/BKE_multi_function.h
+++ b/source/blender/blenkernel/BKE_multi_function.h
@@ -253,7 +253,6 @@ class MultiFunction {
private:
Vector<std::string> m_param_names;
Vector<ParamType> m_param_types;
- Vector<CPPType *> m_param_base_types;
Vector<uint> m_params_with_external_dependencies;
public:
@@ -261,7 +260,7 @@ class MultiFunction {
{
this->readonly_single_input(name, GET_TYPE<T>());
}
- void readonly_single_input(StringRef name, CPPType &type)
+ void readonly_single_input(StringRef name, const CPPType &type)
{
m_param_names.append(name);
m_param_types.append(ParamType(ParamType::ReadonlySingleInput, &type));
@@ -271,7 +270,7 @@ class MultiFunction {
{
this->single_output(name, GET_TYPE<T>(), has_external_dependencies);
}
- void single_output(StringRef name, CPPType &type, bool has_external_dependencies = false)
+ void single_output(StringRef name, const CPPType &type, bool has_external_dependencies = false)
{
if (has_external_dependencies) {
m_params_with_external_dependencies.append(m_param_names.size());
@@ -284,7 +283,7 @@ class MultiFunction {
{
this->readonly_vector_input(name, GET_TYPE<T>());
}
- void readonly_vector_input(StringRef name, CPPType &base_type)
+ void readonly_vector_input(StringRef name, const CPPType &base_type)
{
m_param_names.append(name);
m_param_types.append(ParamType(ParamType::ReadonlyVectorInput, &base_type));
@@ -294,7 +293,9 @@ class MultiFunction {
{
this->vector_output(name, GET_TYPE<T>(), has_external_dependencies);
}
- void vector_output(StringRef name, CPPType &base_type, bool has_external_dependencies = false)
+ void vector_output(StringRef name,
+ const CPPType &base_type,
+ bool has_external_dependencies = false)
{
if (has_external_dependencies) {
m_params_with_external_dependencies.append(m_param_names.size());
@@ -303,7 +304,9 @@ class MultiFunction {
m_param_types.append(ParamType(ParamType::VectorOutput, &base_type));
}
- void mutable_vector(StringRef name, CPPType &base_type, bool has_external_dependencies = false)
+ void mutable_vector(StringRef name,
+ const CPPType &base_type,
+ bool has_external_dependencies = false)
{
if (has_external_dependencies) {
m_params_with_external_dependencies.append(m_param_names.size());
diff --git a/source/blender/blenkernel/BKE_multi_function_network.h b/source/blender/blenkernel/BKE_multi_function_network.h
index 18f1ece3c46..ae0836b42b9 100644
--- a/source/blender/blenkernel/BKE_multi_function_network.h
+++ b/source/blender/blenkernel/BKE_multi_function_network.h
@@ -26,7 +26,7 @@ class BuilderOutputSocket;
class NetworkBuilder;
-class BuilderNode {
+class BuilderNode : BLI::NonCopyable, BLI::NonMovable {
protected:
NetworkBuilder *m_network;
Vector<BuilderInputSocket *> m_inputs;
@@ -69,7 +69,7 @@ class BuilderFunctionNode : public BuilderNode {
class BuilderPlaceholderNode : public BuilderNode {
};
-class BuilderSocket {
+class BuilderSocket : BLI::NonCopyable, BLI::NonMovable {
private:
BuilderNode *m_node;
bool m_is_output;
@@ -177,7 +177,7 @@ class OutputSocket;
class Network;
-class Node {
+class Node : BLI::NonCopyable, BLI::NonMovable {
private:
Network *m_network;
Vector<InputSocket *> m_inputs;
@@ -217,7 +217,7 @@ class FunctionNode : public Node {
class PlaceholderNode : public Node {
};
-class Socket {
+class Socket : BLI::NonCopyable, BLI::NonMovable {
private:
Node *m_node;
bool m_is_output;
@@ -231,6 +231,7 @@ class Socket {
Node &node();
MultiFunctionDataType type();
+ uint index();
uint id();
bool is_input();
@@ -273,111 +274,114 @@ class Network : BLI::NonCopyable, BLI::NonMovable {
public:
Network(std::unique_ptr<NetworkBuilder> builder);
~Network();
+
+ Node &node_by_id(uint id);
};
/* Builder Implementations
*******************************************/
-NetworkBuilder &BuilderNode::network()
+inline NetworkBuilder &BuilderNode::network()
{
return *m_network;
}
-ArrayRef<BuilderInputSocket *> BuilderNode::inputs()
+inline ArrayRef<BuilderInputSocket *> BuilderNode::inputs()
{
return m_inputs;
}
-ArrayRef<BuilderOutputSocket *> BuilderNode::outputs()
+inline ArrayRef<BuilderOutputSocket *> BuilderNode::outputs()
{
return m_outputs;
}
-uint BuilderNode::id()
+inline uint BuilderNode::id()
{
return m_id;
}
-bool BuilderNode::is_function()
+inline bool BuilderNode::is_function()
{
return !m_is_placeholder;
}
-bool BuilderNode::is_placeholder()
+inline bool BuilderNode::is_placeholder()
{
return m_is_placeholder;
}
-BuilderFunctionNode &BuilderNode::as_function()
+inline BuilderFunctionNode &BuilderNode::as_function()
{
BLI_assert(this->is_function());
return *(BuilderFunctionNode *)this;
}
-BuilderPlaceholderNode &BuilderNode::as_placeholder()
+
+inline BuilderPlaceholderNode &BuilderNode::as_placeholder()
{
BLI_assert(this->is_placeholder());
return *(BuilderPlaceholderNode *)this;
}
-MultiFunction &BuilderFunctionNode::function()
+inline MultiFunction &BuilderFunctionNode::function()
{
return *m_function;
}
-ArrayRef<uint> BuilderFunctionNode::input_param_indices()
+inline ArrayRef<uint> BuilderFunctionNode::input_param_indices()
{
return m_input_param_indices;
}
-ArrayRef<uint> BuilderFunctionNode::output_param_indices()
+inline ArrayRef<uint> BuilderFunctionNode::output_param_indices()
{
return m_output_param_indices;
}
-BuilderNode &BuilderSocket::node()
+inline BuilderNode &BuilderSocket::node()
{
return *m_node;
}
-MultiFunctionDataType BuilderSocket::type()
+inline MultiFunctionDataType BuilderSocket::type()
{
return m_type;
}
-uint BuilderSocket::index()
+inline uint BuilderSocket::index()
{
return m_index;
}
-uint BuilderSocket::id()
+inline uint BuilderSocket::id()
{
return m_id;
}
-bool BuilderSocket::is_input()
+inline bool BuilderSocket::is_input()
{
return !m_is_output;
}
-bool BuilderSocket::is_output()
+inline bool BuilderSocket::is_output()
{
return m_is_output;
}
-BuilderInputSocket &BuilderSocket::as_input()
+inline BuilderInputSocket &BuilderSocket::as_input()
{
BLI_assert(this->is_input());
return *(BuilderInputSocket *)this;
}
-BuilderOutputSocket &BuilderSocket::as_output()
+inline BuilderOutputSocket &BuilderSocket::as_output()
{
BLI_assert(this->is_output());
return *(BuilderOutputSocket *)this;
}
-BuilderOutputSocket *BuilderInputSocket::origin()
+inline BuilderOutputSocket *BuilderInputSocket::origin()
{
return m_origin;
}
-ArrayRef<BuilderInputSocket *> BuilderOutputSocket::targets()
+inline ArrayRef<BuilderInputSocket *> BuilderOutputSocket::targets()
{
return m_targets;
}
@@ -385,95 +389,110 @@ ArrayRef<BuilderInputSocket *> BuilderOutputSocket::targets()
/* Network Implementations
**************************************/
-Network &Node::network()
+inline Network &Node::network()
{
return *m_network;
}
-ArrayRef<InputSocket *> Node::inputs()
+inline ArrayRef<InputSocket *> Node::inputs()
{
return m_inputs;
}
-ArrayRef<OutputSocket *> Node::outputs()
+
+inline ArrayRef<OutputSocket *> Node::outputs()
{
return m_outputs;
}
-uint Node::id()
+inline uint Node::id()
{
return m_id;
}
-bool Node::is_function()
+inline bool Node::is_function()
{
return !m_is_placeholder;
}
-bool Node::is_placeholder()
+
+inline bool Node::is_placeholder()
{
return m_is_placeholder;
}
-FunctionNode &Node::as_function()
+inline FunctionNode &Node::as_function()
{
BLI_assert(this->is_function());
return *(FunctionNode *)this;
}
-PlaceholderNode &Node::as_placeholder()
+
+inline PlaceholderNode &Node::as_placeholder()
{
BLI_assert(this->is_placeholder());
return *(PlaceholderNode *)this;
}
-MultiFunction &FunctionNode::function()
+inline MultiFunction &FunctionNode::function()
{
return *m_function;
}
-Node &Socket::node()
+inline Node &Socket::node()
{
return *m_node;
}
-MultiFunctionDataType Socket::type()
+inline MultiFunctionDataType Socket::type()
{
return m_type;
}
-uint Socket::id()
+inline uint Socket::index()
+{
+ return m_index;
+}
+
+inline uint Socket::id()
{
return m_id;
}
-bool Socket::is_input()
+inline bool Socket::is_input()
{
return !m_is_output;
}
-bool Socket::is_output()
+
+inline bool Socket::is_output()
{
return m_is_output;
}
-InputSocket &Socket::as_input()
+inline InputSocket &Socket::as_input()
{
BLI_assert(this->is_input());
return *(InputSocket *)this;
}
-OutputSocket &Socket::as_output()
+
+inline OutputSocket &Socket::as_output()
{
BLI_assert(this->is_output());
return *(OutputSocket *)this;
}
-OutputSocket &InputSocket::origin()
+inline OutputSocket &InputSocket::origin()
{
return *m_origin;
}
-ArrayRef<InputSocket *> OutputSocket::targets()
+inline ArrayRef<InputSocket *> OutputSocket::targets()
{
return m_targets;
}
+inline Node &Network::node_by_id(uint index)
+{
+ return *m_node_by_id[index];
+}
+
} // namespace MultiFunctionNetwork
} // namespace BKE
diff --git a/source/blender/blenkernel/BKE_tuple.h b/source/blender/blenkernel/BKE_tuple.h
index e6031378f5b..ebb2062a8da 100644
--- a/sour
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list