Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2008-09-17 05:29:54 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2008-09-17 05:29:54 +0400
commit9064ed8d6aa934dedc4b344e328566a8549371f6 (patch)
tree81618923ec82eba64aa5caa6af6ffeb6231b996a /source/blender
parent9b7d40dbae1be5aa18894ffbc8f97a4a8c4c6fdd (diff)
Fix for bug #4192: game engine armatures that are dynamically added
but don't have an action got the pose of already added armatures, even though they're not related. This also fixes an issue where the armature in Blender would end up in the pose from the game after ESC, removes unneeded copies made during armature evaluation, and also solves the constraint copying hack.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_action.h4
-rw-r--r--source/blender/blenkernel/intern/action.c55
2 files changed, 59 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h
index 4a13fa31f6c..37ced4cb00b 100644
--- a/source/blender/blenkernel/BKE_action.h
+++ b/source/blender/blenkernel/BKE_action.h
@@ -163,6 +163,10 @@ void extract_ipochannels_from_action(ListBase *lb, struct ID *id, struct bAction
/* write values returned by extract_ipochannels_from_action, returns the number of value written */
int execute_ipochannels(ListBase *lb);
+/* functions used by the game engine */
+void game_copy_pose(struct bPose **dst, struct bPose *src);
+void game_free_pose(struct bPose *pose);
+
#ifdef __cplusplus
};
#endif
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index 043ede5987a..d65a99f23f0 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -62,6 +62,7 @@
#include "BLI_arithb.h"
#include "BLI_blenlib.h"
+#include "BLI_ghash.h"
#include "nla.h"
@@ -340,6 +341,60 @@ void free_pose(bPose *pose)
}
}
+void game_copy_pose(bPose **dst, bPose *src)
+{
+ bPose *out;
+ bPoseChannel *pchan, *outpchan;
+ GHash *ghash;
+
+ /* the game engine copies the current armature pose and then swaps
+ * the object pose pointer. this makes it possible to change poses
+ * without affecting the original blender data. */
+
+ if (!src) {
+ *dst=NULL;
+ return;
+ }
+ else if (*dst==src) {
+ printf("copy_pose source and target are the same\n");
+ *dst=NULL;
+ return;
+ }
+
+ out= MEM_dupallocN(src);
+ out->agroups.first= out->agroups.last= NULL;
+ duplicatelist(&out->chanbase, &src->chanbase);
+
+ /* remap pointers */
+ ghash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
+
+ pchan= src->chanbase.first;
+ outpchan= out->chanbase.first;
+ for (; pchan; pchan=pchan->next, outpchan=outpchan->next)
+ BLI_ghash_insert(ghash, pchan, outpchan);
+
+ for (pchan=out->chanbase.first; pchan; pchan=pchan->next) {
+ pchan->parent= BLI_ghash_lookup(ghash, pchan->parent);
+ pchan->child= BLI_ghash_lookup(ghash, pchan->child);
+ pchan->path= NULL;
+ }
+
+ BLI_ghash_free(ghash, NULL, NULL);
+
+ *dst=out;
+}
+
+void game_free_pose(bPose *pose)
+{
+ if (pose) {
+ /* we don't free constraints, those are owned by the original pose */
+ if(pose->chanbase.first)
+ BLI_freelistN(&pose->chanbase);
+
+ MEM_freeN(pose);
+ }
+}
+
static void copy_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *chan)
{
bConstraint *pcon, *con;