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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user