19 bool &r_used_fallback)
24 if (prev_equal && next_equal) {
25 r_used_fallback =
true;
26 return {0.0f, 0.0f, 0.0f};
52 bool used_fallback =
false;
70 tangents.first() = {0.0f, 0.0f, 0.0f};
77 tangents.last() = {0.0f, 0.0f, 0.0f};
90 int first_valid_tangent_index = -1;
91 for (
const int i :
tangents.index_range()) {
93 first_valid_tangent_index = i;
97 if (first_valid_tangent_index == -1) {
100 const float3 up_vector{0.0f, 0.0f, 1.0f};
104 const float3 &first_valid_tangent =
tangents[first_valid_tangent_index];
107 tangents.take_front(first_valid_tangent_index).fill(first_valid_tangent);
109 for (
const int i :
tangents.index_range().drop_front(first_valid_tangent_index + 1)) {
113 tangent = prev_tangent;
125 for (
const int i :
normals.index_range()) {
128 normals[i] = {1.0f, 0.0f, 0.0f};
140 const float3 &last_tangent,
141 const float3 ¤t_tangent)
169 normals.first() = {1.0f, 0.0f, 0.0f};
190 if (correction_angle >
M_PI) {
191 correction_angle = correction_angle - 2 *
M_PI;
195 const float angle_step = correction_angle /
normals.size();
196 for (
const int i :
normals.index_range()) {
197 const float angle = angle_step * i;
Low-level operations for curves.
float angle_signed_on_axis_v3v3_v3(const float v1[3], const float v2[3], const float axis[3]) ATTR_WARN_UNUSED_RESULT
float angle_normalized_v3v3(const float v1[3], const float v2[3]) ATTR_WARN_UNUSED_RESULT
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
static bool is_cyclic(const Nurb *nu)
ccl_device_inline float2 fabs(const float2 &a)
void calculate_normals_z_up(Span< float3 > tangents, MutableSpan< float3 > normals)
static float3 direction_bisect(const float3 &prev, const float3 &middle, const float3 &next, bool &r_used_fallback)
void calculate_normals_minimum(Span< float3 > tangents, bool cyclic, MutableSpan< float3 > normals)
static float3 calculate_next_normal(const float3 &last_normal, const float3 &last_tangent, const float3 ¤t_tangent)
void calculate_tangents(Span< float3 > positions, bool is_cyclic, MutableSpan< float3 > tangents)
vec_base< T, 3 > cross(const vec_base< T, 3 > &a, const vec_base< T, 3 > &b)
bool almost_equal_relative(const vec_base< T, Size > &a, const vec_base< T, Size > &b, const T &epsilon_factor)
vec_base< T, Size > normalize(const vec_base< T, Size > &v)
float3 rotate_direction_around_axis(const float3 &direction, const float3 &axis, float angle)
SymEdge< T > * prev(const SymEdge< T > *se)
vec_base< float, 3 > float3
MutableSpan< float3 > positions
MutableSpan< float3 > tangents
MutableSpan< float3 > normals