Blender V4.3
blender::bke::curves::poly Namespace Reference

Functions

void calculate_tangents (Span< float3 > positions, bool is_cyclic, MutableSpan< float3 > tangents)
 
void calculate_normals_minimum (Span< float3 > tangents, bool cyclic, MutableSpan< float3 > normals)
 
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)
 
static float3 calculate_next_normal (const float3 &last_normal, const float3 &last_tangent, const float3 &current_tangent)
 

Function Documentation

◆ calculate_next_normal()

static float3 blender::bke::curves::poly::calculate_next_normal ( const float3 & last_normal,
const float3 & last_tangent,
const float3 & current_tangent )
static

Rotate the last normal in the same way the tangent has been rotated.

Definition at line 141 of file curve_poly.cc.

References angle_normalized_v3v3(), blender::math::cross(), blender::math::is_zero(), LIKELY, blender::math::normalize(), and blender::math::rotate_direction_around_axis().

Referenced by calculate_normals_minimum().

◆ calculate_normals_minimum()

void blender::bke::curves::poly::calculate_normals_minimum ( Span< float3 > tangents,
bool cyclic,
MutableSpan< float3 > normals )

Calculate directions perpendicular to the tangent at every point by rotating an arbitrary starting vector by the same rotation of each tangent. If the curve is cyclic, propagate a correction through the entire to make sure the first and last normal align.

Definition at line 161 of file curve_poly.cc.

References angle_signed_on_axis_v3v3_v3(), BLI_assert, calculate_next_normal(), fabs(), blender::Span< T >::first(), blender::math::is_zero(), blender::Span< T >::last(), M_PI, blender::math::normalize(), blender::math::rotate_direction_around_axis(), blender::Span< T >::size(), and UNLIKELY.

◆ calculate_normals_z_up()

void blender::bke::curves::poly::calculate_normals_z_up ( Span< float3 > tangents,
MutableSpan< float3 > normals )

Calculate a vector perpendicular to every tangent on the X-Y plane (unless the tangent is vertical, in that case use the X direction).

Definition at line 121 of file curve_poly.cc.

References BLI_assert, blender::math::normalize(), and blender::Span< T >::size().

◆ calculate_tangents()

void blender::bke::curves::poly::calculate_tangents ( Span< float3 > positions,
bool is_cyclic,
MutableSpan< float3 > tangents )

Calculate the direction at every point, defined as the normalized average of the two neighboring segments (and if non-cyclic, the direction of the first and last segments). This is different than evaluating the derivative of the basis functions for curve types like NURBS, Bezier, or Catmull Rom, though the results may be similar.

Definition at line 43 of file curve_poly.cc.

References blender::math::almost_equal_relative(), BLI_assert, direction_bisect(), blender::IndexRange::drop_front(), blender::MutableSpan< T >::fill(), blender::MutableSpan< T >::first(), blender::MutableSpan< T >::index_range(), is_cyclic(), blender::math::is_zero(), blender::MutableSpan< T >::last(), blender::math::normalize(), blender::MutableSpan< T >::size(), and blender::MutableSpan< T >::take_front().

◆ direction_bisect()

static float3 blender::bke::curves::poly::direction_bisect ( const float3 & prev,
const float3 & middle,
const float3 & next,
bool & r_used_fallback )
static