From 47d961a4b1c14b0cee2817de226ee356e711e146 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Fri, 15 Apr 2022 09:54:15 -0500 Subject: Fix: Apply tilt in curves data-block normals calculation The ported normal calculation from ceed37fc5cbb466a0 neglected to use the tilt attribute to rotate the normals around the tangents. This commit adds that behavior back, adding a new math header file to avoid duplicating the rotation function for normalized axes. Differential Revision: https://developer.blender.org/D14655 --- source/blender/blenlib/intern/math_rotation.cc | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 source/blender/blenlib/intern/math_rotation.cc (limited to 'source/blender/blenlib/intern') diff --git a/source/blender/blenlib/intern/math_rotation.cc b/source/blender/blenlib/intern/math_rotation.cc new file mode 100644 index 00000000000..74300d55954 --- /dev/null +++ b/source/blender/blenlib/intern/math_rotation.cc @@ -0,0 +1,26 @@ +/* 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); +} + +} // namespace blender::math -- cgit v1.2.3