Exemplo n.º 1
0
void dgBody::Serialize (const dgTree<dgInt32, const dgCollision*>& collisionRemapId, dgSerialize serializeCallback, void* const userData)
{
	serializeCallback (userData, &m_rotation, sizeof (m_rotation));
	serializeCallback (userData, &m_matrix.m_posit, sizeof (m_matrix.m_posit));
	serializeCallback (userData, &m_veloc, sizeof (m_veloc));
	serializeCallback (userData, &m_omega, sizeof (m_omega));
	serializeCallback (userData, &m_localCentreOfMass, sizeof (m_localCentreOfMass));
	serializeCallback (userData, &m_aparentMass, sizeof (m_aparentMass));
	serializeCallback (userData, &m_flags, sizeof (m_flags));
	serializeCallback (userData, &m_maxAngulaRotationPerSet2, sizeof (m_maxAngulaRotationPerSet2));

	dgTree<dgInt32, const dgCollision*>::dgTreeNode* const node = collisionRemapId.Find(m_collision->GetChildShape());
	dgAssert (node);

	dgInt32 id = node->GetInfo();
	serializeCallback (userData, &id, sizeof (id));
	m_collision->Serialize(serializeCallback, userData, false);
}
Exemplo n.º 2
0
void dgWorld::DeserializeJointArray (const dgTree<dgBody*, dgInt32>&bodyMap, dgDeserialize serializeCallback, void* const userData)
{
	dgInt32 count = 0;

	dgDeserializeMarker (serializeCallback, userData);
	serializeCallback(userData, &count, sizeof (count));	

	for (dgInt32 i = 0; i < count; i ++) {
		if (m_deserializedJointCallback) {
			dgInt32 bodyIndex0; 
			dgInt32 bodyIndex1; 

			serializeCallback(userData, &bodyIndex0, sizeof (bodyIndex0));
			serializeCallback(userData, &bodyIndex1, sizeof (bodyIndex1));

			dgBody* const body0 = (bodyIndex0 != -1) ? bodyMap.Find (bodyIndex0)->GetInfo() : NULL;
			dgBody* const body1 = (bodyIndex1 != -1) ? bodyMap.Find (bodyIndex1)->GetInfo() : NULL;
			m_deserializedJointCallback (body0, body1, serializeCallback, userData);
		}
		dgDeserializeMarker(serializeCallback, userData);
	}

	dgDeserializeMarker(serializeCallback, userData);
}