Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Resetting scene
PostPosted: Wed May 23, 2012 9:45 pm 
Offline

Joined: Thu Mar 24, 2011 3:50 pm
Posts: 39
I'm trying to reset a scene without deleting the whole scene and creating it again. The problem is that the simulation is different every time I reset it.

What I've done is this:

Code:
for(;it!=bodies.end();++it)
    {
        btRigidBody *bb = (btRigidBody*)(*it)->physicsBody;
        //m_dynamicsWorld->removeRigidBody(bb);
        btTransform transform;
        transform.setIdentity();
        transform.setRotation(btQuaternion((*it)->orientation.x(),(*it)->orientation.y(),(*it)->orientation.z(),(*it)->orientation.w()));
        transform.setOrigin(btVector3(btScalar((*it)->position(0)),btScalar((*it)->position(1)),btScalar((*it)->position(2))));

        btMotionState * motion = bb->getMotionState();
        motion->setWorldTransform(transform);
        bb->setMotionState(motion);
        bb->clearForces();
        btVector3 z(0,0,0);
        bb->setAngularVelocity(z);
        bb->setLinearVelocity(z);
        bb->activate(true);

    }

    m_solver->reset();
    m_dynamicsWorld->clearForces();
    m_broadphase->resetPool(m_dispatcher);
    m_clock.reset();


Top
 Profile  
 
 Post subject: Re: Resetting scene
PostPosted: Tue Jun 12, 2012 2:08 am 
Offline

Joined: Tue May 29, 2012 1:51 pm
Posts: 4
I am trying to do the same thing you are, more or less.
I see you call reset on the solver and on the broad phase which I have not tried, so I'm going to try out some those calls in my own code and see if my results improve.

In my code, I am trying to figure out which behaviors are explained by the problem described in the link below, and which other behaviors are a result of me leaving out important steps of the reset process.

http://www.bulletphysics.org/Bullet/php ... tic#p27147

Please post back if you have found a solution/explanation.

Thanks,
Brian


Top
 Profile  
 
 Post subject: Re: Resetting scene
PostPosted: Tue Jun 12, 2012 6:36 am 
Offline
User avatar

Joined: Tue Mar 16, 2010 1:42 am
Posts: 57
As well as resetting the broadphase pool, I also clean out the overlapping pair cache:
Code:
btOverlappingPairCache* pair_cache = m_dynamics_world->getBroadphase()->getOverlappingPairCache();
btBroadphasePairArray& pair_array = pair_cache->getOverlappingPairArray();
for(int i = 0; i < pair_array.size(); i++)
    pair_cache->cleanOverlappingPair(pair_array[i], m_dynamics_world->getDispatcher());


If you are using softbodies with the SDF based rigid versus softbody collision method, then also reset that:
Code:
softbody_worldinfo.m_sparsesdf.Reset();


---JvdL---


Top
 Profile  
 
 Post subject: Re: Resetting scene
PostPosted: Mon Jun 25, 2012 1:41 pm 
Offline

Joined: Thu Mar 24, 2011 3:50 pm
Posts: 39
Wow, after so many days I wasn't expecting any answers.

Thanks! I'll try it out tonight, and post the result.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group