[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33522] trunk/blender/source/gameengine/ Ketsji: BGE BugFix: [#21246] Some values for ipoactuator. frameEnd and frameStart make ipo not play the first time
Dalai Felinto
dfelinto at gmail.com
Tue Dec 7 02:54:25 CET 2010
Revision: 33522
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33522
Author: dfelinto
Date: 2010-12-07 02:54:25 +0100 (Tue, 07 Dec 2010)
Log Message:
-----------
BGE BugFix: [#21246] Some values for ipoactuator.frameEnd and frameStart make ipo not play the first time
This is a bug as old as the ability to change the actuator values through Python.
For the records: although Blender supports floats as frame values BGE doesn't. It could but it doesn't. So only integers (longs) will be valid start/end frames.
Modified Paths:
--------------
trunk/blender/source/gameengine/Ketsji/KX_IpoActuator.cpp
trunk/blender/source/gameengine/Ketsji/KX_IpoActuator.h
Modified: trunk/blender/source/gameengine/Ketsji/KX_IpoActuator.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_IpoActuator.cpp 2010-12-07 01:38:42 UTC (rev 33521)
+++ trunk/blender/source/gameengine/Ketsji/KX_IpoActuator.cpp 2010-12-07 01:54:25 UTC (rev 33522)
@@ -81,7 +81,7 @@
m_ipo_local(ipo_local),
m_type(acttype)
{
- m_starttime = -2.0*fabs(m_endframe - m_startframe) - 1.0;
+ this->ResetStartTime();
m_bIpoPlaying = false;
}
@@ -176,7 +176,7 @@
bool result=true;
if (!bNegativeEvent)
{
- if (m_starttime < -2.0f*start_smaller_then_end*(m_endframe - m_startframe))
+ if (m_starttime < -2.0f*fabs(m_endframe - m_startframe))
{
// start for all Ipo, initial start for LOOP_STOP
m_starttime = curtime;
@@ -371,13 +371,18 @@
if (!result)
{
if (m_type != KX_ACT_IPO_LOOPSTOP)
- m_starttime = -2.0*start_smaller_then_end*(m_endframe - m_startframe) - 1.0;
+ this->ResetStartTime();
m_bIpoPlaying = false;
}
return result;
}
+void KX_IpoActuator::ResetStartTime()
+{
+ this->m_starttime = -2.0*fabs(this->m_endframe - this->m_startframe) - 1.0;
+}
+
int KX_IpoActuator::string2mode(char* modename) {
IpoActType res = KX_ACT_IPO_NODEF;
@@ -435,8 +440,8 @@
};
PyAttributeDef KX_IpoActuator::Attributes[] = {
- KX_PYATTRIBUTE_FLOAT_RW("frameStart", 0, 300000, KX_IpoActuator, m_startframe),
- KX_PYATTRIBUTE_FLOAT_RW("frameEnd", 0, 300000, KX_IpoActuator, m_endframe),
+ KX_PYATTRIBUTE_RW_FUNCTION("frameStart", KX_IpoActuator, pyattr_get_frame_start, pyattr_set_frame_start),
+ KX_PYATTRIBUTE_RW_FUNCTION("frameEnd", KX_IpoActuator, pyattr_get_frame_end, pyattr_set_frame_end),
KX_PYATTRIBUTE_STRING_RW("propName", 0, 64, false, KX_IpoActuator, m_propname),
KX_PYATTRIBUTE_STRING_RW("framePropName", 0, 64, false, KX_IpoActuator, m_framepropname),
KX_PYATTRIBUTE_INT_RW("mode", KX_ACT_IPO_NODEF+1, KX_ACT_IPO_MAX-1, true, KX_IpoActuator, m_type),
@@ -448,6 +453,48 @@
{ NULL } //Sentinel
};
+PyObject* KX_IpoActuator::pyattr_get_frame_start(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ KX_IpoActuator* self= static_cast<KX_IpoActuator*>(self_v);
+ return PyLong_FromDouble(self->m_startframe);
+}
+
+int KX_IpoActuator::pyattr_set_frame_start(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
+{
+ KX_IpoActuator* self= static_cast<KX_IpoActuator*>(self_v);
+ float param = PyLong_AsDouble(value);
+
+ if (PyErr_Occurred()) {
+ PyErr_SetString(PyExc_AttributeError, "frameStart = integer: KX_IpoActuator, expected an integer value");
+ return PY_SET_ATTR_FAIL;
+ }
+
+ self->m_startframe = param;
+ self->ResetStartTime();
+ return PY_SET_ATTR_SUCCESS;
+}
+
+PyObject* KX_IpoActuator::pyattr_get_frame_end(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ KX_IpoActuator* self= static_cast<KX_IpoActuator*>(self_v);
+ return PyLong_FromDouble(self->m_endframe);
+}
+
+int KX_IpoActuator::pyattr_set_frame_end(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
+{
+ KX_IpoActuator* self= static_cast<KX_IpoActuator*>(self_v);
+ float param = PyLong_AsDouble(value);
+
+ if (PyErr_Occurred()) {
+ PyErr_SetString(PyExc_AttributeError, "frameEnd = integer: KX_IpoActuator, expected an integer value");
+ return PY_SET_ATTR_FAIL;
+ }
+
+ self->m_endframe = param;
+ self->ResetStartTime();
+ return PY_SET_ATTR_SUCCESS;
+}
+
#endif // WITH_PYTHON
/* eof */
Modified: trunk/blender/source/gameengine/Ketsji/KX_IpoActuator.h
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_IpoActuator.h 2010-12-07 01:38:42 UTC (rev 33521)
+++ trunk/blender/source/gameengine/Ketsji/KX_IpoActuator.h 2010-12-07 01:54:25 UTC (rev 33522)
@@ -86,6 +86,9 @@
bool m_bIpoPlaying;
+ /** Reset/Update the start time*/
+ void ResetStartTime();
+
public:
enum IpoActType
{
@@ -100,6 +103,11 @@
KX_ACT_IPO_MAX
};
+ static PyObject* pyattr_get_frame_start(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static int pyattr_set_frame_start(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
+ static PyObject* pyattr_get_frame_end(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static int pyattr_set_frame_end(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
+
static const char *S_KX_ACT_IPO_PLAY_STRING;
static const char *S_KX_ACT_IPO_PINGPONG_STRING;
static const char *S_KX_ACT_IPO_FLIPPER_STRING;
More information about the Bf-blender-cvs
mailing list