[Bf-blender-cvs] [07ccb9b5735] master: Cleanup: use 'len_v2'

Germano Cavalcante noreply at git.blender.org
Fri Aug 26 21:10:30 CEST 2022


Commit: 07ccb9b5735ce7a12e40c1243032e18d8ed42737
Author: Germano Cavalcante
Date:   Fri Aug 26 16:10:22 2022 -0300
Branches: master
https://developer.blender.org/rB07ccb9b5735ce7a12e40c1243032e18d8ed42737

Cleanup: use 'len_v2'

Simplifies readability and avoids repeat casts.

===================================================================

M	source/blender/editors/transform/transform_input.c

===================================================================

diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c
index b541b199328..38dbe742279 100644
--- a/source/blender/editors/transform/transform_input.c
+++ b/source/blender/editors/transform/transform_input.c
@@ -276,9 +276,9 @@ void initMouseInput(
 
 static void calcSpringFactor(MouseInput *mi)
 {
-  mi->factor = sqrtf(
-      ((float)(mi->center[1] - mi->imval[1])) * ((float)(mi->center[1] - mi->imval[1])) +
-      ((float)(mi->center[0] - mi->imval[0])) * ((float)(mi->center[0] - mi->imval[0])));
+  float mdir[2] = {(float)(mi->center[1] - mi->imval[1]), (float)(mi->center[0] - mi->imval[0])};
+
+  mi->factor = len_v2(mdir);
 
   if (mi->factor == 0.0f) {
     mi->factor = 1.0f; /* prevent Inf */



More information about the Bf-blender-cvs mailing list