Browse Source

Skeleton mapper: Inverting a 4x4 matrix can make element 3,3 slightly different from 1 (#389)

Now setting it to 1 to prevent round off issues further down the line.
Jorrit Rouwe 2 years ago
parent
commit
72d91db996
1 changed files with 5 additions and 1 deletions
  1. 5 1
      Jolt/Skeleton/SkeletonMapper.h

+ 5 - 1
Jolt/Skeleton/SkeletonMapper.h

@@ -17,7 +17,11 @@ public:
 	{
 	{
 	public:
 	public:
 							Mapping() = default;
 							Mapping() = default;
-							Mapping(int inJointIdx1, int inJointIdx2, Mat44Arg inJoint1To2) : mJointIdx1(inJointIdx1), mJointIdx2(inJointIdx2), mJoint1To2(inJoint1To2), mJoint2To1(inJoint1To2.Inversed()) { }
+							Mapping(int inJointIdx1, int inJointIdx2, Mat44Arg inJoint1To2) : mJointIdx1(inJointIdx1), mJointIdx2(inJointIdx2), mJoint1To2(inJoint1To2), mJoint2To1(inJoint1To2.Inversed())
+		{
+			// Ensure bottom right element is 1 (numerical imprecision in the inverse can make this not so)
+			mJoint2To1(3, 3) = 1.0f;
+		}
 
 
 		int					mJointIdx1;																	///< Index of joint from skeleton 1
 		int					mJointIdx1;																	///< Index of joint from skeleton 1
 		int					mJointIdx2;																	///< Corresponding index of joint from skeleton 2
 		int					mJointIdx2;																	///< Corresponding index of joint from skeleton 2