[Bf-blender-cvs] [14326619a1a] master: Cleanup: avoid using namespace name in many cases

Jacques Lucke noreply at git.blender.org
Sat Jul 25 21:02:14 CEST 2020


Commit: 14326619a1a94af677c2d1d626b57d7ff2afbd21
Author: Jacques Lucke
Date:   Sat Jul 25 20:39:21 2020 +0200
Branches: master
https://developer.blender.org/rB14326619a1a94af677c2d1d626b57d7ff2afbd21

Cleanup: avoid using namespace name in many cases

===================================================================

M	source/blender/simulation/intern/simulation_collect_influences.cc

===================================================================

diff --git a/source/blender/simulation/intern/simulation_collect_influences.cc b/source/blender/simulation/intern/simulation_collect_influences.cc
index 0fcaf78fe5b..539a9d689d5 100644
--- a/source/blender/simulation/intern/simulation_collect_influences.cc
+++ b/source/blender/simulation/intern/simulation_collect_influences.cc
@@ -31,34 +31,54 @@
 
 namespace blender::sim {
 
+using fn::GVSpan;
+using fn::MFContextBuilder;
+using fn::MFDataType;
+using fn::MFInputSocket;
+using fn::MFNetwork;
+using fn::MFNetworkEvaluator;
+using fn::MFNode;
+using fn::MFOutputSocket;
+using fn::MFParamsBuilder;
+using fn::MFParamType;
+using fn::MultiFunction;
+using fn::VSpan;
+using nodes::DerivedNodeTree;
+using nodes::DInputSocket;
+using nodes::DNode;
+using nodes::DOutputSocket;
+using nodes::DParentNode;
+using nodes::MFNetworkTreeMap;
+using nodes::NodeTreeRefMap;
+
 struct DummyDataSources {
-  Map<const fn::MFOutputSocket *, std::string> particle_attributes;
+  Map<const MFOutputSocket *, std::string> particle_attributes;
 };
 
 extern "C" {
 void WM_clipboard_text_set(const char *buf, bool selection);
 }
 
-static std::string dnode_to_path(const nodes::DNode &dnode)
+static std::string dnode_to_path(const DNode &dnode)
 {
   std::string path;
-  for (const nodes::DParentNode *parent = dnode.parent(); parent; parent = parent->parent()) {
+  for (const DParentNode *parent = dnode.parent(); parent; parent = parent->parent()) {
     path = parent->node_ref().name() + "/" + path;
   }
   path = path + dnode.name();
   return path;
 }
 
-static Span<const nodes::DNode *> get_particle_simulation_nodes(const nodes::DerivedNodeTree &tree)
+static Span<const DNode *> get_particle_simulation_nodes(const DerivedNodeTree &tree)
 {
   return tree.nodes_by_type("SimulationNodeParticleSimulation");
 }
 
 /* Returns true on success. */
-static bool compute_global_inputs(nodes::MFNetworkTreeMap &network_map,
+static bool compute_global_inputs(MFNetworkTreeMap &network_map,
                                   ResourceCollector &resources,
-                                  Span<const fn::MFInputSocket *> sockets,
-                                  MutableSpan<fn::GMutableSpan> r_results)
+                                  Span<const MFInputSocket *> sockets,
+                                  MutableSpan<GMutableSpan> r_results)
 {
   int amount = sockets.size();
   if (amount == 0) {
@@ -69,28 +89,28 @@ static bool compute_global_inputs(nodes::MFNetworkTreeMap &network_map,
     return false;
   }
 
-  fn::MFNetworkEvaluator network_fn{{}, sockets};
-  fn::MFParamsBuilder params{network_fn, 1};
+  MFNetworkEvaluator network_fn{{}, sockets};
+  MFParamsBuilder params{network_fn, 1};
   for (int param_index : network_fn.param_indices()) {
-    fn::MFParamType param_type = network_fn.param_type(param_index);
-    BLI_assert(param_type.category() == fn::MFParamType::Category::SingleOutput); /* For now. */
-    const fn::CPPType &type = param_type.data_type().single_type();
+    MFParamType param_type = network_fn.param_type(param_index);
+    BLI_assert(param_type.category() == MFParamType::Category::SingleOutput); /* For now. */
+    const CPPType &type = param_type.data_type().single_type();
     void *buffer = resources.linear_allocator().allocate(type.size(), type.alignment());
     resources.add(buffer, type.destruct_cb(), AT);
-    fn::GMutableSpan span{type, buffer, 1};
+    GMutableSpan span{type, buffer, 1};
     r_results[param_index] = span;
     params.add_uninitialized_single_output(span);
   }
-  fn::MFContextBuilder context;
+  MFContextBuilder context;
   network_fn.call(IndexRange(1), params, context);
   return true;
 }
 
 static std::optional<Array<std::string>> compute_global_string_inputs(
-    nodes::MFNetworkTreeMap &network_map, Span<const fn::MFInputSocket *> sockets)
+    MFNetworkTreeMap &network_map, Span<const MFInputSocket *> sockets)
 {
   ResourceCollector local_resources;
-  Array<fn::GMutableSpan> computed_values(sockets.size(), NoInitialization());
+  Array<GMutableSpan> computed_values(sockets.size(), NoInitialization());
   if (!compute_global_inputs(network_map, local_resources, sockets, computed_values)) {
     return {};
   }
@@ -102,18 +122,17 @@ static std::optional<Array<std::string>> compute_global_string_inputs(
   return strings;
 }
 
-static void find_and_deduplicate_particle_attribute_nodes(nodes::MFNetworkTreeMap &network_map,
+static void find_and_deduplicate_particle_attribute_nodes(MFNetworkTreeMap &network_map,
                                                           DummyDataSources &r_data_sources)
 {
-  fn::MFNetwork &network = network_map.network();
-  const nodes::DerivedNodeTree &tree = network_map.tree();
+  MFNetwork &network = network_map.network();
+  const DerivedNodeTree &tree = network_map.tree();
 
-  Span<const nodes::DNode *> attribute_dnodes = tree.nodes_by_type(
-      "SimulationNodeParticleAttribute");
+  Span<const DNode *> attribute_dnodes = tree.nodes_by_type("SimulationNodeParticleAttribute");
 
-  Vector<fn::MFInputSocket *> name_sockets;
-  for (const nodes::DNode *dnode : attribute_dnodes) {
-    fn::MFInputSocket &name_socket = network_map.lookup_dummy(dnode->input(0));
+  Vector<MFInputSocket *> name_sockets;
+  for (const DNode *dnode : attribute_dnodes) {
+    MFInputSocket &name_socket = network_map.lookup_dummy(dnode->input(0));
     name_sockets.append(&name_socket);
   }
 
@@ -123,23 +142,22 @@ static void find_and_deduplicate_particle_attribute_nodes(nodes::MFNetworkTreeMa
     return;
   }
 
-  MultiValueMap<std::pair<std::string, fn::MFDataType>, fn::MFNode *>
-      attribute_nodes_by_name_and_type;
+  MultiValueMap<std::pair<std::string, MFDataType>, MFNode *> attribute_nodes_by_name_and_type;
   for (int i : attribute_names->index_range()) {
     attribute_nodes_by_name_and_type.add(
         {(*attribute_names)[i], name_sockets[i]->node().output(0).data_type()},
         &name_sockets[i]->node());
   }
 
-  Map<const fn::MFOutputSocket *, std::string> attribute_inputs;
+  Map<const MFOutputSocket *, std::string> attribute_inputs;
   for (auto item : attribute_nodes_by_name_and_type.items()) {
     StringRef attribute_name = item.key.first;
-    fn::MFDataType data_type = item.key.second;
-    Span<fn::MFNode *> nodes = item.value;
+    MFDataType data_type = item.key.second;
+    Span<MFNode *> nodes = item.value;
 
-    fn::MFOutputSocket &new_attribute_socket = network.add_input(
-        "Attribute '" + attribute_name + "'", data_type);
-    for (fn::MFNode *node : nodes) {
+    MFOutputSocket &new_attribute_socket = network.add_input("Attribute '" + attribute_name + "'",
+                                                             data_type);
+    for (MFNode *node : nodes) {
       network.relink(node->output(0), new_attribute_socket);
     }
     network.remove(nodes);
@@ -151,43 +169,43 @@ static void find_and_deduplicate_particle_attribute_nodes(nodes::MFNetworkTreeMa
 class ParticleAttributeInput : public ParticleFunctionInput {
  private:
   std::string attribute_name_;
-  const fn::CPPType &attribute_type_;
+  const CPPType &attribute_type_;
 
  public:
-  ParticleAttributeInput(std::string attribute_name, const fn::CPPType &attribute_type)
+  ParticleAttributeInput(std::string attribute_name, const CPPType &attribute_type)
       : attribute_name_(std::move(attribute_name)), attribute_type_(attribute_type)
   {
   }
 
-  void add_input(fn::AttributesRef attributes,
-                 fn::MFParamsBuilder &params,
+  void add_input(AttributesRef attributes,
+                 MFParamsBuilder &params,
                  ResourceCollector &UNUSED(resources)) const override
   {
-    std::optional<fn::GSpan> span = attributes.try_get(attribute_name_, attribute_type_);
+    std::optional<GSpan> span = attributes.try_get(attribute_name_, attribute_type_);
     if (span.has_value()) {
       params.add_readonly_single_input(*span);
     }
     else {
-      params.add_readonly_single_input(fn::GVSpan::FromDefault(attribute_type_));
+      params.add_readonly_single_input(GVSpan::FromDefault(attribute_type_));
     }
   }
 };
 
 static const ParticleFunction *create_particle_function_for_inputs(
-    Span<const fn::MFInputSocket *> sockets_to_compute,
+    Span<const MFInputSocket *> sockets_to_compute,
     ResourceCollector &resources,
     DummyDataSources &data_sources)
 {
   BLI_assert(sockets_to_compute.size() >= 1);
-  const fn::MFNetwork &network = sockets_to_compute[0]->node().network();
+  const MFNetwork &network = sockets_to_compute[0]->node().network();
 
-  VectorSet<const fn::MFOutputSocket *> dummy_deps;
-  VectorSet<const fn::MFInputSocket *> unlinked_input_deps;
+  VectorSet<const MFOutputSocket *> dummy_deps;
+  VectorSet<const MFInputSocket *> unlinked_input_deps;
   network.find_dependencies(sockets_to_compute, dummy_deps, unlinked_input_deps);
   BLI_assert(unlinked_input_deps.size() == 0);
 
   Vector<const ParticleFunctionInput *> per_particle_inputs;
-  for (const fn::MFOutputSocket *socket : dummy_deps) {
+  for (const MFOutputSocket *socket : dummy_deps) {
     const std::string *attribute_name = data_sources.particle_attributes.lookup_ptr(socket);
     if (attribute_name == nullptr) {
       return nullptr;
@@ -196,7 +214,7 @@ static const ParticleFunction *create_particle_function_for_inputs(
         AT, *attribute_name, socket->data_type().single_type()));
   }
 
-  const fn::MultiFunction &per_particle_fn = resources.construct<fn::MFNetworkEvaluator>(
+  const MultiFunction &per_particle_fn = resources.construct<MFNetworkEvaluator>(
       AT, dummy_deps.as_span(), sockets_to_compute);
 
   Array<bool> output_is_global(sockets_to_compute.size(), false);
@@ -229,7 +247,7 @@ class ParticleFunctionForce : public ParticleForce {
     ParticleFunctionEvaluator evaluator{
         particle_fn_, context.solve_context, context.particle_chunk_context};
     evaluator.compute();
-    fn::VSpan<float3> forces = evaluator.get<float3>(0, "Force");
+    VSpan<float3> forces = evaluator.get<float3>(0, "Force");
 
     for (int64_t i : mask) {
       r_combined_force[i] += forces[i];
@@ -237,22 +255,20 @@ class ParticleFunctionForce : public ParticleForce {
  

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list