26template<
typename Func>
40 using T =
typename decltype(type_tag)::type;
41 if constexpr (std::is_same_v<T, void>) {
51template<
typename Func>
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));
86template<>
inline float mix2(
const float factor,
const float &a,
const float &
b)
88 return (1.0f - factor) * a + factor *
b;
121template<
typename T> T
mix3(
const float3 &weights,
const T &v0,
const T &v1,
const T &
v2);
126 return int8_t(std::round(weights.x * v0 + weights.y * v1 + weights.z *
v2));
129template<>
inline bool mix3(
const float3 &weights,
const bool &v0,
const bool &v1,
const bool &
v2)
131 return (weights.x * v0 + weights.y * v1 + weights.z *
v2) >= 0.5f;
134template<>
inline int mix3(
const float3 &weights,
const int &v0,
const int &v1,
const int &
v2)
136 return int(std::round(weights.x * v0 + weights.y * v1 + weights.z *
v2));
145inline float mix3(
const float3 &weights,
const float &v0,
const float &v1,
const float &
v2)
147 return weights.x * v0 + weights.y * v1 + weights.z *
v2;
153 return weights.x * v0 + weights.y * v1 + weights.z *
v2;
159 return weights.x * v0 + weights.y * v1 + weights.z *
v2;
182 const float4 mixed = v0_f * weights[0] + v1_f * weights[1] + v2_f * weights[2];
195T
mix4(
const float4 &weights,
const T &v0,
const T &v1,
const T &
v2,
const T &v3);
201 return int8_t(std::round(weights.x * v0 + weights.y * v1 + weights.z *
v2 + weights.w * v3));
206 const float4 &weights,
const bool &v0,
const bool &v1,
const bool &
v2,
const bool &v3)
208 return (weights.x * v0 + weights.y * v1 + weights.z *
v2 + weights.w * v3) >= 0.5f;
212inline int mix4(
const float4 &weights,
const int &v0,
const int &v1,
const int &
v2,
const int &v3)
214 return int(std::round(weights.x * v0 + weights.y * v1 + weights.z *
v2 + weights.w * v3));
227 const float4 &weights,
const float &v0,
const float &v1,
const float &
v2,
const float &v3)
229 return weights.x * v0 + weights.y * v1 + weights.z *
v2 + weights.w * v3;
236 return weights.x * v0 + weights.y * v1 + weights.z *
v2 + weights.w * v3;
243 return weights.x * v0 + weights.y * v1 + weights.z *
v2 + weights.w * v3;
297 :
SimpleMixer(buffer, buffer.index_range(), default_value)
305 : buffer_(buffer), default_value_(default_value), total_weights_(buffer.size(), 0.0f)
308 mask.foreach_index([&](
const int64_t i) { buffer_[i] = default_value_; });
314 void set(
const int64_t index,
const T &value,
const float weight = 1.0f)
316 buffer_[index] = value * weight;
317 total_weights_[index] = weight;
325 buffer_[index] += value * weight;
326 total_weights_[index] += weight;
339 mask.foreach_index([&](
const int64_t i) {
340 const float weight = total_weights_[i];
342 buffer_[i] *= 1.0f / weight;
345 buffer_[i] = default_value_;
377 mask.foreach_index([&](
const int64_t i) { buffer_[i] =
false; });
383 void set(
const int64_t index,
const bool value, [[maybe_unused]]
const float weight = 1.0f)
385 buffer_[index] = value;
391 void mix_in(
const int64_t index,
const bool value, [[maybe_unused]]
const float weight = 1.0f)
393 buffer_[index] |= value;
409 typename AccumulationT,
410 AccumulationT (*ValueToAccumulate)(
const T &value),
411 T (*AccumulateToValue)(
const AccumulationT &value)>
416 AccumulationT value = AccumulationT(0);
435 T default_value = {})
436 : buffer_(buffer), default_value_(default_value), accumulation_buffer_(buffer.size())
438 mask.foreach_index([&](
const int64_t index) { buffer_[index] = default_value_; });
441 void set(
const int64_t index,
const T &value,
const float weight = 1.0f)
443 const AccumulationT converted_value = ValueToAccumulate(value);
444 Item &item = accumulation_buffer_[index];
445 item.value = converted_value * weight;
446 item.weight = weight;
451 const AccumulationT converted_value = ValueToAccumulate(value);
452 Item &item = accumulation_buffer_[index];
453 item.value += converted_value * weight;
454 item.weight += weight;
464 mask.foreach_index([&](
const int64_t i) {
465 const Item &item = accumulation_buffer_[i];
466 if (item.weight > 0.0f) {
467 const float weight_inv = 1.0f / item.weight;
468 const T converted_value = AccumulateToValue(item.value * weight_inv);
469 buffer_[i] = converted_value;
472 buffer_[i] = default_value_;
536 void mix_in(
int64_t index,
const float4x4 &value,
float weight = 1.0f);
572 return int(std::round(value));
594 return value ? 1.0f : 0.0f;
598 return value >= 0.5f;
612 return int8_t(std::round(value));
620 return value.expmap();
#define BLI_assert_unreachable()
#define BLI_STATIC_ASSERT(a, msg)
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])
void interp_v4_v4v4v4(float p[4], const float v1[4], const float v2[4], const float v3[4], const float w[3])
typedef double(DMatrix)[4][4]
ATTR_WARN_UNUSED_RESULT const BMVert * v2
void to_static_type_tag(const Fn &fn) 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)
void set(int64_t index, const ColorGeometry4b &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 set(int64_t index, const float4x4 &value, float weight=1.0f)
local_group_size(16, 16) .push_constant(Type b
node_ attributes set("label", ss.str())
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
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)
void convert_to_static_type(const CPPType &cpp_type, const Func &func)
T mix3(const float3 &weights, const T &v0, const T &v1, const T &v2)
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)
typename DefaultPropagationMixerStruct< T >::type DefaultPropagationMixer
T mix2(float factor, const T &a, const T &b)
const CPPType * custom_data_type_to_cpp_type(eCustomDataType type)
QuaternionBase< float > Quaternion
T interpolate(const T &a, const T &b, const FactorT &t)
VecBase< double, 2 > double2
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
VecBase< float, 3 > float3
ColorSceneLinearByteEncoded4b< eAlpha::Premultiplied > ColorGeometry4b
static float bool_to_float(const bool &value)
static bool float_to_bool(const float &value)
static int2 double_to_int(const double2 &value)
static double2 int_to_double(const int2 &value)
static int8_t float_to_int8_t(const float &value)
static float int8_t_to_float(const int8_t &value)
static double int_to_double(const int &value)
static int double_to_int(const double &value)
static float3 quat_to_expmap(const math::Quaternion &value)
static math::Quaternion expmap_to_quat(const float3 &value)
typename DefaultMixerStruct< T >::type type
VecBase< T, 3 > expmap() const