Blender V5.0
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 bool delta_dir (const float3 &pos, const float3 &next, float3 &r_delta_dir)
static float3 direction_bisect (const float3 &pos, const float3 &next, float3 &other_dir, bool &is_equal)
static float3 calculate_next_normal (const float3 &last_normal, const float3 &last_tangent, const float3 &current_tangent)

Function Documentation

◆ calculate_next_normal()

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 146 of file curve_poly.cc.

References angle(), 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 166 of file curve_poly.cc.

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

Referenced by blender::bke::CurvesGeometry::evaluated_normals().

◆ 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 126 of file curve_poly.cc.

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

Referenced by blender::bke::CurvesGeometry::evaluated_normals().

◆ 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 74 of file curve_poly.cc.

References BLI_assert, delta_dir(), direction_bisect(), blender::IndexRange::drop_back(), blender::IndexRange::drop_front(), blender::MutableSpan< T >::fill(), blender::MutableSpan< T >::first(), blender::Span< T >::first(), i, blender::Span< T >::index_range(), is_cyclic(), blender::Span< T >::is_empty(), blender::MutableSpan< T >::last(), blender::Span< T >::last(), blender::MutableSpan< T >::size(), blender::Span< T >::size(), and blender::MutableSpan< T >::slice().

Referenced by blender::bke::CurvesGeometry::evaluated_tangents().

◆ delta_dir()

bool blender::bke::curves::poly::delta_dir ( const float3 & pos,
const float3 & next,
float3 & r_delta_dir )
static

Definition at line 16 of file curve_poly.cc.

References blender::math::length(), next, norm(), pos, and UNLIKELY.

Referenced by calculate_tangents().

◆ direction_bisect()

float3 blender::bke::curves::poly::direction_bisect ( const float3 & pos,
const float3 & next,
float3 & other_dir,
bool & is_equal )
static

Computes an approximate tangent from the normalized sum from the direction vectors to neighboring points on the curve.

Definition at line 33 of file curve_poly.cc.

References blender::math::cross(), e, blender::math::length(), next, norm(), blender::math::normalize(), pos, and UNLIKELY.

Referenced by calculate_tangents().