[Bf-blender-cvs] [1ac10819530] functions: remove other forces, they should be build using Particle functions
Jacques Lucke
noreply at git.blender.org
Tue Nov 12 14:30:12 CET 2019
Commit: 1ac10819530c4bb24bd43ad81071b2283e5732f6
Author: Jacques Lucke
Date: Tue Nov 12 14:16:36 2019 +0100
Branches: functions
https://developer.blender.org/rB1ac10819530c4bb24bd43ad81071b2283e5732f6
remove other forces, they should be build using Particle functions
===================================================================
M release/scripts/startup/nodes/bparticle_nodes/forces.py
M source/blender/simulations/bparticles/forces.cpp
M source/blender/simulations/bparticles/forces.hpp
M source/blender/simulations/bparticles/node_frontend.cpp
===================================================================
diff --git a/release/scripts/startup/nodes/bparticle_nodes/forces.py b/release/scripts/startup/nodes/bparticle_nodes/forces.py
index 19e8d66c9d3..f423334787c 100644
--- a/release/scripts/startup/nodes/bparticle_nodes/forces.py
+++ b/release/scripts/startup/nodes/bparticle_nodes/forces.py
@@ -11,44 +11,3 @@ class ForceNode(bpy.types.Node, SimulationNode):
def declaration(self, builder: NodeBuilder):
builder.fixed_input("force", "Force", "Vector")
builder.influences_output("force", "Force")
-
-
-class TurbulenceForceNode(bpy.types.Node, SimulationNode):
- bl_idname = "fn_TurbulenceForceNode"
- bl_label = "Turbulence Force"
-
- 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("weight", "Weight", "Float", default=1)
- builder.influences_output("force", "Force")
-
-
-class GravityForceNode(bpy.types.Node, SimulationNode):
- bl_idname = "fn_GravityForceNode"
- bl_label = "Gravity Force"
-
- def declaration(self, builder: NodeBuilder):
- builder.fixed_input("acceleration", "Acceleration", "Vector", default=(0, 0, -1))
- builder.fixed_input("weight", "Weight", "Float", default=1)
- builder.influences_output("force", "Force")
-
-
-class DragForceNode(bpy.types.Node, SimulationNode):
- bl_idname = "fn_DragForceNode"
- bl_label = "Drag Force"
-
- def declaration(self, builder: NodeBuilder):
- builder.fixed_input("strength", "Strength", "Float", default=1)
- builder.fixed_input("weight", "Weight", "Float", default=1)
- builder.influences_output("force", "Force")
-
-
-class MeshForceNode(bpy.types.Node, SimulationNode):
- bl_idname = "fn_MeshForceNode"
- bl_label = "Mesh Force"
-
- def declaration(self, builder: NodeBuilder):
- builder.fixed_input("object", "Object", "Object")
- builder.fixed_input("strength", "Strength", "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 8263f1eadf2..bef5794c5e6 100644
--- a/source/blender/simulations/bparticles/forces.cpp
+++ b/source/blender/simulations/bparticles/forces.cpp
@@ -19,85 +19,4 @@ void CustomForce::add_force(ForceInterface &interface)
}
}
-void GravityForce::add_force(ForceInterface &interface)
-{
- MutableArrayRef<float3> destination = interface.combined_destination();
-
- auto inputs = m_inputs_fn->compute(interface);
-
- for (uint pindex : interface.pindices()) {
- float3 acceleration = inputs->get<float3>("Acceleration", 0, pindex);
- float weight = inputs->get<float>("Weight", 1, pindex);
- destination[pindex] += acceleration * weight;
- }
-};
-
-void TurbulenceForce::add_force(ForceInterface &interface)
-{
- MutableArrayRef<float3> destination = interface.combined_destination();
- auto positions = interface.attributes().get<float3>("Position");
-
- auto inputs = m_inputs_fn->compute(interface);
-
- 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 = 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;
- destination[pindex] += float3(x, y, z) * weight;
- }
-}
-
-void DragForce::add_force(ForceInterface &interface)
-{
- MutableArrayRef<float3> destination = interface.combined_destination();
- auto velocities = interface.attributes().get<float3>("Velocity");
-
- auto inputs = m_inputs_fn->compute(interface);
-
- for (uint pindex : interface.pindices()) {
- float3 velocity = velocities[pindex];
- float strength = inputs->get<float>("Strength", 0, pindex);
- float weight = inputs->get<float>("Weight", 1, pindex);
- destination[pindex] -= velocity * strength * weight;
- }
-}
-
-void MeshForce::add_force(ForceInterface &interface)
-{
- MutableArrayRef<float3> destination = interface.combined_destination();
- auto positions = interface.attributes().get<float3>("Position");
-
- auto inputs = m_inputs_fn->compute(interface);
-
- for (uint pindex : interface.pindices()) {
- float3 position = positions[pindex];
- float3 local_position = m_world_to_local.transform_position(position);
-
- BVHTreeNearest nearest = {0};
- nearest.dist_sq = 10000.0f;
- nearest.index = -1;
- BLI_bvhtree_find_nearest(m_bvhtree_data.tree,
- local_position,
- &nearest,
- m_bvhtree_data.nearest_callback,
- (void *)&m_bvhtree_data);
-
- if (nearest.index == -1) {
- continue;
- }
-
- float3 difference_local = float3(nearest.co) - local_position;
- float3 difference = m_local_to_world.transform_direction(difference_local);
- float distance_squared = difference.length_squared();
- float factor = 1 / std::max(0.1f, distance_squared);
-
- float strength = inputs->get<float>("Strength", 1, pindex);
- destination[pindex] += difference * strength * factor;
- }
-}
-
} // namespace BParticles
diff --git a/source/blender/simulations/bparticles/forces.hpp b/source/blender/simulations/bparticles/forces.hpp
index c5d06def35e..af3a22d3bd1 100644
--- a/source/blender/simulations/bparticles/forces.hpp
+++ b/source/blender/simulations/bparticles/forces.hpp
@@ -32,66 +32,4 @@ class CustomForce : public Force {
void add_force(ForceInterface &interface) override;
};
-class GravityForce : public Force {
- private:
- ParticleFunction *m_inputs_fn;
-
- public:
- GravityForce(ParticleFunction *inputs_fn) : m_inputs_fn(inputs_fn)
- {
- }
-
- void add_force(ForceInterface &interface) override;
-};
-
-class TurbulenceForce : public Force {
- private:
- ParticleFunction *m_inputs_fn;
-
- public:
- TurbulenceForce(ParticleFunction *inputs_fn) : m_inputs_fn(inputs_fn)
- {
- }
-
- void add_force(ForceInterface &interface) override;
-};
-
-class DragForce : public Force {
- private:
- ParticleFunction *m_inputs_fn;
-
- public:
- DragForce(ParticleFunction *inputs_fn) : m_inputs_fn(inputs_fn)
- {
- }
-
- void add_force(ForceInterface &interface) override;
-};
-
-class MeshForce : public Force {
- private:
- ParticleFunction *m_inputs_fn;
- Object *m_object;
- BVHTreeFromMesh m_bvhtree_data;
- float4x4 m_local_to_world;
- float4x4 m_world_to_local;
-
- public:
- MeshForce(ParticleFunction *inputs_fn, Object *object) : m_inputs_fn(inputs_fn), m_object(object)
- {
- BLI_assert(object->type == OB_MESH);
- m_local_to_world = m_object->obmat;
- m_world_to_local = m_local_to_world.inverted__LocRotScale();
-
- BKE_bvhtree_from_mesh_get(&m_bvhtree_data, (Mesh *)object->data, BVHTREE_FROM_LOOPTRI, 2);
- }
-
- ~MeshForce()
- {
- free_bvhtree_from_mesh(&m_bvhtree_data);
- }
-
- void add_force(ForceInterface &interface) override;
-};
-
} // namespace BParticles
diff --git a/source/blender/simulations/bparticles/node_frontend.cpp b/source/blender/simulations/bparticles/node_frontend.cpp
index 7a92f5d0326..7937baf4966 100644
--- a/source/blender/simulations/bparticles/node_frontend.cpp
+++ b/source/blender/simulations/bparticles/node_frontend.cpp
@@ -528,25 +528,6 @@ static void PARSE_mesh_emitter(InfluencesCollector &collector,
collector.m_emitters.append(emitter);
}
-static void PARSE_gravity_force(InfluencesCollector &collector,
- VTreeData &vtree_data,
- WorldTransition &UNUSED(world_transition),
- const VNode &vnode)
-{
- ParticleFunction *inputs_fn = vtree_data.particle_function_for_all_inputs(vnode);
- if (inputs_fn == nullptr) {
- return;
- }
-
- 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);
- collector.m_forces.add(system_name, force);
- }
-}
-
static void PARSE_custom_force(InfluencesCollector &collector,
VTreeData &vtree_data,
WorldTransition &UNUSED(world_transition),
@@ -636,44 +617,6 @@ static void PARSE_initial_grid_emitter(InfluencesCollector &collector,
collector.m_emitters.append(emitter);
}
-static void PARSE_turbulence_force(InfluencesCollector &collector,
- VTreeData &vtree_data,
- WorldTransition &UNUSED(world_transition),
- const VNode &vnode)
-{
- ParticleFunction *inputs_fn = vtree_data.particle_function_for_all_inputs(vnode);
- if (inputs_fn == nullptr) {
- return;
- }
-
- 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);
- collector.m_forces.add(system_name, force);
- }
-}
-
-static void PARSE_drag_force(InfluencesCollector &collector,
- VTreeData &vtree_data,
- WorldTransition &UNUSED(world_transition),
- const VNode &vnode)
-{
- ParticleFunction *inputs_fn = vtree_data.particle_function_for_all_inputs(vnode);
- if (inputs_fn == nullptr) {
- return;
- }
-
- 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 DragForce(inputs_fn);
- collector.m_forces.add(system_name, force);
- }
-}
-
static void PARSE_mesh_collision(InfluencesCollector &collector,
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list