Revision: 37533
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37533
Author:   moguri
Date:     2011-06-16 01:18:52 +0000 (Thu, 16 Jun 2011)
Log Message:
-----------
BGE Animations: Adding the ipo flag options to the action actuator. This still 
needs more testing.

Modified Paths:
--------------
    branches/soc-2011-pepper/source/blender/editors/space_logic/logic_window.c
    branches/soc-2011-pepper/source/blender/makesrna/intern/rna_actuator.c
    branches/soc-2011-pepper/source/gameengine/Converter/BL_ActionActuator.cpp
    branches/soc-2011-pepper/source/gameengine/Converter/BL_ActionActuator.h
    branches/soc-2011-pepper/source/gameengine/Converter/KX_ConvertActuators.cpp
    branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.cpp
    branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.h
    branches/soc-2011-pepper/source/gameengine/Ketsji/BL_ActionManager.cpp
    branches/soc-2011-pepper/source/gameengine/Ketsji/BL_ActionManager.h
    branches/soc-2011-pepper/source/gameengine/Ketsji/KX_GameObject.cpp
    branches/soc-2011-pepper/source/gameengine/Ketsji/KX_GameObject.h

Modified: 
branches/soc-2011-pepper/source/blender/editors/space_logic/logic_window.c
===================================================================
--- branches/soc-2011-pepper/source/blender/editors/space_logic/logic_window.c  
2011-06-15 23:43:02 UTC (rev 37532)
+++ branches/soc-2011-pepper/source/blender/editors/space_logic/logic_window.c  
2011-06-16 01:18:52 UTC (rev 37533)
@@ -3677,12 +3677,22 @@
 {
        Object *ob = (Object *)ptr->id.data;
        PointerRNA settings_ptr;
-       uiLayout *row;
+       uiLayout *row, *subrow, *col;;
 
        RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, 
&settings_ptr);
 
        row= uiLayoutRow(layout, 0);
        uiItemR(row, ptr, "play_mode", 0, "", ICON_NONE);
