Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-03-26 04:42:01 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-03-26 04:42:01 +0300
commitbba2bdf41e064c4c6602aa5e6c6c79364f51b08d (patch)
treeac72efafca9154fef5c413b78d244fb40e5e1616
parentc53577a1189dd71efe6a2bdd589dab7896deb946 (diff)
Added attributes for Ipo Actuator settings (replacing all methods)
-rw-r--r--source/blender/render/intern/source/convertblender.c4
-rw-r--r--source/gameengine/Ketsji/KX_IpoActuator.cpp65
-rw-r--r--source/gameengine/Ketsji/KX_IpoActuator.h6
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.cpp1
-rw-r--r--source/gameengine/PyDoc/KX_IpoActuator.py47
5 files changed, 96 insertions, 27 deletions
diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c
index 4e4e27fe286..601acc881de 100644
--- a/source/blender/render/intern/source/convertblender.c
+++ b/source/blender/render/intern/source/convertblender.c
@@ -1988,12 +1988,12 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
part->bb_align,part->draw&PART_DRAW_BB_LOCK,
a,totpart+totchild,part->bb_uv_split,part->bb_anim,part->bb_split_offset,random,pa_time,part->bb_offset,uv);
}
- else if(strandbuf) {
+ else if(strandbuf) { if(svert) {
VECCOPY(svert->co, loc);
svert->strandco= -1.0f + 2.0f*time;
svert++;
strand->totvert++;
- }
+ } }
else{
if(k==1){
VECSUB(loc0,loc1,loc);
diff --git a/source/gameengine/Ketsji/KX_IpoActuator.cpp b/source/gameengine/Ketsji/KX_IpoActuator.cpp
index 623a939bf62..f6fdce9de0f 100644
--- a/source/gameengine/Ketsji/KX_IpoActuator.cpp
+++ b/source/gameengine/Ketsji/KX_IpoActuator.cpp
@@ -84,7 +84,7 @@ KX_IpoActuator::KX_IpoActuator(SCA_IObject* gameobj,
m_ipo_as_force(ipo_as_force),
m_ipo_add(ipo_add),
m_ipo_local(ipo_local),
- m_type((IpoActType)acttype)
+ m_type(acttype)
{
m_starttime = -2.0*fabs(m_endframe - m_startframe) - 1.0;
m_bIpoPlaying = false;
@@ -190,7 +190,7 @@ bool KX_IpoActuator::Update(double curtime, bool frame)
}
}
- switch (m_type)
+ switch ((IpoActType)m_type)
{
case KX_ACT_IPO_PLAY:
@@ -383,7 +383,7 @@ bool KX_IpoActuator::Update(double curtime, bool frame)
return result;
}
-KX_IpoActuator::IpoActType KX_IpoActuator::string2mode(char* modename) {
+int KX_IpoActuator::string2mode(char* modename) {
IpoActType res = KX_ACT_IPO_NODEF;
if (modename == S_KX_ACT_IPO_PLAY_STRING) {
@@ -441,6 +441,8 @@ PyParentObject KX_IpoActuator::Parents[] = {
PyMethodDef KX_IpoActuator::Methods[] = {
{"set", (PyCFunction) KX_IpoActuator::sPySet, METH_VARARGS, (PY_METHODCHAR)Set_doc},
+
+ // deprecated
{"setProperty", (PyCFunction) KX_IpoActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc},
{"setStart", (PyCFunction) KX_IpoActuator::sPySetStart, METH_VARARGS, (PY_METHODCHAR)SetStart_doc},
{"getStart", (PyCFunction) KX_IpoActuator::sPyGetStart, METH_NOARGS, (PY_METHODCHAR)GetStart_doc},
@@ -450,22 +452,47 @@ PyMethodDef KX_IpoActuator::Methods[] = {
{"getIpoAsForce", (PyCFunction) KX_IpoActuator::sPyGetIpoAsForce, METH_NOARGS, (PY_METHODCHAR)GetIpoAsForce_doc},
{"setIpoAdd", (PyCFunction) KX_IpoActuator::sPySetIpoAdd, METH_VARARGS, (PY_METHODCHAR)SetIpoAdd_doc},
{"getIpoAdd", (PyCFunction) KX_IpoActuator::sPyGetIpoAdd, METH_NOARGS, (PY_METHODCHAR)GetIpoAdd_doc},
- {"setType", (PyCFunction) KX_IpoActuator::sPySetType, METH_VARARGS, (PY_METHODCHAR)SetType_doc},
- {"getType", (PyCFunction) KX_IpoActuator::sPyGetType, METH_NOARGS, (PY_METHODCHAR)GetType_doc},
{"setForceIpoActsLocal", (PyCFunction) KX_IpoActuator::sPySetForceIpoActsLocal, METH_VARARGS, (PY_METHODCHAR)SetForceIpoActsLocal_doc},
{"getForceIpoActsLocal", (PyCFunction) KX_IpoActuator::sPyGetForceIpoActsLocal, METH_NOARGS, (PY_METHODCHAR)GetForceIpoActsLocal_doc},
+ {"setType", (PyCFunction) KX_IpoActuator::sPySetType, METH_VARARGS, (PY_METHODCHAR)SetType_doc},
+ {"getType", (PyCFunction) KX_IpoActuator::sPyGetType, METH_NOARGS, (PY_METHODCHAR)GetType_doc},
{NULL,NULL} //Sentinel
};
PyAttributeDef KX_IpoActuator::Attributes[] = {
+ KX_PYATTRIBUTE_FLOAT_RW("startFrame", 0, 300000, KX_IpoActuator, m_startframe),
+ KX_PYATTRIBUTE_FLOAT_RW("endFrame", 0, 300000, KX_IpoActuator, m_endframe),
+ 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("type", KX_ACT_IPO_NODEF+1, KX_ACT_IPO_MAX-1, true, KX_IpoActuator, m_type),
+ KX_PYATTRIBUTE_BOOL_RW("useIpoAsForce", KX_IpoActuator, m_ipo_as_force),
+ KX_PYATTRIBUTE_BOOL_RW("useIpoAdd", KX_IpoActuator, m_ipo_add),
+ KX_PYATTRIBUTE_BOOL_RW("useIpoLocal", KX_IpoActuator, m_ipo_local),
+ KX_PYATTRIBUTE_BOOL_RW("useChildren", KX_IpoActuator, m_recurse),
+
{ NULL } //Sentinel
};
PyObject* KX_IpoActuator::_getattr(const char *attr) {
+ PyObject* object = _getattr_self(Attributes, this, attr);
+ if (object != NULL)
+ return object;
+
+ if (!strcmp(attr, "__dict__")) { /* python 3.0 uses .__dir__()*/
+ return _getattr_dict(SCA_IActuator::_getattr(attr), Methods, Attributes);
+ }
+
_getattr_up(SCA_IActuator);
}
-
+int KX_IpoActuator::_setattr(const char *attr, PyObject *value) // _setattr method
+{
+ int ret = _setattr_self(Attributes, this, attr, value);
+ if (ret >= 0)
+ return ret;
+
+ return SCA_IActuator::_setattr(attr, value);
+}
/* set --------------------------------------------------------------------- */
const char KX_IpoActuator::Set_doc[] =
@@ -478,12 +505,15 @@ const char KX_IpoActuator::Set_doc[] =
PyObject* KX_IpoActuator::PySet(PyObject* self,
PyObject* args,
PyObject* kwds) {
+
+ ShowDeprecationWarning("set()", "a number properties");
+
/* sets modes PLAY, PINGPONG, FLIPPER, LOOPSTOP, LOOPEND */
/* arg 1 = mode string, arg 2 = startframe, arg3 = stopframe, */
/* arg4 = force toggle */
char* mode;
int forceToggle;
- IpoActType modenum;
+ int modenum;
int startFrame, stopFrame;
if(!PyArg_ParseTuple(args, "siii", &mode, &startFrame,
&stopFrame, &forceToggle)) {
@@ -518,6 +548,9 @@ const char KX_IpoActuator::SetProperty_doc[] =
PyObject* KX_IpoActuator::PySetProperty(PyObject* self,
PyObject* args,
PyObject* kwds) {
+
+ ShowDeprecationWarning("setProperty()", "the propName property");
+
/* mode is implicit here, but not supported yet... */
/* args: property */
char *propertyName;
@@ -538,6 +571,9 @@ const char KX_IpoActuator::SetStart_doc[] =
PyObject* KX_IpoActuator::PySetStart(PyObject* self,
PyObject* args,
PyObject* kwds) {
+
+ ShowDeprecationWarning("setStart()", "the startFrame property");
+
float startArg;
if(!PyArg_ParseTuple(args, "f", &startArg)) {
return NULL;
@@ -552,6 +588,7 @@ const char KX_IpoActuator::GetStart_doc[] =
"getStart()\n"
"\tReturns the frame from which the ipo starts playing.\n";
PyObject* KX_IpoActuator::PyGetStart(PyObject* self) {
+ ShowDeprecationWarning("getStart()", "the startFrame property");
return PyFloat_FromDouble(m_startframe);
}
@@ -563,6 +600,7 @@ const char KX_IpoActuator::SetEnd_doc[] =
PyObject* KX_IpoActuator::PySetEnd(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("setEnd()", "the endFrame property");
float endArg;
if(!PyArg_ParseTuple(args, "f", &endArg)) {
return NULL;
@@ -577,6 +615,7 @@ const char KX_IpoActuator::GetEnd_doc[] =
"getEnd()\n"
"\tReturns the frame at which the ipo stops playing.\n";
PyObject* KX_IpoActuator::PyGetEnd(PyObject* self) {
+ ShowDeprecationWarning("getEnd()", "the endFrame property");
return PyFloat_FromDouble(m_endframe);
}
@@ -588,6 +627,7 @@ const char KX_IpoActuator::SetIpoAsForce_doc[] =
PyObject* KX_IpoActuator::PySetIpoAsForce(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("setIpoAsForce()", "the useIpoAsForce property");
int boolArg;
if (!PyArg_ParseTuple(args, "i", &boolArg)) {
@@ -605,6 +645,7 @@ const char KX_IpoActuator::GetIpoAsForce_doc[] =
"getIpoAsForce()\n"
"\tReturns whether to interpret the ipo as a force rather than a displacement.\n";
PyObject* KX_IpoActuator::PyGetIpoAsForce(PyObject* self) {
+ ShowDeprecationWarning("getIpoAsForce()", "the useIpoAsForce property");
return BoolToPyArg(m_ipo_as_force);
}
@@ -616,6 +657,7 @@ const char KX_IpoActuator::SetIpoAdd_doc[] =
PyObject* KX_IpoActuator::PySetIpoAdd(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("setIpoAdd()", "the useIpoAdd property");
int boolArg;
if (!PyArg_ParseTuple(args, "i", &boolArg)) {
@@ -633,6 +675,7 @@ const char KX_IpoActuator::GetIpoAdd_doc[] =
"getIpoAsAdd()\n"
"\tReturns whether to interpret the ipo as additive rather than absolute.\n";
PyObject* KX_IpoActuator::PyGetIpoAdd(PyObject* self) {
+ ShowDeprecationWarning("getIpoAdd()", "the useIpoAdd property");
return BoolToPyArg(m_ipo_add);
}
@@ -644,6 +687,7 @@ const char KX_IpoActuator::SetType_doc[] =
PyObject* KX_IpoActuator::PySetType(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("setType()", "the type property");
int typeArg;
if (!PyArg_ParseTuple(args, "i", &typeArg)) {
@@ -651,8 +695,8 @@ PyObject* KX_IpoActuator::PySetType(PyObject* self,
}
if ( (typeArg > KX_ACT_IPO_NODEF)
- && (typeArg < KX_ACT_IPO_KEY2KEY) ) {
- m_type = (IpoActType) typeArg;
+ && (typeArg < KX_ACT_IPO_MAX) ) {
+ m_type = typeArg;
}
Py_RETURN_NONE;
@@ -662,6 +706,7 @@ const char KX_IpoActuator::GetType_doc[] =
"getType()\n"
"\tReturns the operation mode of the actuator.\n";
PyObject* KX_IpoActuator::PyGetType(PyObject* self) {
+ ShowDeprecationWarning("getType()", "the type property");
return PyInt_FromLong(m_type);
}
@@ -675,6 +720,7 @@ const char KX_IpoActuator::SetForceIpoActsLocal_doc[] =
PyObject* KX_IpoActuator::PySetForceIpoActsLocal(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("setForceIpoActsLocal()", "the useIpoLocal property");
int boolArg;
if (!PyArg_ParseTuple(args, "i", &boolArg)) {
@@ -691,6 +737,7 @@ const char KX_IpoActuator::GetForceIpoActsLocal_doc[] =
"\tReturn whether to apply the force in the object's local\n"
"\tcoordinates rather than the world global coordinates.\n";
PyObject* KX_IpoActuator::PyGetForceIpoActsLocal(PyObject* self) {
+ ShowDeprecationWarning("getForceIpoActsLocal()", "the useIpoLocal property");
return BoolToPyArg(m_ipo_local);
}
diff --git a/source/gameengine/Ketsji/KX_IpoActuator.h b/source/gameengine/Ketsji/KX_IpoActuator.h
index 12e1835ab49..fa8e58ae861 100644
--- a/source/gameengine/Ketsji/KX_IpoActuator.h
+++ b/source/gameengine/Ketsji/KX_IpoActuator.h
@@ -108,9 +108,9 @@ public:
static STR_String S_KX_ACT_IPO_KEY2KEY_STRING;
static STR_String S_KX_ACT_IPO_FROM_PROP_STRING;
- IpoActType string2mode(char* modename);
+ int string2mode(char* modename);
- IpoActType m_type;
+ int m_type;
KX_IpoActuator(SCA_IObject* gameobj,
const STR_String& propname,
@@ -142,6 +142,8 @@ public:
/* --------------------------------------------------------------------- */
virtual PyObject* _getattr(const char *attr);
+ virtual int _setattr(const char *attr, PyObject *value);
+
//KX_PYMETHOD_DOC
KX_PYMETHOD_DOC(KX_IpoActuator,Set);
KX_PYMETHOD_DOC(KX_IpoActuator,SetProperty);
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
index d974d67bf33..bc2111571ac 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInit.cpp
@@ -970,6 +970,7 @@ PyObject* initGameLogic(KX_KetsjiEngine *engine, KX_Scene* scene) // quick hack
KX_MACRO_addTypesToDict(d, KX_IPOACT_FLIPPER, KX_IpoActuator::KX_ACT_IPO_FLIPPER);
KX_MACRO_addTypesToDict(d, KX_IPOACT_LOOPSTOP, KX_IpoActuator::KX_ACT_IPO_LOOPSTOP);
KX_MACRO_addTypesToDict(d, KX_IPOACT_LOOPEND, KX_IpoActuator::KX_ACT_IPO_LOOPEND);
+ KX_MACRO_addTypesToDict(d, KX_IPOACT_FROM_PROP,KX_IpoActuator::KX_ACT_IPO_FROM_PROP);
/* 5. Random distribution types */
KX_MACRO_addTypesToDict(d, KX_RANDOMACT_BOOL_CONST, SCA_RandomActuator::KX_RANDOMACT_BOOL_CONST);
diff --git a/source/gameengine/PyDoc/KX_IpoActuator.py b/source/gameengine/PyDoc/KX_IpoActuator.py
index e2fe3b289e3..ebc0b855f0a 100644
--- a/source/gameengine/PyDoc/KX_IpoActuator.py
+++ b/source/gameengine/PyDoc/KX_IpoActuator.py
@@ -5,10 +5,29 @@ from SCA_IActuator import *
class KX_IpoActuator(SCA_IActuator):
"""
IPO actuator activates an animation.
+
+ @ivar startFrame: Start frame.
+ @type startFrame: float
+ @ivar endFrame: End frame.
+ @type endFrame: float
+ @ivar propName: Use this property to define the Ipo position
+ @type propName: string
+ @ivar framePropName: Assign this property this action current frame number
+ @type framePropName: string
+ @ivar type: Play mode for the ipo. (In GameLogic.KX_IPOACT_PLAY, KX_IPOACT_PINGPONG, KX_IPOACT_FLIPPER, KX_IPOACT_LOOPSTOP, KX_IPOACT_LOOPEND, KX_IPOACT_FROM_PROP)
+ @type type: int
+ @ivar useIpoAsForce: Apply Ipo as a global or local force depending on the local option (dynamic objects only)
+ @type useIpoAsForce: bool
+ @ivar useIpoAdd: Ipo is added to the current loc/rot/scale in global or local coordinate according to Local flag
+ @type useIpoAdd: bool
+ @ivar useIpoLocal: Let the ipo acts in local coordinates, used in Force and Add mode.
+ @type useIpoLocal: bool
+ @ivar useChildren: Update IPO on all children Objects as well
+ @type useChildren: bool
"""
def set(mode, startframe, endframe, force):
"""
- Sets the properties of the actuator.
+ Sets the properties of the actuator. (B{deprecated})
@param mode: "Play", "PingPong", "Flipper", "LoopStop", "LoopEnd" or "FromProp"
@type mode: string
@@ -21,70 +40,70 @@ class KX_IpoActuator(SCA_IActuator):
"""
def setProperty(property):
"""
- Sets the name of the property to be used in FromProp mode.
+ Sets the name of the property to be used in FromProp mode. (B{deprecated})
@type property: string
"""
def setStart(startframe):
"""
- Sets the frame from which the IPO starts playing.
+ Sets the frame from which the IPO starts playing. (B{deprecated})
@type startframe: integer
"""
def getStart():
"""
- Returns the frame from which the IPO starts playing.
+ Returns the frame from which the IPO starts playing. (B{deprecated})
@rtype: integer
"""
def setEnd(endframe):
"""
- Sets the frame at which the IPO stops playing.
+ Sets the frame at which the IPO stops playing. (B{deprecated})
@type endframe: integer
"""
def getEnd():
"""
- Returns the frame at which the IPO stops playing.
+ Returns the frame at which the IPO stops playing. (B{deprecated})
@rtype: integer
"""
def setIpoAsForce(force):
"""
- Set whether to interpret the ipo as a force rather than a displacement.
+ Set whether to interpret the ipo as a force rather than a displacement. (B{deprecated})
@type force: boolean
@param force: KX_TRUE or KX_FALSE
"""
def getIpoAsForce():
"""
- Returns whether to interpret the ipo as a force rather than a displacement.
+ Returns whether to interpret the ipo as a force rather than a displacement. (B{deprecated})
@rtype: boolean
"""
def setIpoAdd(add):
"""
- Set whether to interpret the ipo as additive rather than absolute.
+ Set whether to interpret the ipo as additive rather than absolute. (B{deprecated})
@type add: boolean
@param add: KX_TRUE or KX_FALSE
"""
def getIpoAdd():
"""
- Returns whether to interpret the ipo as additive rather than absolute.
+ Returns whether to interpret the ipo as additive rather than absolute. (B{deprecated})
@rtype: boolean
"""
def setType(mode):
"""
- Sets the operation mode of the actuator.
+ Sets the operation mode of the actuator. (B{deprecated})
@param mode: KX_IPOACT_PLAY, KX_IPOACT_PINGPONG, KX_IPOACT_FLIPPER, KX_IPOACT_LOOPSTOP, KX_IPOACT_LOOPEND
@type mode: string
"""
def getType():
"""
- Returns the operation mode of the actuator.
+ Returns the operation mode of the actuator. (B{deprecated})
@rtype: integer
@return: KX_IPOACT_PLAY, KX_IPOACT_PINGPONG, KX_IPOACT_FLIPPER, KX_IPOACT_LOOPSTOP, KX_IPOACT_LOOPEND
@@ -92,7 +111,7 @@ class KX_IpoActuator(SCA_IActuator):
def setForceIpoActsLocal(local):
"""
Set whether to apply the force in the object's local
- coordinates rather than the world global coordinates.
+ coordinates rather than the world global coordinates. (B{deprecated})
@param local: Apply the ipo-as-force in the object's local
coordinates? (KX_TRUE, KX_FALSE)
@@ -101,5 +120,5 @@ class KX_IpoActuator(SCA_IActuator):
def getForceIpoActsLocal():
"""
Return whether to apply the force in the object's local
- coordinates rather than the world global coordinates.
+ coordinates rather than the world global coordinates. (B{deprecated})
"""