Bounciness of Slider Constraint

mathis
Posts: 16
Joined: Tue Sep 01, 2009 3:49 pm
Location: Germany

Bounciness of Slider Constraint

Post by mathis »

I am testing the slider constraint, and I would like to have a bouncing behaviour. I played with the parameters, but couldn't find a satisfying set-up. Then I played with the code, and I can get a bouncing behaviour if I remove the conditions (vel < 0) and (newc > info->m_constraintError[srow]) when the constraint error for the slider axis is computed (lines starting with ////):

Code: Select all

			if(bounce > btScalar(0.0))
			{
				btScalar vel = linVelA.dot(ax1);
				vel -= linVelB.dot(ax1);
				vel *= signFact;
				// only apply bounce if the velocity is incoming, and if the
				// resulting c[] exceeds what we already have.
				if(limit == 1)
				{	// low limit
					////if(vel < 0)
					{
						btScalar newc = -bounce * vel;
						////if (newc > info->m_constraintError[srow])
						{
							info->m_constraintError[srow] = newc;
						}
					}
				}
				else
				{ // high limit - all those computations are reversed
					////if(vel > 0)
					{
						btScalar newc = -bounce * vel;
						////if(newc < info->m_constraintError[srow]) 
						{
							info->m_constraintError[srow] = newc;
						}
					}
				}
			}
Why is the bounciness only applied for incoming velocity? I mean, then the "collision" at the limit has already occured, but usually the bounciness shall control the collision?

BTW: Most of the slider parameters are only used in the obsolete constraint methods.
fishboy82
Posts: 91
Joined: Wed Jun 10, 2009 4:01 am

Re: Bounciness of Slider Constraint

Post by fishboy82 »

It's natrual because if the current relative velocity is outward the limit then the bounce velocity will be toward the limit this will make the limit more deep but not leave the limit. So th bouncy should applied for incoming velocity
mathis
Posts: 16
Joined: Tue Sep 01, 2009 3:49 pm
Location: Germany

Re: Bounciness of Slider Constraint

Post by mathis »

Thanks for the explanation! But still the question remains why I cannot get a bouncing behaviour with the current implementation, and why it works fine when I remove the conditions?