BGE Animations: Fixing a bug with priority and non continuous animations.
authorMitchell Stokes <mogurijin@gmail.com>
Wed, 29 Jun 2011 01:53:17 +0000 (01:53 +0000)
committerMitchell Stokes <mogurijin@gmail.com>
Wed, 29 Jun 2011 01:53:17 +0000 (01:53 +0000)
source/gameengine/Converter/BL_ActionActuator.cpp
source/gameengine/Ketsji/BL_Action.cpp
source/gameengine/Ketsji/BL_Action.h
source/gameengine/Ketsji/BL_ActionManager.cpp
source/gameengine/Ketsji/BL_ActionManager.h
source/gameengine/Ketsji/KX_GameObject.cpp
source/gameengine/Ketsji/KX_GameObject.h

index 3368e43c9e8118bbc6475599ad7ba743d27f0fb7..5a91c10c189c6c874ca77501741645f984464654 100644 (file)
@@ -184,8 +184,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
        if (!m_is_going && bPositiveEvent)
        {               
                m_is_going = true;
-               obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, m_blendin, play_mode, 0, m_ipo_flags);
-               if (m_end_reset)
+               if (obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, m_blendin, play_mode, 0, m_ipo_flags) && m_end_reset)
                        obj->SetActionFrame(m_layer, m_localtime);
        }
        else if (m_is_going && bNegativeEvent)
index 1741e74a771688853b571c7bcaa0e1b0c37627bc..149189b6a7921238324b753d63fd0c616eebed36 100644 (file)
@@ -104,7 +104,7 @@ BL_Action::~BL_Action()
                delete m_ptrrna;
 }
 
-void BL_Action::Play(const char* name,
+bool BL_Action::Play(const char* name,
                                        float start,
                                        float end,
                                        short priority,
@@ -118,7 +118,7 @@ void BL_Action::Play(const char* name,
        // Only start playing a new action if we're done, or if
        // the new action has a higher priority
        if (priority != 0 && !IsDone() && priority >= m_priority)
-               return;
+               return false;
        m_priority = priority;
        bAction* prev_action = m_action;
 
@@ -128,7 +128,7 @@ void BL_Action::Play(const char* name,
        {
                printf("Failed to load action: %s\n", name);
                m_done = true;
-               return;
+               return false;
        }
 
        if (prev_action != m_action)
@@ -178,6 +178,8 @@ void BL_Action::Play(const char* name,
        m_speed = playback_speed;
        
        m_done = false;
+
+       return true;
 }
 
 void BL_Action::Stop()
@@ -329,6 +331,9 @@ void BL_Action::Update(float curtime)
                        game_blend_poses(m_pose, m_blendpose, weight);
                }
 
+
+               // Handle layer blending
+               
                obj->SetPose(m_pose);
 
                obj->SetActiveAction(NULL, 0, curtime);
index de09ab13c688b9f7457d7f5ac89efe36655cd758..c4544fcda4414a2031d19c2fa0fe672e68b4d4b3 100644 (file)
@@ -78,7 +78,7 @@ public:
        BL_Action(class KX_GameObject* gameobj);
        ~BL_Action();
 
-       void Play(const char* name,
+       bool Play(const char* name,
                        float start,
                        float end,
                        short priority,
index 9e847b20c9d4da1f57a8ef31e6b010cc9e758dd7..dfa06bd19d5a2068d9e098e755668b377f496803 100644 (file)
@@ -56,7 +56,7 @@ void BL_ActionManager::SetActionFrame(short layer, float frame)
                m_layers[layer]->SetFrame(frame);
 }
 
-void BL_ActionManager::PlayAction(const char* name,
+bool BL_ActionManager::PlayAction(const char* name,
                                                                float start,
                                                                float end,
                                                                short layer,
@@ -67,7 +67,7 @@ void BL_ActionManager::PlayAction(const char* name,
                                                                short ipo_flags,
                                                                float playback_speed)
 {
-       m_layers[layer]->Play(name, start, end, priority, blendin, play_mode, blend_mode, ipo_flags, playback_speed);
+       return m_layers[layer]->Play(name, start, end, priority, blendin, play_mode, blend_mode, ipo_flags, playback_speed);
 }
 
 void BL_ActionManager::StopAction(short layer)
index 41907c202047b505155ff4b7dafd3b9436614bac..99053ba27a623e3d803786d257870b12be233d6d 100644 (file)
@@ -42,7 +42,7 @@ public:
        BL_ActionManager(class KX_GameObject* obj);
        ~BL_ActionManager();
 
-       void PlayAction(const char* name,
+       bool PlayAction(const char* name,
                                        float start,
                                        float end,
                                        short layer=0,
index 152efed7a4b5553417f306e8deae0d9517a2a6ab..35fe956b0e87e1c22c51e02f73c0676ad0235f46 100644 (file)
@@ -360,7 +360,7 @@ BL_ActionManager* KX_GameObject::GetActionManager()
        return m_actionManager;
 }
 
-void KX_GameObject::PlayAction(const char* name,
+bool KX_GameObject::PlayAction(const char* name,
                                                                float start,
                                                                float end,
                                                                short layer,
@@ -371,7 +371,7 @@ void KX_GameObject::PlayAction(const char* name,
                                                                short ipo_flags,
                                                                float playback_speed)
 {
-       GetActionManager()->PlayAction(name, start, end, layer, priority, blendin, play_mode, blend_mode, ipo_flags, playback_speed);
+       return GetActionManager()->PlayAction(name, start, end, layer, priority, blendin, play_mode, blend_mode, ipo_flags, playback_speed);
 }
 
 void KX_GameObject::StopAction(short layer)
index b55b2bba60a5dece20db27686d7b8a376b4768a9..b43b5e02d458d74b67d0cc32cc0ab89d213c1bfe 100644 (file)
@@ -211,7 +211,7 @@ public:
        /**
         * Adds an action to the object's action manager
         */
-       void PlayAction(const char* name,
+       bool PlayAction(const char* name,
                                        float start,
                                        float end,
                                        short layer=0,