95 : buffer_(buffer), default_color_(default_color), total_weights_(buffer.size(), 0.0f)
109 total_weights_[
index] = weight;
117 output_color.
r +=
color.r * weight;
118 output_color.
g +=
color.g * weight;
119 output_color.
b +=
color.b * weight;
120 output_color.
a +=
color.a * weight;
121 total_weights_[
index] += weight;
126 this->
finalize(buffer_.index_range());
132 const float weight = total_weights_[i];
135 const float weight_inv = 1.0f / weight;
136 output_color.
r *= weight_inv;
137 output_color.
g *= weight_inv;
138 output_color.
b *= weight_inv;
139 output_color.
a *= weight_inv;
142 output_color = default_color_;
157 default_color_(default_color),
158 total_weights_(buffer.size(), 0.0f),
159 accumulation_buffer_(buffer.size(),
float4(0, 0, 0, 0))
165void ColorGeometry4bMixer::ColorGeometry4bMixer::set(
int64_t index,
169 accumulation_buffer_[
index][0] =
color.r * weight;
170 accumulation_buffer_[
index][1] =
color.g * weight;
171 accumulation_buffer_[
index][2] =
color.b * weight;
172 accumulation_buffer_[
index][3] =
color.a * weight;
173 total_weights_[
index] = weight;
179 accum_value[0] +=
color.r * weight;
180 accum_value[1] +=
color.g * weight;
181 accum_value[2] +=
color.b * weight;
182 accum_value[3] +=
color.a * weight;
183 total_weights_[
index] += weight;
188 this->
finalize(buffer_.index_range());
195 const float weight = total_weights_[i];
196 const float4 &accum_value = accumulation_buffer_[i];
199 const float weight_inv = 1.0f / weight;
200 output_color.
r = accum_value[0] * weight_inv;
201 output_color.
g = accum_value[1] * weight_inv;
202 output_color.
b = accum_value[2] * weight_inv;
203 output_color.
a = accum_value[3] * weight_inv;
206 output_color = default_color_;
218 total_weights_(buffer.size(), 0.0f),
219 location_buffer_(buffer.size(),
float3(0)),
220 expmap_buffer_(buffer.size(),
float3(0)),
221 scale_buffer_(buffer.size(),
float3(0))
230 total_weights_[
index] = weight;
240 location_buffer_[
index] += location * weight;
241 expmap_buffer_[
index] += rotation.expmap() * weight;
243 total_weights_[
index] += weight;
248 this->
finalize(buffer_.index_range());
255 const float weight = total_weights_[i];
257 const float weight_inv =
math::rcp(weight);
259 location_buffer_[i] * weight_inv,
261 scale_buffer_[i] * weight_inv);
274 for (
const int i : indices) {
279 location_accum += location;
280 expmap_accum += rotation.expmap();
281 scale_accum +=
scale;
287 scale_accum * weight_inv);
298 dst_mask.
foreach_index([&](
const int dst_i,
const int group_i) {
308 float total_weight = 0.0f;
310 const float weight = weights[i];
315 location_accum += location * weight;
316 expmap_accum += rotation.expmap() * weight;
317 scale_accum +=
scale * weight;
318 total_weight += weight;
324 scale_accum * weight_inv);
336 dst_mask.
foreach_index([&](
const int dst_i,
const int group_i) {
338 src, all_indices.
slice(groups[group_i]), all_weights.
slice(groups[group_i]));
364 if constexpr (!std::is_same_v<T, std::string>) {
365 threading::parallel_for(
366 groups.index_range(),
368 [&](const IndexRange range) {
369 const IndexMask dst_mask_slice = dst_mask.slice(range);
371 mix_groups(src.typed<T>(),
379 mix_groups(src.typed<T>(),
386 threading::accumulated_task_sizes(
387 [&](const IndexRange range) { return groups[range].size(); }));
395 if (
ELEM(src_begin, dst_begin, src_end)) {
398 std::move(
data.data() + src_begin,
data.data() + src_end,
data.data() + dst_begin);
404 shift_left(data.typed<T>(), src_begin, src_end, dst_begin);
410 if (
ELEM(src_end, dst_end, src_begin)) {
413 std::move_backward(
data.data() + src_begin,
data.data() + src_end,
data.data() + dst_end);
419 shift_right(data.typed<T>(), src_begin, src_end, dst_begin);
441 array_utils::gather(src.typed<T>(), map, dst_mask, dst.typed<T>());
452 array_utils::gather_group_to_group(
453 src_offsets, dst_offsets, selection, src.typed<T>(), dst.typed<T>());
463 Span<T> src_span = src.typed<T>();
464 MutableSpan<T> dst_span = dst.typed<T>();
466 threading::parallel_for(src_ranges.index_range(), 512, [&](const IndexRange range) {
467 for (const int i : range) {
468 dst_span.slice(dst_offsets[i]).copy_from(src_span.slice(src_ranges[i]));
480 array_utils::gather_to_groups(dst_offsets, src_selection, src.typed<T>(), dst.typed<T>());
#define PRF_scope_with_name(ui_name, category)
const CPPType & type() const
const CPPType & type() const
static GVArray from_span(GSpan span)
constexpr IndexRange()=default
constexpr Span slice(int64_t start, int64_t size) const
constexpr int64_t size() const
constexpr IndexRange index_range() const
ColorGeometry4bMixer(MutableSpan< ColorGeometry4b > buffer, ColorGeometry4b default_color=ColorGeometry4b(0, 0, 0, 255))
void mix_in(int64_t index, const ColorGeometry4b &color, float weight=1.0f)
void mix_in(int64_t index, const ColorGeometry4f &color, float weight=1.0f)
ColorGeometry4fMixer(MutableSpan< ColorGeometry4f > buffer, ColorGeometry4f default_color=ColorGeometry4f(0.0f, 0.0f, 0.0f, 1.0f))
void set(int64_t index, const ColorGeometry4f &color, float weight=1.0f)
void mix_in(int64_t index, const float4x4 &value, float weight=1.0f)
float4x4Mixer(MutableSpan< float4x4 > buffer)
void foreach_index(Fn &&fn, Mode mode=exec_mode::serial) const
float3x3 scale(float3x3 mat, float2 scale)
T mix_indices(const Span< T > src, const Span< int > indices)
void gather(GSpan src, Span< int > map, GMutableSpan dst)
void gather_to_groups(OffsetIndices< int > dst_offsets, const IndexMask &src_selection, GSpan src, GMutableSpan dst)
T mix3(const float3 &weights, const T &v0, const T &v1, const T &v2)
void gather_ranges_to_groups(Span< IndexRange > src_ranges, OffsetIndices< int > dst_offsets, GSpan src, GMutableSpan dst)
void shift_right(GMutableSpan data, int src_begin, int src_end, int dst_begin)
T mix4(const float4 &weights, const T &v0, const T &v1, const T &v2, const T &v3)
void gather_group_to_group(OffsetIndices< int > src_offsets, OffsetIndices< int > dst_offsets, const IndexMask &selection, GSpan src, GMutableSpan dst)
void shift_left(GMutableSpan data, int src_begin, int src_end, int dst_begin)
void mix_groups(GSpan src, OffsetIndices< int > groups, Span< int > all_indices, std::optional< Span< float > > all_weights, GMutableSpan dst)
void to_static_type(const CPPType &cpp_type, Fn &&fn)
T mix2(float factor, const T &a, const T &b)
void masked_fill(MutableSpan< T > data, const T &value, const IndexMask &mask)
QuaternionBase< float > Quaternion
QuaternionBase< T > to_quaternion(const AxisAngleBase< T, AngleT > &axis_angle)
T interpolate(const T &a, const T &b, const FactorT &t)
QuaternionBase< T > normalized_to_quaternion_safe(const MatBase< T, 3, 3 > &mat)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
VecBase< T, 3 > to_scale(const MatBase< T, NumCol, NumRow > &mat)
void to_loc_rot_scale_safe(const MatBase< T, 4, 4 > &mat, VecBase< T, 3 > &r_location, RotationT &r_rotation, VecBase< T, 3 > &r_scale)
MatT from_loc_rot_scale(const typename MatT::loc_type &location, const RotationT &rotation, const VecBase< typename MatT::base_type, ScaleDim > &scale)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
MatBase< float, 4, 4 > float4x4
VecBase< float, 4 > float4
BMesh const char void * data
MatBase< float, 3, 3 > float3x3
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
VecBase< float, 3 > float3
ColorSceneLinearByteEncoded4b< eAlpha::Premultiplied > ColorGeometry4b
static MatBase identity()
VecBase< float, 3 > expmap() const
static QuaternionBase expmap(const VecBase< T, 3 > &expmap)