[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38179] branches/soc-2011-cucumber/source/ gameengine/Ketsji/KX_GameObject.cpp: Fixed the transform attribute of KX_GameObject' s set method to properly deal with negative scaling.
Daniel Stokes
kupomail at gmail.com
Thu Jul 7 07:46:49 CEST 2011
Revision: 38179
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38179
Author: kupoman
Date: 2011-07-07 05:46:48 +0000 (Thu, 07 Jul 2011)
Log Message:
-----------
Fixed the transform attribute of KX_GameObject's set method to properly deal with negative scaling.
Modified Paths:
--------------
branches/soc-2011-cucumber/source/gameengine/Ketsji/KX_GameObject.cpp
Modified: branches/soc-2011-cucumber/source/gameengine/Ketsji/KX_GameObject.cpp
===================================================================
--- branches/soc-2011-cucumber/source/gameengine/Ketsji/KX_GameObject.cpp 2011-07-07 05:28:09 UTC (rev 38178)
+++ branches/soc-2011-cucumber/source/gameengine/Ketsji/KX_GameObject.cpp 2011-07-07 05:46:48 UTC (rev 38179)
@@ -2106,12 +2106,19 @@
MT_Vector3 y = MT_Vector3(transform[0][1], transform[1][1], transform[2][1]);
MT_Vector3 z = MT_Vector3(transform[0][2], transform[1][2], transform[2][2]);
+ MT_Matrix3x3 rot = MT_Matrix3x3(x[0], y[0], z[0], x[1], y[1], z[1], x[2], y[2], z[2]);
MT_Vector3 scale = MT_Vector3(x.length(), y.length(), z.length());
+
+ // If the determinant of the 3x3 submatrix is negative, we need to flip an arbitrary axis' scale value
+ // to account for negative scaling
+ if (rot[0][0]*rot[1][1]*rot[2][2] + rot[0][1]*rot[1][2]*rot[2][0] + rot[0][2]*rot[1][0]*rot[2][1] -
+ rot[0][0]*rot[1][2]*rot[2][1] - rot[0][1]*rot[1][0]*rot[2][2] - rot[0][2]*rot[1][1]*rot[2][0] < 0)
+ scale[0] *= -1;
+
self->NodeSetWorldScale(scale);
// Decompose rotation
MT_Matrix3x3 scale_mat = MT_Matrix3x3(scale[0], 0, 0, 0, scale[1], 0, 0, 0, scale[2]).inverse();
- MT_Matrix3x3 rot = MT_Matrix3x3(x[0], y[0], z[0], x[1], y[1], z[1], x[2], y[2], z[2]);
rot = rot * scale_mat;
self->NodeSetGlobalOrientation(rot);
More information about the Bf-blender-cvs
mailing list