[Bf-blender-cvs] [1d031a92a5f] functions: define attributes as part of particle type

Jacques Lucke noreply at git.blender.org
Sat Jun 29 16:25:52 CEST 2019


Commit: 1d031a92a5f1d6248db526ccba9d9affd3b2ad07
Author: Jacques Lucke
Date:   Sat Jun 29 15:05:15 2019 +0200
Branches: functions
https://developer.blender.org/rB1d031a92a5f1d6248db526ccba9d9affd3b2ad07

define attributes as part of particle type

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

M	source/blender/simulations/bparticles/c_wrapper.cpp
M	source/blender/simulations/bparticles/core.hpp
M	source/blender/simulations/bparticles/simulate.cpp

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

diff --git a/source/blender/simulations/bparticles/c_wrapper.cpp b/source/blender/simulations/bparticles/c_wrapper.cpp
index 74e947983da..28dfd825384 100644
--- a/source/blender/simulations/bparticles/c_wrapper.cpp
+++ b/source/blender/simulations/bparticles/c_wrapper.cpp
@@ -138,6 +138,12 @@ class ModifierParticleType : public ParticleType {
   {
     return *m_integrator;
   }
+
+  ArrayRef<std::string> float3_attributes() override
+  {
+    static std::array<std::string, 2> attributes = {"Position", "Velocity"};
+    return attributes;
+  }
 };
 
 class ModifierStepDescription : public StepDescription {
diff --git a/source/blender/simulations/bparticles/core.hpp b/source/blender/simulations/bparticles/core.hpp
index fd19d64c282..1475fc02a23 100644
--- a/source/blender/simulations/bparticles/core.hpp
+++ b/source/blender/simulations/bparticles/core.hpp
@@ -417,6 +417,21 @@ class ParticleType {
   virtual ArrayRef<Event *> events() = 0;
   virtual ArrayRef<Action *> action_per_event() = 0;
   virtual Integrator &integrator() = 0;
+
+  virtual ArrayRef<std::string> byte_attributes()
+  {
+    return {};
+  }
+
+  virtual ArrayRef<std::string> float_attributes()
+  {
+    return {};
+  }
+
+  virtual ArrayRef<std::string> float3_attributes()
+  {
+    return {};
+  }
 };
 
 class StepDescription {
diff --git a/source/blender/simulations/bparticles/simulate.cpp b/source/blender/simulations/bparticles/simulate.cpp
index bfd9f12f892..35d07615cb6 100644
--- a/source/blender/simulations/bparticles/simulate.cpp
+++ b/source/blender/simulations/bparticles/simulate.cpp
@@ -566,11 +566,19 @@ BLI_NOINLINE static void ensure_required_containers_exist(
   }
 }
 
-BLI_NOINLINE static AttributesInfo build_attribute_info_for_type(ParticleType &UNUSED(type),
+BLI_NOINLINE static AttributesInfo build_attribute_info_for_type(ParticleType &type,
                                                                  AttributesInfo &UNUSED(last_info))
 {
-  AttributesInfo new_info{{"Kill State"}, {"Birth Time"}, {"Position", "Velocity"}};
-  return new_info;
+  SmallSetVector<std::string> byte_attributes = {"Kill State"};
+  SmallSetVector<std::string> float_attributes = {"Birth Time"};
+  SmallSetVector<std::string> float3_attributes = {};
+
+  byte_attributes.add_multiple(type.byte_attributes());
+  float_attributes.add_multiple(type.float_attributes());
+  float3_attributes.add_multiple(type.float3_attributes());
+
+  return AttributesInfo(
+      byte_attributes.values(), float_attributes.values(), float3_attributes.values());
 }
 
 BLI_NOINLINE static void ensure_required_attributes_exist(



More information about the Bf-blender-cvs mailing list