diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-12-06 11:29:41 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-12-06 11:29:41 +0300 |
commit | 357826aa6e18c3af1625223656d748b92db86696 (patch) | |
tree | 59f54a1e51387b251c253f92fcd3ff83d7d80dd1 /source/gameengine | |
parent | 4dceafc928ff2fdb0fcf609759cdd02401bedfd5 (diff) |
bugfix [#24967] bge.KX_GameObject.worldAngularVelocity does not work, breaks mathutils somehow
- Exceptions from reading vector values in the game engine where not being caught.
- Also wrote specific KX_GameObject exceptions, without these the errors are quite confusing.
Diffstat (limited to 'source/gameengine')
-rw-r--r-- | source/gameengine/Ketsji/KX_GameObject.cpp | 16 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_PyMath.h | 12 |
2 files changed, 19 insertions, 9 deletions
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 6b1c36a1589..1de7eee134e 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1266,7 +1266,9 @@ static int mathutils_kxgameob_vector_get(BaseMathObject *bmo, int subtype) KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(bmo->cb_user); if(self==NULL) return 0; - + +#define PHYS_ERR(attr) PyErr_SetString(PyExc_AttributeError, "KX_GameObject." attr ", is missing a physics controller") + switch(subtype) { case MATHUTILS_VEC_CB_POS_LOCAL: self->NodeGetLocalPosition().getValue(bmo->data); @@ -1281,31 +1283,33 @@ static int mathutils_kxgameob_vector_get(BaseMathObject *bmo, int subtype) self->NodeGetWorldScaling().getValue(bmo->data); break; case MATHUTILS_VEC_CB_INERTIA_LOCAL: - if(!self->GetPhysicsController()) return 0; + if(!self->GetPhysicsController()) return PHYS_ERR("localInertia"), 0; self->GetPhysicsController()->GetLocalInertia().getValue(bmo->data); break; case MATHUTILS_VEC_CB_OBJECT_COLOR: self->GetObjectColor().getValue(bmo->data); break; case MATHUTILS_VEC_CB_LINVEL_LOCAL: - if(!self->GetPhysicsController()) return 0; + if(!self->GetPhysicsController()) return PHYS_ERR("localLinearVelocity"), 0; self->GetLinearVelocity(true).getValue(bmo->data); break; case MATHUTILS_VEC_CB_LINVEL_GLOBAL: - if(!self->GetPhysicsController()) return 0; + if(!self->GetPhysicsController()) return PHYS_ERR("worldLinearVelocity"), 0; self->GetLinearVelocity(false).getValue(bmo->data); break; case MATHUTILS_VEC_CB_ANGVEL_LOCAL: - if(!self->GetPhysicsController()) return 0; + if(!self->GetPhysicsController()) return PHYS_ERR("localLinearVelocity"), 0; self->GetAngularVelocity(true).getValue(bmo->data); break; case MATHUTILS_VEC_CB_ANGVEL_GLOBAL: - if(!self->GetPhysicsController()) return 0; + if(!self->GetPhysicsController()) return PHYS_ERR("worldLinearVelocity"), 0; self->GetAngularVelocity(false).getValue(bmo->data); break; } +#undef PHYS_ERR + return 1; } diff --git a/source/gameengine/Ketsji/KX_PyMath.h b/source/gameengine/Ketsji/KX_PyMath.h index 589bd72c760..282e9a8f1f6 100644 --- a/source/gameengine/Ketsji/KX_PyMath.h +++ b/source/gameengine/Ketsji/KX_PyMath.h @@ -110,7 +110,9 @@ bool PyVecTo(PyObject* pyval, T& vec) if(VectorObject_Check(pyval)) { VectorObject *pyvec= (VectorObject *)pyval; - BaseMath_ReadCallback(pyvec); + if(!BaseMath_ReadCallback(pyvec)) { + return false; /* exception raised */ + } if (pyvec->size != Size(vec)) { PyErr_Format(PyExc_AttributeError, "error setting vector, %d args, should be %d", pyvec->size, Size(vec)); return false; @@ -120,7 +122,9 @@ bool PyVecTo(PyObject* pyval, T& vec) } else if(QuaternionObject_Check(pyval)) { QuaternionObject *pyquat= (QuaternionObject *)pyval; - BaseMath_ReadCallback(pyquat); + if(!BaseMath_ReadCallback(pyquat)) { + return false; /* exception raised */ + } if (4 != Size(vec)) { PyErr_Format(PyExc_AttributeError, "error setting vector, %d args, should be %d", 4, Size(vec)); return false; @@ -131,7 +135,9 @@ bool PyVecTo(PyObject* pyval, T& vec) } else if(EulerObject_Check(pyval)) { EulerObject *pyeul= (EulerObject *)pyval; - BaseMath_ReadCallback(pyeul); + if(!BaseMath_ReadCallback(pyeul)) { + return false; /* exception raised */ + } if (3 != Size(vec)) { PyErr_Format(PyExc_AttributeError, "error setting vector, %d args, should be %d", 3, Size(vec)); return false; |