[Bf-blender-cvs] [aa1c4663a16] functions: remove lots of redundant code
Jacques Lucke
noreply at git.blender.org
Mon Jul 29 17:57:36 CEST 2019
Commit: aa1c4663a16556ac4ef53588a2f01454b7f9056b
Author: Jacques Lucke
Date: Mon Jul 29 15:08:05 2019 +0200
Branches: functions
https://developer.blender.org/rBaa1c4663a16556ac4ef53588a2f01454b7f9056b
remove lots of redundant code
===================================================================
M source/blender/simulations/bparticles/events.cpp
M source/blender/simulations/bparticles/force_interface.hpp
M source/blender/simulations/bparticles/integrator.cpp
M source/blender/simulations/bparticles/integrator.hpp
M source/blender/simulations/bparticles/offset_handlers.cpp
M source/blender/simulations/bparticles/particle_function.cpp
M source/blender/simulations/bparticles/step_description_interfaces.cpp
M source/blender/simulations/bparticles/step_description_interfaces.hpp
===================================================================
diff --git a/source/blender/simulations/bparticles/events.cpp b/source/blender/simulations/bparticles/events.cpp
index 30c6d9c83ef..0ffc1ad7880 100644
--- a/source/blender/simulations/bparticles/events.cpp
+++ b/source/blender/simulations/bparticles/events.cpp
@@ -16,7 +16,7 @@ void AgeReachedEvent::filter(EventFilterInterface &interface)
auto birth_times = particles.attributes().get_float("Birth Time");
auto was_activated_before = particles.attributes().get_byte(m_identifier);
- float end_time = interface.end_time();
+ float end_time = interface.step_end_time();
auto inputs = m_compute_inputs->compute(interface);
diff --git a/source/blender/simulations/bparticles/force_interface.hpp b/source/blender/simulations/bparticles/force_interface.hpp
index 8195d7ac676..639f893460c 100644
--- a/source/blender/simulations/bparticles/force_interface.hpp
+++ b/source/blender/simulations/bparticles/force_interface.hpp
@@ -1,55 +1,23 @@
#pragma once
-#include "particles_container.hpp"
+#include "step_description_interfaces.hpp"
namespace BParticles {
-class ForceInterface {
+class ForceInterface : public BlockStepDataAccess {
private:
- ParticlesBlock &m_block;
- ArrayAllocator &m_array_allocator;
- ArrayRef<float> m_remaining_durations;
- float m_step_end_time;
ArrayRef<float3> m_destination;
public:
- ForceInterface(ParticlesBlock &block,
- ArrayAllocator &array_allocator,
- ArrayRef<float> remaining_durations,
- float step_end_time,
- ArrayRef<float3> destination)
- : m_block(block),
- m_array_allocator(array_allocator),
- m_remaining_durations(remaining_durations),
- m_step_end_time(step_end_time),
- m_destination(destination)
+ ForceInterface(BlockStepData &step_data, ArrayRef<float3> destination)
+ : BlockStepDataAccess(step_data), m_destination(destination)
{
}
- ParticlesBlock &block()
- {
- return m_block;
- }
-
- ArrayAllocator &array_allocator()
- {
- return m_array_allocator;
- }
-
ArrayRef<float3> combined_destination()
{
return m_destination;
}
-
- ArrayRef<float> remaining_durations()
- {
- return m_remaining_durations;
- }
-
- float step_end_time()
- {
- return m_step_end_time;
- }
};
} // namespace BParticles
diff --git a/source/blender/simulations/bparticles/integrator.cpp b/source/blender/simulations/bparticles/integrator.cpp
index 806e0803df3..7ef3f06d6fa 100644
--- a/source/blender/simulations/bparticles/integrator.cpp
+++ b/source/blender/simulations/bparticles/integrator.cpp
@@ -18,7 +18,7 @@ void ConstantVelocityIntegrator::integrate(IntegratorInterface &interface)
{
ParticlesBlock &block = interface.block();
auto velocities = block.attributes().get_float3("Velocity");
- auto position_offsets = interface.offsets().get_float3("Position");
+ auto position_offsets = interface.attribute_offsets().get_float3("Position");
auto durations = interface.remaining_durations();
for (uint pindex = 0; pindex < block.active_amount(); pindex++) {
@@ -48,18 +48,13 @@ AttributesInfo &EulerIntegrator::offset_attributes_info()
void EulerIntegrator::integrate(IntegratorInterface &interface)
{
- ParticlesBlock &block = interface.block();
- AttributeArrays r_offsets = interface.offsets();
+ AttributeArrays r_offsets = interface.attribute_offsets();
ArrayRef<float> durations = interface.remaining_durations();
ArrayAllocator::Array<float3> combined_force(interface.array_allocator());
- this->compute_combined_force(block,
- interface.array_allocator(),
- interface.remaining_durations(),
- interface.step_end_time(),
- combined_force);
+ this->compute_combined_force(interface, combined_force);
- auto last_velocities = block.attributes().get_float3("Velocity");
+ auto last_velocities = interface.block().attributes().get_float3("Velocity");
auto position_offsets = r_offsets.get_float3("Position");
auto velocity_offsets = r_offsets.get_float3("Velocity");
@@ -67,18 +62,15 @@ void EulerIntegrator::integrate(IntegratorInterface &interface)
durations, last_velocities, combined_force, position_offsets, velocity_offsets);
}
-BLI_NOINLINE void EulerIntegrator::compute_combined_force(ParticlesBlock &block,
- ArrayAllocator &array_allocator,
- ArrayRef<float> remaining_durations,
- float step_end_time,
+BLI_NOINLINE void EulerIntegrator::compute_combined_force(IntegratorInterface &interface,
ArrayRef<float3> r_force)
{
r_force.fill({0, 0, 0});
- ForceInterface interface(block, array_allocator, remaining_durations, step_end_time, r_force);
+ ForceInterface force_interface(interface.step_data(), r_force);
for (Force *force : m_forces) {
- force->add_force(interface);
+ force->add_force(force_interface);
}
}
diff --git a/source/blender/simulations/bparticles/integrator.hpp b/source/blender/simulations/bparticles/integrator.hpp
index ec8759e5492..5c6bb52467f 100644
--- a/source/blender/simulations/bparticles/integrator.hpp
+++ b/source/blender/simulations/bparticles/integrator.hpp
@@ -28,11 +28,7 @@ class EulerIntegrator : public Integrator {
void integrate(IntegratorInterface &interface) override;
private:
- void compute_combined_force(ParticlesBlock &block,
- ArrayAllocator &array_allocator,
- ArrayRef<float> remaining_durations,
- float step_end_time,
- ArrayRef<float3> r_force);
+ void compute_combined_force(IntegratorInterface &interface, ArrayRef<float3> r_force);
void compute_offsets(ArrayRef<float> durations,
ArrayRef<float3> last_velocities,
diff --git a/source/blender/simulations/bparticles/offset_handlers.cpp b/source/blender/simulations/bparticles/offset_handlers.cpp
index 697bd2aea68..2d20dd99cb3 100644
--- a/source/blender/simulations/bparticles/offset_handlers.cpp
+++ b/source/blender/simulations/bparticles/offset_handlers.cpp
@@ -6,7 +6,7 @@ void CreateTrailHandler::execute(OffsetHandlerInterface &interface)
{
ParticleSet particles = interface.particles();
auto positions = particles.attributes().get_float3("Position");
- auto position_offsets = interface.offsets().get_float3("Position");
+ auto position_offsets = interface.attribute_offsets().get_float3("Position");
auto inputs = m_compute_inputs->compute(interface);
diff --git a/source/blender/simulations/bparticles/particle_function.cpp b/source/blender/simulations/bparticles/particle_function.cpp
index 26255d0cf6f..219c6c65fcb 100644
--- a/source/blender/simulations/bparticles/particle_function.cpp
+++ b/source/blender/simulations/bparticles/particle_function.cpp
@@ -51,11 +51,11 @@ std::unique_ptr<ParticleFunctionResult> ParticleFunction::compute(ActionInterfac
std::unique_ptr<ParticleFunctionResult> ParticleFunction::compute(
OffsetHandlerInterface &interface)
{
- return this->compute(
- interface.array_allocator(),
- interface.particles(),
- ParticleTimes::FromDurationsAndEnd(interface.durations(), interface.step_end_time()),
- nullptr);
+ return this->compute(interface.array_allocator(),
+ interface.particles(),
+ ParticleTimes::FromDurationsAndEnd(interface.remaining_durations(),
+ interface.step_end_time()),
+ nullptr);
}
std::unique_ptr<ParticleFunctionResult> ParticleFunction::compute(ForceInterface &interface)
@@ -70,11 +70,11 @@ std::unique_ptr<ParticleFunctionResult> ParticleFunction::compute(ForceInterface
std::unique_ptr<ParticleFunctionResult> ParticleFunction::compute(EventFilterInterface &interface)
{
- return this->compute(
- interface.array_allocator(),
- interface.particles(),
- ParticleTimes::FromDurationsAndEnd(interface.durations(), interface.end_time()),
- nullptr);
+ return this->compute(interface.array_allocator(),
+ interface.particles(),
+ ParticleTimes::FromDurationsAndEnd(interface.remaining_durations(),
+ interface.step_end_time()),
+ nullptr);
}
std::unique_ptr<ParticleFunctionResult> ParticleFunction::compute(ArrayAllocator &array_allocator,
diff --git a/source/blender/simulations/bparticles/step_description_interfaces.cpp b/source/blender/simulations/bparticles/step_description_interfaces.cpp
index def3d8f8b49..15977aae1ed 100644
--- a/source/blender/simulations/bparticles/step_description_interfaces.cpp
+++ b/source/blender/simulations/bparticles/step_description_interfaces.cpp
@@ -17,7 +17,7 @@ EventFilterInterface::EventFilterInterface(BlockStepData &step_data,
EventStorage &r_event_storage,
Vector<uint> &r_filtered_pindices,
Vector<float> &r_filtered_time_factors)
- : m_step_data(step_data),
+ : BlockStepDataAccess(step_data),
m_pindices(pindices),
m_known_min_time_factors(known_min_time_factors),
m_event_storage(r_event_storage),
@@ -30,21 +30,21 @@ EventExecuteInterface::EventExecuteInterface(BlockStepData &step_data,
ArrayRef<uint> pindices,
ArrayRef<float> current_times,
EventStorage &event_storage)
- : m_step_data(step_data),
+ : BlockStepDataAccess(step_data),
m_pindices(pindices),
m_current_times(current_times),
m_event_storage(event_storage)
{
}
-IntegratorInterface::IntegratorInterface(BlockStepData &step_data) : m_step_data(step_data)
+IntegratorInterface::Int
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list