From b03e5dec5fe9ce09f28eea62fd72d0dd7e8377d2 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Tue, 26 Sep 2017 11:40:38 -0700 Subject: [PATCH] return -1 for debugDrawItems in DIRECT mode, instead of failing the API --- examples/pybullet/pybullet.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/examples/pybullet/pybullet.c b/examples/pybullet/pybullet.c index 873430e8a..1c3758e47 100644 --- a/examples/pybullet/pybullet.c +++ b/examples/pybullet/pybullet.c @@ -3373,6 +3373,8 @@ static PyObject* pybullet_addUserDebugText(PyObject* self, PyObject* args, PyObj double textSize = 1.f; double lifeTime = 0.f; int physicsClientId = 0; + int debugItemUniqueId = -1; + b3PhysicsClientHandle sm = 0; static char* kwlist[] = {"text", "textPosition", "textColorRGB", "textSize", "lifeTime", "textOrientation", "parentObjectUniqueId", "parentLinkIndex", "physicsClientId", NULL}; @@ -3425,15 +3427,14 @@ static PyObject* pybullet_addUserDebugText(PyObject* self, PyObject* args, PyObj statusHandle = b3SubmitClientCommandAndWaitStatus(sm, commandHandle); statusType = b3GetStatusType(statusHandle); + if (statusType == CMD_USER_DEBUG_DRAW_COMPLETED) { - int debugItemUniqueId = b3GetDebugItemUniqueId(statusHandle); - PyObject* item = PyInt_FromLong(debugItemUniqueId); - return item; + debugItemUniqueId = b3GetDebugItemUniqueId(statusHandle); } - PyErr_SetString(SpamError, "Error in addUserDebugText."); - return NULL; + PyObject* item = PyInt_FromLong(debugItemUniqueId); + return item; } static PyObject* pybullet_addUserDebugLine(PyObject* self, PyObject* args, PyObject* keywds) @@ -3455,6 +3456,7 @@ static PyObject* pybullet_addUserDebugLine(PyObject* self, PyObject* args, PyObj double lineWidth = 1.f; double lifeTime = 0.f; int physicsClientId = 0; + int debugItemUniqueId = -1; b3PhysicsClientHandle sm = 0; static char* kwlist[] = {"lineFromXYZ", "lineToXYZ", "lineColorRGB", "lineWidth", "lifeTime", "parentObjectUniqueId", "parentLinkIndex", "physicsClientId", NULL}; @@ -3498,13 +3500,10 @@ static PyObject* pybullet_addUserDebugLine(PyObject* self, PyObject* args, PyObj statusType = b3GetStatusType(statusHandle); if (statusType == CMD_USER_DEBUG_DRAW_COMPLETED) { - int debugItemUniqueId = b3GetDebugItemUniqueId(statusHandle); - PyObject* item = PyInt_FromLong(debugItemUniqueId); - return item; + debugItemUniqueId = b3GetDebugItemUniqueId(statusHandle); } - - PyErr_SetString(SpamError, "Error in addUserDebugLine."); - return NULL; + PyObject* item = PyInt_FromLong(debugItemUniqueId); + return item; } static PyObject* pybullet_removeUserDebugItem(PyObject* self, PyObject* args, PyObject* keywds)