moonshineTheleocat / bullet

Automatically exported from code.google.com/p/bullet
Other
0 stars 0 forks source link

btCollisionShape resize not recognized while in contact. #687

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I modified the HelloWorld demo to test dynamic resizing of collision shapes. 
I've noticed a case for which the resize doesn't seem to be recognized when the 
collision body is in contact. I've attached a patch for the HelloWorld demo.

What steps will reproduce the problem?
1. When run with no arguments (ie. `./AppHelloWorld`), the modified demo prints 
the Y position of a sphere every other time step. It starts at Y=2 and ends at 
Y=1.

i=000 sphere posY = 1.997222 i=002 sphere posY = 1.983333 i=004 sphere posY = 1.958333 i=006 sphere posY = 1.922222 i=008 sphere posY = 1.875000 i=010 sphere posY = 1.816667 i=012 sphere posY = 1.747222 i=014 sphere posY = 1.666667 i=016 sphere posY = 1.575000 i=018 sphere posY = 1.472222 i=020 sphere posY = 1.358333 i=022 sphere posY = 1.233333 i=024 sphere posY = 1.097222 i=026 sphere posY = 1.000002 i=028 sphere posY = 1.000002 i=030 sphere posY = 1.000002 i=032 sphere posY = 1.000002 i=034 sphere posY = 1.000002 i=036 sphere posY = 1.000000 i=038 sphere posY = 1.000000 i=040 sphere posY = 1.000000 i=042 sphere posY = 1.000000 i=044 sphere posY = 1.000000 i=046 sphere posY = 1.000000 i=048 sphere posY = 1.000000 i=050 sphere posY = 1.000000 i=052 sphere posY = 1.000000 i=054 sphere posY = 1.000000 i=056 sphere posY = 1.000000 i=058 sphere posY = 1.000000 i=060 sphere posY = 1.000001 i=062 sphere posY = 1.000001 i=064 sphere posY = 1.000001 i=066 sphere posY = 1.000001 i=068 sphere posY = 1.000001 i=070 sphere posY = 1.000001 i=072 sphere posY = 1.000001 i=074 sphere posY = 0.999999 i=076 sphere posY = 0.999999 i=078 sphere posY = 0.999999 i=080 sphere posY = 0.999997 i=082 sphere posY = 0.999996 i=084 sphere posY = 0.999998 i=086 sphere posY = 0.999999 i=088 sphere posY = 0.999999 i=090 sphere posY = 0.999999 i=092 sphere posY = 0.999999 i=094 sphere posY = 0.999999 i=096 sphere posY = 0.999999 i=098 sphere posY = 0.999999

2. When run with a single argument (ie. `./AppHelloWorld a`), the sphere is 
resized to a smaller size before hitting the ground object and comes to rest at 
a height of Y=0.5 instead of Y=1.

i=000 sphere posY = 1.997222 i=002 sphere posY = 1.983333 i=004 sphere posY = 1.958333 i=006 sphere posY = 1.922222 i=008 sphere posY = 1.875000 i=010 sphere posY = 1.816667 i=012 sphere posY = 1.747222 i=014 sphere posY = 1.666667 i=016 sphere posY = 1.575000 i=018 sphere posY = 1.472222 i=020 sphere posY = 1.358333 resize sphere i=022 sphere posY = 1.233333 i=024 sphere posY = 1.097222 i=026 sphere posY = 0.950000 i=028 sphere posY = 0.791667 i=030 sphere posY = 0.622222 i=032 sphere posY = 0.441667 i=034 sphere posY = 0.490666 i=036 sphere posY = 0.494026 i=038 sphere posY = 0.496176 i=040 sphere posY = 0.497552 i=042 sphere posY = 0.498433 i=044 sphere posY = 0.498997 i=046 sphere posY = 0.499359 i=048 sphere posY = 0.499589 i=050 sphere posY = 0.499737 i=052 sphere posY = 0.499832 i=054 sphere posY = 0.499892 i=056 sphere posY = 0.499931 i=058 sphere posY = 0.499956 i=060 sphere posY = 0.499972 i=062 sphere posY = 0.499983 i=064 sphere posY = 0.499989 i=066 sphere posY = 0.499991 i=068 sphere posY = 0.499995 i=070 sphere posY = 0.499996 i=072 sphere posY = 0.499996 i=074 sphere posY = 0.499996 i=076 sphere posY = 0.499997 i=078 sphere posY = 0.499998 i=080 sphere posY = 0.499999 i=082 sphere posY = 0.499999 i=084 sphere posY = 0.499999 i=086 sphere posY = 0.499999 i=088 sphere posY = 0.499999 i=090 sphere posY = 0.499999 i=092 sphere posY = 0.499999 i=094 sphere posY = 0.499999 i=096 sphere posY = 0.499999 i=098 sphere posY = 0.499999

