merge with trunk at r31523
[blender.git] / source / gameengine / Converter / BL_ArmatureObject.cpp
index a6066adc03e2ba610b29ca5786eb7524a4648635..5d05dfcff521dace8ca63a16696d81f8d1fad52c 100644 (file)
@@ -15,7 +15,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
  * All rights reserved.
 #include "BL_ArmatureObject.h"
 #include "BL_ActionActuator.h"
 #include "KX_BlenderSceneConverter.h"
+#include "MEM_guardedalloc.h"
 #include "BLI_blenlib.h"
 #include "BLI_ghash.h"
-#include "BLI_arithb.h"
+#include "BLI_math.h"
 #include "BIK_api.h"
 #include "BKE_action.h"
 #include "BKE_armature.h"
 
 #include "MT_Matrix4x4.h"
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
 /** 
  * Move here pose function for game engine so that we can mix with GE objects
  * Principle is as follow:
@@ -68,8 +65,7 @@
  * When it is about to evaluate the pose, set the KX object position in the obmat of the corresponding
  * Blender objects and restore after the evaluation.
  */
-void game_copy_pose(bPose **dst, bPose *src, int copy_constraint)
-{
+void game_copy_pose(bPose **dst, bPose *src, int copy_constraint) {
        bPose *out;
        bPoseChannel *pchan, *outpchan;
        GHash *ghash;
@@ -89,6 +85,7 @@ void game_copy_pose(bPose **dst, bPose *src, int copy_constraint)
        }
        
        out= (bPose*)MEM_dupallocN(src);
+       out->chanhash = NULL;
        out->agroups.first= out->agroups.last= NULL;
        out->ikdata = NULL;
        out->ikparam = MEM_dupallocN(out->ikparam);
@@ -96,7 +93,7 @@ void game_copy_pose(bPose **dst, bPose *src, int copy_constraint)
        BLI_duplicatelist(&out->chanbase, &src->chanbase);
 
        /* remap pointers */
-       ghash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
+       ghash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "game_copy_pose gh");
 
        pchan= (bPoseChannel*)src->chanbase.first;
        outpchan= (bPoseChannel*)out->chanbase.first;
@@ -111,16 +108,22 @@ void game_copy_pose(bPose **dst, bPose *src, int copy_constraint)
                if (copy_constraint) {
                        ListBase listb;
                        // copy all constraint for backward compatibility
-                       copy_constraints(&listb, &pchan->constraints);  // copy_constraints NULLs listb
+                       copy_constraints(&listb, &pchan->constraints, FALSE);  // copy_constraints NULLs listb, no need to make extern for this operation.
                        pchan->constraints= listb;
                } else {
                        pchan->constraints.first = NULL;
                        pchan->constraints.last = NULL;
                }
+
+               // fails to link, props are not used in the BGE yet.
+               /* if(pchan->prop)
+                       pchan->prop= IDP_CopyProperty(pchan->prop); */
+               pchan->prop= NULL;
        }
 
        BLI_ghash_free(ghash, NULL, NULL);
-       
+       // set acceleration structure for channel lookup
+       make_pose_channels_hash(out);
        *dst=out;
 }
 
@@ -158,13 +161,13 @@ void game_blend_poses(bPose *dst, bPose *src, float srcweight/*, short mode*/)
                        QUATCOPY(dquat, dchan->quat);
                        QUATCOPY(squat, schan->quat);
                        if (mode==ACTSTRIPMODE_BLEND)
-                               QuatInterpol(dchan->quat, dquat, squat, srcweight);
+                               interp_qt_qtqt(dchan->quat, dquat, squat, srcweight);
                        else {
-                               QuatMulFac(squat, srcweight);
-                               QuatMul(dchan->quat, dquat, squat);
+                               mul_fac_qt_fl(squat, srcweight);
+                               mul_qt_qtqt(dchan->quat, dquat, squat);
                        }
                        
-                       NormalQuat(dchan->quat);
+                       normalize_qt(dchan->quat);
                }
 
                for (i=0; i<3; i++) {