Problem Setting Bounciness

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
piotre_005
Posts: 7
Joined: Wed Nov 20, 2013 7:16 pm

Problem Setting Bounciness

Post by piotre_005 »

Hello,

i have a Problem with Setting Material Settings Correctly.
We create the Space in the Project with Parrallel Looper by Processor Count. And Update the Physik in a seperate Thread.
Everything we put for "Material.Friciton" ore "Material.Bounciness" is not realy working. When we Debug it the Material is setted Correctly.

We tested this in the Multithreading Demo and in the Updating Asynchronously Demo
[Inserting only one box with a new Material of (0,0,1f) bevore adding it to the space]
The Box doesn't bounce ...

In the CoefficientsDemo we found the "MaterialManager.MaterialBlender = delegate....." and we tryed it with this.....
When we Debugged it we found out that this is called twice by one hit of the Floor. For a better Tracking we added in the "Material.Tag" a indicator to each object
we insert in the space. The first time the delegate is called its with the expected tags and Material options but then the second time the tag is null and
the Materials are 0. When we set the properties.Bounciness for example fixed to 1 it*s jumping. But we need different frictions for the stuff we have in
the Simulation...

Hope that anybody can help ;)

And thanks for that greate Invention we realy like it !!!!
Best wishes from Bavaria :)
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Problem Setting Bounciness

Post by Norbo »

We tested this in the Multithreading Demo and in the Updating Asynchronously Demo
[Inserting only one box with a new Material of (0,0,1f) bevore adding it to the space]
The Box doesn't bounce ...
The default bounciness (and friction) blending is multiplicative, so if one of the two involved objects in a collision has 0 bounciness, the resulting bounciness for the collision will be 0.
In the CoefficientsDemo we found the "MaterialManager.MaterialBlender = delegate....." and we tryed it with this.....
When we Debugged it we found out that this is called twice by one hit of the Floor. For a better Tracking we added in the "Material.Tag" a indicator to each object
we insert in the space. The first time the delegate is called its with the expected tags and Material options but then the second time the tag is null and
the Materials are 0. When we set the properties.Bounciness for example fixed to 1 it*s jumping. But we need different frictions for the stuff we have in
the Simulation...
I'm not following what's happening here exactly. It sounds like there's another unrelated collision happening. In the CoefficientsDemo, if everything but the ground and one bouncy sphere is removed, the delegate only fires one time for each collision with expected results. If you're seeing differently, could you reproduce the issue in the demo and show me the demo code?

By the way, it's possible to use the MaterialManager.MaterialInteractions dictionary to define the behavior between materials explicitly without doing any blending operation. Also note that Material instances can be shared between multiple objects.
piotre_005
Posts: 7
Joined: Wed Nov 20, 2013 7:16 pm

Re: Problem Setting Bounciness

Post by piotre_005 »

Hello sorry that it take so long to replay to your answer...

The Problem is that we use CompundBody ... and where now able to reproduce the problem in on of you examples for that
we only created somehting like that:

Code: Select all

   Space = new Space(parallelLooper);
            //Space = new Space();
            Space.ForceUpdater.Gravity = new Vector3(0, -9.81f, 0);
            Entity Floor = new Box(Vector3.Zero, 30, 1, 30);
            Floor.Material = new Material(0,0,2);
            Space.Add(Floor);

            //Create a singel Box
            Entity Test = new Box(new Vector3(-10,0,0), 1, 1, 1, 1);
            Test.Material = new BEPUphysics.Materials.Material(0, 0, 1);
            Space.Add(Test);


            List<CompoundShapeEntry> ShapeList = new List<CompoundShapeEntry>();
            BoxShape toAdd = new BoxShape(5, 5, 5);
            ShapeList.Add(new CompoundShapeEntry(toAdd, new Vector3(0, 50, 0)));
            Entity myEntity = new CompoundBody(ShapeList, 10);
            myEntity.Material = new Material(0, 0, 1);
            Space.Add(myEntity);

            ModelDrawer.Add(toAdd);

Then the Result is that the "normal Box is Jumping" but the CompoundBody is not Jumping (So it's not Bouncing...)
Hope now you know what the problem is for use in the momenent.
The models we use are only realy dicripeable with the CompundBody because it contains from many parts .....
Is it only a problem with the Bouncines oder is it also with the friction then ??

Thx for you Help :)
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Problem Setting Bounciness

Post by Norbo »

Each compound child has its own material property (compoundEntity.CollisionInformation.Children.Material) which overrides the entity's material if present. If the child's material is null, it uses the compoundEntity.Material as a fallback.

Unfortunately, the CompoundCollidable did something a little unintuitive: it filled all the child materials with the the entity's initial material. The entity's initial material is the default material, so it didn't bounce.

To work around that behavior, you can explicitly set a child's material to null to force it to fall back to the parent entity's material, or set the child's material to the desired behavior. For example:

Code: Select all

compound.CollisionInformation.Children[0].Material = null;
I also removed the parent material propagation behavior in the latest changeset so that this workaround is not necessary.
Post Reply