3. When run with two arguments (ie. `./AppHelloWorld a b`), the sphere is 
resized to a smaller size after hitting the ground object and coming to rest at 
a height of Y=1, but the resize has no effect on the Y position.

i=000 sphere posY = 1.997222 i=002 sphere posY = 1.983333 i=004 sphere posY = 1.958333 i=006 sphere posY = 1.922222 i=008 sphere posY = 1.875000 i=010 sphere posY = 1.816667 i=012 sphere posY = 1.747222 i=014 sphere posY = 1.666667 i=016 sphere posY = 1.575000 i=018 sphere posY = 1.472222 i=020 sphere posY = 1.358333 i=022 sphere posY = 1.233333 i=024 sphere posY = 1.097222 i=026 sphere posY = 1.000002 i=028 sphere posY = 1.000002 i=030 sphere posY = 1.000002 i=032 sphere posY = 1.000002 i=034 sphere posY = 1.000002 i=036 sphere posY = 1.000000 i=038 sphere posY = 1.000000 i=040 sphere posY = 1.000000 resize sphere i=042 sphere posY = 1.000000 i=044 sphere posY = 1.000000 i=046 sphere posY = 1.000000 i=048 sphere posY = 1.000000 i=050 sphere posY = 1.000000 i=052 sphere posY = 1.000000 i=054 sphere posY = 1.000000 i=056 sphere posY = 1.000000 i=058 sphere posY = 1.000000 i=060 sphere posY = 1.000000 i=062 sphere posY = 1.000000 i=064 sphere posY = 1.000000 i=066 sphere posY = 1.000000 i=068 sphere posY = 1.000000 i=070 sphere posY = 1.000000 i=072 sphere posY = 1.000000 i=074 sphere posY = 1.000000 i=076 sphere posY = 1.000000 i=078 sphere posY = 1.000000 i=080 sphere posY = 1.000000 i=082 sphere posY = 1.000000 i=084 sphere posY = 1.000000 i=086 sphere posY = 1.000000 i=088 sphere posY = 1.000000 i=090 sphere posY = 1.000000 i=092 sphere posY = 1.000000 i=094 sphere posY = 1.000000 i=096 sphere posY = 1.000000 i=098 sphere posY = 1.000000

4. When run with three arguments (ie. `./AppHelloWorld a b c`), the sphere is 
perturbed by setting an upward velocity after an ineffectual resize. This 
causes the sphere to rise and then settle at Y=0.5.

