MCPcopy Create free account
hub / github.com/bulletphysics/bullet3 / addUserData

Method addUserData

examples/SharedMemory/PhysicsServerCommandProcessor.cpp:3152–3182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3150}
3151
3152int PhysicsServerCommandProcessor::addUserData(int bodyUniqueId, int linkIndex, int visualShapeIndex, const char* key, const char* valueBytes, int valueLength, int valueType)
3153{
3154 InternalBodyData* body = m_data->m_bodyHandles.getHandle(bodyUniqueId);
3155 if (!body)
3156 {
3157 return -1;
3158 }
3159
3160 SharedMemoryUserDataHashKey userDataIdentifier(key, bodyUniqueId, linkIndex, visualShapeIndex);
3161
3162 int* userDataHandlePtr = m_data->m_userDataHandleLookup.find(userDataIdentifier);
3163 int userDataHandle = userDataHandlePtr ? *userDataHandlePtr : m_data->m_userDataHandles.allocHandle();
3164
3165 SharedMemoryUserData* userData = m_data->m_userDataHandles.getHandle(userDataHandle);
3166 if (!userData)
3167 {
3168 return -1;
3169 }
3170
3171 if (!userDataHandlePtr)
3172 {
3173 userData->m_key = key;
3174 userData->m_bodyUniqueId = bodyUniqueId;
3175 userData->m_linkIndex = linkIndex;
3176 userData->m_visualShapeIndex = visualShapeIndex;
3177 m_data->m_userDataHandleLookup.insert(userDataIdentifier, userDataHandle);
3178 body->m_userDataHandles.push_back(userDataHandle);
3179 }
3180 userData->replaceValue(valueBytes, valueLength, valueType);
3181 return userDataHandle;
3182}
3183
3184void PhysicsServerCommandProcessor::addUserData(const btHashMap<btHashString, std::string>& user_data_entries, int bodyUniqueId, int linkIndex, int visualShapeIndex)
3185{

Callers 12

testAddUserDataMethod · 0.80
testGetNumUserDataMethod · 0.80
testReplaceUserDataMethod · 0.80
testGetUserDataIdMethod · 0.80
testRemoveUserDataMethod · 0.80
testRemoveBodyMethod · 0.80
testMultipleBodiesMethod · 0.80
testMultipleLinksMethod · 0.80
testMultipleClientsMethod · 0.80
userData.pyFile · 0.80

Calls 10

replaceValueMethod · 0.80
c_strMethod · 0.80
getHandleMethod · 0.45
findMethod · 0.45
allocHandleMethod · 0.45
insertMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45
getKeyAtIndexMethod · 0.45
getAtIndexMethod · 0.45

Tested by 11

testAddUserDataMethod · 0.64
testGetNumUserDataMethod · 0.64
testReplaceUserDataMethod · 0.64
testGetUserDataIdMethod · 0.64
testRemoveUserDataMethod · 0.64
testRemoveBodyMethod · 0.64
testMultipleBodiesMethod · 0.64
testMultipleLinksMethod · 0.64
testMultipleClientsMethod · 0.64