This commit ports the fillet curves node to the new curves data-block, and moves the fillet node implementation to the geometry module to help separate the implementation from the node. The changes are similar to the subdivide node or resample node. I've resused common utilities where it makes sense, though some things like the iteration over attributes can be generalized further. The node is now multi-threaded per-curve and inside each curve, and some buffers are reused per curve to avoid many allocations. The code is more explicit now, and though there is more boilerplate to pass around many spans, the more complex logic should be more readable. Differential Revision: https://developer.blender.org/D15346
40 lines
1006 B
C++
40 lines
1006 B
C++
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/** \file
|
|
* \ingroup bli
|
|
*/
|
|
|
|
#include "BLI_math_base.h"
|
|
#include "BLI_math_rotation.hh"
|
|
#include "BLI_math_vector.h"
|
|
#include "BLI_math_vector.hh"
|
|
|
|
namespace blender::math {
|
|
|
|
float3 rotate_direction_around_axis(const float3 &direction, const float3 &axis, const float angle)
|
|
{
|
|
BLI_ASSERT_UNIT_V3(direction);
|
|
BLI_ASSERT_UNIT_V3(axis);
|
|
|
|
const float3 axis_scaled = axis * math::dot(direction, axis);
|
|
const float3 diff = direction - axis_scaled;
|
|
const float3 cross = math::cross(axis, diff);
|
|
|
|
return axis_scaled + diff * std::cos(angle) + cross * std::sin(angle);
|
|
}
|
|
|
|
float3 rotate_around_axis(const float3 &vector,
|
|
const float3 ¢er,
|
|
const float3 &axis,
|
|
const float angle)
|
|
|
|
{
|
|
float3 result = vector - center;
|
|
float mat[3][3];
|
|
axis_angle_normalized_to_mat3(mat, axis, angle);
|
|
mul_m3_v3(mat, result);
|
|
return result + center;
|
|
}
|
|
|
|
} // namespace blender::math
|