87 : buffer_(buffer), default_color_(default_color), total_weights_(buffer.size(), 0.0f)
90 mask.foreach_index([&](
const int64_t i) { buffer_[i] = zero; });
97 buffer_[index].r = color.r * weight;
98 buffer_[index].g = color.g * weight;
99 buffer_[index].b = color.b * weight;
100 buffer_[index].a = color.a * weight;
101 total_weights_[index] = weight;
109 output_color.
r += color.r * weight;
110 output_color.
g += color.g * weight;
111 output_color.
b += color.b * weight;
112 output_color.
a += color.a * weight;
113 total_weights_[index] += weight;
118 this->
finalize(buffer_.index_range());
123 mask.foreach_index([&](
const int64_t i) {
124 const float weight = total_weights_[i];
127 const float weight_inv = 1.0f / weight;
128 output_color.
r *= weight_inv;
129 output_color.
g *= weight_inv;
130 output_color.
b *= weight_inv;
131 output_color.
a *= weight_inv;
134 output_color = default_color_;
149 default_color_(default_color),
150 total_weights_(buffer.size(), 0.0f),
151 accumulation_buffer_(buffer.size(),
float4(0, 0, 0, 0))
154 mask.foreach_index([&](
const int64_t i) { buffer_[i] = zero; });
157void ColorGeometry4bMixer::ColorGeometry4bMixer::set(
int64_t index,
161 accumulation_buffer_[index][0] = color.
r * weight;
162 accumulation_buffer_[index][1] = color.g * weight;
163 accumulation_buffer_[index][2] = color.b * weight;
164 accumulation_buffer_[index][3] = color.a * weight;
165 total_weights_[index] = weight;
170 float4 &accum_value = accumulation_buffer_[index];
171 accum_value[0] += color.r * weight;
172 accum_value[1] += color.g * weight;
173 accum_value[2] += color.
b * weight;
174 accum_value[3] += color.a * weight;
175 total_weights_[index] += weight;
180 this->
finalize(buffer_.index_range());
185 mask.foreach_index([&](
const int64_t i) {
186 const float weight = total_weights_[i];
187 const float4 &accum_value = accumulation_buffer_[i];
190 const float weight_inv = 1.0f / weight;
191 output_color.
r = accum_value[0] * weight_inv;
192 output_color.
g = accum_value[1] * weight_inv;
193 output_color.
b = accum_value[2] * weight_inv;
194 output_color.
a = accum_value[3] * weight_inv;
197 output_color = default_color_;
209 total_weights_(buffer.size(), 0.0f),
210 location_buffer_(buffer.size(),
float3(0)),
211 expmap_buffer_(buffer.size(),
float3(0)),
212 scale_buffer_(buffer.size(),
float3(0))
216void float4x4Mixer::float4x4Mixer::set(
int64_t index,
const float4x4 &value,
const float weight)
218 location_buffer_[index] = value.location() * weight;
221 total_weights_[index] = weight;
226 location_buffer_[index] += value.location() * weight;
229 total_weights_[index] += weight;
234 this->
finalize(buffer_.index_range());
239 mask.foreach_index([&](
const int64_t i) {
240 const float weight = total_weights_[i];
242 const float weight_inv =
math::rcp(weight);
244 location_buffer_[i] * weight_inv,
246 scale_buffer_[i] * weight_inv);
257 using T = decltype(dummy);
258 array_utils::gather(src.typed<T>(), map, dst.typed<T>());
265 using T = decltype(dummy);
266 array_utils::gather(src.typed<T>(), map, dst.typed<T>());
277 using T = decltype(dummy);
278 array_utils::gather_group_to_group(
279 src_offsets, dst_offsets, selection, src.typed<T>(), dst.typed<T>());
289 using T = decltype(dummy);
290 array_utils::gather_to_groups(dst_offsets, src_selection, src.typed<T>(), dst.typed<T>());
ATTR_WARN_UNUSED_RESULT const BMVert * v2
const CPPType & type() const
const CPPType & type() 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)
local_group_size(16, 16) .push_constant(Type b
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)
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)
T mix2(float factor, const T &a, const T &b)
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)
MatT from_loc_rot_scale(const typename MatT::loc_type &location, const RotationT &rotation, const VecBase< typename MatT::base_type, ScaleDim > &scale)
MatBase< float, 3, 3 > float3x3
static MatBase identity()
VecBase< T, 3 > expmap() const
static QuaternionBase expmap(const VecBase< T, 3 > &expmap)