EDIT: Erwin, this can wait until next release...(and looks like perhaps some Blender mods to btSoftBody.cpp) thanks
Erwin, if you can and when you have time it would be much appreciated if you could push a Bullet Library refresh out to Blender 2.6x.
Capsules have not been working right in Blender 2.5x & 2.6x since last year (with 2.78; I never bothered to report it).
Capsules appear to work correctly in the most recent Bullet Library (2.80). (disclaimer: I haven't tried 2.80 inside Blender.)
If you're curious what the problem was with 2.78: I'm not quite sure; something to do with an implicit margin subtraction along with jumpy collision behaviour. For example: compounded flat lined up capsules (end-to-end) have staircase like collisions with a rolling sphere, and box-capsule collisions are very jumpy.
But again, capsules and their collisions appear to work well with 2.80 (edit: issue apparently fixed in r2469), so this is not a Bullet issue.
But on a related note, enhancement issue 339 (Box-Capsule Collision Detection) has me curious... is that primarily for enhanced performance, or will it actually enhance collision handling as well? And does that mean that Bullet could potentially benefit from specialized SphereCapsule and CapsuleCapsule collision detection as well?
Thanks!
Capsules and Blender bullet physics engine refresh
-
- Posts: 141
- Joined: Tue Sep 16, 2008 11:31 am
-
- Posts: 141
- Joined: Tue Sep 16, 2008 11:31 am
Re: Capsules and Blender bullet physics engine refresh
Hmmm, still not working right in Blender with 2.80 either... Looks like btCapsuleShape contains an implicit margin of 0.04, which is considered part of its (radius and height) dimensions. setMargin(0.) makes a capsule 0.04 larger than the specified radius and height. And increasing the margin with setMargin() reduces the dimensions rather than add an actual margin?... Doesn't seem right (and not getting expected results from serialization export). This might be related to issue 446.
I had assumed a capsule was like a sphere where its entire radius is the collision margin.
I'm not getting good results with capsules that do use a 0.04 margin (good results with 0.0); so I guess I'll need to change Blender so that it subtracts a hardcoded margin of "0.04" from the dimensions passed when creating a new btCapsuleShapeZ.
Edit: Seems to be working in Blender with 2.80: (CcdPhysicsController.cpp ==> case PHY_SHAPE_CAPSULE:)(still not expected resuits from serializer export)
I had assumed a capsule was like a sphere where its entire radius is the collision margin.
I'm not getting good results with capsules that do use a 0.04 margin (good results with 0.0); so I guess I'll need to change Blender so that it subtracts a hardcoded margin of "0.04" from the dimensions passed when creating a new btCapsuleShapeZ.
Edit: Seems to be working in Blender with 2.80: (CcdPhysicsController.cpp ==> case PHY_SHAPE_CAPSULE:)
Code: Select all
collisionShape = new btCapsuleShapeZ(m_radius-0.04+margin, m_height-0.08+2.*margin);
-
- Posts: 66
- Joined: Tue Mar 02, 2010 6:13 am
Re: Capsules and Blender bullet physics engine refresh
I believe I did patch this in my bullet version
it was a fairly simple patch in the capsule shape code,
you should just change it there and make sure the set margin method
works as expected
I don't have access to my code right now so can't tell exactly
it was a fairly simple patch in the capsule shape code,
you should just change it there and make sure the set margin method
works as expected
I don't have access to my code right now so can't tell exactly
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: Capsules and Blender bullet physics engine refresh
There are likely various issue with the btCapsuleShape, so it is important to be very precise about describing the issue.
In a nutshell, the btCapsuleShape is supposed to be a line segment, with the radius being the full margin. At export time, the radius is left to zero and the margin contains the radius.
Another issue is the non-smooth sliding of capsules over internal edges of triangle mesh/boxes. You can reduce this effect by setting the contact processing threshold for capsules to zero (setContactProcessingThreshold). This CPT used to be an advanced rigid body setting in Blender 2.49, not sure if it has been ported over to Blender 2.6x, can you check it?
majestik666 and others, can you please let us know what changes/patches did you make?
Thanks,
Erwin
In a nutshell, the btCapsuleShape is supposed to be a line segment, with the radius being the full margin. At export time, the radius is left to zero and the margin contains the radius.
Another issue is the non-smooth sliding of capsules over internal edges of triangle mesh/boxes. You can reduce this effect by setting the contact processing threshold for capsules to zero (setContactProcessingThreshold). This CPT used to be an advanced rigid body setting in Blender 2.49, not sure if it has been ported over to Blender 2.6x, can you check it?
majestik666 and others, can you please let us know what changes/patches did you make?
Thanks,
Erwin
-
- Posts: 141
- Joined: Tue Sep 16, 2008 11:31 am
Re: Capsules and Blender bullet physics engine refresh
Yes, sorry I hastily started this thread out of frustration. To clarify:
Main issue is margin related. I'm connecting together precisely measured capsules (curves, strings, wireframes, etc.). setMargin(0.) changes the dimensions (both radius and height), which may misalign capsules; also capsules that do set an actual collision margin don't work well (it appears the margin applies only to the capsule's ends and not its middle?). Seems to me implicit margin and all margin functions need to be disabled in btCapsuleShape, no? EDIT: ok, I'm making the mistake that my capsules (radius) are too small for the implicit margin, which probably explains the strange behaviour when using a collision margin. Originally I was expecting, as you seemed to, that capsule radius would be the full margin (like sphere). Appears it doesn't work like that?; still, something's not right with capsule margin handling; I'll just defer to issue 446.
While I'm at it, another issue with capsules is related to their angular momentum: at collision there is angular acceleration (even moderate to high rotation damping will not stop this).
I'll look into contact processing threshold later, thanks.
I'm attaching .blend and .bullet files to illustrate these problems:
Main issue is margin related. I'm connecting together precisely measured capsules (curves, strings, wireframes, etc.). setMargin(0.) changes the dimensions (both radius and height), which may misalign capsules; also capsules that do set an actual collision margin don't work well (it appears the margin applies only to the capsule's ends and not its middle?). Seems to me implicit margin and all margin functions need to be disabled in btCapsuleShape, no? EDIT: ok, I'm making the mistake that my capsules (radius) are too small for the implicit margin, which probably explains the strange behaviour when using a collision margin. Originally I was expecting, as you seemed to, that capsule radius would be the full margin (like sphere). Appears it doesn't work like that?; still, something's not right with capsule margin handling; I'll just defer to issue 446.
While I'm at it, another issue with capsules is related to their angular momentum: at collision there is angular acceleration (even moderate to high rotation damping will not stop this).
I'll look into contact processing threshold later, thanks.
I'm attaching .blend and .bullet files to illustrate these problems:
- When this works, the sphere rolling on the compounded capsules should roll smoothly for over a minute, back and forth, without stopping. (includes script to clear / set all capsule margins).
- The stand-alone capsule on the ground should not roll away (angular acceleration).
You do not have the required permissions to view the files attached to this post.
-
- Posts: 141
- Joined: Tue Sep 16, 2008 11:31 am
Re: Capsules and Blender bullet physics engine refresh
Tried a hack this weekend in Blender to use the entire capsule radius as its margin. It gave me good collision results, the best I've had with capsules so far.
So if btCapsule can be changed to behave like btSphere, where its entire radius is the collision margin, that'd be great.
Unfortunately, I don't yet know enough about Bullet's collision shapes or serialization to supply the needed changes in bullet for this, but btCapsuleShape would require several changes which may or may not impact some users? (although scaling's also not working for me right now, nor do I understand why calculateLocalInertia is using a hard coded margin?)
So if btCapsule can be changed to behave like btSphere, where its entire radius is the collision margin, that'd be great.
Unfortunately, I don't yet know enough about Bullet's collision shapes or serialization to supply the needed changes in bullet for this, but btCapsuleShape would require several changes which may or may not impact some users? (although scaling's also not working for me right now, nor do I understand why calculateLocalInertia is using a hard coded margin?)
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: Capsules and Blender bullet physics engine refresh
Good point, the btCapsuleShape should behave like the btSphereShape, its entire radius is margin. The attempt is to have 'setMargin/getMargin' work consistently, but apparently that attempt failed.RBD wrote: So if btCapsule can be changed to behave like btSphere, where its entire radius is the collision margin, that'd be great.
I'll look into it soon, you can track progress here: http://code.google.com/p/bullet/issues/detail?id=446
Thanks!
Erwin