How to clone all physics properties

anuwat_boy
Posts: 1
Joined: Mon Jan 19, 2015 5:20 am

How to clone all physics properties

Post by anuwat_boy »

Hi,

I am simulating adaptive movements of objects with various parameters. The system has many instances of dynamic world.
each dynamic world has same structure of rigid and collision objects.

My experiment is involving in an optimization system so it need to clone all dynamic world to the best dynamic world on the fly.

now I am trying to clone each object properties like below

Code: Select all

          btDefaultMotionState* dest_myMotionState = (btDefaultMotionState*)dest_body->getMotionState();
			btDefaultMotionState* src_myMotionState = (btDefaultMotionState*)src_body->getMotionState();
			dest_myMotionState->m_graphicsWorldTrans = src_myMotionState->m_graphicsWorldTrans;
			
			dest_body->setCenterOfMassTransform(src_body->getCenterOfMassTransform());						
			dest_body->setInterpolationWorldTransform( src_body->getInterpolationWorldTransform());
			dest_body->setWorldTransform( src_body->getWorldTransform());
			dest_body->forceActivationState( src_body->getActivationState());
			dest_body->setDeactivationTime(src_body->getDeactivationTime());	

			dest_body->setInterpolationAngularVelocity(src_body->getInterpolationAngularVelocity());
			dest_body->setInterpolationLinearVelocity(src_body->getInterpolationLinearVelocity());
			dest_body->getBroadphaseProxy()->m_aabbMax = src_body->getBroadphaseProxy()->m_aabbMax;
			dest_body->getBroadphaseProxy()->m_aabbMin = src_body->getBroadphaseProxy()->m_aabbMin;
			dest_body->setLinearVelocity(src_body->getLinearVelocity());
			dest_body->setAngularVelocity(src_body->getAngularVelocity());
			
			dest_body->updateInertiaTensor();

dest_dynamic_world->performDiscreteCollisionDetection();

... clone btScalar vertices by memcpy
The problem is it seems I still cannot clone correctly. It cannot give same result when I retest the optimizing result (No cloning).
What I am missing ?