diff options
author | Jacques Lucke <mail@jlucke.com> | 2019-12-31 16:59:48 +0300 |
---|---|---|
committer | Jacques Lucke <mail@jlucke.com> | 2019-12-31 16:59:48 +0300 |
commit | c2d3708224c1df8976f8a54ad80e9bce62f8839c (patch) | |
tree | 7a653ba650bcab16f6a37a54e4deade49733cffc /source/blender/simulations | |
parent | 36221652a4d9ef3ab7fe0f87939b1a3d9660325c (diff) |
introduce MutableAttributesRef
Diffstat (limited to 'source/blender/simulations')
8 files changed, 21 insertions, 17 deletions
diff --git a/source/blender/simulations/bparticles/actions.cpp b/source/blender/simulations/bparticles/actions.cpp index 3f74a447260..c60a7967b98 100644 --- a/source/blender/simulations/bparticles/actions.cpp +++ b/source/blender/simulations/bparticles/actions.cpp @@ -22,7 +22,7 @@ static void update_position_and_velocity_offsets(ParticleActionContext &context) } AttributesRef attributes = context.attributes(); - AttributesRef attribute_offsets = offsets_context->offsets; + MutableAttributesRef attribute_offsets = offsets_context->offsets; ArrayRef<float> remaining_times = remaining_times_context->remaining_times; auto velocities = attributes.get<float3>("Velocity"); diff --git a/source/blender/simulations/bparticles/block_step_data.hpp b/source/blender/simulations/bparticles/block_step_data.hpp index 62a1a41ee9f..4e33a148ccc 100644 --- a/source/blender/simulations/bparticles/block_step_data.hpp +++ b/source/blender/simulations/bparticles/block_step_data.hpp @@ -10,11 +10,12 @@ namespace BParticles { using BLI::FloatInterval; using FN::AttributesRef; +using FN::MutableAttributesRef; struct BlockStepData { SimulationState &simulation_state; - AttributesRef attributes; - AttributesRef attribute_offsets; + MutableAttributesRef attributes; + MutableAttributesRef attribute_offsets; MutableArrayRef<float> remaining_durations; float step_end_time; @@ -48,12 +49,12 @@ class BlockStepDataAccess { return m_step_data; } - AttributesRef attributes() + MutableAttributesRef attributes() { return m_step_data.attributes; } - AttributesRef attribute_offsets() + MutableAttributesRef attribute_offsets() { return m_step_data.attribute_offsets; } diff --git a/source/blender/simulations/bparticles/integrator.cpp b/source/blender/simulations/bparticles/integrator.cpp index dda578f87c9..8cd83e4953b 100644 --- a/source/blender/simulations/bparticles/integrator.cpp +++ b/source/blender/simulations/bparticles/integrator.cpp @@ -46,7 +46,7 @@ const AttributesInfo &EulerIntegrator::offset_attributes_info() void EulerIntegrator::integrate(IntegratorInterface &interface) { - AttributesRef r_offsets = interface.attribute_offsets(); + MutableAttributesRef r_offsets = interface.attribute_offsets(); ArrayRef<float> durations = interface.remaining_durations(); LargeScopedArray<float3> combined_force(interface.array_size()); diff --git a/source/blender/simulations/bparticles/particle_action.cpp b/source/blender/simulations/bparticles/particle_action.cpp index 918c6cfebb9..42ec6728333 100644 --- a/source/blender/simulations/bparticles/particle_action.cpp +++ b/source/blender/simulations/bparticles/particle_action.cpp @@ -15,7 +15,7 @@ ParticleAction::~ParticleAction() void ParticleAction::execute_from_emitter(AttributesRefGroup &new_particles, EmitterInterface &emitter_interface) { - for (AttributesRef attributes : new_particles) { + for (MutableAttributesRef attributes : new_particles) { ParticleCurrentTimesContext current_times_context; current_times_context.current_times = attributes.get<float>("Birth Time"); @@ -32,7 +32,7 @@ void ParticleAction::execute_for_new_particles(AttributesRefGroup &new_particles ParticleActionContext &parent_context) { - for (AttributesRef attributes : new_particles) { + for (MutableAttributesRef attributes : new_particles) { ParticleCurrentTimesContext current_times_context; current_times_context.current_times = attributes.get<float>("Birth Time"); @@ -48,7 +48,7 @@ void ParticleAction::execute_for_new_particles(AttributesRefGroup &new_particles void ParticleAction::execute_for_new_particles(AttributesRefGroup &new_particles, OffsetHandlerInterface &offset_handler_interface) { - for (AttributesRef attributes : new_particles) { + for (MutableAttributesRef attributes : new_particles) { ParticleCurrentTimesContext current_times_context; current_times_context.current_times = attributes.get<float>("Birth Time"); diff --git a/source/blender/simulations/bparticles/particle_action.hpp b/source/blender/simulations/bparticles/particle_action.hpp index 532a15b3977..9b0341c8f8d 100644 --- a/source/blender/simulations/bparticles/particle_action.hpp +++ b/source/blender/simulations/bparticles/particle_action.hpp @@ -16,7 +16,7 @@ class ParticleActionContext { private: ParticleAllocator &m_particle_allocator; IndexMask m_mask; - AttributesRef m_attributes; + MutableAttributesRef m_attributes; ArrayRef<BLI::class_id_t> m_custom_context_ids; ArrayRef<void *> m_custom_contexts; @@ -24,7 +24,7 @@ class ParticleActionContext { public: ParticleActionContext(ParticleAllocator &particle_allocator, IndexMask mask, - AttributesRef attributes, + MutableAttributesRef attributes, ArrayRef<BLI::class_id_t> custom_context_ids, ArrayRef<void *> custom_contexts) : m_particle_allocator(particle_allocator), @@ -56,7 +56,7 @@ class ParticleActionContext { return m_mask; } - AttributesRef attributes() + MutableAttributesRef attributes() { return m_attributes; } @@ -96,7 +96,7 @@ struct ParticleCurrentTimesContext { }; struct ParticleIntegratedOffsets { - AttributesRef offsets; + MutableAttributesRef offsets; }; struct ParticleRemainingTimeInStep { diff --git a/source/blender/simulations/bparticles/particle_allocator.cpp b/source/blender/simulations/bparticles/particle_allocator.cpp index a6c9203602b..7a1346524cd 100644 --- a/source/blender/simulations/bparticles/particle_allocator.cpp +++ b/source/blender/simulations/bparticles/particle_allocator.cpp @@ -44,7 +44,7 @@ void ParticleAllocator::initialize_new_particles(AttributesRefGroup &attributes_ { const AttributesInfo &info = attributes_group.info(); - for (AttributesRef attributes : attributes_group) { + for (MutableAttributesRef attributes : attributes_group) { for (uint i : info.indices()) { StringRef attribute_name = info.name_of(i); const void *default_value = info.default_of(attribute_name); diff --git a/source/blender/simulations/bparticles/particles_state.hpp b/source/blender/simulations/bparticles/particles_state.hpp index 87ff2cc0020..e29737ef73a 100644 --- a/source/blender/simulations/bparticles/particles_state.hpp +++ b/source/blender/simulations/bparticles/particles_state.hpp @@ -19,6 +19,7 @@ using FN::AttributesBlock; using FN::AttributesBlockContainer; using FN::AttributesInfo; using FN::AttributesRef; +using FN::MutableAttributesRef; class ParticlesState { private: diff --git a/source/blender/simulations/bparticles/simulate.cpp b/source/blender/simulations/bparticles/simulate.cpp index 7a5f4d789fb..3a662647cdd 100644 --- a/source/blender/simulations/bparticles/simulate.cpp +++ b/source/blender/simulations/bparticles/simulate.cpp @@ -88,7 +88,9 @@ BLI_NOINLINE static void forward_particles_to_next_event_or_end( } BLI_NOINLINE static void update_remaining_attribute_offsets( - IndexMask mask, ArrayRef<float> time_factors_to_next_event, AttributesRef attribute_offsets) + IndexMask mask, + ArrayRef<float> time_factors_to_next_event, + MutableAttributesRef attribute_offsets) { for (uint attribute_index : attribute_offsets.info().indices()) { /* Only vectors can be integrated for now. */ @@ -285,7 +287,7 @@ BLI_NOINLINE static void apply_remaining_offsets(BlockStepData &step_data, BLI_NOINLINE static void simulate_particle_chunk(SimulationState &simulation_state, ParticleAllocator &particle_allocator, - AttributesRef attributes, + MutableAttributesRef attributes, ParticleSystemInfo &system_info, MutableArrayRef<float> remaining_durations, float end_time) @@ -300,7 +302,7 @@ BLI_NOINLINE static void simulate_particle_chunk(SimulationState &simulation_sta void *ptr = BLI_temporary_allocate(type->size() * amount); offset_buffers.append(ptr); } - AttributesRef attribute_offsets(offsets_info, offset_buffers, amount); + MutableAttributesRef attribute_offsets(offsets_info, offset_buffers, amount); BlockStepData step_data = { simulation_state, attributes, attribute_offsets, remaining_durations, end_time}; |