mirror of
https://github.com/bulletphysics/bullet3
synced 2025-01-18 21:10:05 +00:00
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)
This commit is contained in:
parent
df0b2a2e3a
commit
f5ffb11bc5
@ -66,17 +66,18 @@ static GLInstanceGraphicsShape* LoadMeshFromSTL(const char* relativeFileName)
|
||||
for (int i=0;i<numTriangles;i++)
|
||||
{
|
||||
char* curPtr = &memoryBuffer[84+i*50];
|
||||
MySTLTriangle* tri = (MySTLTriangle*) curPtr;
|
||||
MySTLTriangle tmp;
|
||||
memcpy(&tmp,curPtr,sizeof(MySTLTriangle));
|
||||
|
||||
GLInstanceVertex v0,v1,v2;
|
||||
v0.uv[0] = v1.uv[0] = v2.uv[0] = 0.5;
|
||||
v0.uv[1] = v1.uv[1] = v2.uv[1] = 0.5;
|
||||
for (int v=0;v<3;v++)
|
||||
{
|
||||
v0.xyzw[v] = tri->vertex0[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;
|
||||
|
||||
|
@ -9,6 +9,12 @@
|
||||
#include <Python.h>
|
||||
#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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user