+
+       subrow= uiLayoutRow(row, 1);
+       uiItemR(subrow, ptr, "use_force", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
+       uiItemR(subrow, ptr, "use_additive", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
+
+       col = uiLayoutColumn(subrow, 0);
+       uiLayoutSetActive(col, (RNA_boolean_get(ptr, "use_additive") || 
RNA_boolean_get(ptr, "use_force")));
+       uiItemR(col, ptr, "use_local", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
+
+       row= uiLayoutRow(layout, 0);
        uiItemR(row, ptr, "action", 0, "", ICON_NONE);
        uiItemR(row, ptr, "use_continue_last_frame", 0, NULL, ICON_NONE);
 
@@ -3695,6 +3705,8 @@
                uiItemR(row, ptr, "frame_end", 0, NULL, ICON_NONE);
        }
 
+       uiItemR(row, ptr, "apply_to_children", 0, NULL, ICON_NONE);
+
        row= uiLayoutRow(layout, 0);
        uiItemR(row, ptr, "frame_blend_in", 0, NULL, ICON_NONE);
        uiItemR(row, ptr, "priority", 0, NULL, ICON_NONE);

Modified: branches/soc-2011-pepper/source/blender/makesrna/intern/rna_actuator.c
===================================================================
--- branches/soc-2011-pepper/source/blender/makesrna/intern/rna_actuator.c      
2011-06-15 23:43:02 UTC (rev 37532)
+++ branches/soc-2011-pepper/source/blender/makesrna/intern/rna_actuator.c      
2011-06-16 01:18:52 UTC (rev 37533)
@@ -353,7 +353,30 @@
                ia->flag &= ~ACT_IPOFORCE;
 }
 
+static void rna_ActionActuator_add_set(struct PointerRNA *ptr, int value)
+{
+       bActuator *act = (bActuator *)ptr->data;
+       bActionActuator *aa = act->data;
 
+       if(value == 1){
+               aa->flag &= ~ACT_IPOFORCE;
+               aa->flag |= ACT_IPOADD;
+       }else
+               aa->flag &= ~ACT_IPOADD;
+}
+
+static void rna_ActionActuator_force_set(struct PointerRNA *ptr, int value)
+{
+       bActuator *act = (bActuator *)ptr->data;
+       bActionActuator *aa = act->data;
+
+       if(value == 1){
+               aa->flag &= ~ACT_IPOADD;
+               aa->flag |= ACT_IPOFORCE;
+       }else
+               aa->flag &= ~ACT_IPOFORCE;
+}
+
 static void rna_ObjectActuator_type_set(struct PointerRNA *ptr, int value)
 {
        bActuator *act= (bActuator *)ptr->data;
@@ -626,6 +649,29 @@
        RNA_def_property_ui_text(prop, "Frame Property", "Assign the action's 
current frame number to this property");
        RNA_def_property_update(prop, NC_LOGIC, NULL);
 
+       /* booleans */
+       prop= RNA_def_property(srna, "use_additive", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_IPOADD);
+       RNA_def_property_boolean_funcs(prop, NULL, 
"rna_ActionActuator_add_set");
+       RNA_def_property_ui_text(prop, "Add", "Action is added to the current 
loc/rot/scale in global or local coordinate according to Local flag");
+       RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+       prop= RNA_def_property(srna, "use_force", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_IPOFORCE);
+       RNA_def_property_boolean_funcs(prop, NULL, 
"rna_ActionActuator_force_set");
+       RNA_def_property_ui_text(prop, "Force", "Apply Action as a global or 
local force depending on the local option (dynamic objects only)");
+       RNA_def_property_update(prop, NC_LOGIC, NULL);
+       
+       prop= RNA_def_property(srna, "use_local", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_IPOLOCAL);
+       RNA_def_property_ui_text(prop, "L", "Let the Action act in local 
coordinates, used in Force and Add mode");
+       RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+       prop= RNA_def_property(srna, "apply_to_children", PROP_BOOLEAN, 
PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_IPOCHILD);
+       RNA_def_property_ui_text(prop, "Child", "Update Action on all children 
Objects as well");
+       RNA_def_property_update(prop, NC_LOGIC, NULL);
+
 #ifdef __NLA_ACTION_BY_MOTION_ACTUATOR
        prop= RNA_def_property(srna, "stride_length", PROP_FLOAT, PROP_NONE);
        RNA_def_property_float_sdna(prop, NULL, "stridelength");

Modified: 
branches/soc-2011-pepper/source/gameengine/Converter/BL_ActionActuator.cpp
===================================================================
--- branches/soc-2011-pepper/source/gameengine/Converter/BL_ActionActuator.cpp  
2011-06-15 23:43:02 UTC (rev 37532)
+++ branches/soc-2011-pepper/source/gameengine/Converter/BL_ActionActuator.cpp  
2011-06-16 01:18:52 UTC (rev 37533)
@@ -180,7 +180,7 @@
        if (!m_is_going && bPositiveEvent)
        {               
                m_is_going = true;
-               obj->PlayAction(m_action->id.name+2, start, end, m_layer, 
m_blendin, play_mode);
+               obj->PlayAction(m_action->id.name+2, start, end, m_layer, 
m_blendin, play_mode, 0, m_ipo_flags);
                if (m_end_reset)
                        obj->SetActionFrame(m_layer, m_localtime);
        }

Modified: 
branches/soc-2011-pepper/source/gameengine/Converter/BL_ActionActuator.h
===================================================================
--- branches/soc-2011-pepper/source/gameengine/Converter/BL_ActionActuator.h    
2011-06-15 23:43:02 UTC (rev 37532)
+++ branches/soc-2011-pepper/source/gameengine/Converter/BL_ActionActuator.h    
2011-06-16 01:18:52 UTC (rev 37533)
@@ -53,6 +53,7 @@
                                                short   blendin,
                                                short   priority,
                                                short   layer,
+                                               short   ipo_flags,
                                                short   end_reset,
                                                float   stride) 
                : SCA_IActuator(gameobj, KX_ACT_ACTION),
@@ -71,6 +72,7 @@
                m_playtype(playtype),
                m_priority(priority),
                m_layer(layer),
+               m_ipo_flags(ipo_flags),
                m_end_reset(end_reset),
                m_is_going(false),
                m_pose(NULL),
@@ -166,6 +168,7 @@
        short   m_playtype;
        short   m_priority;
        short   m_layer;
+       short   m_ipo_flags;
        bool    m_end_reset;
        bool    m_is_going;
        struct bPose* m_pose;

Modified: 
branches/soc-2011-pepper/source/gameengine/Converter/KX_ConvertActuators.cpp
===================================================================
--- 
branches/soc-2011-pepper/source/gameengine/Converter/KX_ConvertActuators.cpp    
    2011-06-15 23:43:02 UTC (rev 37532)
+++ 
branches/soc-2011-pepper/source/gameengine/Converter/KX_ConvertActuators.cpp    
    2011-06-16 01:18:52 UTC (rev 37533)
@@ -95,6 +95,7 @@
 #include "BL_ActionActuator.h"
 #include "BL_ShapeActionActuator.h"
 #include "BL_ArmatureActuator.h"
+#include "BL_Action.h"
 /* end of blender include block */
 
 #include "BL_BlenderDataConversion.h"
@@ -195,6 +196,14 @@
                                bActionActuator* actact = (bActionActuator*) 
bact->data;
                                STR_String propname = (actact->name ? 
actact->name : "");
                                STR_String propframe = (actact->frameProp ? 
actact->frameProp : "");
+
+                               short ipo_flags = 0;
+
+                               // Convert flags
+                               if (actact->flag & ACT_IPOFORCE) ipo_flags |= 
BL_Action::ACT_IPOFLAG_FORCE;
+                               if (actact->flag & ACT_IPOLOCAL) ipo_flags |= 
BL_Action::ACT_IPOFLAG_LOCAL;
+                               if (actact->flag & ACT_IPOADD) ipo_flags |= 
BL_Action::ACT_IPOFLAG_ADD;
+                               if (actact->flag & ACT_IPOCHILD) ipo_flags |= 
BL_Action::ACT_IPOFLAG_CHILD;
                                        
                                BL_ActionActuator* tmpbaseact = new 
BL_ActionActuator(
                                        gameobj,
@@ -207,6 +216,7 @@
                                        actact->blendin,
                                        actact->priority,
                                        actact->layer,
+                                       ipo_flags,
                                        actact->end_reset,
                                        actact->stridelength
                                        // Ketsji at 1, because zero is 
reserved for "NoDef"

Modified: branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.cpp
===================================================================
--- branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.cpp     
2011-06-15 23:43:02 UTC (rev 37532)
+++ branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.cpp     
2011-06-16 01:18:52 UTC (rev 37533)
@@ -58,6 +58,7 @@
        m_blendframe(0.f),
        m_blendstart(0.f),
        m_speed(0.f),
+       m_ipo_flags(0),
        m_pose(NULL),
        m_blendpose(NULL),
        m_sg_contr(NULL),
@@ -85,6 +86,7 @@
                                        float blendin,
                                        short play_mode,
                                        short blend_mode,
+                                       short ipo_flags,
                                        float playback_speed)
 {
        bAction* prev_action = m_action;
@@ -105,8 +107,10 @@
                m_sg_contr = BL_CreateIPO(m_action, m_obj, 
KX_GetActiveScene()->GetSceneConverter());
                m_obj->GetSGNode()->AddSGController(m_sg_contr);
                m_sg_contr->SetObject(m_obj->GetSGNode());
-               InitIPO();
        }
+       
+       m_ipo_flags = ipo_flags;
+       InitIPO();
 
        // Now that we have an action, we have something we can play
        m_starttime = KX_GetActiveEngine()->GetFrameTime();
@@ -131,9 +135,9 @@
 {
                // Initialize the IPO
                m_sg_contr->SetOption(SG_Controller::SG_CONTR_IPO_RESET, true);
-               m_sg_contr->SetOption(SG_Controller::SG_CONTR_IPO_IPO_AS_FORCE, 
false);
-               m_sg_contr->SetOption(SG_Controller::SG_CONTR_IPO_IPO_ADD, 
false);
-               m_sg_contr->SetOption(SG_Controller::SG_CONTR_IPO_LOCAL, false);
+               m_sg_contr->SetOption(SG_Controller::SG_CONTR_IPO_IPO_AS_FORCE, 
m_ipo_flags & ACT_IPOFLAG_FORCE);
+               m_sg_contr->SetOption(SG_Controller::SG_CONTR_IPO_IPO_ADD, 
m_ipo_flags & ACT_IPOFLAG_ADD);
+               m_sg_contr->SetOption(SG_Controller::SG_CONTR_IPO_LOCAL, 
m_ipo_flags & ACT_IPOFLAG_LOCAL);
 }
 
 float BL_Action::GetFrame()
@@ -259,8 +263,6 @@
        else
        {
                InitIPO();
-               m_sg_contr->SetSimulatedTime(m_localtime);
-               m_obj->GetSGNode()->UpdateWorldData(m_localtime);
-               m_obj->UpdateTransform();
+               m_obj->UpdateIPO(m_localtime, m_ipo_flags & ACT_IPOFLAG_CHILD);
        }
 }

Modified: branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.h
===================================================================
--- branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.h       
2011-06-15 23:43:02 UTC (rev 37532)
+++ branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.h       
2011-06-16 01:18:52 UTC (rev 37533)
@@ -59,6 +59,8 @@
        short m_playmode;
        short m_blendmode;
 
+       short m_ipo_flags;
+
        bool m_done;
 
        void InitIPO();
@@ -73,6 +75,7 @@
                        float blendin,
                        short play_mode,
                        short blend_mode,
+                       short ipo_flags,
                        float playback_speed);
        void Stop();
        bool IsDone() {return m_done;}
@@ -99,6 +102,14 @@
                ACT_BLEND_MAX,
        };
 
+       enum
+       {
+               ACT_IPOFLAG_FORCE = 1,
+               ACT_IPOFLAG_LOCAL = 2,
+               ACT_IPOFLAG_ADD = 4,
+               ACT_IPOFLAG_CHILD = 8,
+       };
+
 #ifdef WITH_CXX_GUARDEDALLOC
 public:
        void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, 
"GE:BL_Action"); }

Modified: branches/soc-2011-pepper/source/gameengine/Ketsji/BL_ActionManager.cpp

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to