The clearForces in btDiscreteDynamicsWorld::stepSimulation

Post Reply
Adversus
Posts: 19
Joined: Mon Nov 10, 2008 11:24 am

The clearForces in btDiscreteDynamicsWorld::stepSimulation

Post by Adversus »

At the very bottom there's a few lines of code that read

Code: Select all

	synchronizeMotionStates();

	clearForces();

#ifndef BT_NO_PROFILE
	CProfileManager::Increment_Frame_Counter();
#endif //BT_NO_PROFILE
	
	return numSimulationSubSteps;
I get my callback before this however if I apply a few forces in this callback (e.g. based on collision detection) they will get cleared before they have a chance to be applied.

Is there any solution for this?
ola
Posts: 169
Joined: Sun Jan 14, 2007 7:56 pm
Location: Norway
Contact:

Re: The clearForces in btDiscreteDynamicsWorld::stepSimulation

Post by ola »

I think you can use a pre-tick callback, see this article: (there is a preTick = true argument)
http://bulletphysics.org/mediawiki-1.5. ... _Callbacks

You can add both a pre-tick callback function and a post-tick callback.

The actual code executing this is found in btDiscreteDynamicsWorld::internalSingleStepSimulation:

Code: Select all

void	btDiscreteDynamicsWorld::internalSingleStepSimulation(btScalar timeStep)
{
	
	BT_PROFILE("internalSingleStepSimulation");

	if(0 != m_internalPreTickCallback) {
		(*m_internalPreTickCallback)(this, timeStep);
	}	

	///apply gravity, predict motion
	predictUnconstraintMotion(timeStep);

	btDispatcherInfo& dispatchInfo = getDispatchInfo();

	dispatchInfo.m_timeStep = timeStep;
	dispatchInfo.m_stepCount = 0;
	dispatchInfo.m_debugDraw = getDebugDrawer();

	///perform collision detection
	performDiscreteCollisionDetection();

	calculateSimulationIslands();

	
	getSolverInfo().m_timeStep = timeStep;
	


	///solve contact and other joint constraints
	solveConstraints(getSolverInfo());
	
	///CallbackTriggers();

	///integrate transforms
	integrateTransforms(timeStep);

	///update vehicle simulation
	updateActions(timeStep);
	
	updateActivationState( timeStep );

	if(0 != m_internalTickCallback) {
		(*m_internalTickCallback)(this, timeStep);
	}	
}
Cheers, Ola
Post Reply