[Bf-blender-cvs] [881b5377cf1] functions: change ownership of name vectors
Jacques Lucke
noreply at git.blender.org
Mon Sep 16 16:00:57 CEST 2019
Commit: 881b5377cf1b8cd771202c29df9b35ab5e264742
Author: Jacques Lucke
Date: Mon Sep 16 10:41:37 2019 +0200
Branches: functions
https://developer.blender.org/rB881b5377cf1b8cd771202c29df9b35ab5e264742
change ownership of name vectors
===================================================================
M source/blender/simulations/bparticles/actions.hpp
M source/blender/simulations/bparticles/emitters.hpp
M source/blender/simulations/bparticles/node_frontend.cpp
===================================================================
diff --git a/source/blender/simulations/bparticles/actions.hpp b/source/blender/simulations/bparticles/actions.hpp
index 703f1460151..789157e2965 100644
--- a/source/blender/simulations/bparticles/actions.hpp
+++ b/source/blender/simulations/bparticles/actions.hpp
@@ -87,15 +87,15 @@ class ChangePositionAction : public Action {
class ExplodeAction : public Action {
private:
- Vector<std::string> m_systems_to_emit;
+ ArrayRef<std::string> m_systems_to_emit;
ParticleFunction *m_inputs_fn;
std::unique_ptr<Action> m_on_birth_action;
public:
- ExplodeAction(Vector<std::string> systems_to_emit,
+ ExplodeAction(ArrayRef<std::string> systems_to_emit,
ParticleFunction *inputs_fn,
std::unique_ptr<Action> on_birth_action)
- : m_systems_to_emit(std::move(systems_to_emit)),
+ : m_systems_to_emit(systems_to_emit),
m_inputs_fn(inputs_fn),
m_on_birth_action(std::move(on_birth_action))
{
diff --git a/source/blender/simulations/bparticles/emitters.hpp b/source/blender/simulations/bparticles/emitters.hpp
index da79e482931..4027519e688 100644
--- a/source/blender/simulations/bparticles/emitters.hpp
+++ b/source/blender/simulations/bparticles/emitters.hpp
@@ -13,7 +13,7 @@ using FN::TupleCallBody;
class SurfaceEmitter : public Emitter {
private:
- Vector<std::string> m_systems_to_emit;
+ ArrayRef<std::string> m_systems_to_emit;
std::unique_ptr<Action> m_on_birth_action;
Object *m_object;
@@ -23,13 +23,13 @@ class SurfaceEmitter : public Emitter {
Vector<float> m_vertex_weights;
public:
- SurfaceEmitter(Vector<std::string> systems_to_emit,
+ SurfaceEmitter(ArrayRef<std::string> systems_to_emit,
std::unique_ptr<Action> on_birth_action,
Object *object,
VaryingFloat4x4 transform,
float rate,
Vector<float> vertex_weights)
- : m_systems_to_emit(std::move(systems_to_emit)),
+ : m_systems_to_emit(systems_to_emit),
m_on_birth_action(std::move(on_birth_action)),
m_object(object),
m_transform(transform),
@@ -43,17 +43,17 @@ class SurfaceEmitter : public Emitter {
class PointEmitter : public Emitter {
private:
- Vector<std::string> m_systems_to_emit;
+ ArrayRef<std::string> m_systems_to_emit;
VaryingFloat3 m_position;
VaryingFloat3 m_velocity;
VaryingFloat m_size;
public:
- PointEmitter(Vector<std::string> systems_to_emit,
+ PointEmitter(ArrayRef<std::string> systems_to_emit,
VaryingFloat3 position,
VaryingFloat3 velocity,
VaryingFloat size)
- : m_systems_to_emit(std::move(systems_to_emit)),
+ : m_systems_to_emit(systems_to_emit),
m_position(position),
m_velocity(velocity),
m_size(size)
@@ -65,7 +65,7 @@ class PointEmitter : public Emitter {
class InitialGridEmitter : public Emitter {
private:
- Vector<std::string> m_systems_to_emit;
+ ArrayRef<std::string> m_systems_to_emit;
uint m_amount_x;
uint m_amount_y;
float m_step_x;
@@ -73,13 +73,13 @@ class InitialGridEmitter : public Emitter {
float m_size;
public:
- InitialGridEmitter(Vector<std::string> systems_to_emit,
+ InitialGridEmitter(ArrayRef<std::string> systems_to_emit,
uint amount_x,
uint amount_y,
float step_x,
float step_y,
float size)
- : m_systems_to_emit(std::move(systems_to_emit)),
+ : m_systems_to_emit(systems_to_emit),
m_amount_x(amount_x),
m_amount_y(amount_y),
m_step_x(step_x),
diff --git a/source/blender/simulations/bparticles/node_frontend.cpp b/source/blender/simulations/bparticles/node_frontend.cpp
index c47a1359cf3..1d6ad0eaea1 100644
--- a/source/blender/simulations/bparticles/node_frontend.cpp
+++ b/source/blender/simulations/bparticles/node_frontend.cpp
@@ -50,6 +50,7 @@ class VTreeData {
Vector<SharedFunction> m_functions;
Vector<std::unique_ptr<Tuple>> m_tuples;
Vector<std::unique_ptr<FN::FunctionOutputNamesProvider>> m_name_providers;
+ Vector<std::unique_ptr<Vector<std::string>>> m_string_vectors;
public:
VTreeData(VTreeDataGraph &vtree_data) : m_vtree_data_graph(vtree_data)
@@ -129,13 +130,14 @@ class VTreeData {
return NamedTupleRef(fn_out, name_provider);
}
- Vector<std::string> find_target_system_names(VirtualSocket *output_vsocket)
+ ArrayRef<std::string> find_target_system_names(VirtualSocket *output_vsocket)
{
- Vector<std::string> system_names;
+ Vector<std::string> *system_names = new Vector<std::string>();
for (VirtualNode *vnode : find_target_system_nodes(output_vsocket)) {
- system_names.append(vnode->name());
+ system_names->append(vnode->name());
}
- return system_names;
+ m_string_vectors.append(std::unique_ptr<Vector<std::string>>(system_names));
+ return *system_names;
}
private:
@@ -231,7 +233,7 @@ static std::unique_ptr<Action> ACTION_explode(VTreeData &vtree_data,
std::unique_ptr<Action> on_birth_action = build_action_list(
vtree_data, vnode, "Execute on Birth");
- Vector<std::string> system_names = vtree_data.find_target_system_names(
+ ArrayRef<std::string> system_names = vtree_data.find_target_system_names(
vnode->output(1, "Explode System"));
Action *action = new ExplodeAction(system_names, inputs_fn, std::move(on_birth_action));
@@ -355,7 +357,7 @@ static void PARSE_point_emitter(InfluencesCollector &collector,
VirtualNode *vnode)
{
NamedTupleRef inputs = vtree_data.compute_all_inputs(vnode);
- Vector<std::string> system_names = vtree_data.find_target_system_names(
+ ArrayRef<std::string> system_names = vtree_data.find_target_system_names(
vnode->output(0, "Emitter"));
std::string name = vnode->name();
@@ -439,7 +441,7 @@ static void PARSE_mesh_emitter(InfluencesCollector &collector,
VaryingFloat4x4 transform = world_transition.update_float4x4(
vnode->name(), "Transform", object->obmat);
- Vector<std::string> system_names = vtree_data.find_target_system_names(
+ ArrayRef<std::string> system_names = vtree_data.find_target_system_names(
vnode->output(0, "Emitter"));
Emitter *emitter = new SurfaceEmitter(std::move(system_names),
std::move(on_birth_action),
@@ -466,9 +468,9 @@ static void PARSE_gravity_force(InfluencesCollector &collector,
return;
}
- Vector<std::string> system_names = vtree_data.find_target_system_names(
+ ArrayRef<std::string> system_names = vtree_data.find_target_system_names(
vnode->output(0, "Force"));
- for (std::string &system_name : system_names) {
+ for (const std::string &system_name : system_names) {
GravityForce *force = new GravityForce(inputs_fn, falloff.get_unique_copy());
collector.m_forces.add(system_name, force);
}
@@ -484,9 +486,9 @@ static void PARSE_age_reached_event(InfluencesCollector &collector,
return;
}
- Vector<std::string> system_names = vtree_data.find_target_system_names(
+ ArrayRef<std::string> system_names = vtree_data.find_target_system_names(
vnode->output(0, "Event"));
- for (std::string &system_name : system_names) {
+ for (const std::string &system_name : system_names) {
auto action = build_action_list(vtree_data, vnode, "Execute on Event");
Event *event = new AgeReachedEvent(vnode->name(), inputs_fn, std::move(action));
@@ -499,9 +501,9 @@ static void PARSE_trails(InfluencesCollector &collector,
WorldTransition &UNUSED(world_transition),
VirtualNode *vnode)
{
- Vector<std::string> main_system_names = vtree_data.find_target_system_names(
+ ArrayRef<std::string> main_system_names = vtree_data.find_target_system_names(
vnode->output(0, "Main System"));
- Vector<std::string> trail_system_names = vtree_data.find_target_system_names(
+ ArrayRef<std::string> trail_system_names = vtree_data.find_target_system_names(
vnode->output(1, "Trail System"));
ParticleFunction *inputs_fn = vtree_data.particle_function_for_all_inputs(vnode);
@@ -509,7 +511,7 @@ static void PARSE_trails(InfluencesCollector &collector,
return;
}
- for (std::string &main_type : main_system_names) {
+ for (const std::string &main_type : main_system_names) {
auto action = build_action_list(vtree_data, vnode, "Execute on Birth");
OffsetHandler *offset_handler = new CreateTrailHandler(
@@ -525,7 +527,7 @@ static void PARSE_initial_grid_emitter(InfluencesCollector &collector,
{
NamedTupleRef inputs = vtree_data.compute_all_inputs(vnode);
- Vector<std::string> system_names = vtree_data.find_target_system_names(
+ ArrayRef<std::string> system_names = vtree_data.find_target_system_names(
vnode->output(0, "Emitter"));
Emitter *emitter = new InitialGridEmitter(std::move(system_names),
std::max(0, inputs.get<int>(0, "Amount X")),
@@ -552,9 +554,9 @@ static void PARSE_turbulence_force(InfluencesCollector &collector,
return;
}
- Vector<std::string> system_names = vtree_data.find_target_system_names(
+ ArrayRef<std::string> system_names = vtree_data.find_target_system_names(
vnode->output(0, "Force"));
- for (std::string &system_name : system_names) {
+ for (const std::string &system_name : system_names) {
Force *force = new TurbulenceForce(inputs_fn, falloff.get_unique_copy());
collector.m_forces.add(system_name, force);
@@ -577,9 +579,9 @@ static void PARSE_drag_force(InfluencesCollector &collector,
return;
}
- Vector<std::string> system_names = vtree_data.find_target_system_names(
+ ArrayRef<std::string> system_names = vtree_data.find_target_system_names(
vnode->output(0, "Force"));
- for (std::string &system_name : system_names) {
+ for (const std::string &system_name : system_names) {
Force *force = new DragForce(inputs_fn, falloff.get_unique_copy());
collector.m_forces.add(system_name, force);
@@ -610,9 +612,9 @@ static void PARSE_mesh_collision(InfluencesCollector
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list