Bumpy triangle meshes

sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York
Contact:

Re: Bumpy triangle meshes

Post by sparkprime »

I updated Bullet to svn revision 1785. I didn't notice any difference with or without setContactProcessingThreshold(0) when sliding a box over a btBVHTriangleMesh. It still jerks up into the air for most of the edges that it slides over. Sometimes the jerk is so violent the box does a flip.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Bumpy triangle meshes

Post by Erwin Coumans »

There are two separate problems:

1) A capsule shape or sphere shape should slide smoothly when using setContactProcessingThreshold(0). Please confirm or create a reproduction case in one of the Bullet demos, showing problems with capsule/sphere sliding over a triangle mesh.

2) A box, convex or gimpact shape sliding over a triangle mesh, hitting internal triangle edged. This requires fixing the triangle normal and penetration depth, using a contact callback, as mentioned in this issue. Have you applied this fix?
If it still doesn't work after applying this fix, please provide a reproduction case.

Thanks a lot,
Erwin
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York
Contact:

Re: Bumpy triangle meshes

Post by sparkprime »

Ah setContactProcessingThreshold(0) is only for spheres and capsules... I never had any problem with spheres and have never used capsules. The fix you link to is actually written by me and I've been using it for over a year :) It does fix about 75% of the problem but there's still some catching going on. I can get it down to a reasonable level by just changing the step size though.
gjaegy
Posts: 178
Joined: Fri Apr 18, 2008 2:20 pm

Re: Bumpy triangle meshes

Post by gjaegy »

Hi,
sorry for resuscitating an old topic. I am having a similar issue when using the raycast vehicle. when the car is upside-down (after a crash), it slides on the ground but bumps when sliding on some edges.
I am going to apply the fix you mentioned Erwin. However I wonder why you don't fix this in the release directly ?

Cheers,
Gregory
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York
Contact:

Re: Bumpy triangle meshes

Post by sparkprime »

The fix has a number of issues.

Firstly, objects can get 'jammed' in the ground, not necessarily between triangles. The bodies linear velocity slowly increases but their position never changes, not even by tiny amounts.

Secondly, if you have two triangles at a sharp angle to each other, e.g. if you have a wall (essentially a box, but using triangles) and a box sitting on top of the wall, it can end up toppling off and swinging inside the wall as it falls.
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York
Contact:

Re: Bumpy triangle meshes

Post by sparkprime »

This is a video to demonstrate the second problem: http://www.youtube.com/watch?v=aQNiVzEWXD4
gjaegy
Posts: 178
Joined: Fri Apr 18, 2008 2:20 pm

Re: Bumpy triangle meshes

Post by gjaegy »

Understood Sparkprime.

So basically there is not perfect solution to this problem yet, is that right ?
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York
Contact:

Re: Bumpy triangle meshes

Post by sparkprime »

If there is, I'd like to know about it :)
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Bumpy triangle meshes

Post by Erwin Coumans »

There are some ways to improve the solution given in the issue tracker.

Sparkprime, could you help creating a reproduction case for each problem?
Thanks a lot,
Erwin
vturchenko
Posts: 7
Joined: Fri Jul 18, 2008 4:32 pm

Re: Bumpy triangle meshes

Post by vturchenko »

I just sent similar case to RP. Sphere falling perfectly down on perfectly horizontal mesh floor in VehicleDemo and bouncing sideways. Somebody explained to me before that it happens because Bullet treats triangles as convex hulls. I'm not sure how it could cause that but this behavior looks to me as a big flaw in Bullet system. Can that easily be fixed?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Bumpy triangle meshes

Post by Erwin Coumans »

vturchenko wrote:I just sent similar case to RP. Sphere falling perfectly down on perfectly horizontal mesh floor in VehicleDemo and bouncing sideways. Somebody explained to me before that it happens because Bullet treats triangles as convex hulls. I'm not sure how it could cause that but this behavior looks to me as a big flaw in Bullet system. Can that easily be fixed?
If you want the sphere to collide using the triangle normals, just apply this fix.

Hope this helps.
Thanks,
Erwin
kester
Posts: 27
Joined: Mon Dec 01, 2008 5:08 am

Re: Bumpy triangle meshes

Post by kester »

I found when using the triangle normal that the contact point had to be reprojected. Otherwise the contact would break since the movement orthogonal to (new) normal was too large:

Code: Select all

/// Changes a btManifoldPoint collision normal to the normal from the mesh.
static void FixMeshNormal(btManifoldPoint& cp, const btCollisionObject* colObj0, int /*partId0*/, int /*index0*/)
{
	const btTriangleShape* tri_shape = static_cast<const btTriangleShape*>(colObj0->getCollisionShape());
	btVector3 tri_normal;
	tri_shape->calcNormal(cp.m_normalWorldOnB);
	cp.m_normalWorldOnB = colObj0->getWorldTransform().getBasis() * cp.m_normalWorldOnB;

	// Reproject collision point along normal.
	cp.m_positionWorldOnB = cp.m_positionWorldOnA - cp.m_normalWorldOnB * cp.m_distance1;
	cp.m_localPointB = colObj0->getWorldTransform().invXform(cp.m_positionWorldOnB);
}
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York
Contact:

Re: Bumpy triangle meshes

Post by sparkprime »

kester that may fix my problem, i'll try it (hopefully soon)
tp
Posts: 13
Joined: Sat Dec 09, 2006 8:10 am

Re: Bumpy triangle meshes

Post by tp »

I have a situation where my game level is composed of tiles made of convex hulls that are placed right next to each other (most of my level is flat, i.e. the tops of the hulls are flat and they are at the same height). Both a capsule and a cylinder, when moved on top of the board, jump around when hitting tile edges, the cylinder doing considerably worse.

Does the issue described in this thread apply to adjacent convex hulls as well as adjacent triangles in a triangle mesh? Can I use the same callback mechanism to try and fix it?

It seems to me that convex hull faces have normals that are assumed to point directly perpendicular to the face, but edges have normals that are the average of the faces adjacent to that edge. Is this conclusion correct?
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York
Contact:

Re: Bumpy triangle meshes

Post by sparkprime »

It wouldn't suprise me if you have a similar issue, but the contact_added hack won't work because it is designed for triangle meshes only. Hulls don't have triangles afaik so it would be harder to override the normal in these cases. You are also straddling two entire objects instead of just two subparts of a single object, but the way Bullet is designed I don't think this matters.
Post Reply