Cleanup: Replace raw float[4]
for math::Quaternion
#126725
@ -19,6 +19,7 @@
|
||||
#include "BLI_array.hh"
|
||||
#include "BLI_enumerable_thread_specific.hh"
|
||||
#include "BLI_math_matrix.hh"
|
||||
#include "BLI_math_quaternion.hh"
|
||||
#include "BLI_math_rotation.h"
|
||||
#include "BLI_math_vector.h"
|
||||
#include "BLI_math_vector.hh"
|
||||
@ -75,12 +76,9 @@ static float3 sculpt_rake_rotate(const StrokeCache &cache,
|
||||
const float3 &v_co,
|
||||
float factor)
|
||||
{
|
||||
float q_interp[4];
|
||||
float3 vec_rot = v_co - sculpt_co;
|
||||
|
||||
copy_qt_qt(q_interp, cache.rake_rotation_symmetry);
|
||||
pow_qt_fl_normalized(q_interp, factor);
|
||||
mul_qt_v3(q_interp, vec_rot);
|
||||
const math::Quaternion rotation = math::pow(*cache.rake_rotation_symmetry, factor);
|
||||
vec_rot = math::transform_point(rotation, vec_rot);
|
||||
|
||||
vec_rot += sculpt_co;
|
||||
return vec_rot - v_co;
|
||||
@ -135,7 +133,7 @@ BLI_NOINLINE static void calc_rake_rotation_influence(const StrokeCache &cache,
|
||||
const Span<float> factors,
|
||||
const MutableSpan<float3> translations)
|
||||
{
|
||||
if (!cache.is_rake_rotation_valid) {
|
||||
if (!cache.rake_rotation_symmetry) {
|
||||
return;
|
||||
}
|
||||
for (const int i : positions.index_range()) {
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "BLI_math_matrix.h"
|
||||
#include "BLI_math_matrix.hh"
|
||||
#include "BLI_math_rotation.h"
|
||||
#include "BLI_math_rotation.hh"
|
||||
#include "BLI_set.hh"
|
||||
#include "BLI_span.hh"
|
||||
#include "BLI_task.h"
|
||||
@ -3689,8 +3690,14 @@ void SCULPT_cache_calc_brushdata_symm(blender::ed::sculpt_paint::StrokeCache &ca
|
||||
mul_m4_v3(cache.symm_rot_mat.ptr(), cache.gravity_direction);
|
||||
}
|
||||
|
||||
if (cache.is_rake_rotation_valid) {
|
||||
flip_qt_qt(cache.rake_rotation_symmetry, cache.rake_rotation, symm);
|
||||
if (cache.rake_rotation) {
|
||||
float4 new_quat;
|
||||
float4 existing(cache.rake_rotation->w,
|
||||
cache.rake_rotation->x,
|
||||
cache.rake_rotation->y,
|
||||
cache.rake_rotation->z);
|
||||
flip_qt_qt(new_quat, existing, symm);
|
||||
cache.rake_rotation_symmetry = math::Quaternion(existing);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4424,8 +4431,6 @@ static void brush_delta_update(const Depsgraph &depsgraph,
|
||||
}
|
||||
|
||||
/* Handle 'rake' */
|
||||
cache->is_rake_rotation_valid = false;
|
||||
|
||||
invert_m4_m4(imat, ob.object_to_world().ptr());
|
||||
mul_mat3_m4_v3(imat, grab_location);
|
||||
|
||||
@ -4456,18 +4461,10 @@ static void brush_delta_update(const Depsgraph &depsgraph,
|
||||
1.0f :
|
||||
sqrtf(rake_dist_sq) / cache->rake_data.follow_dist;
|
||||
|
||||
float axis[3], angle;
|
||||
float tquat[4];
|
||||
|
||||
rotation_between_vecs_to_quat(tquat, v1, v2);
|
||||
|
||||
/* Use axis-angle to scale rotation since the factor may be above 1. */
|
||||
quat_to_axis_angle(axis, &angle, tquat);
|
||||
normalize_v3(axis);
|
||||
|
||||
angle *= brush.rake_factor * rake_fade;
|
||||
axis_angle_normalized_to_quat(cache->rake_rotation, axis, angle);
|
||||
cache->is_rake_rotation_valid = true;
|
||||
const math::AxisAngle between_vecs(v1, v2);
|
||||
const math::AxisAngle rotated(between_vecs.axis(),
|
||||
between_vecs.angle() * brush.rake_factor * rake_fade);
|
||||
cache->rake_rotation = math::to_quaternion(rotated);
|
||||
}
|
||||
}
|
||||
rake_data_update(&cache->rake_data, grab_location);
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "BLI_array.hh"
|
||||
#include "BLI_generic_array.hh"
|
||||
#include "BLI_math_matrix_types.hh"
|
||||
#include "BLI_math_quaternion_types.hh"
|
||||
#include "BLI_math_vector_types.hh"
|
||||
#include "BLI_set.hh"
|
||||
#include "BLI_span.hh"
|
||||
@ -211,8 +212,8 @@ struct StrokeCache {
|
||||
float3 old_grab_location, orig_grab_location;
|
||||
|
||||
/* screen-space rotation defined by mouse motion */
|
||||
float rake_rotation[4], rake_rotation_symmetry[4];
|
||||
bool is_rake_rotation_valid;
|
||||
std::optional<math::Quaternion> rake_rotation;
|
||||
std::optional<math::Quaternion> rake_rotation_symmetry;
|
||||
SculptRakeData rake_data;
|
||||
|
||||
/* Face Sets */
|
||||
|
Loading…
Reference in New Issue
Block a user