From f5ffb11bc55bc041312e88a3c46d5350906080be Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Thu, 23 Jun 2016 05:10:00 +0000 Subject: [PATCH] fix bus error on Raspberry Pi, unaligned float access when loading STL files fix pybullet Python 3 issue (PyString_FromString -> PyBytes_FromString and PyInt_FromLong -> PyLong_FromLong) --- examples/Importers/ImportSTLDemo/LoadMeshFromSTL.h | 11 ++++++----- examples/pybullet/pybullet.c | 8 ++++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/examples/Importers/ImportSTLDemo/LoadMeshFromSTL.h b/examples/Importers/ImportSTLDemo/LoadMeshFromSTL.h index f670dfeec..65bdd330b 100644 --- a/examples/Importers/ImportSTLDemo/LoadMeshFromSTL.h +++ b/examples/Importers/ImportSTLDemo/LoadMeshFromSTL.h @@ -66,17 +66,18 @@ static GLInstanceGraphicsShape* LoadMeshFromSTL(const char* relativeFileName) for (int i=0;ivertex0[v]; - v1.xyzw[v] = tri->vertex1[v]; - v2.xyzw[v] = tri->vertex2[v]; - v0.normal[v] = v1.normal[v] = v2.normal[v] = tri->normal[v]; + v0.xyzw[v] = tmp.vertex0[v]; + v1.xyzw[v] = tmp.vertex1[v]; + v2.xyzw[v] = tmp.vertex2[v]; + v0.normal[v] = v1.normal[v] = v2.normal[v] = tmp.normal[v]; } v0.xyzw[3] = v1.xyzw[3] = v2.xyzw[3] = 0.f; diff --git a/examples/pybullet/pybullet.c b/examples/pybullet/pybullet.c index 9235f3e5a..2a3545bb3 100644 --- a/examples/pybullet/pybullet.c +++ b/examples/pybullet/pybullet.c @@ -9,6 +9,12 @@ #include #endif + +#if PY_MAJOR_VERSION >= 3 +#define PyInt_FromLong PyLong_FromLong +#define PyString_FromString PyBytes_FromString +#endif + enum eCONNECT_METHOD { eCONNECT_GUI=1, @@ -769,7 +775,6 @@ pybullet_getJointInfo(PyObject* self, PyObject* args) // info.m_flags, // info.m_jointDamping, // info.m_jointFriction); - PyTuple_SetItem(pyListJointInfo, 0, PyInt_FromLong(info.m_jointIndex)); PyTuple_SetItem(pyListJointInfo, 1, @@ -786,7 +791,6 @@ pybullet_getJointInfo(PyObject* self, PyObject* args) PyFloat_FromDouble(info.m_jointDamping)); PyTuple_SetItem(pyListJointInfo, 7, PyFloat_FromDouble(info.m_jointFriction)); - return pyListJointInfo; } }