Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2020-07-25 21:39:21 +0300
committerJacques Lucke <jacques@blender.org>2020-07-25 21:39:21 +0300
commit14326619a1a94af677c2d1d626b57d7ff2afbd21 (patch)
treec0dfff2c714e49ddbfb8e6b9a73494d25f122d64 /source/blender/simulation
parent1e999c7bdb63576fd66815c1770d096d165b8281 (diff)
Cleanup: avoid using namespace name in many cases
Diffstat (limited to 'source/blender/simulation')
-rw-r--r--source/blender/simulation/intern/simulation_collect_influences.cc168
1 files changed, 91 insertions, 77 deletions
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 {
}
};
-static void create_forces_for_particle_simulation(const nodes::DNode &simulation_node,
- nodes::MFNetworkTreeMap &network_map,
+static void create_forces_for_particle_simulation(const DNode &simulation_node,
+ MFNetworkTreeMap &network_map,
ResourceCollector &resources,
DummyDataSources &data_sources,
SimulationInfluences &r_influences)
{
Vector<const ParticleForce *> forces;
- for (const nodes::DOutputSocket *origin_socket :
- simulation_node.input(2, "Forces").linked_sockets()) {
- const nodes::DNode &origin_node = origin_socket->node();
+ for (const DOutputSocket *origin_socket : simulation_node.input(2, "Forces").linked_sockets()) {
+ const DNode &origin_node = origin_socket->node();
if (origin_node.idname() != "SimulationNodeForce") {
continue;
}
- const fn::MFInputSocket &force_socket = network_map.lookup_dummy(
- origin_node.input(0, "Force"));
+ const MFInputSocket &force_socket = network_map.lookup_dummy(origin_node.input(0, "Force"));
const ParticleFunction *particle_fn = create_particle_function_for_inputs(
{&force_socket}, resources, data_sources);
@@ -269,22 +285,21 @@ static void create_forces_for_particle_simulation(const nodes::DNode &simulation
r_influences.particle_forces.add_multiple(std::move(particle_name), forces);
}
-static void collect_forces(nodes::MFNetworkTreeMap &network_map,
+static void collect_forces(MFNetworkTreeMap &network_map,
ResourceCollector &resources,
DummyDataSources &data_sources,
SimulationInfluences &r_influences)
{
- for (const nodes::DNode *dnode : get_particle_simulation_nodes(network_map.tree())) {
+ for (const DNode *dnode : get_particle_simulation_nodes(network_map.tree())) {
create_forces_for_particle_simulation(
*dnode, network_map, resources, data_sources, r_influences);
}
}
-static Vector<const nodes::DNode *> find_linked_particle_simulations(
- const nodes::DOutputSocket &output_socket)
+static Vector<const DNode *> find_linked_particle_simulations(const DOutputSocket &output_socket)
{
- Vector<const nodes::DNode *> simulation_nodes;
- for (const nodes::DInputSocket *target_socket : output_socket.linked_sockets()) {
+ Vector<const DNode *> simulation_nodes;
+ for (const DInputSocket *target_socket : output_socket.linked_sockets()) {
if (target_socket->node().idname() == "SimulationNodeParticleSimulation") {
simulation_nodes.append(&target_socket->node());
}
@@ -292,13 +307,12 @@ static Vector<const nodes::DNode *> find_linked_particle_simulations(
return simulation_nodes;
}
-static ParticleEmitter *create_particle_emitter(const nodes::DNode &dnode,
+static ParticleEmitter *create_particle_emitter(const DNode &dnode,
ResourceCollector &resources,
- nodes::MFNetworkTreeMap &network_map,
+ MFNetworkTreeMap &network_map,
RequiredStates &r_required_states)
{
- Vector<const nodes::DNode *> simulation_dnodes = find_linked_particle_simulations(
- dnode.output(0));
+ Vector<const DNode *> simulation_dnodes = find_linked_particle_simulations(dnode.output(0));
if (simulation_dnodes.size() == 0) {
return nullptr;
}
@@ -308,7 +322,7 @@ static ParticleEmitter *create_particle_emitter(const nodes::DNode &dnode,
names[i] = dnode_to_path(*simulation_dnodes[i]);
}
- Array<const fn::MFInputSocket *> input_sockets{dnode.inputs().size()};
+ Array<const MFInputSocket *> input_sockets{dnode.inputs().size()};
for (int i : input_sockets.index_range()) {
input_sockets[i] = &network_map.lookup_dummy(dnode.input(i));
}
@@ -317,8 +331,8 @@ static ParticleEmitter *create_particle_emitter(const nodes::DNode &dnode,
return nullptr;
}
- fn::MultiFunction &inputs_fn = resources.construct<fn::MFNetworkEvaluator>(
- AT, Span<const fn::MFOutputSocket *>(), input_sockets.as_span());
+ MultiFunction &inputs_fn = resources.construct<MFNetworkEvaluator>(
+ AT, Span<const MFOutputSocket *>(), input_sockets.as_span());
std::string own_state_name = dnode_to_path(dnode);
r_required_states.add(own_state_name, SIM_TYPE_NAME_PARTICLE_MESH_EMITTER);
@@ -327,12 +341,12 @@ static ParticleEmitter *create_particle_emitter(const nodes::DNode &dnode,
return &emitter;
}
-static void collect_emitters(nodes::MFNetworkTreeMap &network_map,
+static void collect_emitters(MFNetworkTreeMap &network_map,
ResourceCollector &resources,
SimulationInfluences &r_influences,
RequiredStates &r_required_states)
{
- for (const nodes::DNode *dnode :
+ for (const DNode *dnode :
network_map.tree().nodes_by_type("SimulationNodeParticleMeshEmitter")) {
ParticleEmitter *emitter = create_particle_emitter(
*dnode, resources, network_map, r_required_states);
@@ -360,24 +374,24 @@ class RandomizeVelocityAction : public ParticleAction {
}
};
-static void collect_birth_events(nodes::MFNetworkTreeMap &network_map,
+static void collect_birth_events(MFNetworkTreeMap &network_map,
ResourceCollector &resources,
SimulationInfluences &r_influences)
{
RandomizeVelocityAction &action = resources.construct<RandomizeVelocityAction>(AT);
- for (const nodes::DNode *dnode : get_particle_simulation_nodes(network_map.tree())) {
+ for (const DNode *dnode : get_particle_simulation_nodes(network_map.tree())) {
std::string particle_name = dnode_to_path(*dnode);
r_influences.particle_birth_actions.add_as(std::move(particle_name), &action);
}
}
-static void prepare_particle_attribute_builders(nodes::MFNetworkTreeMap &network_map,
+static void prepare_particle_attribute_builders(MFNetworkTreeMap &network_map,
ResourceCollector &resources,
SimulationInfluences &r_influences)
{
- for (const nodes::DNode *dnode : get_particle_simulation_nodes(network_map.tree())) {
+ for (const DNode *dnode : get_particle_simulation_nodes(network_map.tree())) {
std::string name = dnode_to_path(*dnode);
- fn::AttributesInfoBuilder &builder = resources.construct<fn::AttributesInfoBuilder>(AT);
+ AttributesInfoBuilder &builder = resources.construct<AttributesInfoBuilder>(AT);
builder.add<float3>("Position", {0, 0, 0});
builder.add<float3>("Velocity", {0, 0, 0});
builder.add<int>("ID", 0);
@@ -395,11 +409,11 @@ void collect_simulation_influences(Simulation &simulation,
SimulationInfluences &r_influences,
RequiredStates &r_required_states)
{
- nodes::NodeTreeRefMap tree_refs;
- const nodes::DerivedNodeTree tree{simulation.nodetree, tree_refs};
+ NodeTreeRefMap tree_refs;
+ const DerivedNodeTree tree{simulation.nodetree, tree_refs};
- fn::MFNetwork &network = resources.construct<fn::MFNetwork>(AT);
- nodes::MFNetworkTreeMap network_map = insert_node_tree_into_mf_network(network, tree, resources);
+ MFNetwork &network = resources.construct<MFNetwork>(AT);
+ MFNetworkTreeMap network_map = insert_node_tree_into_mf_network(network, tree, resources);
prepare_particle_attribute_builders(network_map, resources, r_influences);
@@ -415,7 +429,7 @@ void collect_simulation_influences(Simulation &simulation,
collect_emitters(network_map, resources, r_influences, r_required_states);
collect_birth_events(network_map, resources, r_influences);
- for (const nodes::DNode *dnode : get_particle_simulation_nodes(tree)) {
+ for (const DNode *dnode : get_particle_simulation_nodes(tree)) {
r_required_states.add(dnode_to_path(*dnode), SIM_TYPE_NAME_PARTICLE_SIMULATION);
}
}