[Bf-blender-cvs] [7884ae9bc3f] functions-experimental-refactor: port particle system to new functions system

Jacques Lucke noreply at git.blender.org
Thu Nov 7 11:44:22 CET 2019


Commit: 7884ae9bc3f2b243533016a1bba8acb118789639
Author: Jacques Lucke
Date:   Thu Nov 7 11:44:08 2019 +0100
Branches: functions-experimental-refactor
https://developer.blender.org/rB7884ae9bc3f2b243533016a1bba8acb118789639

port particle system to new functions system

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

D	source/blender/blenkernel/BKE_attributes_block_container.hpp
D	source/blender/blenkernel/BKE_attributes_ref.hpp
M	source/blender/blenkernel/BKE_virtual_node_tree.h
M	source/blender/blenkernel/CMakeLists.txt
D	source/blender/blenkernel/intern/attributes_block_container.cpp
D	source/blender/blenkernel/intern/attributes_ref.cpp
M	source/blender/blenlib/BLI_allocator.h
M	source/blender/blenlib/BLI_resource_collector.h
M	source/blender/functions2/FN_attributes_block_container.h
M	source/blender/functions2/FN_attributes_ref.h
M	source/blender/functions2/FN_generic_array_ref.h
M	source/blender/functions2/FN_generic_tuple.h
M	source/blender/functions2/FN_multi_function_network.h
M	source/blender/functions2/FN_vtree_multi_function_network.h
M	source/blender/functions2/intern/attributes_block_container.cc
M	source/blender/functions2/intern/attributes_ref.cc
M	source/blender/functions2/intern/cpp_types.cc
M	source/blender/functions2/intern/multi_function_network.cc
M	source/blender/simulations/CMakeLists.txt
M	source/blender/simulations/bparticles/action_interface.hpp
M	source/blender/simulations/bparticles/block_step_data.hpp
M	source/blender/simulations/bparticles/c_wrapper.cpp
M	source/blender/simulations/bparticles/emitters.cpp
M	source/blender/simulations/bparticles/emitters.hpp
M	source/blender/simulations/bparticles/event_interface.hpp
M	source/blender/simulations/bparticles/integrator.cpp
M	source/blender/simulations/bparticles/node_frontend.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
M	source/blender/simulations/bparticles/particle_function_builder.hpp
M	source/blender/simulations/bparticles/particle_function_input_providers.cpp
M	source/blender/simulations/bparticles/particle_function_input_providers.hpp
M	source/blender/simulations/bparticles/particles_state.hpp
M	source/blender/simulations/bparticles/simulate.cpp
M	source/blender/simulations/bparticles/simulate.hpp

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

