Hello,
in my Fracture Modifier Compound implementation (which unfortunately works only partially, as in not good controllable)
I created a btHashMap of ObjectID and ShardID as key (combined string) and stored the shape indexes there.... 
to be able to track which shard ids map to which shape indexes.
(i use a subclass of btDynamicsWorld ... btFractureDynamicsWorld)
btw m_idCallback calls a blender function which returns the shard and object IDs...
see for example here
https://developer.blender.org/diffusion ... d26f63$493
This is added to the btFractureDynamicsWorld...
Code: Select all
m_childIndexHash = new btHashMap<btHashString, int>();
Here I populate the hashmap...
Code: Select all
...
			for (int i=0; i<numChildren; i++)
			{
				int obIndex, shIndex;
				btCollisionShape *cshape = newCompound->getChildShape(i);
				m_idCallback(cshape->getUserPointer(), &obIndex, &shIndex);
				m_childIndexHash->insert(to_str(obIndex, shIndex), i);
			}
			newBody->recomputeConnectivityByConstraints(this);
...
See also this file...
https://developer.blender.org/diffusion ... 1d26f63$91
Here I access this hashmap "m_childIndexHash" like following...
Code: Select all
void btFractureBody::recomputeConnectivityByConstraints(btCollisionWorld *world1)
{
	btFractureDynamicsWorld *world = (btFractureDynamicsWorld*)world1;
	if (world->m_idCallback != NULL)
	{
		int i, size = world->m_compoundConstraints.size();
		m_connections.clear();
		for (i=0; i<size;i++)
		{
			btCompoundConstraint *con = world->m_compoundConstraints[i];
			if (con->isEnabled())
			{
				int obIdA, shardIdA, obIdB, shardIdB;
				btFractureBody *obA = (btFractureBody*)&con->getRigidBodyA();
				btFractureBody *obB = (btFractureBody*)&con->getRigidBodyB();
				//if (this == obA || this == obB)
				{
					int *index0 = NULL, *index1 = NULL;
					world->m_idCallback(obA->getUserPointer(), &obIdA, &shardIdA);
					world->m_idCallback(obB->getUserPointer(), &obIdB, &shardIdB);
					index0 = world->m_childIndexHash->find(to_str(obIdA, shardIdA));
					index1 = world->m_childIndexHash->find(to_str(obIdB, shardIdB));
					if ((obIdA == obIdB) && (shardIdA != shardIdB) &&
					    index0 && index1 && *index0 > -1 && *index1 > -1)
					{
						btConnection tmp;
						tmp.m_childIndex0 = *index0;
						tmp.m_childIndex1 = *index1;
						tmp.m_childShape0 = obA->getCollisionShape();
						tmp.m_childShape1 = obB->getCollisionShape();
						tmp.m_strength = con->getBreakingImpulseThreshold();
						tmp.m_obA = obA;
						tmp.m_obB = obB;
						tmp.m_parent = this;
						tmp.m_id = i;
						m_connections.push_back(tmp);
					}
					//break;
				}
			}
		}
		m_connections.quickSort(btConnectionSortPredicate());
		//build a connection map
		m_connection_map->clear();
		size = m_connections.size();
		for (i=0; i < size; i++)
		{
			btConnection& con = m_connections[i];
			btAlignedObjectArray<int> *adjacents = m_connection_map->find(con.m_childIndex0);
			if (!adjacents) {
				btAlignedObjectArray<int> adj;
				adj.push_back(con.m_childIndex1);
				m_connection_map->insert(con.m_childIndex0, adj);
			}
			else
			{
				if (adjacents->size() != adjacents->findLinearSearch(con.m_childIndex1))
					adjacents->push_back(con.m_childIndex1);
			}
		}
	}
}
Thats the general idea how i map shape indexes to shards.
Hope this helps you a bit.
Greetings, scorpion81