From 230aed624220a5c7eee956254b5bf36eaf3b04f6 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Wed, 16 Feb 2011 19:53:39 +0000 Subject: BGE: Action and ShapeKey Actuator PingPong playmode. I have no idea why this hasn't been implemented before (the DEFINES were even there already). But since the Ipo (Fcurve) Actuator supports it I don't see why Action and ShapeKey shouldn't. More than a new feature or a bugfix this is actually a step forward into unifying them. --- source/blender/makesrna/intern/rna_actuator.c | 2 ++ source/gameengine/Converter/BL_ActionActuator.cpp | 22 ++++++++++++++++++++++ source/gameengine/Converter/BL_ActionActuator.h | 1 + .../Converter/BL_ShapeActionActuator.cpp | 22 ++++++++++++++++++++++ .../gameengine/Converter/BL_ShapeActionActuator.h | 1 + source/gameengine/Ketsji/KX_PythonInit.cpp | 1 + 6 files changed, 49 insertions(+) diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index 0fe8483dfac..80a5a5fbe4f 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -549,6 +549,7 @@ static void rna_def_action_actuator(BlenderRNA *brna) static EnumPropertyItem prop_type_items[] ={ {ACT_ACTION_PLAY, "PLAY", 0, "Play", ""}, + {ACT_ACTION_PINGPONG, "PINGPONG", 0, "Ping Pong", ""}, {ACT_ACTION_FLIPPER, "FLIPPER", 0, "Flipper", ""}, {ACT_ACTION_LOOP_STOP, "LOOPSTOP", 0, "Loop Stop", ""}, {ACT_ACTION_LOOP_END, "LOOPEND", 0, "Loop End", ""}, @@ -1778,6 +1779,7 @@ static void rna_def_shape_action_actuator(BlenderRNA *brna) static EnumPropertyItem prop_type_items[] ={ {ACT_ACTION_PLAY, "PLAY", 0, "Play", ""}, + {ACT_ACTION_PINGPONG, "PINGPONG", 0, "Ping Pong", ""}, {ACT_ACTION_FLIPPER, "FLIPPER", 0, "Flipper", ""}, {ACT_ACTION_LOOP_STOP, "LOOPSTOP", 0, "Loop Stop", ""}, {ACT_ACTION_LOOP_END, "LOOPEND", 0, "Loop End", ""}, diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index ac35007129a..859bcab5c6a 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -232,6 +232,16 @@ bool BL_ActionActuator::Update(double curtime, bool frame) apply=false; } break; + case ACT_ACTION_PINGPONG: + if (bPositiveEvent){ + if (!(m_flag & ACT_FLAG_LOCKINPUT)){ + m_flag &= ~ACT_FLAG_KEYUP; + m_localtime = m_starttime; + m_starttime = curtime; + m_flag |= ACT_FLAG_LOCKINPUT; + } + } + break; case ACT_ACTION_FLIPPER: if (bPositiveEvent){ if (!(m_flag & ACT_FLAG_LOCKINPUT)){ @@ -306,6 +316,18 @@ bool BL_ActionActuator::Update(double curtime, bool frame) break; case ACT_ACTION_LOOP_STOP: break; + case ACT_ACTION_PINGPONG: + if (wrap){ + if (!(m_flag & ACT_FLAG_REVERSE)) + m_localtime = m_endframe; + else + m_localtime = m_startframe; + + m_flag &= ~ACT_FLAG_LOCKINPUT; + m_flag ^= ACT_FLAG_REVERSE; //flip direction + keepgoing = false; + } + break; case ACT_ACTION_FLIPPER: if (wrap){ if (!(m_flag & ACT_FLAG_REVERSE)){ diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h index 9682c0e45f7..bfbb160e464 100644 --- a/source/gameengine/Converter/BL_ActionActuator.h +++ b/source/gameengine/Converter/BL_ActionActuator.h @@ -121,6 +121,7 @@ public: switch (act->m_playtype) { case ACT_ACTION_PLAY: + case ACT_ACTION_PINGPONG: case ACT_ACTION_FLIPPER: case ACT_ACTION_LOOP_STOP: case ACT_ACTION_LOOP_END: diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp index 4f6e07206dd..d4ced2634ea 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp +++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp @@ -226,6 +226,16 @@ bool BL_ShapeActionActuator::Update(double curtime, bool frame) apply=false; } break; + case ACT_ACTION_PINGPONG: + if (bPositiveEvent){ + if (!(m_flag & ACT_FLAG_LOCKINPUT)){ + m_flag &= ~ACT_FLAG_KEYUP; + m_localtime = m_starttime; + m_starttime = curtime; + m_flag |= ACT_FLAG_LOCKINPUT; + } + } + break; case ACT_ACTION_FLIPPER: if (bPositiveEvent){ if (!(m_flag & ACT_FLAG_LOCKINPUT)){ @@ -300,6 +310,18 @@ bool BL_ShapeActionActuator::Update(double curtime, bool frame) break; case ACT_ACTION_LOOP_STOP: break; + case ACT_ACTION_PINGPONG: + if (wrap){ + if (!(m_flag & ACT_FLAG_REVERSE)) + m_localtime = m_endframe; + else + m_localtime = m_startframe; + + m_flag &= ~ACT_FLAG_LOCKINPUT; + m_flag ^= ACT_FLAG_REVERSE; //flip direction + keepgoing = false; + } + break; case ACT_ACTION_FLIPPER: if (wrap){ if (!(m_flag & ACT_FLAG_REVERSE)){ diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.h b/source/gameengine/Converter/BL_ShapeActionActuator.h index e6457e2c686..64b75967874 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.h +++ b/source/gameengine/Converter/BL_ShapeActionActuator.h @@ -113,6 +113,7 @@ public: switch (act->m_playtype) { case ACT_ACTION_PLAY: + case ACT_ACTION_PINGPONG: case ACT_ACTION_FLIPPER: case ACT_ACTION_LOOP_STOP: case ACT_ACTION_LOOP_END: diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 8cc62e2c2fb..d0a6a9a9bec 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1398,6 +1398,7 @@ PyObject* initGameLogic(KX_KetsjiEngine *engine, KX_Scene* scene) // quick hack /* 7. Action actuator */ KX_MACRO_addTypesToDict(d, KX_ACTIONACT_PLAY, ACT_ACTION_PLAY); + KX_MACRO_addTypesToDict(d, KX_ACTIONACT_PINGPONG, ACT_ACTION_PINGPONG); KX_MACRO_addTypesToDict(d, KX_ACTIONACT_FLIPPER, ACT_ACTION_FLIPPER); KX_MACRO_addTypesToDict(d, KX_ACTIONACT_LOOPSTOP, ACT_ACTION_LOOP_STOP); KX_MACRO_addTypesToDict(d, KX_ACTIONACT_LOOPEND, ACT_ACTION_LOOP_END); -- cgit v1.2.3