strange surface behaviour

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Nablabla
Posts: 14
Joined: Wed Mar 18, 2015 12:36 am

strange surface behaviour

Post by Nablabla »

Hi, I ran into a problem:
I have added things into the physics Space to form the worlds obstacles, like walls and floor. They are all put into an Entity as elements of a compoundShapes with mass 0.0f.
And I have a box which I can move around by applying forces upon it (similar to the characterController).
This works fine on these objects.
But then I add some more objects in the same manner and on those objects the box gets very 'sticky'.
I checked the debug draw and everything seems to be fine (no out of place/overlapping).

This is how I add the things, which work fine:

Code: Select all

using Microsoft.Xna.Framework;
using BEPUphysics.CollisionShapes;
using BEPUphysics.CollisionShapes.ConvexShapes;
using BEPUphysics.Entities;
...
var shapes = new List<CompoundShapeEntry>();

for (each of some 'size' and 'trans' I defined)
{
  Vector3 pos = trans.Translation;
  Quaternion orientation = Quaternion.CreateFromRotationMatrix(trans);
  var box = new BoxShape(size.X, size.Y, size.Z);               
  shapes.Add(new CompoundShapeEntry(box, new BEPUutilities.RigidTransform(pos, orientation)));
}

Xna.Vector3 centerOffset;
CompoundShape compoundShape = new CompoundShape(shapes, out centerOffset);
var rigidBody = new Entity(compoundShape, 0.0f);
rigidBody.Position = centerOffset;
_physicSpace.Add(rigidBody);
DebugDrawer.Add(rigidBody);
Ok I just figured, that the other (problematic) obejcts are added in the same way (by the same code)
the only difference is that they are put into other lists of shapes and added afterwords, but again by the very same code. Is there any restriction that there can only be one object with mass 0.0f?
What else can mess up the contact/friction behavior?

Best regards,
Nablabla

== Edit ==
my box slides over all of the compoundShape entity, very slippery, but on some it seems to be glued to
To define "sticky": It does turn a bit (so the force is defenitely present) but it hangs on its edges, which are not moving at all, not even drifting.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: strange surface behaviour

Post by Norbo »

The behavior which sounds most similar to what you describe is the lack of boundary smoothing between objects. If there are two boxes next to each other, a third box sliding on top can hit the border between the two boxes because there's nothing stopping a contact from being generated with the side of the box.

Triangle meshes jump through some pretty complicated hoops to avoid this problem, but it requires connectivity information to function. Compounds of convex shapes do not have any such connectivity information, so cannot smooth boundaries out.

(One of my wishlist items for v2.0 is a boundary smoothing system that operates across completely arbitrary geometry flawlessly without baking. Not sure I'll be able to pull it off- all my ideas so far are too slow to justify, but maybe!)

That said, there is nothing special about any one object in this regard, and being kinematic or dynamic should not affect it.
Nablabla
Posts: 14
Joined: Wed Mar 18, 2015 12:36 am

Re: strange surface behaviour

Post by Nablabla »

Hi, and thanks for the quick response.

The lack of boundary smoothing on compound shapes is pretty good point. I have witnessed this problem in some situations, but it is not that severe I guess.
But the problem that I had also occoured when standing on only one of the compound shapes childs.

Now the very very strange thing is, the problem disappeares if i add only few additional compound shapes into the physics space. :roll: :?: Then I can just slide over it as I can over world-CompoundShape.
And it sometimes does not appear for all of them and sometimes its stronger and sometimes weaker. And some boxes can be traversed without problem, even if there are holes between them.

Any other idea what might cause this?

By the way, I am not using the latest version of BEPUphysics. Can that be af any sort of concern?
(where can I see the version number?)

Image
In the picture:
The cabin is a compoundShape consisting of the bottom and top and the walls.
Then there are the doors compoundSahpe of two boxes.
And The Box I want to move (magenta/ugly person) the orange line is the force which I apply.
Normally the box would move (fast) but here the box only gets tilted

Best Regards
Nablabla
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: strange surface behaviour

Post by Norbo »

I don't know what would cause that. Updating to the latest version is a good idea, even if I don't remember fixing any bugs like this.

If that doesn't magically fix it, I will probably need a simplified minimal reproduction case in the BEPUphysicsDemos to figure it out.
Nablabla
Posts: 14
Joined: Wed Mar 18, 2015 12:36 am

Re: strange surface behaviour

Post by Nablabla »

hi norbo, I am still working on my project. I added items and the bepu engine does a great job!!!! :D

However I found that the sticky-surface-issue occurs when my object/character is standing on a very thin CompoundShapeEntry. Like on a BoxShape with dimensions like (0.5f 0.05f, 0.5f)
It also happens when standing on long thin things like a BoxShape(0.1f 0.1f, 1.0f).
The compound shape has many entries (> 1000), it only seems to happen if there are many components.
Also I am running on an old version because I changed some code (nothing significant) => I want to switch later.
But maybe you know a solution to this.
Is ther another/better way (not using a compound shape) ? I am constructing my complete world out of it.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: strange surface behaviour

Post by Norbo »

If the problem is related to the lack of boundary smoothing, then moving the world representation to a mesh (with an index list that shares vertices) would help. But I am still not sure if what you are seeing is actually the lack of boundary smoothing, so it's hard to give specific advice.

If you can reproduce it in the BEPUphysicsDemos for me to look at, I could give you a more definitive answer.
Post Reply