// It thing for smooth node
// in_ is VArray of input field
Array<bool> access_mask(in_.size(), false);
Array<T> swap_buffer_a(is_.size());
Array<T> swap_buffer_b(is_.size());
bool swap_flag = true;
VArray field_access = blender::VArray<T>::ForFunc(in_.size(),
[access_mask, swap_buffer_a, swap_buffer_b, swap_flag, in_](const int index){
if (access_mask[index]){
swap_buffer_a[index] = in[in_]; // Mean that the entire buffer will be filled on the first loop
access_mask[index] = true;
return swap_buffer_a[index]; // I will be read/write A and B buffer after i write one of this
}else{
if (swap_flag) {
return swap_buffer_a[index];
}else{
return swap_buffer_b[index];
}
}
});
...
// And so... i can just return this like VArray as final field?
if (swap_flag) { // for no make finalaze of all elements by myself
return blender::VArray<T>::ForFunc(in_.size(),
[access_mask, swap_buffer_a, in_](const int index){
if (access_mask[index]){
return swap_buffer_a[index];
}else{
return in_[index];
}
});
}else{
return blender::VArray<T>::ForFunc(in_.size(),
[access_mask, swap_buffer_b, in_](const int index){
if (access_mask[index]){
return swap_buffer_b[index];
}else{
return in_[index];
}
});
}