no bounce

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
wizzy123
Posts: 1
Joined: Fri Jun 18, 2010 1:39 pm

no bounce

Post by wizzy123 »

Hi,

first of all great product!

I have nodified the BasicSetupDemo source to have a couple of bars fall down on top of each other. To problem is that the last bars jump up (bounce). Is it possible to suppress this?
I know that there are a lot of settings that I can tweak the physics with ...

in the BasicSetupGame.cs i have nodified this:

LoadContent() methode
Remove:

Code: Select all

space.add(new Box(new Vector3(0, 4, 0), 1, 1, 1, 1));
space.add(new Box(new Vector3(0, 8, 0), 1, 1, 1, 1));
space.add(new Box(new Vector3(0, 12, 0), 1, 1, 1, 1));
Replace with:

Code: Select all

			
			//Create bars
			float Height = 5;
			bool Switch = true;
			int mass = 1;
			float Size = 1;
			float Space = 0.25f;
			float lengte = Size * 3 + Space * 2;
			for (int iCounter = 1; iCounter < 5; iCounter++)
			{
				if (Switch)
				{
					space.add(new Box(new Vector3(0, Height, 0), 1, 1, lengte, mass));
					space.add(new Box(new Vector3(1.25f, Height, 0), 1, 1, lengte, mass));
					space.add(new Box(new Vector3(2.5f, Height, 0), 1, 1, lengte, mass));
				}
				else
				{
					space.add(new Box(new Vector3(1.25f, Height, 1.25f), lengte, 1, 1, mass));
					space.add(new Box(new Vector3(1.25f, Height, 0), lengte, 1, 1, mass));
					space.add(new Box(new Vector3(1.25f, Height, -1.25f), lengte, 1, 1, mass));
				}
				Height += 3f;
				Switch = !Switch;
			}

I have have added

Code: Select all

box.collisionMargin = 0f
in the foreach loop.

Code: Select all

			foreach (Entity e in space.entities)
			{
				Box box = e as Box;
				if (box != null) //This won't create any graphics for an entity that isn't a box since the model being used is a box.
				{
					box.collisionMargin = 0f;
Matrix scaling = Matrix.CreateScale(box.width, box.height, box.length); //Since the cube model is 1x1x1, it needs to be scaled to match the size of each individual box.
					//Add the drawable game component for this entity to the game.
					Components.Add(new EntityModel(e, cubeModel, scaling, this));
				}
			}
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: no bounce

Post by Norbo »

The BasicSetupDemo is currently running under an earlier version of BEPUphysics, since the covered material hasn't changed. However, the newest version of BEPUphysics may provide better behavior.

As far as other tweaks go, most of the bounce in the newest version of the engine is related to position correction. When objects interpenetrate, the engine applies an extra push to get them apart. In tall stacks, this small bounce can propagate into a larger one. The speed and strength of this push can be changed using these settings:

Code: Select all

space.simulationSettings.collisionResponse.maximumPositionCorrectionSpeed
space.simulationSettings.collisionResponse.penetrationRecoveryStiffness
To keep things from slowly sifting through each other, some amount of position correction is necessary, so I wouldn't recommend totally turning it off.

I strongly recommend not reducing the collision margin to 0. It won't change the bounce much (if any), and collision margins are required for some collision detection systems to be efficient. More information can be found here: http://www.bepu-games.com/forums/viewto ... 409&p=4181
Post Reply