Page MenuHome

Looptools circle fails when new plane created aligned to view
Closed, ResolvedPublic

Description

System Information
Operating system: Windows-10-10.0.18362 64 Bits
Graphics card: GeForce GTX 1080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 436.02

Blender Version
Broken:
version: 2.81 (sub 15), branch: master, commit date: 2019-10-15 17:59, hash: rBcfb6ffd48f77
version: 2.80 (sub 75), branch: master, commit date: 2019-07-29 14:47, hash: rBf6cb5f54494e
version: 2.79b, commit date: 2018-03-22 14:10, hash: f4dc9f9d68b

Short description of error
Sometimes looptools circle fails seemingly randomly. Figured out why. If the plane is spawned aligned to view then it is "corrupted" and the circle operation fails as long as the origin is exactly on the plane. Any movement of the faces or origin fixes it. Clearing rotation in object mode does not help.

Exact steps for others to reproduce the error
Factory startup settings.

  1. Change Editing -> New Objects -> Align To -> View. Enable Looptools.
  2. Right click to set the cursor and add a plane
  3. Select some faces, activate Circle from the Looptools menu.
  4. Circle is not aligned to the surface.

Event Timeline

It will work if you apply rotation of the object first.

Germano Cavalcante (mano-wii) lowered the priority of this task from Needs Triage by Developer to Confirmed, Medium.Fri, Oct 18, 4:02 PM

@Vladimir Spivak (cwolf3d), any progress?
This patch seems to solve the problem:

diff --git a/mesh_looptools.py b/mesh_looptools.py
index 41c1be0a..67855477 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:

Thanks for the work. Yes, this patch solves the problem.