From bd92f15128d57398729fe4de3d6f9af97767f668 Mon Sep 17 00:00:00 2001 From: kimmi Date: Sat, 27 Nov 2010 13:53:34 +0000 Subject: [PATCH] - BUGFIX : Fix aiQuaternion::nomalize method. - UPDATE : Improve performance by avoiding multiple divisions. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@873 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- CREDITS | 3 +++ code/CMakeLists.txt | 4 ++++ include/aiQuaternion.h | 11 ++++++----- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CREDITS b/CREDITS index 1722a84147..b40cd7198f 100644 --- a/CREDITS +++ b/CREDITS @@ -97,3 +97,6 @@ Contributed updated and improved xcode workspaces - drparallax Contributed the /samples/SimpleAssimpViewX sample + +- Carsten Fuchs +Contributed a fix for the Normalize method in aiQuaternion. diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 07baa759f4..489479ea4d 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -112,6 +112,8 @@ SOURCE_GROUP( Common FILES ScenePreprocessor.h SkeletonMeshBuilder.cpp SkeletonMeshBuilder.h + SplitByBoneCountProcess.cpp + SplitByBoneCountProcess.h SmoothingGroups.h StandardShapes.cpp StandardShapes.h @@ -615,6 +617,8 @@ ADD_LIBRARY( assimp SHARED SceneCombiner.h ScenePreprocessor.cpp ScenePreprocessor.h + SplitByBoneCountProcess.cpp + SplitByBoneCountProcess.h SkeletonMeshBuilder.cpp SkeletonMeshBuilder.h SmoothingGroups.h diff --git a/include/aiQuaternion.h b/include/aiQuaternion.h index 1b54dcc3ec..0b3032a854 100644 --- a/include/aiQuaternion.h +++ b/include/aiQuaternion.h @@ -264,13 +264,14 @@ inline void aiQuaternion::Interpolate( aiQuaternion& pOut, const aiQuaternion& p inline aiQuaternion& aiQuaternion::Normalize() { // compute the magnitude and divide through it - const float mag = x*x+y*y+z*z+w*w; + const float mag = sqrt(x*x + y*y + z*z + w*w); if (mag) { - x /= mag; - y /= mag; - z /= mag; - w /= mag; + const float invMag = 1.0f/mag; + x *= invMag; + y *= invMag; + z *= invMag; + w *= invMag; } return *this; }