Blender V5.3
GEO_xpbd_updater_gauss_seidel.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2026 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
8
10
11namespace blender::xpbd {
12
14{
15 return math::normalize(math::Quaternion(float4(rotation) + offset));
16}
17
22 private:
23 Span<GeometryRef> geometry_refs_;
24 float total_error_squared_;
25 int total_error_count_;
26
27 public:
29 : geometry_refs_(geometry_refs), total_error_squared_(0.0f), total_error_count_(0.0f)
30 {
31 }
32
33 float total_error_squared() const
34 {
35 return total_error_squared_;
36 }
38 {
39 return total_error_count_;
40 }
41
42 void update_position(const int geo_i, const int point_i, const float3 &offset)
43 {
44 geometry_refs_[geo_i].positions[point_i] += offset;
45 }
46 void update_rotation(const int geo_i, const int point_i, const math::Quaternion &offset)
47 {
48 math::Quaternion &rotation = geometry_refs_[geo_i].rotations[point_i];
49 rotation = apply_rotation_offset(rotation, float4(offset));
50 }
51 void add_residual_error(const int /*geo_i*/, const float error_squared)
52 {
53 /* Geometry index is ignored for now for simplicity. We could record a separate error for each
54 * geometry. */
55 total_error_squared_ += error_squared;
56 ++total_error_count_;
57 }
58};
59
60} // namespace blender::xpbd
GaussSeidelUpdater(Span< GeometryRef > geometry_refs)
void add_residual_error(const int, const float error_squared)
void update_rotation(const int geo_i, const int point_i, const math::Quaternion &offset)
void update_position(const int geo_i, const int point_i, const float3 &offset)
QuaternionBase< float > Quaternion
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
math::Quaternion apply_rotation_offset(math::Quaternion rotation, float4 offset)
VecBase< float, 4 > float4
VecBase< float, 3 > float3