Blender
V3.3
|
Go to the source code of this file.
Namespaces | |
blender | |
blender::detail | |
blender::varray_tag | |
Variables | |
template<typename T > | |
constexpr bool | blender::is_trivial_extended_v< VArrayImpl_For_Span_final< T > > = true |
template<typename T > | |
constexpr bool | blender::is_trivial_extended_v< VArrayImpl_For_Single< T > > = is_trivial_extended_v<T> |
template<typename StructT , typename ElemT , ElemT(*)(const StructT &) GetFunc, void(*)(StructT &, ElemT) SetFunc> | |
constexpr bool | blender::is_trivial_extended_v< VArrayImpl_For_DerivedSpan< StructT, ElemT, GetFunc, SetFunc > > = true |
template<typename T > | |
static constexpr bool | blender::is_VArray_v = false |
template<typename T > | |
static constexpr bool | blender::is_VArray_v< VArray< T > > = true |
template<typename T > | |
static constexpr bool | blender::is_VMutableArray_v = false |
template<typename T > | |
static constexpr bool | blender::is_VMutableArray_v< VMutableArray< T > > = true |
A virtual array is a data structure that behaves similar to an array, but its elements are accessed through virtual methods. This improves the decoupling of a function from its callers, because it does not have to know exactly how the data is laid out in memory, or if it is stored in memory at all. It could just as well be computed on the fly.
Taking a virtual array as parameter instead of a more specific non-virtual type has some tradeoffs. Access to individual elements of the individual elements is higher due to function call overhead. On the other hand, potential callers don't have to convert the data into the specific format required for the function. This can be a costly conversion if only few of the elements are accessed in the end.
Functions taking a virtual array as input can still optimize for different data layouts. For example, they can check if the array is stored as an array internally or if it is the same element for all indices. Whether it is worth to optimize for different data layouts in a function has to be decided on a case by case basis. One should always do some benchmarking to see of the increased compile time and binary size is worth it.
Definition in file BLI_virtual_array.hh.