Hello,
I have a surface trimesh and a ball that rolls around on that surface, and I'm seeing the ball, when it has a low linear velocity, rolling along the interior edges, so the result is that when you would expect it to roll straight, it will instead roll as though constrained by a triangle. I saw a post in the R&D section mentioning something like this, and I was wondering a) if this was a known behavior and b) if there was a workaround.
Thanks.
- Alex
Strange Trimesh edge behavior
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: Strange Trimesh edge behavior
Yes, most engines suffer this behaviour unless you use a workaround(Havok, Ageia, Bullet, ODE etc).AlexSilverman wrote: a) if this was a known behavior and
Yes, the easiest is to always use the triangle normal for closest points. You can modify/set the normal of the contact point, to be the triangle normal in the callback.b) if there was a workaround.
See the ConcaveDemo, look for
Code: Select all
gContactAddedCallback = CustomMaterialCombinerCallback;
bool CustomMaterialCombinerCallback(btManifoldPoint& cp, const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1)
{
///overwrite the normal...
}
Hope this helps,
Erwin
-
- Posts: 141
- Joined: Mon Jul 02, 2007 5:12 pm
Re: Strange Trimesh edge behavior
Thanks for the direction. I stumbled upon that callback when looking for a way to notify objects that they have been collided with. I have a few questions about the parameters of it though.
1 - Am I correct in saying that the index for each collision object is the face number when that collision object is a triangle mesh?
2 - What does the partID represent? (This one is more curiosity)
Assuming I'm correct on #1, is there a method to obtain the normal for that face? If not, my plan is to get the information I need from the btStridingMeshInterface.
Thanks for your help.
- Alex
1 - Am I correct in saying that the index for each collision object is the face number when that collision object is a triangle mesh?
2 - What does the partID represent? (This one is more curiosity)
Assuming I'm correct on #1, is there a method to obtain the normal for that face? If not, my plan is to get the information I need from the btStridingMeshInterface.
Thanks for your help.
- Alex
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: Strange Trimesh edge behavior
Yes, the index and partId identify the triangle, so you can use the btStridingMeshInterface to get access to the triangle.AlexSilverman wrote:1 - Am I correct in saying that the index for each collision object is the face number when that collision object is a triangle mesh?
2 - What does the partID represent? (This one is more curiosity)
Assuming I'm correct on #1, is there a method to obtain the normal for that face? If not, my plan is to get the information I need from the btStridingMeshInterface.
btStridingMeshInterface allows multiple meshes, each mesh is identified by a partId. It is best to gather multiple static meshes for performance reasons (internally it builds an acceleration structure using a bvh tree, and one big tree is better then several smaller trees).
You should still consider simply copy/paste the btSphereTriangleAlgorithm and customizing it, it is probably easier.
Hope this helps,
Erwin
-
- Posts: 141
- Joined: Mon Jul 02, 2007 5:12 pm
Re: Strange Trimesh edge behavior
I went for the callback method because I thought it would be simpler, but I just looked at the sphere-triangle algorithm files and they do indeed look easier, and more fun
Thanks for the explanation.
- Alex
Thanks for the explanation.
- Alex