49 float4x4>([&]<
typename T>() {
fn.template operator()<
T>(); });
64template<
typename T>
T mix2(
float factor,
const T &a,
const T &
b);
66template<>
inline bool mix2(
const float factor,
const bool &a,
const bool &
b)
68 return ((1.0f - factor) * a + factor *
b) >= 0.5f;
73 return int8_t(std::round((1.0f - factor) * a + factor *
b));
76template<>
inline int mix2(
const float factor,
const int &a,
const int &
b)
78 return int(std::round((1.0f - factor) * a + factor *
b));
91template<>
inline float mix2(
const float factor,
const float &a,
const float &
b)
93 return (1.0f - factor) * a + factor *
b;
136 return int8_t(std::round(weights.x * v0 + weights.y * v1 + weights.z *
v2));
139template<>
inline bool mix3(
const float3 &weights,
const bool &v0,
const bool &v1,
const bool &
v2)
141 return (weights.x * v0 + weights.y * v1 + weights.z *
v2) >= 0.5f;
144template<>
inline int mix3(
const float3 &weights,
const int &v0,
const int &v1,
const int &
v2)
146 return int(std::round(weights.x * v0 + weights.y * v1 + weights.z *
v2));
161inline float mix3(
const float3 &weights,
const float &v0,
const float &v1,
const float &
v2)
163 return weights.x * v0 + weights.y * v1 + weights.z *
v2;
169 return weights.x * v0 + weights.y * v1 + weights.z *
v2;
175 return weights.x * v0 + weights.y * v1 + weights.z *
v2;
181 return weights.x * v0 + weights.y * v1 + weights.z *
v2;
204 const float4 mixed = v0_f * weights[0] + v1_f * weights[1] + v2_f * weights[2];
223 return int8_t(std::round(weights.x * v0 + weights.y * v1 + weights.z *
v2 + weights.w * v3));
228 const float4 &weights,
const bool &v0,
const bool &v1,
const bool &
v2,
const bool &v3)
230 return (weights.x * v0 + weights.y * v1 + weights.z *
v2 + weights.w * v3) >= 0.5f;
234inline int mix4(
const float4 &weights,
const int &v0,
const int &v1,
const int &
v2,
const int &v3)
236 return int(std::round(weights.x * v0 + weights.y * v1 + weights.z *
v2 + weights.w * v3));
257 const float4 &weights,
const float &v0,
const float &v1,
const float &
v2,
const float &v3)
259 return weights.x * v0 + weights.y * v1 + weights.z *
v2 + weights.w * v3;
266 return weights.x * v0 + weights.y * v1 + weights.z *
v2 + weights.w * v3;
273 return weights.x * v0 + weights.y * v1 + weights.z *
v2 + weights.w * v3;
280 return weights.x * v0 + weights.y * v1 + weights.z *
v2 + weights.w * v3;
326 return double(value);
330 return int(std::round(value));
348 return int8_t(std::round(value));
371 return float4(value.
r, value.
g, value.
b, value.
a);
384 for (
const int i : indices) {
385 accum += src[i] * weight;
390template<
typename T,
typename ToAccumFn,
typename ToFinalFn>
393 const ToAccumFn &to_accum_fn,
394 const ToFinalFn &to_final_fn)
396 using AccumT = std::invoke_result_t<ToAccumFn, T>;
397 static_assert(std::is_same_v<std::invoke_result_t<ToFinalFn, AccumT>,
T>);
400 for (
const int i : indices) {
401 accum += to_accum_fn(src[i]) * weight;
403 return to_final_fn(accum);
408 return std::ranges::any_of(indices, [&](
const int i) {
return src[i]; });
452 float weight_accum = 0.0f;
454 accum += src[indices[i]] * weights[i];
455 weight_accum += weights[i];
460template<
typename T,
typename ToAccumFn,
typename ToFinalFn>
464 const ToAccumFn &to_accum_fn,
465 const ToFinalFn &to_final_fn)
467 using AccumT = std::invoke_result_t<ToAccumFn, T>;
468 static_assert(std::is_same_v<std::invoke_result_t<ToFinalFn, AccumT>,
T>);
470 float weight_accum = 0.0f;
472 accum += to_accum_fn(src[indices[i]]) * weights[i];
473 weight_accum += weights[i];
481 if (src[indices[i]] && weights[i] > 0.0f) {
548 :
SimpleMixer(buffer, buffer.index_range(), default_value)
556 : buffer_(buffer), default_value_(default_value), total_weights_(buffer.size(), 0.0f)
567 buffer_[
index] = value * weight;
568 total_weights_[
index] = weight;
576 buffer_[
index] += value * weight;
577 total_weights_[
index] += weight;
592 const float weight = total_weights_[i];
594 buffer_[i] *= 1.0f / weight;
597 buffer_[i] = default_value_;
635 void set(
const int64_t index,
const bool value, [[maybe_unused]]
const float weight = 1.0f)
637 buffer_[
index] = value;
645 buffer_[
index] |= value;
661 typename AccumulationT,
662 AccumulationT (*ValueToAccumulate)(
const T &value),
663 T (*AccumulateToValue)(
const AccumulationT &value)>
668 AccumulationT value = AccumulationT(0);
687 T default_value = {})
688 : buffer_(buffer), default_value_(default_value), accumulation_buffer_(buffer.size())
695 const AccumulationT converted_value = ValueToAccumulate(value);
696 Item &item = accumulation_buffer_[
index];
697 item.value = converted_value * weight;
698 item.weight = weight;
703 const AccumulationT converted_value = ValueToAccumulate(value);
704 Item &item = accumulation_buffer_[
index];
705 item.value += converted_value * weight;
706 item.weight += weight;
711 this->
finalize(buffer_.index_range());
718 const Item &item = accumulation_buffer_[i];
719 if (item.weight > 0.0f) {
720 const float weight_inv = 1.0f / item.weight;
721 const T converted_value = AccumulateToValue(item.value * weight_inv);
722 buffer_[i] = converted_value;
725 buffer_[i] = default_value_;
844 return value ? 1.0f : 0.0f;
848 return value >= 0.5f;
910 mix_groups(src, groups, all_indices, std::nullopt, dst);
#define PRF_scope_with_name(ui_name, category)
void to_static_type(Fn &&fn) const
Span< NewT > constexpr cast() const
constexpr int64_t size() const
constexpr IndexRange index_range() const
BooleanPropagationMixer(MutableSpan< bool > buffer)
void finalize(const IndexMask &)
BooleanPropagationMixer(MutableSpan< bool > buffer, const IndexMask &mask)
void set(const int64_t index, const bool value, const float weight=1.0f)
void mix_in(const int64_t index, const bool value, const float weight=1.0f)
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 set(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)
SimpleMixerWithAccumulationType(MutableSpan< T > buffer, const IndexMask &mask, T default_value={})
void mix_in(const int64_t index, const T &value, const float weight=1.0f)
void finalize(const IndexMask &mask)
SimpleMixerWithAccumulationType(MutableSpan< T > buffer, T default_value={})
void set(const int64_t index, const T &value, const float weight=1.0f)
SimpleMixer(MutableSpan< T > buffer, const IndexMask &mask, T default_value={})
void finalize(const IndexMask &mask)
void mix_in(const int64_t index, const T &value, const float weight=1.0f)
void set(const int64_t index, const T &value, const float weight=1.0f)
SimpleMixer(MutableSpan< T > buffer, T default_value={})
void mix_in(int64_t index, const float4x4 &value, float weight=1.0f)
void set(int64_t index, const float4x4 &value, float weight=1.0f)
float4x4Mixer(MutableSpan< float4x4 > buffer)
static short2 float2_to_short2(const float2 &value)
static int8_t float_to_int8_t(const float &value)
static int double_to_int(const double &value)
static float int8_t_to_float(const int8_t &value)
static float3 quat_to_expmap(const math::Quaternion &value)
static int2 double2_to_int2(const double2 &value)
static double int_to_double(const int &value)
static float4 byte_color_to_float4(const ColorGeometry4b &value)
static math::Quaternion expmap_to_quat(const float3 &value)
static float2 short2_to_float2(const short2 &value)
static ColorGeometry4b float4_to_byte_color(const float4 &value)
static double2 int2_to_double2(const int2 &value)
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)
typename DefaultMixerStruct< T >::type DefaultMixer
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)
typename DefaultPropagationMixerStruct< T >::type DefaultPropagationMixer
void to_static_type(const CPPType &cpp_type, Fn &&fn)
T mix2(float factor, const T &a, const T &b)
const CPPType & attribute_type_to_cpp_type(AttrType type)
void masked_fill(MutableSpan< T > data, const T &value, const IndexMask &mask)
QuaternionBase< float > Quaternion
T interpolate(const T &a, const T &b, const FactorT &t)
BLI_STATIC_ASSERT(ARRAY_SIZE(data_mode_strings)==CTX_MODE_NUM+1, "Must have a string for each context mode") const char *CTX_data_mode_string(const bContext *C)
void interp_v4_v4v4v4(float p[4], const float v1[4], const float v2[4], const float v3[4], const float w[3])
VecBase< double, 2 > double2
MatBase< float, 4, 4 > float4x4
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
BMesh const char void * data
ATTR_WARN_UNUSED_RESULT const BMVert * v2
VecBase< int16_t, 2 > short2
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
VecBase< float, 3 > float3
void interp_v4_v4v4v4v4(float p[4], const float v1[4], const float v2[4], const float v3[4], const float v4[4], const float w[4])
ColorSceneLinearByteEncoded4b< eAlpha::Premultiplied > ColorGeometry4b
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
ColorGeometry4bMixer type
ColorGeometry4fMixer type
static float bool_to_float(const bool &value)
static bool float_to_bool(const float &value)
SimpleMixerWithAccumulationType< bool, float, bool_to_float, float_to_bool > type
SimpleMixer< float2 > type
SimpleMixer< float3 > type
SimpleMixer< float4 > type
SimpleMixer< float > type
SimpleMixerWithAccumulationType< int2, double2, detail::int2_to_double2, detail::double2_to_int2 > type
SimpleMixerWithAccumulationType< int8_t, float, detail::int8_t_to_float, detail::float_to_int8_t > type
SimpleMixerWithAccumulationType< int, double, detail::int_to_double, detail::double_to_int > type
SimpleMixerWithAccumulationType< math::Quaternion, float3, detail::quat_to_expmap, detail::expmap_to_quat > type
SimpleMixerWithAccumulationType< short2, float2, detail::short2_to_float2, detail::float2_to_short2 > type
BooleanPropagationMixer type
typename DefaultMixerStruct< T >::type type
VecBase< float, 3 > expmap() const
static QuaternionBase expmap(const VecBase< T, 3 > &expmap)
OffsetIndices< int > offsets