resititution and friction don't work

lsgmasa
Posts: 8
Joined: Thu Dec 06, 2007 7:10 pm

resititution and friction don't work

Post by lsgmasa »

I am using bullet ver 2.64.
When I use SpuGatheringCollisionDispatcher and btParallelSequentialImpulseSolver on Win32/Xbox360, I couldn't change the friction and restitution of rigid body at all no matter what values I use for btRigidBody constructor. I realized the m_combinedFriction and m_combinedRestitution are hard-coded and I couldn't change the behavior of rigid body even if I change the values. I looked at the code base, and realized that m_combinedFriction and m_combinedRestitution in SpuContactResult.cpp line 138 are hard-coded, and the code ignores the values stored in btCollisionObjects.

Code: Select all

#ifdef DEBUG_SPU_COLLISION_DETECTION
		spu_printf("SPU: same contact detected, nothing done\n");
#endif //DEBUG_SPU_COLLISION_DETECTION
		// This is not needed, just use the old info! saves a DMA transfer as well
	} else
	{

		newPt.m_combinedFriction = 0.25f;//calculateCombinedFriction(m_body0,m_body1);
		newPt.m_combinedRestitution = 0.0f;//calculateCombinedRestitution(m_body0,m_body1);
I tried to fix this by calculating combinedFriction & combinnedRestitution:

Code: Select all

#ifdef DEBUG_SPU_COLLISION_DETECTION
		spu_printf("SPU: same contact detected, nothing done\n");
#endif //DEBUG_SPU_COLLISION_DETECTION
		// This is not needed, just use the old info! saves a DMA transfer as well
	} else
	{
        btCollisionObject* body0 = (btCollisionObject*)manifoldPtr->getBody0();
        btCollisionObject* body1 = (btCollisionObject*)manifoldPtr->getBody1();

		newPt.m_combinedFriction = calculateCombinedFriction(body0,body1);
		newPt.m_combinedRestitution = calculateCombinedRestitution(body0,body1);
with this hack, now I can use SpuGatheringCollisionDispatcher instead of btCollisionDispatcher, and the result is good.
However, If I use btParallelSequentialImpulseSolver instead of btSequentialImpulseConstraintSolver, the restitution value seems ignored again.

I am planing to use Bullet on PS3 and Xbox360, and it is very important to utilize multiple cpu cores. So if you can fix this or give me some hints to correct this, that would be great.

Thanks in advance, Masaki
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: resititution and friction don't work

Post by Erwin Coumans »

Several features have not been ported to the parallel version yet, and they will be added at request.

I'll make sure to that friction and restitution will work in the parallel version of Bullet 2.65 (SpuGatheringCollisionDispatcher + btParallelSequentialImpulseSolver), hopefully within a few days.

Thanks for the feedback,
Erwin
lsgmasa
Posts: 8
Joined: Thu Dec 06, 2007 7:10 pm

Re: resititution and friction don't work

Post by lsgmasa »

Thank you. I will be waiting for the next release :)
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: resititution and friction don't work

Post by Erwin Coumans »

Friction and restitution has been fixed in BulletMultiThreaded.

The btParallelSequentialImpulseSolver is unfortunately mostly duplicated code from btSequentialImpulseConstraintSolver, and some of the fixes were not applied. Main issue was setting constraint.m_penetration to zero, instead of restitution, in the snippet below.

Code: Select all

	btScalar penVel = -constraint.m_penetration/taskDesc.m_commandData.m_manifoldSetup.m_solverInfo.m_timeStep;
									constraint.m_penetration *= 
										-(taskDesc.m_commandData.m_manifoldSetup.m_solverInfo.m_erp/taskDesc.m_commandData.m_manifoldSetup.m_solverInfo.m_timeStep);
								
									if (rest > penVel)
									{
										constraint.m_penetration = btScalar(0.);
									}
The fixes are included in Bullet 2.65 beta 2

More work is needed for BulletMultiThreaded, so any feedback/contributions are welcome!
Hope this helps,
Erwin