From ee68a17611920264c4353a1fdc79f80be08fc710 Mon Sep 17 00:00:00 2001
From: Germano Cavalcante <germano.costa@ig.com.br>
Date: Fri, 18 Oct 2019 14:22:48 -0300
Subject: [PATCH] Fix T70899: Looptools circle fails when new plane created
 aligned to view

loop tools uses a custom matrix inverse function with high precision.
So this precision has to extend to other parts.
---
 mesh_looptools.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/mesh_looptools.py b/mesh_looptools.py
index 41c1be0a4..67855477c 100644
--- a/mesh_looptools.py
+++ b/mesh_looptools.py
@@ -19,7 +19,7 @@
 bl_info = {
     "name": "LoopTools",
     "author": "Bart Crouch",
-    "version": (4, 6, 7),
+    "version": (4, 6, 8),
     "blender": (2, 80, 0),
     "location": "View3D > Sidebar > Edit Tab / Edit Mode Context Menu",
     "warning": "",
@@ -290,8 +290,10 @@ def calculate_plane(bm_mod, loop, method="best_fit", object=False):
             for i in range(itermax):
                 vec = vec2
                 vec2 = mat @ vec
-                if vec2.length != 0:
-                    vec2 /= vec2.length
+                # Calculate length with double precision to avoid problems with `inf`
+                vec2_length = math.sqrt(vec2[0] ** 2 + vec2[1] ** 2 + vec2[2] ** 2)
+                if vec2_length != 0:
+                    vec2 /= vec2_length
                 if vec2 == vec:
                     break
             if vec2.length == 0:
-- 
GitLab