i=000 sphere posY = 1.997222 i=002 sphere posY = 1.983333 i=004 sphere posY = 1.958333 i=006 sphere posY = 1.922222 i=008 sphere posY = 1.875000 i=010 sphere posY = 1.816667 i=012 sphere posY = 1.747222 i=014 sphere posY = 1.666667 i=016 sphere posY = 1.575000 i=018 sphere posY = 1.472222 i=020 sphere posY = 1.358333 i=022 sphere posY = 1.233333 i=024 sphere posY = 1.097222 i=026 sphere posY = 1.000002 i=028 sphere posY = 1.000002 i=030 sphere posY = 1.000002 i=032 sphere posY = 1.000002 i=034 sphere posY = 1.000002 i=036 sphere posY = 1.000000 i=038 sphere posY = 1.000000 i=040 sphere posY = 1.000000 resize sphere i=042 sphere posY = 1.000000 i=044 sphere posY = 1.000000 i=046 sphere posY = 1.000000 i=048 sphere posY = 1.000000 i=050 sphere posY = 1.000000 i=052 sphere posY = 1.000000 i=054 sphere posY = 1.000000 i=056 sphere posY = 1.000000 i=058 sphere posY = 1.000000 i=060 sphere posY = 1.000000 perturbed sphere i=062 sphere posY = 1.025000 i=064 sphere posY = 1.038889 i=066 sphere posY = 1.041667 i=068 sphere posY = 1.033334 i=070 sphere posY = 1.013889 i=072 sphere posY = 0.983334 i=074 sphere posY = 0.941667 i=076 sphere posY = 0.888889 i=078 sphere posY = 0.825000 i=080 sphere posY = 0.750000 i=082 sphere posY = 0.663889 i=084 sphere posY = 0.566667 i=086 sphere posY = 0.500002 i=088 sphere posY = 0.499996 i=090 sphere posY = 0.499997 i=092 sphere posY = 0.499995 i=094 sphere posY = 0.499996 i=096 sphere posY = 0.499997 i=098 sphere posY = 0.499995


I've tested this on Ubuntu 12.04 and Mac 10.8.2.

I'm new to bullet, so I'm not exactly sure where to dig around to fix this. I'd 
be happy to look if someone can recommend where.

Thanks.

Original issue reported on code.google.com by scpet...@osrfoundation.org on 4 Jan 2013 at 1:15

Attachments:

GoogleCodeExporter commented 9 years ago
This seemed like a cache problem to me, and after reading the User Manual more 
closely, I decided the btPersistentManifold was a likely place to look. I've 
managed to resolve the problem by manually clearing all contact manifolds after 
the sphere resize. This feels a bit heavy-handed. I could probably check for 
any manifolds involving that particular body and clear those.

I've attached a patch for my fix. Building and running the patched HelloWorld 
demo with four arguments  (ie. `./AppHelloWorld a b c d`) will show that the 
sphere does fall to a final height of 0.5 after clearing the manifolds.

Is this the intended behavior? It seems like the resize should trigger a change 
in the bounding box, which should cause the broadphase to notice that there's 
no longer any overlap, and thus tell the dispatcher to remove the cached 
contact points.

Original comment by scpet...@osrfoundation.org on 31 Jan 2013 at 8:19

Attachments:

GoogleCodeExporter commented 9 years ago
Before you make any change to the collision shape (replace shape, resize etc) 
you need to 

1) remove the rigid body from the world
2) make the change (resize etc)
3) re-insert the body into the world

Alternatively you can flush the contact points manually for the object involved:

 dynamicsWorld->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(body->getBroadphaseHandle(), dynamicsWorld->getDispatcher());

Original comment by erwin.coumans on 31 Jan 2013 at 8:31

GoogleCodeExporter commented 9 years ago
Ok, thanks very much. I probably should have posted this to the forum. You can 
mark this issue as not a bug.

Original comment by scpet...@osrfoundation.org on 31 Jan 2013 at 8:39

GoogleCodeExporter commented 9 years ago
it is valid feedback. Such things should be made clear in the API, 
documentation/manual/faq, because many Bullet users run into this issue.

Original comment by erwin.coumans on 31 Jan 2013 at 8:59

GoogleCodeExporter commented 9 years ago
See https://github.com/bulletphysics/bullet3/issues/102

Original comment by erwin.coumans on 30 Mar 2014 at 6:22