Cleanup: Assert normalized first before performing any operation

Pull Request: https://projects.blender.org/blender/blender/pulls/139408
This commit is contained in:
Mohamed El Shorbagy
2025-06-05 15:56:10 +02:00
committed by Brecht Van Lommel
parent b92d926c03
commit 9dd02f355d

View File

@@ -129,25 +129,25 @@ MINLINE float shell_angle_to_dist(const float angle)
}
MINLINE float shell_v3v3_normalized_to_dist(const float a[3], const float b[3])
{
const float angle_cos = fabsf(dot_v3v3(a, b));
BLI_ASSERT_UNIT_V3(a);
BLI_ASSERT_UNIT_V3(b);
const float angle_cos = fabsf(dot_v3v3(a, b));
return (UNLIKELY(angle_cos < SMALL_NUMBER)) ? 1.0f : (1.0f / angle_cos);
}
MINLINE float shell_v2v2_normalized_to_dist(const float a[2], const float b[2])
{
const float angle_cos = fabsf(dot_v2v2(a, b));
BLI_ASSERT_UNIT_V2(a);
BLI_ASSERT_UNIT_V2(b);
const float angle_cos = fabsf(dot_v2v2(a, b));
return (UNLIKELY(angle_cos < SMALL_NUMBER)) ? 1.0f : (1.0f / angle_cos);
}
MINLINE float shell_v3v3_mid_normalized_to_dist(const float a[3], const float b[3])
{
float angle_cos;
float ab[3];
BLI_ASSERT_UNIT_V3(a);
BLI_ASSERT_UNIT_V3(b);
float angle_cos;
float ab[3];
add_v3_v3v3(ab, a, b);
angle_cos = (normalize_v3(ab) != 0.0f) ? fabsf(dot_v3v3(a, ab)) : 0.0f;
return (UNLIKELY(angle_cos < SMALL_NUMBER)) ? 1.0f : (1.0f / angle_cos);
@@ -155,10 +155,10 @@ MINLINE float shell_v3v3_mid_normalized_to_dist(const float a[3], const float b[
MINLINE float shell_v2v2_mid_normalized_to_dist(const float a[2], const float b[2])
{
float angle_cos;
float ab[2];
BLI_ASSERT_UNIT_V2(a);
BLI_ASSERT_UNIT_V2(b);
float angle_cos;
float ab[2];
add_v2_v2v2(ab, a, b);
angle_cos = (normalize_v2(ab) != 0.0f) ? fabsf(dot_v2v2(a, ab)) : 0.0f;
return (UNLIKELY(angle_cos < SMALL_NUMBER)) ? 1.0f : (1.0f / angle_cos);