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());
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());
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),
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;
231 location_buffer_[index] += location * weight;
232 expmap_buffer_[index] += rotation.
expmap() * weight;
233 scale_buffer_[index] += scale * weight;
234 total_weights_[index] += weight;
239 this->
finalize(buffer_.index_range());
245 const float weight = total_weights_[
i];
247 const float weight_inv =
math::rcp(weight);
249 location_buffer_[
i] * weight_inv,
251 scale_buffer_[
i] * weight_inv);
262 using T = decltype(dummy);
263 array_utils::gather(src.typed<T>(), map, dst.typed<T>());
270 using T = decltype(dummy);
271 array_utils::gather(src.typed<T>(), map, dst.typed<T>());
282 using T = decltype(dummy);
283 array_utils::gather_group_to_group(
284 src_offsets, dst_offsets, selection, src.typed<T>(), dst.typed<T>());
294 using T = decltype(dummy);
295 Span<T> src_span = src.typed<T>();
296 MutableSpan<T> dst_span = dst.typed<T>();
298 threading::parallel_for(src_ranges.index_range(), 512, [&](const IndexRange range) {
299 for (const int i : range) {
300 dst_span.slice(dst_offsets[i]).copy_from(src_span.slice(src_ranges[i]));
312 using T = decltype(dummy);
313 array_utils::gather_to_groups(dst_offsets, src_selection, src.typed<T>(), dst.typed<T>());
ATTR_WARN_UNUSED_RESULT const BMVert * v2
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
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)
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
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)
void gather_ranges_to_groups(Span< IndexRange > src_ranges, OffsetIndices< int > dst_offsets, GSpan src, GMutableSpan dst)
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< 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)
MatBase< float, 4, 4 > float4x4
VecBase< float, 4 > float4
MatBase< float, 3, 3 > float3x3
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)