Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJacques Lucke <mail@jlucke.com>2019-08-21 18:38:54 +0300
committerJacques Lucke <mail@jlucke.com>2019-08-21 18:38:54 +0300
commitfda6430d6af754ebbea7a07424642d5c70f57b5b (patch)
tree6510fe7a41df3158f808ac0eccaca6d2a8119f67 /source
parent700ff7b0731bdeaf0710b40deb7aeefe1770411d (diff)
improve const correctness in many places
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_node_tree.hpp9
-rw-r--r--source/blender/blenlib/BLI_array.hpp9
-rw-r--r--source/blender/blenlib/BLI_array_ref.hpp204
-rw-r--r--source/blender/blenlib/BLI_map.hpp16
-rw-r--r--source/blender/blenlib/BLI_monotonic_allocator.hpp4
-rw-r--r--source/blender/blenlib/BLI_multi_map.hpp4
-rw-r--r--source/blender/blenlib/BLI_refcount.hpp22
-rw-r--r--source/blender/blenlib/BLI_set_vector.hpp5
-rw-r--r--source/blender/blenlib/BLI_stack.hpp14
-rw-r--r--source/blender/blenlib/BLI_task.hpp4
-rw-r--r--source/blender/blenlib/BLI_vector.hpp31
-rw-r--r--source/blender/functions/backends/cpp/list.hpp6
-rw-r--r--source/blender/functions/backends/llvm/build_ir_body.hpp4
-rw-r--r--source/blender/functions/backends/tuple_call/fgraph_tuple_call.cpp8
-rw-r--r--source/blender/functions/core/data_graph.hpp40
-rw-r--r--source/blender/functions/core/data_graph_builder.cpp16
-rw-r--r--source/blender/functions/core/function.hpp16
-rw-r--r--source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp2
-rw-r--r--source/blender/functions/frontends/data_flow_nodes/unlinked_input_groupers.cpp4
-rw-r--r--source/blender/functions/frontends/data_flow_nodes/unlinked_input_inserters.cpp6
-rw-r--r--source/blender/functions/frontends/data_flow_nodes/unlinked_input_inserters.hpp6
-rw-r--r--source/blender/functions/functions/array_execution.cpp11
-rw-r--r--source/blender/functions/functions/array_execution.hpp2
-rw-r--r--source/blender/functions/functions/auto_vectorization.cpp2
-rw-r--r--source/blender/functions/functions/object_input.cpp2
-rw-r--r--source/blender/simulations/bparticles/attributes.hpp9
-rw-r--r--source/blender/simulations/bparticles/c_wrapper.cpp4
-rw-r--r--source/blender/simulations/bparticles/force_interface.hpp6
-rw-r--r--source/blender/simulations/bparticles/forces.cpp6
-rw-r--r--source/blender/simulations/bparticles/integrator.cpp6
-rw-r--r--source/blender/simulations/bparticles/integrator.hpp6
-rw-r--r--source/blender/simulations/bparticles/particle_allocator.cpp2
-rw-r--r--source/blender/simulations/bparticles/particle_function_builder.cpp12
-rw-r--r--source/blender/simulations/bparticles/particle_set.hpp4
-rw-r--r--source/blender/simulations/bparticles/particles_container.cpp2
-rw-r--r--source/blender/simulations/bparticles/particles_container.hpp2
-rw-r--r--source/blender/simulations/bparticles/simulate.cpp28
-rw-r--r--source/blender/simulations/bparticles/step_description_interfaces.hpp4
38 files changed, 355 insertions, 183 deletions
diff --git a/source/blender/blenkernel/BKE_node_tree.hpp b/source/blender/blenkernel/BKE_node_tree.hpp
index 3892d31e480..e13da37887b 100644
--- a/source/blender/blenkernel/BKE_node_tree.hpp
+++ b/source/blender/blenkernel/BKE_node_tree.hpp
@@ -19,6 +19,7 @@ using BLI::IntrusiveListBaseWrapper;
using BLI::Map;
using BLI::MonotonicAllocator;
using BLI::MultiMap;
+using BLI::MutableArrayRef;
using BLI::StringRef;
using BLI::StringRefNull;
using BLI::Vector;
@@ -94,8 +95,8 @@ class VirtualNode {
VirtualNodeTree *m_backlink;
bNodeTree *m_btree;
bNode *m_bnode;
- ArrayRef<VirtualSocket *> m_inputs;
- ArrayRef<VirtualSocket *> m_outputs;
+ MutableArrayRef<VirtualSocket *> m_inputs;
+ MutableArrayRef<VirtualSocket *> m_outputs;
public:
ArrayRef<VirtualSocket *> inputs()
@@ -160,8 +161,8 @@ class VirtualSocket {
bNodeSocket *m_bsocket;
uint m_id;
- ArrayRef<VirtualSocket *> m_direct_links;
- ArrayRef<VirtualSocket *> m_links;
+ MutableArrayRef<VirtualSocket *> m_direct_links;
+ MutableArrayRef<VirtualSocket *> m_links;
public:
bool is_input() const
diff --git a/source/blender/blenlib/BLI_array.hpp b/source/blender/blenlib/BLI_array.hpp
index 2e299de76dd..4bd9b0e900f 100644
--- a/source/blender/blenlib/BLI_array.hpp
+++ b/source/blender/blenlib/BLI_array.hpp
@@ -90,6 +90,11 @@ template<typename T, typename Allocator = GuardedAllocator> class Array {
return ArrayRef<T>(m_data, m_size);
}
+ operator MutableArrayRef<T>()
+ {
+ return MutableArrayRef<T>(m_data, m_size);
+ }
+
T &operator[](uint index)
{
BLI_assert(index < m_size);
@@ -103,12 +108,12 @@ template<typename T, typename Allocator = GuardedAllocator> class Array {
void fill(const T &value)
{
- ArrayRef<T>(*this).fill(value);
+ MutableArrayRef<T>(*this).fill(value);
}
void fill_indices(ArrayRef<uint> indices, const T &value)
{
- ArrayRef<T>(*this).fill_indices(indices, value);
+ MutableArrayRef<T>(*this).fill_indices(indices, value);
}
T *begin()
diff --git a/source/blender/blenlib/BLI_array_ref.hpp b/source/blender/blenlib/BLI_array_ref.hpp
index 5ac73ca124b..fd8f6468f7b 100644
--- a/source/blender/blenlib/BLI_array_ref.hpp
+++ b/source/blender/blenlib/BLI_array_ref.hpp
@@ -40,7 +40,7 @@ namespace BLI {
template<typename T> class ArrayRef {
private:
- T *m_start = nullptr;
+ const T *m_start = nullptr;
uint m_size = 0;
public:
@@ -50,15 +50,11 @@ template<typename T> class ArrayRef {
*/
ArrayRef() = default;
- ArrayRef(T *start, uint size) : m_start(start), m_size(size)
+ ArrayRef(const T *start, uint size) : m_start(start), m_size(size)
{
}
- ArrayRef(const T *start, uint size) : m_start((T *)start), m_size(size)
- {
- }
-
- ArrayRef(const std::initializer_list<T> &list) : ArrayRef((T *)list.begin(), list.size())
+ ArrayRef(const std::initializer_list<T> &list) : ArrayRef(list.begin(), list.size())
{
}
@@ -117,61 +113,34 @@ template<typename T> class ArrayRef {
}
/**
- * Replace all elements in the referenced array with the given value.
- */
- void fill(const T &element)
- {
- std::fill_n(m_start, m_size, element);
- }
-
- /**
- * Replace a subset of all elements with the given value.
- */
- void fill_indices(ArrayRef<uint> indices, const T &element)
- {
- for (uint i : indices) {
- m_start[i] = element;
- }
- }
-
- /**
- * Copy the values from another array into the references array.
- */
- void copy_from(const T *ptr)
- {
- BLI::copy_n(ptr, m_size, m_start);
- }
-
- void copy_from(ArrayRef<T> other)
- {
- BLI_assert(this->size() == other.size());
- this->copy_from(other.begin());
- }
-
- /**
* Copy the values in this array to another array.
*/
- void copy_to(T *ptr)
+ void copy_to(T *ptr) const
{
BLI::copy_n(m_start, m_size, ptr);
}
- T *begin() const
+ const T *begin() const
{
return m_start;
}
- T *end() const
+ const T *end() const
{
return m_start + m_size;
}
- T &operator[](uint index) const
+ const T &operator[](uint index) const
{
BLI_assert(index < m_size);
return m_start[index];
}
+ const T *data() const
+ {
+ return m_start;
+ }
+
/**
* Return the number of elements in the referenced array.
*/
@@ -192,9 +161,9 @@ template<typename T> class ArrayRef {
* Does a linear search to see of the value is in the array.
* Return true if it is, otherwise false.
*/
- bool contains(const T &value)
+ bool contains(const T &value) const
{
- for (T &element : *this) {
+ for (const T &element : *this) {
if (element == value) {
return true;
}
@@ -206,7 +175,7 @@ template<typename T> class ArrayRef {
* Does a constant time check to see if the pointer is within the referenced array.
* Return true if it is, otherwise false.
*/
- bool contains_ptr(const T *ptr)
+ bool contains_ptr(const T *ptr) const
{
return (this->begin() <= ptr) && (ptr < this->end());
}
@@ -215,10 +184,10 @@ template<typename T> class ArrayRef {
* Does a linear search to count how often the value is in the array.
* Returns the number of occurences.
*/
- uint count(const T &value)
+ uint count(const T &value) const
{
uint counter = 0;
- for (T &element : *this) {
+ for (const T &element : *this) {
if (element == value) {
counter++;
}
@@ -230,7 +199,7 @@ template<typename T> class ArrayRef {
* Return a reference to the first element in the array.
* Asserts when the array is empty.
*/
- T &first()
+ const T &first() const
{
BLI_assert(m_size > 0);
return m_start[0];
@@ -240,7 +209,7 @@ template<typename T> class ArrayRef {
* Return a reference to the last elemeent in the array.
* Asserts when the array is empty.
*/
- T &last()
+ const T &last() const
{
BLI_assert(m_size > 0);
return m_start[m_size - 1];
@@ -283,6 +252,141 @@ template<typename T> class ArrayRef {
}
};
+template<typename T> class MutableArrayRef {
+ private:
+ T *m_start;
+ uint m_size;
+
+ public:
+ MutableArrayRef() = default;
+
+ MutableArrayRef(T *start, uint size) : m_start(start), m_size(size)
+ {
+ }
+
+ MutableArrayRef(std::initializer_list<T> &list) : MutableArrayRef(list.begin(), list.size())
+ {
+ }
+
+ MutableArrayRef(std::vector<T> &vector) : MutableArrayRef(vector.data(), vector.size())
+ {
+ }
+
+ template<std::size_t N>
+ MutableArrayRef(std::array<T, N> &array) : MutableArrayRef(array.data(), N)
+ {
+ }
+
+ operator ArrayRef<T>()
+ {
+ return ArrayRef<T>(this->data(), this->size());
+ }
+
+ T *data() const
+ {
+ return m_start;
+ }
+
+ uint size() const
+ {
+ return m_size;
+ }
+
+ /**
+ * Replace all elements in the referenced array with the given value.
+ */
+ void fill(const T &element)
+ {
+ std::fill_n(m_start, m_size, element);
+ }
+
+ /**
+ * Replace a subset of all elements with the given value.
+ */
+ void fill_indices(ArrayRef<uint> indices, const T &element)
+ {
+ for (uint i : indices) {
+ m_start[i] = element;
+ }
+ }
+
+ /**
+ * Copy the values from another array into the references array.
+ */
+ void copy_from(const T *ptr)
+ {
+ BLI::copy_n(ptr, m_size, m_start);
+ }
+
+ void copy_from(ArrayRef<T> other)
+ {
+ BLI_assert(this->size() == other.size());
+ this->copy_from(other.begin());
+ }
+
+ T *begin() const
+ {
+ return m_start;
+ }
+
+ T *end() const
+ {
+ return m_start + m_size;
+ }
+
+ T &operator[](uint index) const
+ {
+ BLI_assert(index < this->size());
+ return m_start[index];
+ }
+
+ /**
+ * Return a continuous part of the array.
+ * This will assert when the slice is out of bounds.
+ */
+ MutableArrayRef slice(uint start, uint length) const
+ {
+ BLI_assert(start + length <= this->size());
+ return MutableArrayRef(m_start + start, length);
+ }
+
+ /**
+ * Return a new MutableArrayRef with n elements removed from the beginning.
+ */
+ MutableArrayRef drop_front(uint n = 1) const
+ {
+ BLI_assert(n <= this->size());
+ return this->slice(n, this->size() - n);
+ }
+
+ /**
+ * Return a new MutableArrayRef with n elements removed from the beginning.
+ */
+ MutableArrayRef drop_back(uint n = 1) const
+ {
+ BLI_assert(n <= this->size());
+ return this->slice(0, this->size() - n);
+ }
+
+ /**
+ * Return a new MutableArrayRef that only contains the first n elements.
+ */
+ MutableArrayRef take_front(uint n) const
+ {
+ BLI_assert(n <= this->size());
+ return this->slice(0, n);
+ }
+
+ /**
+ * Return a new MutableArrayRef that only contains the last n elements.
+ */
+ MutableArrayRef take_back(uint n) const
+ {
+ BLI_assert(n <= this->size());
+ return this->slice(this->size() - n, n);
+ }
+};
+
/**
* Shorthand to make use of automatic template parameter deduction.
*/
diff --git a/source/blender/blenlib/BLI_map.hpp b/source/blender/blenlib/BLI_map.hpp
index bafb10f965f..6d30a87f6f0 100644
--- a/source/blender/blenlib/BLI_map.hpp
+++ b/source/blender/blenlib/BLI_map.hpp
@@ -265,7 +265,7 @@ template<typename KeyT, typename ValueT, typename Allocator = GuardedAllocator>
key, [&value]() { return value; }, [&value](ValueT &old_value) { old_value = value; });
}
- ValueT *lookup_ptr(const KeyT &key) const
+ const ValueT *lookup_ptr(const KeyT &key) const
{
ITER_SLOTS_BEGIN (key, m_array, const, item, offset) {
if (item.is_empty(offset)) {
@@ -278,11 +278,23 @@ template<typename KeyT, typename ValueT, typename Allocator = GuardedAllocator>
ITER_SLOTS_END(offset);
}
- ValueT &lookup(const KeyT &key) const
+ const ValueT &lookup(const KeyT &key) const
{
return *this->lookup_ptr(key);
}
+ ValueT *lookup_ptr(const KeyT &key)
+ {
+ const Map *const_this = this;
+ return const_cast<ValueT *>(const_this->lookup_ptr(key));
+ }
+
+ ValueT &lookup(const KeyT &key)
+ {
+ const Map *const_this = this;
+ return const_cast<ValueT &>(const_this->lookup(key));
+ }
+
ValueT lookup_default(const KeyT &key, ValueT default_value) const
{
ValueT *ptr = this->lookup_ptr(key);
diff --git a/source/blender/blenlib/BLI_monotonic_allocator.hpp b/source/blender/blenlib/BLI_monotonic_allocator.hpp
index 13d327993d1..1ed920ca029 100644
--- a/source/blender/blenlib/BLI_monotonic_allocator.hpp
+++ b/source/blender/blenlib/BLI_monotonic_allocator.hpp
@@ -78,9 +78,9 @@ class MonotonicAllocator {
return (T *)this->allocate(sizeof(T));
}
- template<typename T> ArrayRef<T> allocate_array(uint length)
+ template<typename T> MutableArrayRef<T> allocate_array(uint length)
{
- return ArrayRef<T>((T *)this->allocate(sizeof(T) * length), length);
+ return MutableArrayRef<T>((T *)this->allocate(sizeof(T) * length), length);
}
void *allocate_aligned(uint size, uint alignment)
diff --git a/source/blender/blenlib/BLI_multi_map.hpp b/source/blender/blenlib/BLI_multi_map.hpp
index 7fe3cc36804..75bfd962e1b 100644
--- a/source/blender/blenlib/BLI_multi_map.hpp
+++ b/source/blender/blenlib/BLI_multi_map.hpp
@@ -35,7 +35,7 @@ template<typename K, typename V, uint N = 4> class MultiMap {
uint length;
uint capacity;
- ArrayRef<V> get_slice(ArrayRef<V> array)
+ ArrayRef<V> get_slice(ArrayRef<V> array) const
{
return array.slice(offset, length);
}
@@ -130,7 +130,7 @@ template<typename K, typename V, uint N = 4> class MultiMap {
ArrayRef<V> lookup_default(const K &key, ArrayRef<V> default_array = ArrayRef<V>()) const
{
- Entry *entry = m_map.lookup_ptr(key);
+ const Entry *entry = m_map.lookup_ptr(key);
if (entry == nullptr) {
return default_array;
}
diff --git a/source/blender/blenlib/BLI_refcount.hpp b/source/blender/blenlib/BLI_refcount.hpp
index 7320a895e8e..69c63de76e5 100644
--- a/source/blender/blenlib/BLI_refcount.hpp
+++ b/source/blender/blenlib/BLI_refcount.hpp
@@ -167,7 +167,12 @@ template<typename T> class AutoRefCount {
/**
* Get the pointer that is currently wrapped. This pointer can be null.
*/
- T *ptr() const
+ const T *ptr() const
+ {
+ return m_object;
+ }
+
+ T *ptr()
{
return m_object;
}
@@ -176,7 +181,13 @@ template<typename T> class AutoRefCount {
* Get a reference to the object that is currently wrapped.
* Asserts when no object is wrapped.
*/
- T &ref() const
+ const T &ref() const
+ {
+ BLI_assert(m_object);
+ return *m_object;
+ }
+
+ T &ref()
{
BLI_assert(m_object);
return *m_object;
@@ -193,7 +204,12 @@ template<typename T> class AutoRefCount {
return value;
}
- T *operator->() const
+ const T *operator->() const
+ {
+ return this->ptr();
+ }
+
+ T *operator->()
{
return this->ptr();
}
diff --git a/source/blender/blenlib/BLI_set_vector.hpp b/source/blender/blenlib/BLI_set_vector.hpp
index 399a0e6de6f..f938b7da19e 100644
--- a/source/blender/blenlib/BLI_set_vector.hpp
+++ b/source/blender/blenlib/BLI_set_vector.hpp
@@ -272,6 +272,11 @@ template<typename T, typename Allocator = GuardedAllocator> class SetVector {
return m_elements;
}
+ operator MutableArrayRef<T>()
+ {
+ return m_elements;
+ }
+
private:
void update_slot_index(T &value, uint old_index, uint new_index)
{
diff --git a/source/blender/blenlib/BLI_stack.hpp b/source/blender/blenlib/BLI_stack.hpp
index ad772b19bc3..4c0ebc225e7 100644
--- a/source/blender/blenlib/BLI_stack.hpp
+++ b/source/blender/blenlib/BLI_stack.hpp
@@ -94,12 +94,22 @@ template<typename T, uint N = 4, typename Allocator = GuardedAllocator> class St
return m_elements[this->size() - 1];
}
- T *begin() const
+ T *begin()
{
return m_elements.begin();
}
- T *end() const
+ T *end()
+ {
+ return m_elements.end();
+ }
+
+ const T *begin() const
+ {
+ return m_elements.begin();
+ }
+
+ const T *end() const
{
return m_elements.end();
}
diff --git a/source/blender/blenlib/BLI_task.hpp b/source/blender/blenlib/BLI_task.hpp
index 2ed6ffaee9a..88f4a03ee77 100644
--- a/source/blender/blenlib/BLI_task.hpp
+++ b/source/blender/blenlib/BLI_task.hpp
@@ -83,7 +83,7 @@ static void parallel_array_elements(ArrayRef<T> array,
if (!use_threading) {
LocalData local_data = create_thread_local();
- for (T &element : array) {
+ for (const T &element : array) {
process_element(element, local_data);
}
free_thread_local(local_data);
@@ -120,7 +120,7 @@ static void parallel_array_elements(ArrayRef<T> array,
}
data.thread_locals_mutex.unlock();
- T &element = data.array[index];
+ const T &element = data.array[index];
data.process_element(element, local_data);
},
&settings);
diff --git a/source/blender/blenlib/BLI_vector.hpp b/source/blender/blenlib/BLI_vector.hpp
index 7d371ec1f52..6cc78ac006b 100644
--- a/source/blender/blenlib/BLI_vector.hpp
+++ b/source/blender/blenlib/BLI_vector.hpp
@@ -159,6 +159,11 @@ template<typename T, uint N = 4, typename Allocator = GuardedAllocator> class Ve
return ArrayRef<T>(m_elements, m_size);
}
+ operator MutableArrayRef<T>()
+ {
+ return MutableArrayRef<T>(m_elements, m_size);
+ }
+
Vector &operator=(const Vector &other)
{
if (this == &other) {
@@ -291,7 +296,7 @@ template<typename T, uint N = 4, typename Allocator = GuardedAllocator> class Ve
* Return a reference to the last element in the vector.
* This will assert when the vector is empty.
*/
- T &last() const
+ const T &last() const
{
BLI_assert(m_size > 0);
return m_elements[m_size - 1];
@@ -309,7 +314,7 @@ template<typename T, uint N = 4, typename Allocator = GuardedAllocator> class Ve
void fill_indices(ArrayRef<uint> indices, const T &value)
{
- ArrayRef<T>(*this).fill_indices(indices, value);
+ MutableArrayRef<T>(*this).fill_indices(indices, value);
}
/**
@@ -406,28 +411,34 @@ template<typename T, uint N = 4, typename Allocator = GuardedAllocator> class Ve
return true;
}
- T &operator[](const int index) const
+ const T &operator[](uint index) const
{
BLI_assert(this->is_index_in_range(index));
return m_elements[index];
}
- T *begin() const
+ T &operator[](uint index)
+ {
+ BLI_assert(this->is_index_in_range(index));
+ return m_elements[index];
+ }
+
+ T *begin()
{
return m_elements;
}
- T *end() const
+ T *end()
{
- return this->begin() + this->size();
+ return m_elements + m_size;
}
- const T *cbegin() const
+ const T *begin() const
{
- return this->begin();
+ return m_elements;
}
- const T *cend() const
+ const T *end() const
{
- return this->end();
+ return m_elements + m_size;
}
void print_stats() const
diff --git a/source/blender/functions/backends/cpp/list.hpp b/source/blender/functions/backends/cpp/list.hpp
index a38662b5a58..57c9e803f1f 100644
--- a/source/blender/functions/backends/cpp/list.hpp
+++ b/source/blender/functions/backends/cpp/list.hpp
@@ -85,7 +85,7 @@ class List : public RefCounter {
{
BLI_assert(this->is_mutable());
BLI_assert(m_type == other->m_type);
- List &other_ = other.ref();
+ const List &other_ = other.ref();
this->reserve(m_size + other_.size());
void *src = other_.m_storage;
void *dst = POINTER_OFFSET(m_storage, m_size * m_type_info->size());
@@ -104,10 +104,10 @@ class List : public RefCounter {
return static_cast<T *>(m_storage);
}
- template<typename T> ArrayRef<T> as_array_ref() const
+ template<typename T> MutableArrayRef<T> as_array_ref()
{
BLI_assert(this->can_be_type<T>());
- return ArrayRef<T>(this->storage<T>(), m_size);
+ return MutableArrayRef<T>(this->storage<T>(), m_size);
}
template<typename T> bool can_be_type() const
diff --git a/source/blender/functions/backends/llvm/build_ir_body.hpp b/source/blender/functions/backends/llvm/build_ir_body.hpp
index 1d60753b297..ebd58bcb3f7 100644
--- a/source/blender/functions/backends/llvm/build_ir_body.hpp
+++ b/source/blender/functions/backends/llvm/build_ir_body.hpp
@@ -20,13 +20,13 @@ using FunctionIRCache = Map<void *, llvm::Function *>;
class CodeInterface {
private:
ArrayRef<llvm::Value *> m_inputs;
- ArrayRef<llvm::Value *> m_outputs;
+ MutableArrayRef<llvm::Value *> m_outputs;
llvm::Value *m_context_ptr;
FunctionIRCache &m_function_ir_cache;
public:
CodeInterface(ArrayRef<llvm::Value *> inputs,
- ArrayRef<llvm::Value *> outputs,
+ MutableArrayRef<llvm::Value *> outputs,
llvm::Value *context_ptr,
FunctionIRCache &function_ir_cache)
: m_inputs(inputs),
diff --git a/source/blender/functions/backends/tuple_call/fgraph_tuple_call.cpp b/source/blender/functions/backends/tuple_call/fgraph_tuple_call.cpp
index 5964e083c72..7f042aff96e 100644
--- a/source/blender/functions/backends/tuple_call/fgraph_tuple_call.cpp
+++ b/source/blender/functions/backends/tuple_call/fgraph_tuple_call.cpp
@@ -440,7 +440,7 @@ class ExecuteFGraph : public TupleCallBody {
BLI_assert(storage.is_output_initialized(output_id));
auto possible_target_ids = m_graph->targets_of_output(output_id);
- SocketInfo &output_info = m_output_info[output_id];
+ const SocketInfo &output_info = m_output_info[output_id];
CPPTypeInfo *type_info = output_info.type;
uint *target_ids_array = (uint *)alloca(possible_target_ids.size() * sizeof(uint));
@@ -523,7 +523,7 @@ class ExecuteFGraph : public TupleCallBody {
Tuple &fn_out) const
{
for (uint target_id : target_ids) {
- SocketInfo &socket_info = m_input_info[target_id];
+ const SocketInfo &socket_info = m_input_info[target_id];
if (socket_info.is_fn_output) {
uint index = m_fgraph.outputs().index(DataSocket::FromInput(target_id));
void *value_ptr = storage.input_value_ptr(target_id);
@@ -536,14 +536,14 @@ class ExecuteFGraph : public TupleCallBody {
{
for (uint input_id = 0; input_id < m_inputs_init_buffer_size; input_id++) {
if (storage.is_input_initialized(input_id)) {
- SocketInfo &socket_info = m_input_info[input_id];
+ const SocketInfo &socket_info = m_input_info[input_id];
void *value_ptr = storage.input_value_ptr(input_id);
socket_info.type->destruct(value_ptr);
}
}
for (uint output_id = 0; output_id < m_outputs_init_buffer_size; output_id++) {
if (storage.is_output_initialized(output_id)) {
- SocketInfo &socket_info = m_output_info[output_id];
+ const SocketInfo &socket_info = m_output_info[output_id];
void *value_ptr = storage.output_value_ptr(output_id);
socket_info.type->destruct(value_ptr);
}
diff --git a/source/blender/functions/core/data_graph.hpp b/source/blender/functions/core/data_graph.hpp
index f79d4b9137b..6c06c4b0063 100644
--- a/source/blender/functions/core/data_graph.hpp
+++ b/source/blender/functions/core/data_graph.hpp
@@ -222,46 +222,48 @@ class DataGraph : public RefCounter {
return Range<uint>(0, m_nodes.size());
}
- SharedFunction &function_of_node(uint node_id)
+ SharedFunction &function_of_node(uint node_id) const
{
- return m_nodes[node_id].function;
+ /* A function is mostly immutable anyway. */
+ const SharedFunction &fn = m_nodes[node_id].function;
+ return const_cast<SharedFunction &>(fn);
}
- SharedFunction &function_of_input(uint input_id)
+ SharedFunction &function_of_input(uint input_id) const
{
return this->function_of_node(m_inputs[input_id].node);
}
- SharedFunction &function_of_output(uint output_id)
+ SharedFunction &function_of_output(uint output_id) const
{
return this->function_of_node(m_outputs[output_id].node);
}
- uint id_of_node_input(uint node_id, uint input_index)
+ uint id_of_node_input(uint node_id, uint input_index) const
{
BLI_assert(input_index < this->input_ids_of_node(node_id).size());
return m_nodes[node_id].inputs_start + input_index;
}
- uint id_of_node_output(uint node_id, uint output_index)
+ uint id_of_node_output(uint node_id, uint output_index) const
{
BLI_assert(output_index < this->output_ids_of_node(node_id).size());
return m_nodes[node_id].outputs_start + output_index;
}
- DataSocket socket_of_node_input(uint node_id, uint input_index)
+ DataSocket socket_of_node_input(uint node_id, uint input_index) const
{
return DataSocket(false, this->id_of_node_input(node_id, input_index));
}
- DataSocket socket_of_node_output(uint node_id, uint output_index)
+ DataSocket socket_of_node_output(uint node_id, uint output_index) const
{
return DataSocket(true, this->id_of_node_output(node_id, output_index));
}
Range<uint> input_ids_of_node(uint node_id) const
{
- Node &node = m_nodes[node_id];
+ const Node &node = m_nodes[node_id];
return Range<uint>(node.inputs_start, node.inputs_start + node.function->input_amount());
}
@@ -272,7 +274,7 @@ class DataGraph : public RefCounter {
Range<uint> output_ids_of_node(uint node_id) const
{
- Node &node = m_nodes[node_id];
+ const Node &node = m_nodes[node_id];
return Range<uint>(node.outputs_start, node.outputs_start + node.function->output_amount());
}
@@ -314,7 +316,7 @@ class DataGraph : public RefCounter {
ArrayRef<uint> targets_of_output(uint output_id) const
{
- OutputSocket &data = m_outputs[output_id];
+ const OutputSocket &data = m_outputs[output_id];
return ArrayRef<uint>(&m_targets[data.targets_start], data.targets_amount);
}
@@ -388,7 +390,7 @@ class DataGraph : public RefCounter {
return this->index_of_output(output_socket.id());
}
- const StringRefNull name_of_socket(DataSocket socket)
+ StringRefNull name_of_socket(DataSocket socket) const
{
if (socket.is_input()) {
return this->name_of_input(socket.id());
@@ -398,7 +400,7 @@ class DataGraph : public RefCounter {
}
}
- Type *type_of_socket(DataSocket socket)
+ Type *type_of_socket(DataSocket socket) const
{
if (socket.is_input()) {
return this->type_of_input(socket.id());
@@ -408,33 +410,33 @@ class DataGraph : public RefCounter {
}
}
- const StringRefNull name_of_input(uint input_id)
+ StringRefNull name_of_input(uint input_id) const
{
return this->function_of_input(input_id)->input_name(this->index_of_input(input_id));
}
- const StringRefNull name_of_output(uint output_id)
+ StringRefNull name_of_output(uint output_id) const
{
return this->function_of_output(output_id)->output_name(this->index_of_output(output_id));
}
- Type *type_of_input(uint input_id)
+ Type *type_of_input(uint input_id) const
{
return this->function_of_input(input_id)->input_type(this->index_of_input(input_id));
}
- Type *type_of_output(uint output_id)
+ Type *type_of_output(uint output_id) const
{
return this->function_of_output(output_id)->output_type(this->index_of_output(output_id));
}
- Type *type_of_input(DataSocket input_socket)
+ Type *type_of_input(DataSocket input_socket) const
{
BLI_assert(input_socket.is_input());
return this->type_of_input(input_socket.id());
}
- Type *type_of_output(DataSocket output_socket)
+ Type *type_of_output(DataSocket output_socket) const
{
BLI_assert(output_socket.is_output());
return this->type_of_output(output_socket.id());
diff --git a/source/blender/functions/core/data_graph_builder.cpp b/source/blender/functions/core/data_graph_builder.cpp
index f9de86b0f72..179c39a58ce 100644
--- a/source/blender/functions/core/data_graph_builder.cpp
+++ b/source/blender/functions/core/data_graph_builder.cpp
@@ -26,14 +26,14 @@ BuilderNode *DataGraphBuilder::insert_function(SharedFunction function, SourceIn
/* Allocate memory for node, input sockets and output sockets. */
BuilderNode *node = m_allocator.allocate<BuilderNode>();
- ArrayRef<BuilderInputSocket> input_sockets = m_allocator.allocate_array<BuilderInputSocket>(
- function->input_amount());
- ArrayRef<BuilderInputSocket *> input_socket_pointers =
+ MutableArrayRef<BuilderInputSocket> input_sockets =
+ m_allocator.allocate_array<BuilderInputSocket>(function->input_amount());
+ MutableArrayRef<BuilderInputSocket *> input_socket_pointers =
m_allocator.allocate_array<BuilderInputSocket *>(function->input_amount());
- ArrayRef<BuilderOutputSocket> output_sockets = m_allocator.allocate_array<BuilderOutputSocket>(
- function->output_amount());
- ArrayRef<BuilderOutputSocket *> output_socket_pointers =
+ MutableArrayRef<BuilderOutputSocket> output_sockets =
+ m_allocator.allocate_array<BuilderOutputSocket>(function->output_amount());
+ MutableArrayRef<BuilderOutputSocket *> output_socket_pointers =
m_allocator.allocate_array<BuilderOutputSocket *>(function->output_amount());
/* Initialize input sockets. */
@@ -78,8 +78,8 @@ void DataGraphBuilder::insert_link(BuilderOutputSocket *from, BuilderInputSocket
if (from->m_targets.is_full()) {
uint old_capacity = from->m_targets.capacity();
uint new_capacity = (old_capacity == 0) ? 1 : old_capacity * 2;
- ArrayRef<BuilderInputSocket *> new_targets = m_allocator.allocate_array<BuilderInputSocket *>(
- new_capacity);
+ MutableArrayRef<BuilderInputSocket *> new_targets =
+ m_allocator.allocate_array<BuilderInputSocket *>(new_capacity);
new_targets.take_front(old_capacity).copy_from(from->m_targets);
from->m_targets = VectorAdaptor<BuilderInputSocket *>(
new_targets.begin(), new_capacity, old_capacity);
diff --git a/source/blender/functions/core/function.hpp b/source/blender/functions/core/function.hpp
index 21e39c5ba1b..88d71f45142 100644
--- a/source/blender/functions/core/function.hpp
+++ b/source/blender/functions/core/function.hpp
@@ -106,22 +106,22 @@ class Function final : public RefCounter {
/**
* Get the type of the input at the given index.
*/
- Type *input_type(uint index);
+ Type *input_type(uint index) const;
/**
* Get the type of the output at the given index.
*/
- Type *output_type(uint index);
+ Type *output_type(uint index) const;
/**
* Get the name of the input at the given index.
*/
- StringRefNull input_name(uint index);
+ StringRefNull input_name(uint index) const;
/**
* Get the name of the output at the given index.
*/
- StringRefNull output_name(uint index);
+ StringRefNull output_name(uint index) const;
/**
* Utility to get a specific type extension for all inputs.
@@ -223,22 +223,22 @@ inline uint Function::output_amount() const
return m_output_names.size();
}
-inline Type *Function::input_type(uint index)
+inline Type *Function::input_type(uint index) const
{
return m_input_types[index];
}
-inline Type *Function::output_type(uint index)
+inline Type *Function::output_type(uint index) const
{
return m_output_types[index];
}
-inline StringRefNull Function::input_name(uint index)
+inline StringRefNull Function::input_name(uint index) const
{
return m_input_names[index].to_string_ref(m_strings);
}
-inline StringRefNull Function::output_name(uint index)
+inline StringRefNull Function::output_name(uint index) const
{
return m_output_names[index].to_string_ref(m_strings);
}
diff --git a/source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp b/source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp
index 16f0e5d21cc..d373ea9b153 100644
--- a/source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp
+++ b/source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp
@@ -18,7 +18,7 @@ class UnlinkedInputsInserter {
public:
virtual void insert(VTreeDataGraphBuilder &builder,
ArrayRef<VirtualSocket *> unlinked_inputs,
- ArrayRef<BuilderOutputSocket *> r_new_origins) = 0;
+ MutableArrayRef<BuilderOutputSocket *> r_new_origins) = 0;
};
ValueOrError<VTreeDataGraph> generate_graph(VirtualNodeTree &vtree);
diff --git a/source/blender/functions/frontends/data_flow_nodes/unlinked_input_groupers.cpp b/source/blender/functions/frontends/data_flow_nodes/unlinked_input_groupers.cpp
index 9055f347952..3fe53ffd6af 100644
--- a/source/blender/functions/frontends/data_flow_nodes/unlinked_input_groupers.cpp
+++ b/source/blender/functions/frontends/data_flow_nodes/unlinked_input_groupers.cpp
@@ -51,8 +51,8 @@ void AllInOneSocketInputs::group(VTreeDataGraphBuilder &builder,
static void update_hash_of_used_vsockets(VTreeDataGraphBuilder &builder,
VirtualSocket *vsocket,
uint random,
- ArrayRef<uint> hash_per_vsocket,
- ArrayRef<bool> was_updated_per_vsocket,
+ MutableArrayRef<uint> hash_per_vsocket,
+ MutableArrayRef<bool> was_updated_per_vsocket,
Vector<uint> &updated_vsockets)
{
hash_per_vsocket[vsocket->id()] ^= random;
diff --git a/source/blender/functions/frontends/data_flow_nodes/unlinked_input_inserters.cpp b/source/blender/functions/frontends/data_flow_nodes/unlinked_input_inserters.cpp
index 0a9f6dfdfe1..c63f80893b2 100644
--- a/source/blender/functions/frontends/data_flow_nodes/unlinked_input_inserters.cpp
+++ b/source/blender/functions/frontends/data_flow_nodes/unlinked_input_inserters.cpp
@@ -66,7 +66,7 @@ class SocketLoaderDependencies : public DepsBody {
void DynamicSocketLoader::insert(VTreeDataGraphBuilder &builder,
ArrayRef<VirtualSocket *> unlinked_inputs,
- ArrayRef<BuilderOutputSocket *> r_new_origins)
+ MutableArrayRef<BuilderOutputSocket *> r_new_origins)
{
auto &socket_loaders = MAPPING_socket_loaders();
@@ -155,7 +155,7 @@ class ConstantOutputGen : public LLVMBuildIRBody {
void ConstantInputsHandler::insert(VTreeDataGraphBuilder &builder,
ArrayRef<VirtualSocket *> unlinked_inputs,
- ArrayRef<BuilderOutputSocket *> r_new_origins)
+ MutableArrayRef<BuilderOutputSocket *> r_new_origins)
{
auto &socket_loaders = MAPPING_socket_loaders();
@@ -219,7 +219,7 @@ ReloadableInputs::~ReloadableInputs()
void ReloadableInputs::insert(VTreeDataGraphBuilder &builder,
ArrayRef<VirtualSocket *> unlinked_inputs,
- ArrayRef<BuilderOutputSocket *> r_new_origins)
+ MutableArrayRef<BuilderOutputSocket *> r_new_origins)
{
BLI_assert(m_tuple.get() == nullptr);
diff --git a/source/blender/functions/frontends/data_flow_nodes/unlinked_input_inserters.hpp b/source/blender/functions/frontends/data_flow_nodes/unlinked_input_inserters.hpp
index eadab8944fb..1186fa3a5c5 100644
--- a/source/blender/functions/frontends/data_flow_nodes/unlinked_input_inserters.hpp
+++ b/source/blender/functions/frontends/data_flow_nodes/unlinked_input_inserters.hpp
@@ -9,14 +9,14 @@ class DynamicSocketLoader : public UnlinkedInputsInserter {
public:
void insert(VTreeDataGraphBuilder &builder,
ArrayRef<VirtualSocket *> unlinked_inputs,
- ArrayRef<BuilderOutputSocket *> r_new_origins) override;
+ MutableArrayRef<BuilderOutputSocket *> r_new_origins) override;
};
class ConstantInputsHandler : public UnlinkedInputsInserter {
public:
void insert(VTreeDataGraphBuilder &builder,
ArrayRef<VirtualSocket *> unlinked_inputs,
- ArrayRef<BuilderOutputSocket *> r_new_origins) override;
+ MutableArrayRef<BuilderOutputSocket *> r_new_origins) override;
};
class ReloadableInputs : public UnlinkedInputsInserter {
@@ -36,7 +36,7 @@ class ReloadableInputs : public UnlinkedInputsInserter {
void insert(VTreeDataGraphBuilder &builder,
ArrayRef<VirtualSocket *> unlinked_inputs,
- ArrayRef<BuilderOutputSocket *> r_new_origins) override;
+ MutableArrayRef<BuilderOutputSocket *> r_new_origins) override;
void load();
};
diff --git a/source/blender/functions/functions/array_execution.cpp b/source/blender/functions/functions/array_execution.cpp
index 38eaab54102..2e11c4d2e48 100644
--- a/source/blender/functions/functions/array_execution.cpp
+++ b/source/blender/functions/functions/array_execution.cpp
@@ -33,7 +33,7 @@ class TupleCallArrayExecution : public ArrayExecution {
void call(ArrayRef<uint> indices,
ArrayRef<void *> input_buffers,
- ArrayRef<void *> output_buffers,
+ MutableArrayRef<void *> output_buffers,
ExecutionContext &execution_context) override
{
uint input_amount = m_function->input_amount();
@@ -69,8 +69,11 @@ std::unique_ptr<ArrayExecution> get_tuple_call_array_execution(SharedFunction fu
/* LLVM Array Execution
********************************************/
-typedef void(CompiledFunctionSignature)(
- uint size, uint *indices, void **input_buffers, void **output_buffers, void *context_ptr);
+typedef void(CompiledFunctionSignature)(uint size,
+ const uint *indices,
+ void *const *input_buffers,
+ void **output_buffers,
+ void *context_ptr);
class LLVMArrayExecution : public ArrayExecution {
private:
@@ -89,7 +92,7 @@ class LLVMArrayExecution : public ArrayExecution {
void call(ArrayRef<uint> indices,
ArrayRef<void *> input_buffers,
- ArrayRef<void *> output_buffers,
+ MutableArrayRef<void *> output_buffers,
ExecutionContext &execution_context) override
{
CompiledFunctionSignature *function = (CompiledFunctionSignature *)
diff --git a/source/blender/functions/functions/array_execution.hpp b/source/blender/functions/functions/array_execution.hpp
index 82511e34591..2a04d2b7aaf 100644
--- a/source/blender/functions/functions/array_execution.hpp
+++ b/source/blender/functions/functions/array_execution.hpp
@@ -19,7 +19,7 @@ class ArrayExecution {
virtual void call(ArrayRef<uint> indices,
ArrayRef<void *> input_buffers,
- ArrayRef<void *> output_buffers,
+ MutableArrayRef<void *> output_buffers,
ExecutionContext &execution_context) = 0;
};
diff --git a/source/blender/functions/functions/auto_vectorization.cpp b/source/blender/functions/functions/auto_vectorization.cpp
index c62142cfd20..4352639f275 100644
--- a/source/blender/functions/functions/auto_vectorization.cpp
+++ b/source/blender/functions/functions/auto_vectorization.cpp
@@ -212,7 +212,7 @@ class AutoVectorizationGen : public LLVMBuildIRBody {
CodeBuilder &else_builder = ifthenelse.else_builder();
/* Use default value when list has no elements. */
- SharedFunction &default_builder = m_empty_list_value_builders[list_input_index];
+ const SharedFunction &default_builder = m_empty_list_value_builders[list_input_index];
auto &default_builder_body = default_builder->body<LLVMBuildIRBody>();
Vector<llvm::Value *> default_builder_inputs(0);
Vector<llvm::Value *> default_builder_outputs(1);
diff --git a/source/blender/functions/functions/object_input.cpp b/source/blender/functions/functions/object_input.cpp
index aa81040c712..03018fd7623 100644
--- a/source/blender/functions/functions/object_input.cpp
+++ b/source/blender/functions/functions/object_input.cpp
@@ -61,7 +61,7 @@ class ObjectMeshVertices : public TupleCallBody {
auto vertices = SharedList::New(TYPE_float3);
vertices->reserve_and_set_size(mesh->totvert);
- ArrayRef<float3> vertices_ref = vertices->as_array_ref<float3>();
+ MutableArrayRef<float3> vertices_ref = vertices->as_array_ref<float3>();
float4x4 transform = object->obmat;
diff --git a/source/blender/simulations/bparticles/attributes.hpp b/source/blender/simulations/bparticles/attributes.hpp
index 3d5cc034d82..b11a2133141 100644
--- a/source/blender/simulations/bparticles/attributes.hpp
+++ b/source/blender/simulations/bparticles/attributes.hpp
@@ -16,6 +16,7 @@ namespace BParticles {
using BLI::ArrayRef;
using BLI::float2;
using BLI::float3;
+using BLI::MutableArrayRef;
using BLI::Optional;
using BLI::Range;
using BLI::rgba_b;
@@ -307,13 +308,13 @@ class AttributeArrays {
* Get access to the underlying attribute arrays.
* Asserts when the attribute does not exists.
*/
- template<typename T> ArrayRef<T> get(uint index) const
+ template<typename T> MutableArrayRef<T> get(uint index) const
{
BLI_assert(attribute_type_by_type<T>::value == m_info->type_of(index));
void *ptr = this->get_ptr(index);
- return ArrayRef<T>((T *)ptr, m_size);
+ return MutableArrayRef<T>((T *)ptr, m_size);
}
- template<typename T> ArrayRef<T> get(StringRef name)
+ template<typename T> MutableArrayRef<T> get(StringRef name)
{
uint index = this->attribute_index(name);
return this->get<T>(index);
@@ -323,7 +324,7 @@ class AttributeArrays {
* Get access to the arrays.
* Does not assert when the attribute does not exist.
*/
- template<typename T> Optional<ArrayRef<T>> try_get(StringRef name)
+ template<typename T> Optional<MutableArrayRef<T>> try_get(StringRef name)
{
int index = this->info().attribute_index_try(name, attribute_type_by_type<T>::value);
if (index == -1) {
diff --git a/source/blender/simulations/bparticles/c_wrapper.cpp b/source/blender/simulations/bparticles/c_wrapper.cpp
index df8f649b3ba..936cc35f431 100644
--- a/source/blender/simulations/bparticles/c_wrapper.cpp
+++ b/source/blender/simulations/bparticles/c_wrapper.cpp
@@ -131,7 +131,7 @@ static uint tetrahedon_loop_edges[12] = {0, 3, 1, 2, 4, 0, 1, 5, 2, 3, 5, 4};
static uint tetrahedon_edges[6][2] = {{0, 1}, {0, 2}, {0, 3}, {1, 2}, {1, 3}, {2, 3}};
static void distribute_tetrahedons_range(Mesh *mesh,
- ArrayRef<MLoopCol> loop_colors,
+ MutableArrayRef<MLoopCol> loop_colors,
Range<uint> range,
ArrayRef<float3> centers,
ArrayRef<float> scales,
@@ -183,7 +183,7 @@ static Mesh *distribute_tetrahedons(ArrayRef<float3> centers,
amount * ARRAY_SIZE(tetrahedon_loop_vertices),
amount * ARRAY_SIZE(tetrahedon_loop_starts));
- auto loop_colors = ArrayRef<MLoopCol>(
+ auto loop_colors = MutableArrayRef<MLoopCol>(
(MLoopCol *)CustomData_add_layer_named(
&mesh->ldata, CD_MLOOPCOL, CD_DEFAULT, nullptr, mesh->totloop, "Color"),
mesh->totloop);
diff --git a/source/blender/simulations/bparticles/force_interface.hpp b/source/blender/simulations/bparticles/force_interface.hpp
index 639f893460c..26d863a7cb6 100644
--- a/source/blender/simulations/bparticles/force_interface.hpp
+++ b/source/blender/simulations/bparticles/force_interface.hpp
@@ -6,15 +6,15 @@ namespace BParticles {
class ForceInterface : public BlockStepDataAccess {
private:
- ArrayRef<float3> m_destination;
+ MutableArrayRef<float3> m_destination;
public:
- ForceInterface(BlockStepData &step_data, ArrayRef<float3> destination)
+ ForceInterface(BlockStepData &step_data, MutableArrayRef<float3> destination)
: BlockStepDataAccess(step_data), m_destination(destination)
{
}
- ArrayRef<float3> combined_destination()
+ MutableArrayRef<float3> combined_destination()
{
return m_destination;
}
diff --git a/source/blender/simulations/bparticles/forces.cpp b/source/blender/simulations/bparticles/forces.cpp
index b2818a4e1f7..09afd175d82 100644
--- a/source/blender/simulations/bparticles/forces.cpp
+++ b/source/blender/simulations/bparticles/forces.cpp
@@ -11,7 +11,7 @@ Force::~Force()
void GravityForce::add_force(ForceInterface &interface)
{
ParticlesBlock &block = interface.block();
- ArrayRef<float3> destination = interface.combined_destination();
+ MutableArrayRef<float3> destination = interface.combined_destination();
auto inputs = m_compute_inputs->compute(interface);
@@ -24,7 +24,7 @@ void GravityForce::add_force(ForceInterface &interface)
void TurbulenceForce::add_force(ForceInterface &interface)
{
ParticlesBlock &block = interface.block();
- ArrayRef<float3> destination = interface.combined_destination();
+ MutableArrayRef<float3> destination = interface.combined_destination();
auto positions = block.attributes().get<float3>("Position");
@@ -43,7 +43,7 @@ void TurbulenceForce::add_force(ForceInterface &interface)
void PointForce::add_force(ForceInterface &interface)
{
ParticlesBlock &block = interface.block();
- ArrayRef<float3> destination = interface.combined_destination();
+ MutableArrayRef<float3> destination = interface.combined_destination();
auto inputs = m_compute_inputs->compute(interface);
diff --git a/source/blender/simulations/bparticles/integrator.cpp b/source/blender/simulations/bparticles/integrator.cpp
index 7a927523a24..c715dc2449e 100644
--- a/source/blender/simulations/bparticles/integrator.cpp
+++ b/source/blender/simulations/bparticles/integrator.cpp
@@ -63,7 +63,7 @@ void EulerIntegrator::integrate(IntegratorInterface &interface)
}
BLI_NOINLINE void EulerIntegrator::compute_combined_force(IntegratorInterface &interface,
- ArrayRef<float3> r_force)
+ MutableArrayRef<float3> r_force)
{
r_force.fill({0, 0, 0});
@@ -77,8 +77,8 @@ BLI_NOINLINE void EulerIntegrator::compute_combined_force(IntegratorInterface &i
BLI_NOINLINE void EulerIntegrator::compute_offsets(ArrayRef<float> durations,
ArrayRef<float3> last_velocities,
ArrayRef<float3> combined_force,
- ArrayRef<float3> r_position_offsets,
- ArrayRef<float3> r_velocity_offsets)
+ MutableArrayRef<float3> r_position_offsets,
+ MutableArrayRef<float3> r_velocity_offsets)
{
uint amount = durations.size();
for (uint pindex = 0; pindex < amount; pindex++) {
diff --git a/source/blender/simulations/bparticles/integrator.hpp b/source/blender/simulations/bparticles/integrator.hpp
index 5c6bb52467f..c58595b002f 100644
--- a/source/blender/simulations/bparticles/integrator.hpp
+++ b/source/blender/simulations/bparticles/integrator.hpp
@@ -28,13 +28,13 @@ class EulerIntegrator : public Integrator {
void integrate(IntegratorInterface &interface) override;
private:
- void compute_combined_force(IntegratorInterface &interface, ArrayRef<float3> r_force);
+ void compute_combined_force(IntegratorInterface &interface, MutableArrayRef<float3> r_force);
void compute_offsets(ArrayRef<float> durations,
ArrayRef<float3> last_velocities,
ArrayRef<float3> combined_force,
- ArrayRef<float3> r_position_offsets,
- ArrayRef<float3> r_velocity_offsets);
+ MutableArrayRef<float3> r_position_offsets,
+ MutableArrayRef<float3> r_velocity_offsets);
};
} // namespace BParticles
diff --git a/source/blender/simulations/bparticles/particle_allocator.cpp b/source/blender/simulations/bparticles/particle_allocator.cpp
index adc7237ddf7..46d01622d81 100644
--- a/source/blender/simulations/bparticles/particle_allocator.cpp
+++ b/source/blender/simulations/bparticles/particle_allocator.cpp
@@ -58,7 +58,7 @@ void ParticleAllocator::initialize_new_particles(ParticlesBlock &block, Range<ui
attributes.init_default(i);
}
- ArrayRef<int32_t> particle_ids = block.attributes_all().get<int32_t>("ID");
+ MutableArrayRef<int32_t> particle_ids = block.attributes_all().get<int32_t>("ID");
Range<uint> new_ids = block.container().new_particle_ids(pindices.size());
for (uint i = 0; i < pindices.size(); i++) {
uint pindex = pindices[i];
diff --git a/source/blender/simulations/bparticles/particle_function_builder.cpp b/source/blender/simulations/bparticles/particle_function_builder.cpp
index aae1de6e85c..1e61034f9b7 100644
--- a/source/blender/simulations/bparticles/particle_function_builder.cpp
+++ b/source/blender/simulations/bparticles/particle_function_builder.cpp
@@ -38,7 +38,7 @@ Vector<DataSocket> find_input_data_sockets(VirtualNode *vnode, VTreeDataGraph &d
static SetVector<VirtualSocket *> find_particle_dependencies(
VTreeDataGraph &data_graph,
ArrayRef<DataSocket> sockets,
- ArrayRef<bool> r_depends_on_particle_flags)
+ MutableArrayRef<bool> r_depends_on_particle_flags)
{
SetVector<VirtualSocket *> combined_dependencies;
@@ -89,7 +89,7 @@ class AgeInputProvider : public ParticleFunctionInputProvider {
{
auto birth_times = interface.particles().attributes().get<float>("Birth Time");
float *ages_buffer = (float *)BLI_temporary_allocate(sizeof(float) * birth_times.size());
- ArrayRef<float> ages(ages_buffer, birth_times.size());
+ MutableArrayRef<float> ages(ages_buffer, birth_times.size());
ParticleTimes &times = interface.particle_times();
if (times.type() == ParticleTimes::Type::Current) {
@@ -108,7 +108,7 @@ class AgeInputProvider : public ParticleFunctionInputProvider {
else {
BLI_assert(false);
}
- return {ages, true};
+ return {ArrayRef<float>(ages), true};
}
};
@@ -154,7 +154,7 @@ class SurfaceImageInputProvider : public ParticleFunctionInputProvider {
rgba_b *pixel_buffer = (rgba_b *)m_ibuf->rect;
rgba_f *colors_buffer = (rgba_f *)BLI_temporary_allocate(sizeof(rgba_f) * positions.size());
- ArrayRef<rgba_f> colors{colors_buffer, positions.size()};
+ MutableArrayRef<rgba_f> colors{colors_buffer, positions.size()};
for (uint pindex : interface.particles().pindices()) {
float3 position_world = positions[pindex];
@@ -185,7 +185,7 @@ class SurfaceImageInputProvider : public ParticleFunctionInputProvider {
uint y = uv.y * (m_ibuf->y - 1);
colors[pindex] = pixel_buffer[y * m_ibuf->x + x];
}
- return {colors, true};
+ return {ArrayRef<rgba_f>(colors), true};
}
};
@@ -220,7 +220,7 @@ static SharedFunction create_function__with_deps(
StringRef function_name,
ArrayRef<DataSocket> sockets_to_compute,
ArrayRef<VirtualSocket *> input_vsockets,
- ArrayRef<ParticleFunctionInputProvider *> r_input_providers)
+ MutableArrayRef<ParticleFunctionInputProvider *> r_input_providers)
{
uint input_amount = input_vsockets.size();
BLI_assert(input_amount == r_input_providers.size());
diff --git a/source/blender/simulations/bparticles/particle_set.hpp b/source/blender/simulations/bparticles/particle_set.hpp
index 24f9129546c..f4c84f93b0f 100644
--- a/source/blender/simulations/bparticles/particle_set.hpp
+++ b/source/blender/simulations/bparticles/particle_set.hpp
@@ -39,7 +39,7 @@ struct ParticleSet {
/**
* Number of particles in this set.
*/
- uint size();
+ uint size() const;
/**
* Returns true when pindices()[i] == i for all i, otherwise false.
@@ -137,7 +137,7 @@ inline ArrayRef<uint> ParticleSet::pindices()
return m_pindices;
}
-inline uint ParticleSet::size()
+inline uint ParticleSet::size() const
{
return m_pindices.size();
}
diff --git a/source/blender/simulations/bparticles/particles_container.cpp b/source/blender/simulations/bparticles/particles_container.cpp
index cdbc0240188..e411d020b26 100644
--- a/source/blender/simulations/bparticles/particles_container.cpp
+++ b/source/blender/simulations/bparticles/particles_container.cpp
@@ -202,7 +202,7 @@ void ParticlesBlock::MoveUntilFull(ParticlesBlock &from, ParticlesBlock &to)
to.active_amount() += move_amount;
}
-void ParticlesBlock::Compress(ArrayRef<ParticlesBlock *> blocks)
+void ParticlesBlock::Compress(MutableArrayRef<ParticlesBlock *> blocks)
{
std::sort(blocks.begin(), blocks.end(), [](ParticlesBlock *a, ParticlesBlock *b) {
return a->active_amount() < b->active_amount();
diff --git a/source/blender/simulations/bparticles/particles_container.hpp b/source/blender/simulations/bparticles/particles_container.hpp
index 41e5ae6f2e6..fa6b61e3226 100644
--- a/source/blender/simulations/bparticles/particles_container.hpp
+++ b/source/blender/simulations/bparticles/particles_container.hpp
@@ -197,7 +197,7 @@ class ParticlesBlock {
* Afterwards there will be at most on block the is not full and not empty. Empty blocks are not
* freed by this function.
*/
- static void Compress(ArrayRef<ParticlesBlock *> blocks);
+ static void Compress(MutableArrayRef<ParticlesBlock *> blocks);
};
/* Particles Container
diff --git a/source/blender/simulations/bparticles/simulate.cpp b/source/blender/simulations/bparticles/simulate.cpp
index 67d871f502a..2334ab79a31 100644
--- a/source/blender/simulations/bparticles/simulate.cpp
+++ b/source/blender/simulations/bparticles/simulate.cpp
@@ -26,12 +26,13 @@ static uint get_max_event_storage_size(ArrayRef<Event *> events)
return max_size;
}
-BLI_NOINLINE static void find_next_event_per_particle(BlockStepData &step_data,
- ArrayRef<uint> pindices,
- EventStorage &r_event_storage,
- ArrayRef<int> r_next_event_indices,
- ArrayRef<float> r_time_factors_to_next_event,
- TemporaryVector<uint> &r_pindices_with_event)
+BLI_NOINLINE static void find_next_event_per_particle(
+ BlockStepData &step_data,
+ ArrayRef<uint> pindices,
+ EventStorage &r_event_storage,
+ MutableArrayRef<int> r_next_event_indices,
+ MutableArrayRef<float> r_time_factors_to_next_event,
+ TemporaryVector<uint> &r_pindices_with_event)
{
r_next_event_indices.fill_indices(pindices, -1);
r_time_factors_to_next_event.fill_indices(pindices, 1.0f);
@@ -119,16 +120,17 @@ BLI_NOINLINE static void update_remaining_attribute_offsets(
BLI_NOINLINE static void update_remaining_durations(ArrayRef<uint> pindices_with_event,
ArrayRef<float> time_factors_to_next_event,
- ArrayRef<float> remaining_durations)
+ MutableArrayRef<float> remaining_durations)
{
for (uint pindex : pindices_with_event) {
remaining_durations[pindex] *= (1.0f - time_factors_to_next_event[pindex]);
}
}
-BLI_NOINLINE static void find_pindices_per_event(ArrayRef<uint> pindices_with_events,
- ArrayRef<int> next_event_indices,
- ArrayRef<Vector<uint>> r_particles_per_event)
+BLI_NOINLINE static void find_pindices_per_event(
+ ArrayRef<uint> pindices_with_events,
+ ArrayRef<int> next_event_indices,
+ MutableArrayRef<Vector<uint>> r_particles_per_event)
{
for (uint pindex : pindices_with_events) {
int event_index = next_event_indices[pindex];
@@ -140,7 +142,7 @@ BLI_NOINLINE static void find_pindices_per_event(ArrayRef<uint> pindices_with_ev
BLI_NOINLINE static void compute_current_time_per_particle(ArrayRef<uint> pindices_with_event,
ArrayRef<float> remaining_durations,
float end_time,
- ArrayRef<float> r_current_times)
+ MutableArrayRef<float> r_current_times)
{
for (uint pindex : pindices_with_event) {
r_current_times[pindex] = end_time - remaining_durations[pindex];
@@ -293,7 +295,7 @@ BLI_NOINLINE static void apply_remaining_offsets(BlockStepData &step_data, Array
auto handlers = step_data.particle_type.offset_handlers();
if (handlers.size() > 0) {
TemporaryArray<float> time_factors(step_data.array_size());
- ArrayRef<float>(time_factors).fill_indices(pindices, 1.0f);
+ time_factors.fill_indices(pindices, 1.0f);
OffsetHandlerInterface interface(step_data, pindices, time_factors);
for (OffsetHandler *handler : handlers) {
@@ -325,7 +327,7 @@ BLI_NOINLINE static void apply_remaining_offsets(BlockStepData &step_data, Array
BLI_NOINLINE static void simulate_block(ParticleAllocator &particle_allocator,
ParticlesBlock &block,
ParticleType &particle_type,
- ArrayRef<float> remaining_durations,
+ MutableArrayRef<float> remaining_durations,
float end_time)
{
uint amount = block.active_amount();
diff --git a/source/blender/simulations/bparticles/step_description_interfaces.hpp b/source/blender/simulations/bparticles/step_description_interfaces.hpp
index 0f8f0c9c008..b02e09ba0c1 100644
--- a/source/blender/simulations/bparticles/step_description_interfaces.hpp
+++ b/source/blender/simulations/bparticles/step_description_interfaces.hpp
@@ -12,7 +12,7 @@ struct BlockStepData {
ParticlesBlock &block;
ParticleType &particle_type;
AttributeArrays attribute_offsets;
- ArrayRef<float> remaining_durations;
+ MutableArrayRef<float> remaining_durations;
float step_end_time;
uint array_size()
@@ -60,7 +60,7 @@ class BlockStepDataAccess {
return m_step_data.attribute_offsets;
}
- ArrayRef<float> remaining_durations()
+ MutableArrayRef<float> remaining_durations()
{
return m_step_data.remaining_durations;
}