diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-04-20 13:13:59 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-04-20 13:13:59 +0400 |
commit | dee32d0b3f409007f5a392668068b92c3810026a (patch) | |
tree | 3127ac9c88ea9d783282d3bf8ed5ba8f2a40eb43 /source/gameengine/Ketsji/KX_SoundActuator.cpp | |
parent | 9078ce5da209bcfd31c60b55118076359ce7244f (diff) |
BGE Python API
- initialize pythons sys.argv in the blenderplayer
- ignore all arguments after a single " - " in the blenderplayer (like in blender), so args can be passed to the game.
- add a utility function PyOrientationTo() - to take a Py euler, quat or 3x3 matrix and convert into a C++ MT_Matrix3x3.
- add utility function ConvertPythonToMesh to get a RAS_MeshObject from a KX_MeshProxy or a name.
- Added error prefix arguments to ConvertPythonToGameObject, ConvertPythonToMesh and PyOrientationTo so the error messages can include what function they came from.
- deprecated brick.getOwner() for the "owner" attribute.
Diffstat (limited to 'source/gameengine/Ketsji/KX_SoundActuator.cpp')
-rw-r--r-- | source/gameengine/Ketsji/KX_SoundActuator.cpp | 50 |
1 files changed, 8 insertions, 42 deletions
diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp index b9edd7436df..412be497c5a 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.cpp +++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp @@ -540,50 +540,16 @@ int KX_SoundActuator::pyattr_set_orientation(void *self, const struct KX_PYATTRI MT_Matrix3x3 rot; KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self); - if (!PySequence_Check(value)) { - PyErr_SetString(PyExc_AttributeError, "value = actuator.orientation: KX_SoundActuator, expected a sequence"); - return 1; - } - + /* if value is not a sequence PyOrientationTo makes an error */ + if (!PyOrientationTo(value, rot, "actuator.orientation = value: KX_SoundActuator")) + return NULL; + if (!actuator->m_soundObject) return 0; /* Since not having m_soundObject didn't do anything in the old version, - * it probably should be kept that way */ - - if (PyMatTo(value, rot)) - { - actuator->m_soundObject->SetOrientation(rot); - return 0; - } - PyErr_Clear(); - - - if (PySequence_Size(value) == 4) - { - MT_Quaternion qrot; - if (PyVecTo(value, qrot)) - { - rot.setRotation(qrot); - actuator->m_soundObject->SetOrientation(rot); - return 0; - } - return 1; - } - - if (PySequence_Size(value) == 3) - { - MT_Vector3 erot; - if (PyVecTo(value, erot)) - { - rot.setEuler(erot); - actuator->m_soundObject->SetOrientation(rot); - return 0; - } - return 1; - } - - PyErr_SetString(PyExc_AttributeError, "could not set the orientation from a 3x3 matrix, quaternion or euler sequence"); - return 1; - + * it probably should be kept that way */ + + actuator->m_soundObject->SetOrientation(rot); + return 0; } // Deprecated -----> |