[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20243] trunk/blender/source/gameengine: While testing YoFrankie with the new API attributes found some issues...
Campbell Barton
ideasman42 at gmail.com
Sun May 17 18:30:19 CEST 2009
Revision: 20243
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20243
Author: campbellbarton
Date: 2009-05-17 18:30:18 +0200 (Sun, 17 May 2009)
Log Message:
-----------
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()).
Modified Paths:
--------------
trunk/blender/source/gameengine/Expressions/Value.cpp
trunk/blender/source/gameengine/Expressions/Value.h
trunk/blender/source/gameengine/GameLogic/SCA_PythonController.cpp
trunk/blender/source/gameengine/Ketsji/KX_Camera.cpp
trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp
trunk/blender/source/gameengine/Ketsji/KX_GameObject.h
trunk/blender/source/gameengine/PyDoc/GameTypes.py
Modified: trunk/blender/source/gameengine/Expressions/Value.cpp
===================================================================
--- trunk/blender/source/gameengine/Expressions/Value.cpp 2009-05-17 16:19:13 UTC (rev 20242)
+++ trunk/blender/source/gameengine/Expressions/Value.cpp 2009-05-17 16:30:18 UTC (rev 20243)
@@ -66,13 +66,14 @@
};
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 @@
};
PyAttributeDef CValue::Attributes[] = {
+ KX_PYATTRIBUTE_RO_FUNCTION("name", CValue, pyattr_get_name),
{ NULL } //Sentinel
};
@@ -574,6 +576,11 @@
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)
{
Modified: trunk/blender/source/gameengine/Expressions/Value.h
===================================================================
--- trunk/blender/source/gameengine/Expressions/Value.h 2009-05-17 16:19:13 UTC (rev 20242)
+++ trunk/blender/source/gameengine/Expressions/Value.h 2009-05-17 16:30:18 UTC (rev 20243)
@@ -236,6 +236,8 @@
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);
Modified: trunk/blender/source/gameengine/GameLogic/SCA_PythonController.cpp
===================================================================
--- trunk/blender/source/gameengine/GameLogic/SCA_PythonController.cpp 2009-05-17 16:19:13 UTC (rev 20242)
+++ trunk/blender/source/gameengine/GameLogic/SCA_PythonController.cpp 2009-05-17 16:30:18 UTC (rev 20243)
@@ -494,6 +494,11 @@
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::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;
Modified: trunk/blender/source/gameengine/Ketsji/KX_Camera.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_Camera.cpp 2009-05-17 16:19:13 UTC (rev 20242)
+++ trunk/blender/source/gameengine/Ketsji/KX_Camera.cpp 2009-05-17 16:30:18 UTC (rev 20243)
@@ -757,7 +757,7 @@
"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) {
Modified: trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp 2009-05-17 16:19:13 UTC (rev 20242)
+++ trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp 2009-05-17 16:30:18 UTC (rev 20243)
@@ -1213,6 +1213,8 @@
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 @@
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::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::PySetPosition(PyObject* value)
{
- ShowDeprecationWarning("setPosition()", "the position property");
+ ShowDeprecationWarning("setPosition()", "the localPosition property");
MT_Point3 pos;
if (PyVecTo(value, pos))
{
Modified: trunk/blender/source/gameengine/Ketsji/KX_GameObject.h
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_GameObject.h 2009-05-17 16:19:13 UTC (rev 20242)
+++ trunk/blender/source/gameengine/Ketsji/KX_GameObject.h 2009-05-17 16:30:18 UTC (rev 20243)
@@ -902,6 +902,8 @@
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! */
Modified: trunk/blender/source/gameengine/PyDoc/GameTypes.py
===================================================================
--- trunk/blender/source/gameengine/PyDoc/GameTypes.py 2009-05-17 16:19:13 UTC (rev 20242)
+++ trunk/blender/source/gameengine/PyDoc/GameTypes.py 2009-05-17 16:30:18 UTC (rev 20243)
@@ -45,11 +45,14 @@
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 @@
@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 @@
"""
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 @@
@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 @@
@rtype: list [x, y, z]
@return: the ray target.
"""
+#}
class KX_TouchSensor(SCA_ISensor):
"""
@@ -2736,8 +2745,7 @@
@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 @@
# 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 @@
"""
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 @@
@type use3D: boolean
"""
+#{ Deprecated
def setObject(object):
"""
Sets the object to track.
@@ -4168,6 +4177,7 @@
@deprecated: Use the L{use3D} attribute instead.
@rtype: boolean
"""
+#}
class KX_VehicleWrapper(PyObjectPlus):
"""
More information about the Bf-blender-cvs
mailing list