BGE Animations: Adding a layer option to Action actuators.
authorMitchell Stokes <mogurijin@gmail.com>
Sat, 11 Jun 2011 01:03:03 +0000 (01:03 +0000)
committerMitchell Stokes <mogurijin@gmail.com>
Sat, 11 Jun 2011 01:03:03 +0000 (01:03 +0000)
source/blender/editors/space_logic/logic_window.c
source/blender/makesdna/DNA_actuator_types.h
source/blender/makesrna/intern/rna_actuator.c
source/gameengine/Converter/BL_ActionActuator.cpp
source/gameengine/Converter/BL_ActionActuator.h
source/gameengine/Converter/KX_ConvertActuators.cpp

index 0a9a91a53afb86448b7d6404b135ec8e960867e8..0cbc67a3504dafe08302584cf6d7a782aa476938 100644 (file)
@@ -3699,6 +3699,9 @@ static void draw_actuator_action(uiLayout *layout, PointerRNA *ptr)
        uiItemR(row, ptr, "frame_blend_in", 0, NULL, ICON_NONE);
        uiItemR(row, ptr, "priority", 0, NULL, ICON_NONE);
 
+       row= uiLayoutRow(layout, 0);
+       uiItemR(row, ptr, "layer", 0, NULL, ICON_NONE);
+
        row= uiLayoutRow(layout, 0);
        uiItemPointerR(layout, ptr, "frame_property", &settings_ptr, "properties", NULL, ICON_NONE);
 
index 683d8142cc90a1c015ac118f38b45b0283abe32d..7951ebc8c9922fc202cc91e74c43bc206706bf95 100644 (file)
@@ -56,8 +56,10 @@ typedef struct bActionActuator {
        char    frameProp[32];  /* Set this property to the actions current frame */
        short   blendin;                /* Number of frames of blending */
        short   priority;               /* Execution priority */
+       short   layer;                  /* Animation layer */
        short   end_reset;      /* Ending the actuator (negative pulse) wont reset the the action to its starting frame */
        short   strideaxis;             /* Displacement axis */
+       short   pad[3];
        float   stridelength;   /* Displacement incurred by cycle */ // not in use
 } bActionActuator;                                                                                             
 
index e16d13fafaa57632453be25d4422e8c602102098..656dbc53656ba17c66d2375e6a4ee266665c3f6b 100644 (file)
@@ -616,6 +616,11 @@ static void rna_def_action_actuator(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Priority", "Execution priority - lower numbers will override actions with higher numbers. With 2 or more actions at once, the overriding channels must be lower in the stack");
        RNA_def_property_update(prop, NC_LOGIC, NULL);
 
+       prop= RNA_def_property(srna, "layer", PROP_INT, PROP_NONE);
+       RNA_def_property_range(prop, 0, 4); /* This should match BL_ActionManager::MAX_ACTION_LAYERS */
+       RNA_def_property_ui_text(prop, "Layer", "The animation layer to play the action on");
+       RNA_def_property_update(prop, NC_LOGIC, NULL);
+
        prop= RNA_def_property(srna, "frame_property", PROP_STRING, PROP_NONE);
        RNA_def_property_string_sdna(prop, NULL, "frameProp");
        RNA_def_property_ui_text(prop, "Frame Property", "Assign the action's current frame number to this property");
index a6ef7155522f354b463e46311dcc40715d5d6d1e..6230f03c4ed340589ca5184a3c58f398ad63550b 100644 (file)
@@ -180,9 +180,9 @@ 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, 0, m_blendin, play_mode);
+               obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_blendin, play_mode);
                if (m_end_reset)
-                       obj->SetActionFrame(0, m_localtime);
+                       obj->SetActionFrame(m_layer, m_localtime);
        }
        else if (m_is_going && bNegativeEvent)
        {
@@ -190,19 +190,19 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
                
                if (!m_end_reset)
                {
-                       obj->StopAction(0);
+                       obj->StopAction(m_layer);
                        return false;
                }
 
-               m_localtime = obj->GetActionFrame(0);
-               obj->StopAction(0); // Stop the action after getting the frame
+               m_localtime = obj->GetActionFrame(m_layer);
+               obj->StopAction(m_layer); // Stop the action after getting the frame
        }
 
        // Handle a frame property if it's defined
        if (m_framepropname[0] != 0)
        {
                CValue* oldprop = obj->GetProperty(m_framepropname);
-               CValue* newval = new CFloatValue(obj->GetActionFrame(0));
+               CValue* newval = new CFloatValue(obj->GetActionFrame(m_layer));
                if (oldprop)
                        oldprop->SetValue(newval);
                else
@@ -215,7 +215,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
                return true;
        }
        // Handle a finished animation
-       else if (m_is_going && obj->IsActionDone(0))
+       else if (m_is_going && obj->IsActionDone(m_layer))
        {
                return false;
        }
index 1530ccda00b45e59be43c96b7df06c9f6f90e0ab..6daf412d9a36718e9a661dccf9d7d1f9a1367e1c 100644 (file)
@@ -52,6 +52,7 @@ public:
                                                short   playtype,
                                                short   blendin,
                                                short   priority,
+                                               short   layer,
                                                short   end_reset,
                                                float   stride) 
                : SCA_IActuator(gameobj, KX_ACT_ACTION),
@@ -69,6 +70,7 @@ public:
                m_stridelength(stride),
                m_playtype(playtype),
                m_priority(priority),
+               m_layer(layer),
                m_end_reset(end_reset),
                m_is_going(false),
                m_pose(NULL),
@@ -163,6 +165,7 @@ protected:
        float   m_stridelength;
        short   m_playtype;
        short   m_priority;
+       short   m_layer;
        bool    m_end_reset;
        bool    m_is_going;
        struct bPose* m_pose;
index b8e19c9187adfb64d7a14c46249d249a74761aa6..7bd51fef9f0e4729a2c48de3887afab60c55cc9e 100644 (file)
@@ -205,6 +205,7 @@ void BL_ConvertActuators(char* maggiename,
                                        actact->type, // + 1, because Blender starts to count at zero,
                                        actact->blendin,
                                        actact->priority,
+                                       actact->layer,
                                        actact->end_reset,
                                        actact->stridelength
                                        // Ketsji at 1, because zero is reserved for "NoDef"