fix a few problems introduced in #1730
https://github.com/bulletphysics/bullet3/pull/1730
This commit is contained in:
@@ -680,7 +680,8 @@ static PyObject* pybullet_syncUserData(PyObject* self, PyObject* args, PyObject*
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_RETURN_NONE;
|
Py_INCREF(Py_None);
|
||||||
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject* pybullet_addUserData(PyObject* self, PyObject* args, PyObject* keywds)
|
static PyObject* pybullet_addUserData(PyObject* self, PyObject* args, PyObject* keywds)
|
||||||
@@ -756,9 +757,10 @@ static PyObject* pybullet_removeUserData(PyObject* self, PyObject* args, PyObjec
|
|||||||
if (statusType != CMD_REMOVE_USER_DATA_COMPLETED)
|
if (statusType != CMD_REMOVE_USER_DATA_COMPLETED)
|
||||||
{
|
{
|
||||||
PyErr_SetString(SpamError, "Error in removeUserData command.");
|
PyErr_SetString(SpamError, "Error in removeUserData command.");
|
||||||
Py_RETURN_FALSE;
|
return NULL;
|
||||||
}
|
}
|
||||||
Py_RETURN_TRUE;
|
Py_INCREF(Py_None);
|
||||||
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -817,15 +819,17 @@ static PyObject* pybullet_getUserData(PyObject* self, PyObject* args, PyObject*
|
|||||||
|
|
||||||
|
|
||||||
if (!b3GetUserData(sm, bodyUniqueId, linkIndex, userDataId, &value)) {
|
if (!b3GetUserData(sm, bodyUniqueId, linkIndex, userDataId, &value)) {
|
||||||
Py_RETURN_NONE;
|
|
||||||
|
PyErr_SetString(SpamError, "Cannot get user data");
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
switch (value.m_type) {
|
if (value.m_type != USER_DATA_VALUE_TYPE_STRING)
|
||||||
case USER_DATA_VALUE_TYPE_STRING:
|
{
|
||||||
return PyString_FromString((const char *)value.m_data1);
|
PyErr_SetString(SpamError, "User data value has unknown type");
|
||||||
default:
|
return NULL;
|
||||||
PyErr_SetString(SpamError, "User data value has unknown type");
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return PyString_FromString((const char *)value.m_data1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject* pybullet_getNumUserData(PyObject* self, PyObject* args, PyObject* keywds)
|
static PyObject* pybullet_getNumUserData(PyObject* self, PyObject* args, PyObject* keywds)
|
||||||
@@ -884,8 +888,9 @@ static PyObject* pybullet_getUserDataInfo(PyObject* self, PyObject* args, PyObje
|
|||||||
b3GetUserDataInfo(sm, bodyUniqueId, linkIndex, userDataIndex, &key, &userDataId);
|
b3GetUserDataInfo(sm, bodyUniqueId, linkIndex, userDataIndex, &key, &userDataId);
|
||||||
if (key == 0 || userDataId == -1) {
|
if (key == 0 || userDataId == -1) {
|
||||||
PyErr_SetString(SpamError, "Could not get user data info.");
|
PyErr_SetString(SpamError, "Could not get user data info.");
|
||||||
Py_RETURN_NONE;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
PyObject *userDataInfoTuple = PyTuple_New(2);
|
PyObject *userDataInfoTuple = PyTuple_New(2);
|
||||||
PyTuple_SetItem(userDataInfoTuple, 0, PyInt_FromLong(userDataId));
|
PyTuple_SetItem(userDataInfoTuple, 0, PyInt_FromLong(userDataId));
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ subject to the following restrictions:
|
|||||||
///very basic hashable string implementation, compatible with btHashMap
|
///very basic hashable string implementation, compatible with btHashMap
|
||||||
struct btHashString
|
struct btHashString
|
||||||
{
|
{
|
||||||
std::string m_string;
|
std::string m_string1;
|
||||||
unsigned int m_hash;
|
unsigned int m_hash;
|
||||||
|
|
||||||
SIMD_FORCE_INLINE unsigned int getHash()const
|
SIMD_FORCE_INLINE unsigned int getHash()const
|
||||||
@@ -33,11 +33,11 @@ struct btHashString
|
|||||||
|
|
||||||
btHashString()
|
btHashString()
|
||||||
{
|
{
|
||||||
m_string="";
|
m_string1="";
|
||||||
m_hash=0;
|
m_hash=0;
|
||||||
}
|
}
|
||||||
btHashString(const char* name)
|
btHashString(const char* name)
|
||||||
:m_string(name)
|
:m_string1(name)
|
||||||
{
|
{
|
||||||
/* magic numbers from http://www.isthe.com/chongo/tech/comp/fnv/ */
|
/* magic numbers from http://www.isthe.com/chongo/tech/comp/fnv/ */
|
||||||
static const unsigned int InitialFNV = 2166136261u;
|
static const unsigned int InitialFNV = 2166136261u;
|
||||||
@@ -46,36 +46,18 @@ struct btHashString
|
|||||||
/* Fowler / Noll / Vo (FNV) Hash */
|
/* Fowler / Noll / Vo (FNV) Hash */
|
||||||
unsigned int hash = InitialFNV;
|
unsigned int hash = InitialFNV;
|
||||||
|
|
||||||
for(int i = 0; m_string[i]; i++)
|
for(int i = 0; m_string1.c_str()[i]; i++)
|
||||||
{
|
{
|
||||||
hash = hash ^ (m_string[i]); /* xor the low 8 bits */
|
hash = hash ^ (m_string1.c_str()[i]); /* xor the low 8 bits */
|
||||||
hash = hash * FNVMultiple; /* multiply by the magic number */
|
hash = hash * FNVMultiple; /* multiply by the magic number */
|
||||||
}
|
}
|
||||||
m_hash = hash;
|
m_hash = hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
int portableStringCompare(const char* src, const char* dst) const
|
|
||||||
{
|
|
||||||
int ret = 0 ;
|
|
||||||
|
|
||||||
while( ! (ret = *(const unsigned char *)src - *(const unsigned char *)dst) && *dst)
|
|
||||||
++src, ++dst;
|
|
||||||
|
|
||||||
if ( ret < 0 )
|
|
||||||
ret = -1 ;
|
|
||||||
else if ( ret > 0 )
|
|
||||||
ret = 1 ;
|
|
||||||
|
|
||||||
return( ret );
|
|
||||||
}
|
|
||||||
|
|
||||||
bool equals(const btHashString& other) const
|
bool equals(const btHashString& other) const
|
||||||
{
|
{
|
||||||
return (m_string == other.m_string) ||
|
return (m_string1 == other.m_string1);
|
||||||
(0==portableStringCompare(m_string.c_str(),other.m_string.c_str()));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const int BT_HASH_NULL=0xffffffff;
|
const int BT_HASH_NULL=0xffffffff;
|
||||||
|
|||||||
Reference in New Issue
Block a user