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-05-17 20:30:18 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-05-17 20:30:18 +0400
commit41acd3b81cd2a7156b8c5ced4d4aa257e7575517 (patch)
treedcb2c099c3ed09f0d6b736000cb7cbf922118c45 /source/gameengine
parent65796e2c0712798606497dfb3f36ccbd6e7ab725 (diff)
While testing YoFrankie with the new API attributes found some issues...
- corrections to docs - disallow calling controller.activate(actuator) when the controller is not active. (Raise a SystemError) - Added 2 new attributes, CValue.name - deprecates CValue.getName(), KX_GameObject.children deprecated KX_GameObject.getChildren(), (same for getChildrenRecursive()).
Diffstat (limited to 'source/gameengine')
-rw-r--r--source/gameengine/Expressions/Value.cpp9
-rw-r--r--source/gameengine/Expressions/Value.h2
-rw-r--r--source/gameengine/GameLogic/SCA_PythonController.cpp10
-rw-r--r--source/gameengine/Ketsji/KX_Camera.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp20
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.h2
-rw-r--r--source/gameengine/PyDoc/GameTypes.py22
7 files changed, 58 insertions, 9 deletions
diff --git a/source/gameengine/Expressions/Value.cpp b/source/gameengine/Expressions/Value.cpp
index 83deeef91a3..f61ef1455b4 100644
--- a/source/gameengine/Expressions/Value.cpp
+++ b/source/gameengine/Expressions/Value.cpp
@@ -66,13 +66,14 @@ PyParentObject CValue::Parents[] = {
};
PyMethodDef CValue::Methods[] = {
-// { "printHello", (PyCFunction) CValue::sPyPrintHello, METH_VARARGS},
{ "getName", (PyCFunction) CValue::sPyGetName, METH_NOARGS},
{NULL,NULL} //Sentinel
};
PyObject* CValue::PyGetName()
{
+ ShowDeprecationWarning("getName()", "the name property");
+
return PyString_FromString(this->GetName());
}
@@ -550,6 +551,7 @@ static PyMethodDef CValueMethods[] =
};
PyAttributeDef CValue::Attributes[] = {
+ KX_PYATTRIBUTE_RO_FUNCTION("name", CValue, pyattr_get_name),
{ NULL } //Sentinel
};
@@ -574,6 +576,11 @@ PyObject* CValue::py_getattro_dict() {
py_getattro_dict_up(PyObjectPlus);
}
+PyObject * CValue::pyattr_get_name(void * self_v, const KX_PYATTRIBUTE_DEF * attrdef) {
+ CValue * self = static_cast<CValue *> (self_v);
+ return PyString_FromString(self->GetName());
+}
+
CValue* CValue::ConvertPythonToValue(PyObject* pyobj, const char *error_prefix)
{
diff --git a/source/gameengine/Expressions/Value.h b/source/gameengine/Expressions/Value.h
index e5c95df1c5c..0be76c4f452 100644
--- a/source/gameengine/Expressions/Value.h
+++ b/source/gameengine/Expressions/Value.h
@@ -236,6 +236,8 @@ public:
virtual int py_delattro(PyObject *attr);
virtual int py_setattro(PyObject *attr, PyObject* value);
+ static PyObject * pyattr_get_name(void * self, const KX_PYATTRIBUTE_DEF * attrdef);
+
virtual PyObject* ConvertKeysToPython( void );
KX_PYMETHOD_NOARGS(CValue,GetName);
diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp
index 212366e6526..abb3b36b91e 100644
--- a/source/gameengine/GameLogic/SCA_PythonController.cpp
+++ b/source/gameengine/GameLogic/SCA_PythonController.cpp
@@ -494,6 +494,11 @@ int SCA_PythonController::py_setattro(PyObject *attr, PyObject *value)
PyObject* SCA_PythonController::PyActivate(PyObject *value)
{
+ if(m_sCurrentController != this) {
+ PyErr_SetString(PyExc_SystemError, "Cannot add an actuator from a non-active controller");
+ return NULL;
+ }
+
SCA_IActuator* actu = LinkedActuatorFromPy(value);
if(actu==NULL)
return NULL;
@@ -504,6 +509,11 @@ PyObject* SCA_PythonController::PyActivate(PyObject *value)
PyObject* SCA_PythonController::PyDeActivate(PyObject *value)
{
+ if(m_sCurrentController != this) {
+ PyErr_SetString(PyExc_SystemError, "Cannot add an actuator from a non-active controller");
+ return NULL;
+ }
+
SCA_IActuator* actu = LinkedActuatorFromPy(value);
if(actu==NULL)
return NULL;
diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp
index 0d2e68243f8..625710fa65d 100644
--- a/source/gameengine/Ketsji/KX_Camera.cpp
+++ b/source/gameengine/Ketsji/KX_Camera.cpp
@@ -757,7 +757,7 @@ KX_PYMETHODDEF_DOC_O(KX_Camera, enableViewport,
"Sets this camera's viewport status\n"
)
{
- ShowDeprecationWarning("enableViewport(bool)", "the isViewport property");
+ ShowDeprecationWarning("enableViewport(bool)", "the useViewport property");
int viewport = PyObject_IsTrue(value);
if (viewport == -1) {
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index 1d7bf56f6d3..cbd17e66f62 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -1213,6 +1213,8 @@ PyAttributeDef KX_GameObject::Attributes[] = {
KX_PYATTRIBUTE_RW_FUNCTION("worldPosition", KX_GameObject, pyattr_get_worldPosition, pyattr_set_worldPosition),
KX_PYATTRIBUTE_RW_FUNCTION("localScale", KX_GameObject, pyattr_get_localScaling, pyattr_set_localScaling),
KX_PYATTRIBUTE_RO_FUNCTION("worldScale", KX_GameObject, pyattr_get_worldScaling),
+ KX_PYATTRIBUTE_RO_FUNCTION("children", KX_GameObject, pyattr_get_children),
+ KX_PYATTRIBUTE_RO_FUNCTION("childrenRecursive", KX_GameObject, pyattr_get_children_recursive),
KX_PYATTRIBUTE_RO_FUNCTION("attrDict", KX_GameObject, pyattr_get_attrDict),
/* Experemental, dont rely on these yet */
@@ -1753,6 +1755,18 @@ PyObject* KX_GameObject::pyattr_get_actuators(void *self_v, const KX_PYATTRIBUTE
return KX_PythonSeq_CreatePyObject((static_cast<KX_GameObject*>(self_v))->m_proxy, KX_PYGENSEQ_OB_TYPE_ACTUATORS);
}
+PyObject* KX_GameObject::pyattr_get_children(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
+ return self->GetChildren()->NewProxy(true);
+}
+
+PyObject* KX_GameObject::pyattr_get_children_recursive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
+ return self->GetChildrenRecursive()->NewProxy(true);
+}
+
PyObject* KX_GameObject::pyattr_get_attrDict(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
@@ -2155,11 +2169,15 @@ PyObject* KX_GameObject::PyRemoveParent()
PyObject* KX_GameObject::PyGetChildren()
{
+ ShowDeprecationWarning("getChildren()", "the children property");
+
return GetChildren()->NewProxy(true);
}
PyObject* KX_GameObject::PyGetChildrenRecursive()
{
+ ShowDeprecationWarning("getChildrenRecursive()", "the childrenRecursive property");
+
return GetChildrenRecursive()->NewProxy(true);
}
@@ -2304,7 +2322,7 @@ PyObject* KX_GameObject::PyGetAxisVect(PyObject* value)
PyObject* KX_GameObject::PySetPosition(PyObject* value)
{
- ShowDeprecationWarning("setPosition()", "the position property");
+ ShowDeprecationWarning("setPosition()", "the localPosition property");
MT_Point3 pos;
if (PyVecTo(value, pos))
{
diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h
index e0e78918dde..0011b8407fd 100644
--- a/source/gameengine/Ketsji/KX_GameObject.h
+++ b/source/gameengine/Ketsji/KX_GameObject.h
@@ -902,6 +902,8 @@ public:
static PyObject* pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
static PyObject* pyattr_get_meshes(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static PyObject* pyattr_get_children(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static PyObject* pyattr_get_children_recursive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static PyObject* pyattr_get_attrDict(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
/* Experemental! */
diff --git a/source/gameengine/PyDoc/GameTypes.py b/source/gameengine/PyDoc/GameTypes.py
index b5b0839c0f4..3a6c62e7d23 100644
--- a/source/gameengine/PyDoc/GameTypes.py
+++ b/source/gameengine/PyDoc/GameTypes.py
@@ -45,11 +45,14 @@ class PyObjectPlus:
class CValue(PyObjectPlus):
"""
This class is a basis for other classes.
+ @ivar name: The name of this CValue derived object (read-only).
+ @type name: string
"""
def getName():
"""
Returns the name of the CValue.
+ @deprecated: Use the L{name} attribute instead.
@note: in most cases the CValue's subclasses will override this function.
@rtype: string
"""
@@ -1584,7 +1587,11 @@ class KX_GameObject(SCA_IObject):
@type actuators: list
@ivar attrDict: get the objects internal python attribute dictionary for direct (faster) access.
@type attrDict: dict
- @group Deprecated: getPosition, setPosition, setWorldPosition, getOrientation, setOrientation, getState, setState, getParent, getVisible, getMass, getMesh
+ @ivar children: direct children of this object, (read-only).
+ @type children: L{CListValue} of L{KX_GameObject}'s
+ @ivar childrenRecursive: all children of this object including childrens children, (read-only).
+ @type childrenRecursive: L{CListValue} of L{KX_GameObject}'s
+ @group Deprecated: getPosition, setPosition, setWorldPosition, getOrientation, setOrientation, getState, setState, getParent, getVisible, getMass, getMesh, getChildren, getChildrenRecursive
"""
def endObject():
"""
@@ -1647,6 +1654,7 @@ class KX_GameObject(SCA_IObject):
"""
Sets the game object's position in world coordinates regardless if the object is root or child.
+ @deprecated: use L{worldPosition}
@type pos: [x, y, z]
@param pos: the new position, in world coordinates.
"""
@@ -2386,7 +2394,7 @@ class KX_MouseFocusSensor(SCA_MouseSensor):
@ivar hitNormal: the worldspace normal from the face at point of intersection.
@type hitNormal: list (normalized vector of 3 floats)
"""
-
+#{ Deprecated
def getHitNormal():
"""
Returns the normal (in worldcoordinates) at the point of collision where the object was hit by this ray.
@@ -2435,6 +2443,7 @@ class KX_MouseFocusSensor(SCA_MouseSensor):
@rtype: list [x, y, z]
@return: the ray target.
"""
+#}
class KX_TouchSensor(SCA_ISensor):
"""
@@ -2736,8 +2745,7 @@ class KX_ObjectActuator(SCA_IActuator):
@rtype: list [dx, dy, dz, local]
@return: A four item list, containing the angular displacement vector, and whether
- the displacement is applied in local coordinates (True) or world
- coordinates (False)
+ the displacement is applied in local coordinates (True) or world coordinates (False)
"""
def setDRot(dx, dy, dz, local):
"""
@@ -3660,7 +3668,7 @@ class KX_SCA_ReplaceMeshActuator(SCA_IActuator):
# The mesh is a different mesh - switch it.
# Check the current mesh is not a better fit.
if curmesh == None or curmesh[1] < depth or curmesh[2] > depth:
- act.setMesh(obj.getName() + newmesh[0])
+ act.mesh = obj.getName() + newmesh[0]
GameLogic.addActiveActuator(act, True)
@warning: Replace mesh actuators will be ignored if at game start, the
@@ -4008,7 +4016,7 @@ class KX_SoundActuator(SCA_IActuator):
"""
Sets the position this sound will come from.
- @deprecated: Use the L{position} attribute instead.
+ @deprecated: Use the L{localPosition} attribute instead.
@type x: float
@param x: The x coordinate of the sound.
@type y: float
@@ -4120,6 +4128,7 @@ class KX_TrackToActuator(SCA_IActuator):
@type use3D: boolean
"""
+#{ Deprecated
def setObject(object):
"""
Sets the object to track.
@@ -4168,6 +4177,7 @@ class KX_TrackToActuator(SCA_IActuator):
@deprecated: Use the L{use3D} attribute instead.
@rtype: boolean
"""
+#}
class KX_VehicleWrapper(PyObjectPlus):
"""