[Bf-blender-cvs] [a18d338d3ff] functions: minor improvements
Jacques Lucke
noreply at git.blender.org
Tue Jul 23 19:17:06 CEST 2019
Commit: a18d338d3ff27f17f5c4c6799d5ae9c275e1de59
Author: Jacques Lucke
Date: Tue Jul 23 19:02:39 2019 +0200
Branches: functions
https://developer.blender.org/rBa18d338d3ff27f17f5c4c6799d5ae9c275e1de59
minor improvements
===================================================================
M source/blender/blenkernel/BKE_node_tree.hpp
M source/blender/blenlib/BLI_set.hpp
M source/blender/functions/core/data_flow_graph.hpp
M source/blender/simulations/bparticles/node_frontend.cpp
===================================================================
diff --git a/source/blender/blenkernel/BKE_node_tree.hpp b/source/blender/blenkernel/BKE_node_tree.hpp
index 4b4289255de..84a761f4d0a 100644
--- a/source/blender/blenkernel/BKE_node_tree.hpp
+++ b/source/blender/blenkernel/BKE_node_tree.hpp
@@ -227,10 +227,15 @@ class VirtualNode {
return rna;
}
- StringRefNull name()
+ const char *name()
{
return m_bnode->name;
}
+
+ const char *idname()
+ {
+ return m_bnode->idname;
+ }
};
class VirtualSocket {
@@ -293,6 +298,11 @@ class VirtualSocket {
RNA_pointer_create(&m_btree->id, &RNA_NodeSocket, m_bsocket, &rna);
return rna;
}
+
+ const char *name()
+ {
+ return m_bsocket->name;
+ }
};
class VirtualLink {
diff --git a/source/blender/blenlib/BLI_set.hpp b/source/blender/blenlib/BLI_set.hpp
index f961e4d6ecb..d56cfd1fb9b 100644
--- a/source/blender/blenlib/BLI_set.hpp
+++ b/source/blender/blenlib/BLI_set.hpp
@@ -91,7 +91,7 @@ template<typename T, uint N = 4> class Set {
/**
* Insert the value in the set if it did not exist before.
- * Return false, when it existed before, otherwise true.
+ * Return true when the value has been newly inserted, otherwise false.
*/
bool add(const T &value)
{
diff --git a/source/blender/functions/core/data_flow_graph.hpp b/source/blender/functions/core/data_flow_graph.hpp
index 72835294071..11ee38c82f9 100644
--- a/source/blender/functions/core/data_flow_graph.hpp
+++ b/source/blender/functions/core/data_flow_graph.hpp
@@ -204,8 +204,7 @@ class DataFlowGraph : public RefCountedBase {
}
}
- template<typename ContainerT>
- Vector<DFGraphSocket> map_sockets(const ContainerT &dfgb_sockets)
+ template<typename ContainerT> Vector<DFGraphSocket> map_sockets(const ContainerT &dfgb_sockets)
{
Vector<DFGraphSocket> sockets;
for (DFGB_Socket socket : dfgb_sockets) {
@@ -414,6 +413,13 @@ class DataFlowGraph : public RefCountedBase {
}
}
+ template<typename T> T *function_body_of_output(DFGraphSocket socket)
+ {
+ BLI_assert(socket.is_output());
+ SharedFunction &fn = this->function_of_output(socket.id());
+ return fn->body<T>();
+ }
+
const StringRefNull name_of_input(uint input_id)
{
return this->function_of_input(input_id)->input_name(this->index_of_input(input_id));
@@ -434,6 +440,18 @@ class DataFlowGraph : public RefCountedBase {
return this->function_of_output(output_id)->output_type(this->index_of_output(output_id));
}
+ SharedType &type_of_input(DFGraphSocket input_socket)
+ {
+ BLI_assert(input_socket.is_input());
+ return this->type_of_input(input_socket.id());
+ }
+
+ SharedType &type_of_output(DFGraphSocket output_socket)
+ {
+ BLI_assert(output_socket.is_output());
+ return this->type_of_output(output_socket.id());
+ }
+
std::string to_dot();
void to_dot__clipboard();
diff --git a/source/blender/simulations/bparticles/node_frontend.cpp b/source/blender/simulations/bparticles/node_frontend.cpp
index 458a28c8ed3..9f3ade60882 100644
--- a/source/blender/simulations/bparticles/node_frontend.cpp
+++ b/source/blender/simulations/bparticles/node_frontend.cpp
@@ -51,7 +51,7 @@ std::unique_ptr<StepDescription> step_description_from_node_tree(VirtualNodeTree
attributes.add_float("Size", 0.01f);
attributes.add_float3("Color", {1.0f, 1.0f, 1.0f});
declarations.add_new(particle_type_node->name(), attributes);
- particle_type_names.add_new(particle_type_node->name().to_std_string());
+ particle_type_names.add_new(particle_type_node->name());
}
auto data_graph = FN::DataFlowNodes::generate_graph(vtree).value();
@@ -65,7 +65,7 @@ std::unique_ptr<StepDescription> step_description_from_node_tree(VirtualNodeTree
if (is_particle_type_node(linked->vnode())) {
auto force = item.value(ctx, vnode);
if (force) {
- forces.add(linked->vnode()->name().to_std_string(), force.release());
+ forces.add(linked->vnode()->name(), force.release());
}
}
}
@@ -79,7 +79,7 @@ std::unique_ptr<StepDescription> step_description_from_node_tree(VirtualNodeTree
if (is_particle_type_node(linked->vnode())) {
auto listener = item.value(ctx, vnode);
if (listener) {
- offset_handlers.add(linked->vnode()->name().to_std_string(), listener.release());
+ offset_handlers.add(linked->vnode()->name(), listener.release());
}
}
}
@@ -93,7 +93,7 @@ std::unique_ptr<StepDescription> step_description_from_node_tree(VirtualNodeTree
if (is_particle_type_node(linked->vnode())) {
auto event = item.value(ctx, vnode);
if (event) {
- events.add(linked->vnode()->name().to_std_string(), event.release());
+ events.add(linked->vnode()->name(), event.release());
}
}
}
@@ -117,7 +117,7 @@ std::unique_ptr<StepDescription> step_description_from_node_tree(VirtualNodeTree
StringMap<ParticleType *> particle_types;
for (VirtualNode *vnode : get_type_nodes(vtree)) {
- std::string name = vnode->name().to_std_string();
+ std::string name = vnode->name();
ArrayRef<Force *> forces_on_type = forces.lookup_default(name);
Integrator *integrator = nullptr;
More information about the Bf-blender-cvs
mailing list