Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/attribute_math.cc
| Show All 33 Lines | void Color4fMixer::mix_in(const int64_t index, const Color4f &color, const float weight) | ||||
| output_color.g += color.g * weight; | output_color.g += color.g * weight; | ||||
| output_color.b += color.b * weight; | output_color.b += color.b * weight; | ||||
| output_color.a += color.a * weight; | output_color.a += color.a * weight; | ||||
| total_weights_[index] += weight; | total_weights_[index] += weight; | ||||
| } | } | ||||
| void Color4fMixer::finalize() | void Color4fMixer::finalize() | ||||
| { | { | ||||
| for (const int64_t i : buffer_.index_range()) { | for (const int64_t i : iter_indices(buffer_)) { | ||||
| const float weight = total_weights_[i]; | const float weight = total_weights_[i]; | ||||
| Color4f &output_color = buffer_[i]; | Color4f &output_color = buffer_[i]; | ||||
| if (weight > 0.0f) { | if (weight > 0.0f) { | ||||
| const float weight_inv = 1.0f / weight; | const float weight_inv = 1.0f / weight; | ||||
| output_color.r *= weight_inv; | output_color.r *= weight_inv; | ||||
| output_color.g *= weight_inv; | output_color.g *= weight_inv; | ||||
| output_color.b *= weight_inv; | output_color.b *= weight_inv; | ||||
| output_color.a *= weight_inv; | output_color.a *= weight_inv; | ||||
| } | } | ||||
| else { | else { | ||||
| output_color = default_color_; | output_color = default_color_; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } // namespace blender::attribute_math | } // namespace blender::attribute_math | ||||