mirror of
https://github.com/bulletphysics/bullet3
synced 2025-01-18 21:10:05 +00:00
fix a few problems introduced in #1730
https://github.com/bulletphysics/bullet3/pull/1730
This commit is contained in:
parent
d7cbe8dd26
commit
fa648a028e
@ -680,7 +680,8 @@ static PyObject* pybullet_syncUserData(PyObject* self, PyObject* args, PyObject*
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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)) {
|
||||
Py_RETURN_NONE;
|
||||
|
||||
PyErr_SetString(SpamError, "Cannot get user data");
|
||||
return NULL;
|
||||
}
|
||||
switch (value.m_type) {
|
||||
case USER_DATA_VALUE_TYPE_STRING:
|
||||
return PyString_FromString((const char *)value.m_data1);
|
||||
default:
|
||||
PyErr_SetString(SpamError, "User data value has unknown type");
|
||||
return NULL;
|
||||
if (value.m_type != USER_DATA_VALUE_TYPE_STRING)
|
||||
{
|
||||
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)
|
||||
@ -884,8 +888,9 @@ static PyObject* pybullet_getUserDataInfo(PyObject* self, PyObject* args, PyObje
|
||||
b3GetUserDataInfo(sm, bodyUniqueId, linkIndex, userDataIndex, &key, &userDataId);
|
||||
if (key == 0 || userDataId == -1) {
|
||||
PyErr_SetString(SpamError, "Could not get user data info.");
|
||||
Py_RETURN_NONE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
{
|
||||
PyObject *userDataInfoTuple = PyTuple_New(2);
|
||||
PyTuple_SetItem(userDataInfoTuple, 0, PyInt_FromLong(userDataId));
|
||||
|
@ -23,7 +23,7 @@ subject to the following restrictions:
|
||||
///very basic hashable string implementation, compatible with btHashMap
|
||||
struct btHashString
|
||||
{
|
||||
std::string m_string;
|
||||
std::string m_string1;
|
||||
unsigned int m_hash;
|
||||
|
||||
SIMD_FORCE_INLINE unsigned int getHash()const
|
||||
@ -33,11 +33,11 @@ struct btHashString
|
||||
|
||||
btHashString()
|
||||
{
|
||||
m_string="";
|
||||
m_string1="";
|
||||
m_hash=0;
|
||||
}
|
||||
btHashString(const char* name)
|
||||
:m_string(name)
|
||||
:m_string1(name)
|
||||
{
|
||||
/* magic numbers from http://www.isthe.com/chongo/tech/comp/fnv/ */
|
||||
static const unsigned int InitialFNV = 2166136261u;
|
||||
@ -46,36 +46,18 @@ struct btHashString
|
||||
/* Fowler / Noll / Vo (FNV) Hash */
|
||||
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 */
|
||||
}
|
||||
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
|
||||
{
|
||||
return (m_string == other.m_string) ||
|
||||
(0==portableStringCompare(m_string.c_str(),other.m_string.c_str()));
|
||||
|
||||
return (m_string1 == other.m_string1);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
const int BT_HASH_NULL=0xffffffff;
|
||||
|
Loading…
Reference in New Issue
Block a user