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 <mail@jlucke.com>2019-09-23 13:08:36 +0300
committerJacques Lucke <mail@jlucke.com>2019-09-23 13:08:36 +0300
commitd4e58e630c26bd142e946df1a0838b54abfd6f6b (patch)
treee9f65e0a9e9ab4d5260d4d303d68c431163f26d2
parent31a3dc769d100e9cecf2f31dae21e6898a42dedb (diff)
Replace Falloff with weight input
-rw-r--r--release/scripts/startup/nodes/bparticle_nodes/forces.py8
-rw-r--r--source/blender/simulations/bparticles/forces.cpp15
-rw-r--r--source/blender/simulations/bparticles/forces.hpp12
-rw-r--r--source/blender/simulations/bparticles/node_frontend.cpp30
4 files changed, 15 insertions, 50 deletions
diff --git a/release/scripts/startup/nodes/bparticle_nodes/forces.py b/release/scripts/startup/nodes/bparticle_nodes/forces.py
index ea3efa09eb9..144f81b109c 100644
--- a/release/scripts/startup/nodes/bparticle_nodes/forces.py
+++ b/release/scripts/startup/nodes/bparticle_nodes/forces.py
@@ -11,7 +11,7 @@ class TurbulenceForceNode(bpy.types.Node, BParticlesNode):
def declaration(self, builder: NodeBuilder):
builder.fixed_input("strength", "Strength", "Vector", default=(1, 1, 1))
builder.fixed_input("size", "Size", "Float", default=0.5)
- builder.fixed_input("falloff", "Falloff", "Falloff")
+ builder.fixed_input("weight", "Weight", "Float", default=1)
builder.influences_output("force", "Force")
@@ -20,8 +20,8 @@ class GravityForceNode(bpy.types.Node, BParticlesNode):
bl_label = "Gravity Force"
def declaration(self, builder: NodeBuilder):
- builder.fixed_input("direction", "Direction", "Vector", default=(0, 0, -1))
- builder.fixed_input("falloff", "Falloff", "Falloff")
+ builder.fixed_input("acceleration", "Acceleration", "Vector", default=(0, 0, -1))
+ builder.fixed_input("weight", "Weight", "Float", default=1)
builder.influences_output("force", "Force")
@@ -31,7 +31,7 @@ class DragForceNode(bpy.types.Node, BParticlesNode):
def declaration(self, builder: NodeBuilder):
builder.fixed_input("strength", "Strength", "Float", default=1)
- builder.fixed_input("falloff", "Falloff", "Falloff")
+ builder.fixed_input("weight", "Weight", "Float", default=1)
builder.influences_output("force", "Force")
diff --git a/source/blender/simulations/bparticles/forces.cpp b/source/blender/simulations/bparticles/forces.cpp
index fed9dc35a8c..973a2e12740 100644
--- a/source/blender/simulations/bparticles/forces.cpp
+++ b/source/blender/simulations/bparticles/forces.cpp
@@ -14,12 +14,9 @@ void GravityForce::add_force(ForceInterface &interface)
auto inputs = m_inputs_fn->compute(interface);
- TemporaryArray<float> weights(destination.size());
- m_falloff->compute(interface.attributes(), interface.pindices(), weights);
-
for (uint pindex : interface.pindices()) {
float3 acceleration = inputs->get<float3>("Direction", 0, pindex);
- float weight = weights[pindex];
+ float weight = inputs->get<float>("Weight", 1, pindex);
destination[pindex] += acceleration * weight;
}
};
@@ -31,14 +28,11 @@ void TurbulenceForce::add_force(ForceInterface &interface)
auto inputs = m_inputs_fn->compute(interface);
- TemporaryArray<float> weights(destination.size());
- m_falloff->compute(interface.attributes(), interface.pindices(), weights);
-
for (uint pindex : interface.pindices()) {
float3 pos = positions[pindex];
float3 strength = inputs->get<float3>("Strength", 0, pindex);
float size = inputs->get<float>("Size", 1, pindex);
- float weight = weights[pindex];
+ float weight = inputs->get<float>("Weight", 2, pindex);
float x = (BLI_gNoise(size, pos.x, pos.y, pos.z + 1000.0f, false, 1) - 0.5f) * strength.x;
float y = (BLI_gNoise(size, pos.x, pos.y + 1000.0f, pos.z, false, 1) - 0.5f) * strength.y;
float z = (BLI_gNoise(size, pos.x + 1000.0f, pos.y, pos.z, false, 1) - 0.5f) * strength.z;
@@ -53,13 +47,10 @@ void DragForce::add_force(ForceInterface &interface)
auto inputs = m_inputs_fn->compute(interface);
- TemporaryArray<float> weights(destination.size());
- m_falloff->compute(interface.attributes(), interface.pindices(), weights);
-
for (uint pindex : interface.pindices()) {
float3 velocity = velocities[pindex];
float strength = inputs->get<float>("Strength", 0, pindex);
- float weight = weights[pindex];
+ float weight = inputs->get<float>("Weight", 1, pindex);
destination[pindex] -= velocity * strength * weight;
}
}
diff --git a/source/blender/simulations/bparticles/forces.hpp b/source/blender/simulations/bparticles/forces.hpp
index 250a40a0df3..63f85af569f 100644
--- a/source/blender/simulations/bparticles/forces.hpp
+++ b/source/blender/simulations/bparticles/forces.hpp
@@ -25,11 +25,9 @@ class Force {
class GravityForce : public Force {
private:
ParticleFunction *m_inputs_fn;
- std::unique_ptr<Falloff> m_falloff;
public:
- GravityForce(ParticleFunction *inputs_fn, std::unique_ptr<Falloff> falloff)
- : m_inputs_fn(inputs_fn), m_falloff(std::move(falloff))
+ GravityForce(ParticleFunction *inputs_fn) : m_inputs_fn(inputs_fn)
{
}
@@ -39,11 +37,9 @@ class GravityForce : public Force {
class TurbulenceForce : public Force {
private:
ParticleFunction *m_inputs_fn;
- std::unique_ptr<Falloff> m_falloff;
public:
- TurbulenceForce(ParticleFunction *inputs_fn, std::unique_ptr<Falloff> falloff)
- : m_inputs_fn(inputs_fn), m_falloff(std::move(falloff))
+ TurbulenceForce(ParticleFunction *inputs_fn) : m_inputs_fn(inputs_fn)
{
}
@@ -53,11 +49,9 @@ class TurbulenceForce : public Force {
class DragForce : public Force {
private:
ParticleFunction *m_inputs_fn;
- std::unique_ptr<Falloff> m_falloff;
public:
- DragForce(ParticleFunction *inputs_fn, std::unique_ptr<Falloff> falloff)
- : m_inputs_fn(inputs_fn), m_falloff(std::move(falloff))
+ DragForce(ParticleFunction *inputs_fn) : m_inputs_fn(inputs_fn)
{
}
diff --git a/source/blender/simulations/bparticles/node_frontend.cpp b/source/blender/simulations/bparticles/node_frontend.cpp
index 85a0fbeb34d..bf10cebc8a9 100644
--- a/source/blender/simulations/bparticles/node_frontend.cpp
+++ b/source/blender/simulations/bparticles/node_frontend.cpp
@@ -546,13 +546,6 @@ static void PARSE_gravity_force(InfluencesCollector &collector,
WorldTransition &UNUSED(world_transition),
VirtualNode *vnode)
{
- Optional<NamedTupleRef> inputs = vtree_data.compute_inputs(vnode, {1});
- if (!inputs.has_value()) {
- return;
- }
-
- auto falloff = inputs->relocate_out<FN::Types::FalloffW>(0, "Falloff");
-
ParticleFunction *inputs_fn = vtree_data.particle_function_for_all_inputs(vnode);
if (inputs_fn == nullptr) {
return;
@@ -560,8 +553,9 @@ static void PARSE_gravity_force(InfluencesCollector &collector,
ArrayRef<std::string> system_names = vtree_data.find_target_system_names(
vnode->output(0, "Force"));
+
for (const std::string &system_name : system_names) {
- GravityForce *force = new GravityForce(inputs_fn, falloff.get_unique_copy());
+ GravityForce *force = new GravityForce(inputs_fn);
collector.m_forces.add(system_name, force);
}
}
@@ -641,13 +635,6 @@ static void PARSE_turbulence_force(InfluencesCollector &collector,
WorldTransition &UNUSED(world_transition),
VirtualNode *vnode)
{
- Optional<NamedTupleRef> inputs = vtree_data.compute_inputs(vnode, {2});
- if (!inputs.has_value()) {
- return;
- }
-
- auto falloff = inputs->relocate_out<FN::Types::FalloffW>(0, "Falloff");
-
ParticleFunction *inputs_fn = vtree_data.particle_function_for_all_inputs(vnode);
if (inputs_fn == nullptr) {
return;
@@ -655,9 +642,9 @@ static void PARSE_turbulence_force(InfluencesCollector &collector,
ArrayRef<std::string> system_names = vtree_data.find_target_system_names(
vnode->output(0, "Force"));
- for (const std::string &system_name : system_names) {
- Force *force = new TurbulenceForce(inputs_fn, falloff.get_unique_copy());
+ for (const std::string &system_name : system_names) {
+ Force *force = new TurbulenceForce(inputs_fn);
collector.m_forces.add(system_name, force);
}
}
@@ -667,13 +654,6 @@ static void PARSE_drag_force(InfluencesCollector &collector,
WorldTransition &UNUSED(world_transition),
VirtualNode *vnode)
{
- Optional<NamedTupleRef> inputs = vtree_data.compute_inputs(vnode, {1});
- if (!inputs.has_value()) {
- return;
- }
-
- auto falloff = inputs->relocate_out<FN::Types::FalloffW>(0, "Falloff");
-
ParticleFunction *inputs_fn = vtree_data.particle_function_for_all_inputs(vnode);
if (inputs_fn == nullptr) {
return;
@@ -683,7 +663,7 @@ static void PARSE_drag_force(InfluencesCollector &collector,
vnode->output(0, "Force"));
for (const std::string &system_name : system_names) {
- Force *force = new DragForce(inputs_fn, falloff.get_unique_copy());
+ Force *force = new DragForce(inputs_fn);
collector.m_forces.add(system_name, force);
}
}