[Bf-blender-cvs] [b9a2dc60e18] functions: rename attribute reference classes

Jacques Lucke noreply at git.blender.org
Tue Sep 3 10:53:24 CEST 2019


Commit: b9a2dc60e18492d6a033e9c756dbf59d6a9147e7
Author: Jacques Lucke
Date:   Tue Sep 3 10:53:07 2019 +0200
Branches: functions
https://developer.blender.org/rBb9a2dc60e18492d6a033e9c756dbf59d6a9147e7

rename attribute reference classes

AttributeArrays -> AttributesRef
NewParticles -> AttributesRefGroup

===================================================================

M	source/blender/simulations/CMakeLists.txt
M	source/blender/simulations/bparticles/action_interface.hpp
M	source/blender/simulations/bparticles/actions.cpp
M	source/blender/simulations/bparticles/attributes.cpp
M	source/blender/simulations/bparticles/attributes.hpp
M	source/blender/simulations/bparticles/block_step_data.hpp
M	source/blender/simulations/bparticles/events.cpp
M	source/blender/simulations/bparticles/integrator.cpp
M	source/blender/simulations/bparticles/particle_allocator.cpp
M	source/blender/simulations/bparticles/particle_allocator.hpp
M	source/blender/simulations/bparticles/particle_function.cpp
M	source/blender/simulations/bparticles/particle_function.hpp
M	source/blender/simulations/bparticles/particle_function_builder.cpp
D	source/blender/simulations/bparticles/particle_set.cpp
D	source/blender/simulations/bparticles/particle_set.hpp
M	source/blender/simulations/bparticles/particles_container.cpp
M	source/blender/simulations/bparticles/particles_container.hpp
M	source/blender/simulations/bparticles/particles_state.hpp
M	source/blender/simulations/bparticles/simulate.cpp

===================================================================

