[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2562] trunk/py/scripts/addons/ mesh_looptools.py: Fix for divide-by-zero errors.
Campbell Barton
ideasman42 at gmail.com
Wed Nov 2 10:29:57 CET 2011
Why not use vec.normalized()?
eg.
vec2 = (mat * vec).normalized()
On Wed, Nov 2, 2011 at 5:52 AM, Bart Crouch <bartius.crouch at gmail.com> wrote:
> Revision: 2562
> http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2562
> Author: crouch
> Date: 2011-11-01 18:52:14 +0000 (Tue, 01 Nov 2011)
> Log Message:
> -----------
> Fix for divide-by-zero errors.
>
> Modified Paths:
> --------------
> trunk/py/scripts/addons/mesh_looptools.py
>
> Modified: trunk/py/scripts/addons/mesh_looptools.py
> ===================================================================
> --- trunk/py/scripts/addons/mesh_looptools.py 2011-11-01 17:01:28 UTC (rev 2561)
> +++ trunk/py/scripts/addons/mesh_looptools.py 2011-11-01 18:52:14 UTC (rev 2562)
> @@ -19,9 +19,9 @@
> bl_info = {
> 'name': "LoopTools",
> 'author': "Bart Crouch",
> - 'version': (3, 2, 0),
> - 'blender': (2, 5, 7),
> - 'api': 35979,
> + 'version': (3, 2, 1),
> + 'blender': (2, 6, 0),
> + 'api': 41270,
> 'location': "View3D > Toolbar and View3D > Specials (W-key)",
> 'warning': "",
> 'description': "Mesh modelling toolkit. Several tools to aid modelling",
> @@ -249,9 +249,13 @@
> vec = mathutils.Vector((1.0, 1.0, 1.0))
> vec2 = (mat * vec)/(mat * vec).length
> while vec != vec2 and iter<itermax:
> - iter += 1
> + iter+=1
> vec = vec2
> - vec2 = (mat * vec)/(mat * vec).length
> + vec2 = mat * vec
> + if vec2.length != 0:
> + vec2 /= vec2.length
> + if vec2.length == 0:
> + vec2 = mathutils.Vector((1.0, 1.0, 1.0))
> normal = vec2
>
> elif method == 'normal':
> @@ -936,7 +940,11 @@
> while vec != vec2 and iter<itermax:
> iter+=1
> vec = vec2
> - vec2 = (mat * vec)/(mat * vec).length
> + vec2 = mat * vec
> + if vec2.length != 0:
> + vec2 /= vec2.length
> + if vec2.length == 0:
> + vec2 = mathutils.Vector((1.0, 1.0, 1.0))
> normal = vec2
> normals.append(normal)
> # have plane normals face in the same direction (maximum angle: 90 degrees)
>
> _______________________________________________
> Bf-extensions-cvs mailing list
> Bf-extensions-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-extensions-cvs
>
--
- Campbell
More information about the Bf-extensions-cvs
mailing list