[Bf-blender-cvs] [6793bab2431] functions: use proper constructors for step description and particle type

Jacques Lucke noreply at git.blender.org
Thu Jul 18 18:19:39 CEST 2019


Commit: 6793bab24315bb30e48190bc832e0f6edce9bf70
Author: Jacques Lucke
Date:   Thu Jul 18 15:39:05 2019 +0200
Branches: functions
https://developer.blender.org/rB6793bab24315bb30e48190bc832e0f6edce9bf70

use proper constructors for step description and particle type

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

M	source/blender/simulations/bparticles/core.hpp
M	source/blender/simulations/bparticles/step_description.hpp

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

diff --git a/source/blender/simulations/bparticles/core.hpp b/source/blender/simulations/bparticles/core.hpp
index 03d7de2d273..d1cf9939262 100644
--- a/source/blender/simulations/bparticles/core.hpp
+++ b/source/blender/simulations/bparticles/core.hpp
@@ -130,11 +130,23 @@ class OffsetHandler {
  * Describes how one type of particle behaves and which attributes it has.
  */
 class ParticleType {
- public:
+ private:
+  AttributesDeclaration m_attributes;
+  Integrator *m_integrator;
   SmallVector<Event *> m_events;
   SmallVector<OffsetHandler *> m_offset_handlers;
-  Integrator *m_integrator;
-  AttributesDeclaration m_attributes;
+
+ public:
+  ParticleType(AttributesDeclaration &attributes,
+               Integrator *integrator,
+               ArrayRef<Event *> events,
+               ArrayRef<OffsetHandler *> offset_handlers)
+      : m_attributes(attributes),
+        m_integrator(integrator),
+        m_events(events),
+        m_offset_handlers(offset_handlers)
+  {
+  }
 
   ~ParticleType();
 
@@ -163,11 +175,16 @@ class ParticleType {
  * Describes how the current state of a particle system transitions to the next state.
  */
 class StepDescription {
- public:
   float m_duration;
   StringMap<ParticleType *> m_types;
   SmallVector<Emitter *> m_emitters;
 
+ public:
+  StepDescription(float duration, StringMap<ParticleType *> types, ArrayRef<Emitter *> emitters)
+      : m_duration(duration), m_types(types), m_emitters(emitters)
+  {
+  }
+
   ~StepDescription();
 
   float step_duration()
diff --git a/source/blender/simulations/bparticles/step_description.hpp b/source/blender/simulations/bparticles/step_description.hpp
index b23f6929cbf..2d578c914bd 100644
--- a/source/blender/simulations/bparticles/step_description.hpp
+++ b/source/blender/simulations/bparticles/step_description.hpp
@@ -37,11 +37,8 @@ class ParticleTypeBuilder {
   ParticleType *build()
   {
     BLI_assert(m_integrator);
-    ParticleType *type = new ParticleType();
-    type->m_integrator = m_integrator;
-    type->m_events = m_events;
-    type->m_offset_handlers = m_offset_handlers;
-    type->m_attributes = m_attributes;
+    ParticleType *type = new ParticleType(m_attributes, m_integrator, m_events, m_offset_handlers);
+    m_integrator = nullptr;
     m_events.clear();
     m_offset_handlers.clear();
     return type;
@@ -78,12 +75,12 @@ class StepDescriptionBuilder {
 
   std::unique_ptr<StepDescription> build(float duration)
   {
-    StepDescription *step_description = new StepDescription();
-    step_description->m_duration = duration;
-    step_description->m_emitters = m_emitters;
+    StringMap<ParticleType *> types;
     for (auto item : m_type_builders.items()) {
-      step_description->m_types.add_new(item.key, item.value->build());
+      types.add_new(item.key, item.value->build());
     }
+
+    StepDescription *step_description = new StepDescription(duration, types, m_emitters);
     return std::unique_ptr<StepDescription>(step_description);
   }
 };



More information about the Bf-blender-cvs mailing list