[Bf-extensions-cvs] [71e564e] master: FBX export: Fix to 'nearly equal' func (would break when both values were 0).

Bastien Montagne noreply at git.blender.org
Fri May 2 23:09:18 CEST 2014


Commit: 71e564e02a0a7c8c0129fc5fa632af23a3fb2a2e
Author: Bastien Montagne
Date:   Fri May 2 23:07:15 2014 +0200
https://developer.blender.org/rBA71e564e02a0a7c8c0129fc5fa632af23a3fb2a2e

FBX export: Fix to 'nearly equal' func (would break when both values were 0).

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

M	io_scene_fbx/export_fbx_bin.py

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

diff --git a/io_scene_fbx/export_fbx_bin.py b/io_scene_fbx/export_fbx_bin.py
index 464ed5d..393005d 100644
--- a/io_scene_fbx/export_fbx_bin.py
+++ b/io_scene_fbx/export_fbx_bin.py
@@ -136,7 +136,10 @@ def matrix_to_array(mat):
 
 def similar_values(v1, v2, e=1e-6):
     """Return True if v1 and v2 are nearly the same."""
-    return abs(v1 - v2) * max(abs(v1), abs(v2)) <= e
+    if v1 == v2:
+        return True
+    return ((abs(v1 - v2) / max(abs(v1), abs(v2))) <= e)
+
 
 RIGHT_HAND_AXES = {
     # Up, Front -> FBX values (tuples of (axis, sign), Up, Front, Coord).



More information about the Bf-extensions-cvs mailing list