diff --git a/source/blender/simulations/CMakeLists.txt b/source/blender/simulations/CMakeLists.txt
index c33d47fc8fc..94bc09a7715 100644
--- a/source/blender/simulations/CMakeLists.txt
+++ b/source/blender/simulations/CMakeLists.txt
@@ -48,8 +48,6 @@ set(SRC
   bparticles/integrator.cpp
   bparticles/node_frontend.hpp
   bparticles/node_frontend.cpp
-  bparticles/particle_set.hpp
-  bparticles/particle_set.cpp
   bparticles/particles_state.hpp
   bparticles/particles_state.cpp
   bparticles/particle_allocator.hpp
diff --git a/source/blender/simulations/bparticles/action_interface.hpp b/source/blender/simulations/bparticles/action_interface.hpp
index 8f10e0821ec..3a74cad2170 100644
--- a/source/blender/simulations/bparticles/action_interface.hpp
+++ b/source/blender/simulations/bparticles/action_interface.hpp
@@ -31,8 +31,8 @@ class ActionInterface {
  private:
   ParticleAllocator &m_particle_allocator;
   ArrayRef<uint> m_pindices;
-  AttributeArrays m_attributes;
-  AttributeArrays m_attribute_offsets;
+  AttributesRef m_attributes;
+  AttributesRef m_attribute_offsets;
   ArrayRef<float> m_current_times;
   ArrayRef<float> m_remaining_durations;
   ActionContext &m_action_context;
@@ -40,8 +40,8 @@ class ActionInterface {
  public:
   ActionInterface(ParticleAllocator &particle_allocator,
                   ArrayRef<uint> pindices,
-                  AttributeArrays attributes,
-                  AttributeArrays attribute_offsets,
+                  AttributesRef attributes,
+                  AttributesRef attribute_offsets,
                   ArrayRef<float> current_times,
                   ArrayRef<float> remaining_durations,
                   ActionContext &action_context);
@@ -49,8 +49,8 @@ class ActionInterface {
   ActionContext &context();
 
   ArrayRef<uint> pindices();
-  AttributeArrays attributes();
-  AttributeArrays attribute_offsets();
+  AttributesRef attributes();
+  AttributesRef attribute_offsets();
   float remaining_time_in_step(uint pindex);
   ArrayRef<float> remaining_durations();
   ArrayRef<float> current_times();
@@ -64,14 +64,15 @@ class Action {
 
   virtual void execute(ActionInterface &interface) = 0;
 
-  void execute_from_emitter(NewParticles &new_particles,
+  void execute_from_emitter(AttributesRefGroup &new_particles,
                             EmitterInterface &emitter_interface,
                             EmitterActionContext *emitter_action_context = nullptr);
   void execute_from_event(EventExecuteInterface &event_interface,
                           ActionContext *action_context = nullptr);
   void execute_for_subset(ArrayRef<uint> pindices, ActionInterface &action_interface);
-  void execute_for_new_particles(NewParticles &new_particles, ActionInterface &action_interface);
-  void execute_for_new_particles(NewParticles &new_particles,
+  void execute_for_new_particles(AttributesRefGroup &new_particles,
+                                 ActionInterface &action_interface);
+  void execute_for_new_particles(AttributesRefGroup &new_particles,
                                  OffsetHandlerInterface &offset_handler_interface);
 };
 
@@ -80,8 +81,8 @@ class Action {
 
 inline ActionInterface::ActionInterface(ParticleAllocator &particle_allocator,
                                         ArrayRef<uint> pindices,
-                                        AttributeArrays attributes,
-                                        AttributeArrays attribute_offsets,
+                                        AttributesRef attributes,
+                                        AttributesRef attribute_offsets,
                                         ArrayRef<float> current_times,
                                         ArrayRef<float> remaining_durations,
                                         ActionContext &action_context)
@@ -104,7 +105,7 @@ class EmptyEmitterActionContext : public EmitterActionContext {
   }
 };
 
-inline void Action::execute_from_emitter(NewParticles &new_particles,
+inline void Action::execute_from_emitter(AttributesRefGroup &new_particles,
                                          EmitterInterface &emitter_interface,
                                          EmitterActionContext *emitter_action_context)
 {
@@ -118,13 +119,13 @@ inline void Action::execute_from_emitter(NewParticles &new_particles,
 
   uint offset = 0;
   for (uint i = 0; i < new_particles.range_amount(); i++) {
-    AttributeArrays attributes = new_particles.segment(i);
+    AttributesRef attributes = new_particles.segment(i);
     uint range_size = attributes.size();
 
     used_emitter_context.update(Range<uint>(offset, offset + range_size));
     offset += range_size;
 
-    AttributeArrays offsets(info, buffers, range_size);
+    AttributesRef offsets(info, buffers, range_size);
     TemporaryArray<float> durations(range_size);
     durations.fill(0);
 
@@ -168,7 +169,7 @@ inline void Action::execute_for_subset(ArrayRef<uint> pindices, ActionInterface
   this->execute(sub_interface);
 }
 
-inline void Action::execute_for_new_particles(NewParticles &new_particles,
+inline void Action::execute_for_new_particles(AttributesRefGroup &new_particles,
                                               ActionInterface &action_interface)
 {
   AttributesInfo info;
@@ -178,10 +179,10 @@ inline void Action::execute_for_new_particles(NewParticles &new_particles,
   EmptyActionContext empty_context;
 
   for (uint i = 0; i < new_particles.range_amount(); i++) {
-    AttributeArrays attributes = new_particles.segment(i);
+    AttributesRef attributes = new_particles.segment(i);
     uint range_size = attributes.size();
 
-    AttributeArrays offsets(info, buffers, range_size);
+    AttributesRef offsets(info, buffers, range_size);
     TemporaryArray<float> durations(range_size);
     durations.fill(0);
 
@@ -196,7 +197,7 @@ inline void Action::execute_for_new_particles(NewParticles &new_particles,
   }
 }
 
-inline void Action::execute_for_new_particles(NewParticles &new_particles,
+inline void Action::execute_for_new_particles(AttributesRefGroup &new_particles,
                                               OffsetHandlerInterface &offset_handler_interface)
 {
   AttributesInfo info;
@@ -205,10 +206,10 @@ inline void Action::execute_for_new_particles(NewParticles &new_particles,
   EmptyActionContext empty_context;
 
   for (uint i = 0; i < new_particles.range_amount(); i++) {
-    AttributeArrays attributes = new_particles.segment(i);
+    AttributesRef attributes = new_particles.segment(i);
     uint range_size = attributes.size();
 
-    AttributeArrays offsets(info, buffers, range_size);
+    AttributesRef offsets(info, buffers, range_size);
     TemporaryArray<float> durations(range_size);
     durations.fill(0);
 
@@ -233,12 +234,12 @@ inline ArrayRef<uint> ActionInterface::pindices()
   return m_pindices;
 }
 
-inline AttributeArrays ActionInterface::attributes()
+inline AttributesRef ActionInterface::attributes()
 {
   return m_attributes;
 }
 
-inline AttributeArrays ActionInterface::attribute_offsets()
+inline AttributesRef ActionInterface::attribute_offsets()
 {
   return m_attribute_offsets;
 }
diff --git a/source/blender/simulations/bparticles/actions.cpp b/source/blender/simulations/bparticles/actions.cpp
index 716c23ad0f3..bf4c8d0b625 100644
--- a/source/blender/simulations/bparticles/actions.cpp
+++ b/source/blender/simulations/bparticles/actions.cpp
@@ -31,8 +31,8 @@ static float3 random_direction()
 
 static void update_position_and_velocity_offsets(ActionInterface &interface)
 {
-  AttributeArrays attributes = interface.attributes();
-  AttributeArrays attribute_offsets = interface.attribute_offsets();
+  AttributesRef attributes = interface.attributes();
+  AttributesRef attribute_offsets = interface.attribute_offsets();
 
   auto velocities = attributes.get<float3>("Velocity");
   auto position_offsets = attribute_offsets.try_get<float3>("Position");
diff --git a/source/blender/simulations/bparticles/attributes.cpp b/source/blender/simulations/bparticles/attributes.cpp
index d94805c6f8c..b60f175e14b 100644
--- a/source/blender/simulations/bparticles/attributes.cpp
+++ b/source/blender/simulations/bparticles/attributes.cpp
@@ -32,4 +32,87 @@ AttributesInfo::AttributesInfo(AttributesDeclaration &builder)
   }
 }
 
+AttributesRefGroup::AttributesRefGroup(AttributesInfo &attributes_info,
+                                       Vector<ArrayRef<void *>> buffers,
+                                       Vector<Range<uint>> ranges)
+    : m_attributes_info(&attributes_info),
+      m_buffers(std::move(buffers)),
+      m_ranges(std::move(ranges))
+{
+  BLI_assert(buffers.size() == ranges.size());
+  m_size = 0;
+  for (Range<uint> range : m_ranges) {
+    m_size += range.size();
+  }
+}
+
+void AttributesRefGroup::set_elements(uint index, void *data)
+{
+  AttributeType type = m_attributes_info->type_of(index);
+  uint element_size = size_of_attribute_type(type);
+
+  void *remaining_data = data;
+
+  for (uint i = 0; i < this->range_amount(); i++) {
+    AttributesRef attributes = this->segment(i);
+    void *dst = attributes.get_ptr(index);
+
+    uint range_size = m_ranges[i].size();
+    for (uint pindex = 0; pindex < range_size; pindex++) {
+      memcpy(POINTER_OFFSET(dst, element_size * pindex),
+             POINTER_OFFSET(remaining_data, element_size * pindex),
+             element_size);
+    }
+
+    remaining_data = POINTER_OFFSET(remaining_data, range_size * element_size);
+  }
+}
+
+void AttributesRefGroup::set_repeated_elements(uint index,
+                                               void *data,
+                                               uint data_element_amount,
+                                               void *default_value)
+{
+  if (data_element_amount == 0) {
+    this->fill_elements(index, default_value);
+    return;
+  }
+
+  AttributeType type = m_attributes_info->type_of(index);
+  uint element_size = size_of_attribute_type(type);
+
+  uint offset = 0;
+  for (uint i = 0; i < this->range_amount(); i++) {
+    AttributesRef attributes = this->segment(i);
+    void *dst = attributes.get_ptr(index);
+
+    uint range_size = m_ranges[i].size();
+    for (uint pindex = 0; pindex < range_size; p

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list