diff --git a/source/blender/blenkernel/BKE_attributes_block_container.hpp b/source/blender/blenkernel/BKE_attributes_block_container.hpp
deleted file mode 100644
index 6dd111e55f7..00000000000
--- a/source/blender/blenkernel/BKE_attributes_block_container.hpp
+++ /dev/null
@@ -1,128 +0,0 @@
-#pragma once
-
-#include <mutex>
-#include <atomic>
-
-#include "BLI_utility_mixins.h"
-
-#include "BKE_attributes_ref.hpp"
-
-namespace BKE {
-
-class AttributesBlock;
-
-class AttributesBlockContainer : BLI::NonCopyable, BLI::NonMovable {
- private:
-  AttributesInfo m_attributes_info;
-  uint m_block_size;
-  VectorSet<AttributesBlock *> m_active_blocks;
-  std::mutex m_blocks_mutex;
-
- public:
-  AttributesBlockContainer(AttributesInfo attributes_info, uint block_size);
-  ~AttributesBlockContainer();
-
-  uint count_active() const;
-
-  const AttributesInfo &attributes_info() const
-  {
-    return m_attributes_info;
-  }
-
-  void update_attributes(AttributesInfo new_info);
-
-  AttributesBlock *new_block();
-  void release_block(AttributesBlock *block);
-
-  void flatten_attribute(StringRef attribute_name, void *dst) const;
-
-  template<typename T> Vector<T> flatten_attribute(StringRef attribute_name)
-  {
-    BLI_assert(m_attributes_info.type_of(attribute_name) == attribute_type_by_type<T>::value);
-    Vector<T> result(this->count_active());
-    this->flatten_attribute(attribute_name, (void *)result.begin());
-    return result;
-  }
-
-  friend bool operator==(const AttributesBlockContainer &a, const AttributesBlockContainer &b)
-  {
-    return &a == &b;
-  }
-
-  ArrayRef<AttributesBlock *> active_blocks()
-  {
-    return m_active_blocks;
-  }
-};
-
-class AttributesBlock : BLI::NonCopyable, BLI::NonMovable {
- private:
-  AttributesBlockContainer &m_owner;
-  Vector<void *> m_buffers;
-  uint m_size;
-  uint m_capacity;
-
- public:
-  AttributesBlock(AttributesBlockContainer &owner, uint capacity);
-  ~AttributesBlock();
-
-  void update_buffers(const AttributesInfoDiff &info_diff);
-
-  uint size() const
-  {
-    return m_size;
-  }
-
-  uint capacity() const
-  {
-    return m_capacity;
-  }
-
-  uint remaining_capacity() const
-  {
-    return m_capacity - m_size;
-  }
-
-  IndexRange active_range() const
-  {
-    return IndexRange(m_size);
-  }
-
-  void set_size(uint new_size)
-  {
-    BLI_assert(new_size <= m_capacity);
-    m_size = new_size;
-  }
-
-  const AttributesInfo &attributes_info() const
-  {
-    return m_owner.attributes_info();
-  }
-
-  AttributesBlockContainer &owner()
-  {
-    return m_owner;
-  }
-
-  void move(uint old_index, uint new_index);
-
-  static void MoveUntilFull(AttributesBlock &from, AttributesBlock &to);
-  static void Compress(MutableArrayRef<AttributesBlock *> blocks);
-
-  AttributesRef as_ref()
-  {
-    return AttributesRef(*this);
-  }
-
-  AttributesRef as_ref__all()
-  {
-    return AttributesRef(m_owner.attributes_info(), m_buffers, m_capacity);
-  }
-
-  operator AttributesRef()
-  {
-    return AttributesRef(m_owner.attributes_info(), m_buffers, m_size);
-  }
-};
-
-}  // namespace BKE
diff --git a/source/blender/blenkernel/BKE_attributes_ref.hpp b/source/blender/blenkernel/BKE_attributes_ref.hpp
deleted file mode 100644
index 6a3e37da5f6..00000000000
--- a/source/blender/blenkernel/BKE_attributes_ref.hpp
+++ /dev/null
@@ -1,561 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- */
-
-/** \file
- * \ingroup bke
- *
- * This file provides classes that allow referencing multiple attribute arrays at the same time.
- * Every attribute array has an element-type, name and default value.
- */
-
-#pragma once
-
-#include <string>
-
-#include "BLI_array_ref.h"
-#include "BLI_math_cxx.h"
-#include "BLI_optional.h"
-#include "BLI_index_range.h"
-#include "BLI_vector_set.h"
-#include "BLI_set.h"
-#include "BLI_string_map.h"
-#include "BLI_string_ref.h"
-#include "BLI_vector.h"
-
-namespace BKE {
-
-using BLI::ArrayRef;
-using BLI::float2;
-using BLI::float3;
-using BLI::IndexRange;
-using BLI::MutableArrayRef;
-using BLI::Optional;
-using BLI::rgba_b;
-using BLI::rgba_f;
-using BLI::StringMap;
-using BLI::StringRef;
-using BLI::StringRefNull;
-using BLI::Vector;
-using BLI::VectorSet;
-
-/**
- * Possible types of attributes. All types are expected to be POD (plain old data).
- * New types can be added when necessary.
- */
-enum AttributeType {
-  Byte,
-  Int32,
-  UInt32,
-  Float,
-  Float2,
-  Float3,
-  RGBA_b,
-  RGBA_f,
-};
-
-template<typename T> struct attribute_type_by_type {
-};
-
-#define ATTRIBUTE_TYPE_BY_TYPE(CPP_TYPE, ATTRIBUTE_TYPE) \
-  template<> struct attribute_type_by_type<CPP_TYPE> { \
-    static const AttributeType value = AttributeType::ATTRIBUTE_TYPE; \
-  }
-
-ATTRIBUTE_TYPE_BY_TYPE(uint8_t, Byte);
-ATTRIBUTE_TYPE_BY_TYPE(int32_t, Int32);
-ATTRIBUTE_TYPE_BY_TYPE(uint32_t, UInt32);
-ATTRIBUTE_TYPE_BY_TYPE(float, Float);
-ATTRIBUTE_TYPE_BY_TYPE(float2, Float2);
-ATTRIBUTE_TYPE_BY_TYPE(float3, Float3);
-ATTRIBUTE_TYPE_BY_TYPE(rgba_b, RGBA_b);
-ATTRIBUTE_TYPE_BY_TYPE(rgba_f, RGBA_f);
-
-#undef ATTRIBUTE_TYPE_BY_TYPE
-
-/**
- * Get the size of an attribute type.
- */
-inline uint size_of_attribute_type(AttributeType type)
-{
-  switch (type) {
-    case AttributeType::Byte:
-      return sizeof(uint8_t);
-    case AttributeType::Int32:
-      return sizeof(int32_t);
-    case AttributeType::UInt32:
-      return sizeof(uint32_t);
-    case AttributeType::Float:
-      return sizeof(float);
-    case AttributeType::Float2:
-      return sizeof(float2);
-    case AttributeType::Float3:
-      return sizeof(float3);
-    case AttributeType::RGBA_b:
-      return sizeof(rgba_b);
-    case AttributeType::RGBA_f:
-      return sizeof(rgba_f);
-  };
-  BLI_assert(false);
-  return 0;
-}
-
-#define MAX_ATTRIBUTE_SIZE sizeof(rgba_f)
-
-/**
- * Container that is large enough to hold one value of any attribute type.
- */
-struct AnyAttributeValue {
-  char storage[MAX_ATTRIBUTE_SIZE];
-
-  template<typename T> static AnyAttributeValue FromValue(T value)
-  {
-    BLI_STATIC_ASSERT(attribute_type_by_type<T>::value >= 0, "");
-    BLI_STATIC_ASSERT(sizeof(T) <= MAX_ATTRIBUTE_SIZE, "");
-    AnyAttributeValue attribute;
-    memcpy(attribute.storage, &value, sizeof(T));
-    return attribute;
-  }
-};
-
-class AttributesInfo;
-
-class AttributesDeclaration {
- private:
-  VectorSet<std::string> m_names;
-  Vector<AttributeType> m_types;
-  Vector<AnyAttributeValue> m_defaults;
-
-  friend AttributesInfo;
-
- public:
-  AttributesDeclaration() = default;
-
-  template<typename T> void add(StringRef name, T default_value)
-  {
-    if (m_names.add(name)) {
-      AttributeType type = attribute_type_by_type<T>::value;
-      m_types.append(type);
-      m_defaults.append(AnyAttributeValue::FromValue(default_value));
-    }
-  }
-
-  uint size() const
-  {
-    return m_names.size();
-  }
-
-  void join(const AttributesDeclaration &other);
-  void join(const AttributesInfo &other);
-};
-
-/**
- * Contains information about a set of attributes. Every attribute is identified by a unique name
- * and a unique index. So two attributes of different types have to have different names.
- *
- * Furthermore, every attribute has a default value.
- */
-class AttributesInfo {
- private:
-  StringMap<int> m_index_by_name;
-  Vector<std::string> m_name_by_index;
-  Vector<AttributeType> m_type_by_index;
-  Vector<AnyAttributeValue> m_default_by_index;
-
-  friend AttributesDeclaration;
-
- public:
-  AttributesInfo() = default;
-  AttributesInfo(AttributesDeclaration &builder);
-
-  /**
-   * Get the number of different attributes.
-   */
-  uint size() const
-  {
-    return m_name_by_index.size();
-  }
-
-  /**
-   * Get the attribute name that corresponds to an index.
-   * Asserts when the index is too large.
-   */
-  StringRefNull name_of(uint index) const
-  {
-    return m_name_by_index[index];
-  }
-
-  /**
-   * Get the type of an attribute identified by its index.
-   * Asserts when the index is too large.
-   */
-  AttributeType type_of(uint index) const
-  {
-    return m_type_by_index[index];
-  }
-
-  /**
-   * Get the type of an attribute identified by its name.
-   * Asserts when the name does not exist.
-   */
-  AttributeType type_of(StringRef name) const
-  {
-    return this->type_of(this->attribute_index(name));
-  }
-
-  /**
-   * Get the types of all attributes. The index into the array is the index of the corresponding
-   * attribute.
-   */
-  ArrayRef<AttributeType> types() const
-  {
-    return m_type_by_index;
-  }
-
-  /**
-   * Get the index corresponding to an attribute name.
-   * Returns -1 when the attribute does not exist.
-   */
-  int attribute_index_try(StringRef name) const
-  {
-    return m_index_by_name.lookup_default(name, -1);
-  }
-
-  /**
-   * Get the index corresponding to an attribute with the given name and type.
-   * Returns -1 when the attribute does not exist.
-   */
-  int attribute_index_try(StringRef name, AttributeType type) const
-  {
-    int index = this->attribute_index_try(name);
-    if (index == -1) {
-      return -1;
-    }
-    else if (this->type_of((uint)index) == type) {
-      return index;
-    }
-    else {
-      return -1;
-    }
-  }
-
-  /**
-   * Get the index corresponding to an attribute name.
-   * Asserts when the attribute does not exist.
-   */
-  uint attribute_index(StringRef name) const
-  {
-    int index = m_index_by_name.lookup(name);
-    re

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list