summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerwincoumans <erwin.coumans@gmail.com>2018-06-05 09:16:00 -0700
committererwincoumans <erwin.coumans@gmail.com>2018-06-05 09:16:00 -0700
commitfa648a028ec01b8d4fe80d865afc76cbf7e58a5d (patch)
tree70cb75aeb3a11558b34c77af2bbbfa362af239a2
parentd7cbe8dd267de293f08d62c140953229257786ab (diff)
downloadbullet3-fa648a028ec01b8d4fe80d865afc76cbf7e58a5d.tar.gz
fix a few problems introduced in #1730
https://github.com/bulletphysics/bullet3/pull/1730
-rw-r--r--examples/pybullet/pybullet.c27
-rw-r--r--src/LinearMath/btHashMap.h30
2 files changed, 22 insertions, 35 deletions
diff --git a/examples/pybullet/pybullet.c b/examples/pybullet/pybullet.c
index 9bc834204..e89724b61 100644
--- a/examples/pybullet/pybullet.c
+++ b/examples/pybullet/pybullet.c
@@ -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));
diff --git a/src/LinearMath/btHashMap.h b/src/LinearMath/btHashMap.h
index 7965c11f6..180e7b44a 100644
--- a/src/LinearMath/btHashMap.h
+++ b/src/LinearMath/btHashMap.h
@@ -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;