Query AABB collision to get approximated intersection volume

Post Reply
felixes_jo
Posts: 4
Joined: Tue Oct 18, 2016 1:50 am

Query AABB collision to get approximated intersection volume

Post by felixes_jo »

Hi all,

I'm currently doing a thesis research and I am trying to do penalty calculation for object in collision.

Since I came to notice that calculating exact penetration volume is a very expensive algorithm (NP-hard?), I would like to instead uses AABB (more precisely, the leaf of AABB tree that are in collision with the other object) to get rough estimate of the intersecting volume. I have searched for how to query bounding boxes of all objects in collision and I still couldn't found the information I need. The closest I have so far is using btPersistentManifold, which only provides me with penetration depth.

Note: I uses btCompoundShape object, made out of convex hulls. Any suggestion would be helpful.
ktfh
Posts: 44
Joined: Thu Apr 14, 2016 3:44 pm

Re: Query AABB collision to get approximated intersection vo

Post by ktfh »

I think something like this could get you an intersecting aabb of two colliding rigid bodies.

Code: Select all

btAABB box0, box1, intersect;
btRigidBody::upcast(persistentManifold->getBody0())->getAabb(box0.m_min, box0.m_max);
btRigidBody::upcast(persistentManifold->getBody1())->getAabb(box1.m_min, box1.m_max);
box0.find_intersection(box1,intersect);
Aabb overlap seems too coarse a measurement to give good insight, why not use spheres packed together to approximate your object. The overlapping volume could be more precisely calculated.
felixes_jo
Posts: 4
Joined: Tue Oct 18, 2016 1:50 am

Re: Query AABB collision to get approximated intersection vo

Post by felixes_jo »

Hi ktfh,

Thank you for your response.
Forgive me if I'm wrong, but I'm assuming your code will give me the intersection between the root (largest) AABB of the object.

The reason I use AABB is because I want to score a pose estimation hypothesis which could be >1000 scene cases based on their physical property. That's why I'm thinking that maybe bullet make uses of a AABB-tree, and I could query the smallest leaf of AABB in the tree of a particular object that intersects with the leaf of other object, which I assume will give me some rough estimate of the intersecting volume.

What I mean by AABB-tree:
Image

Is there any way to get this "leaf" AABB intersection in bullet?
I'm also curious about what do you mean with sphere packed together to approximate my object. Is this technique make a compound object of spheres, and calculate the intersection volume with sphere-to-sphere intersection?
ktfh
Posts: 44
Joined: Thu Apr 14, 2016 3:44 pm

Re: Query AABB collision to get approximated intersection vo

Post by ktfh »

felixes_jo wrote:your code will give me the intersection between the root (largest) AABB of the object.
yes, I think its possible to get the AABB for the colliding child shapes though.

btPersistentManifold has a collection of btManifoldPoint where the two bodies collided. I think btManifoldPoint members m_index0 and m_index1 correspond to the index of the colliding child shapes if the rigid body has a btCompoundShape.

Code: Select all

btPersistentManifold* manifold;
const btManifoldPoint& pt = pmptr->getContactPoint(n);
btCollisionObject* obj = manifold->getBody0();
btCompountShape* compoundshape = (btCompountShape*)obj->getCollisionShape();
btCollisionShape* shape = compoundshape->getChildShape (pt.m_index0);
btTransform shapeloc = compoundshape->getChildTransform (pt.m_index0);
btAABB shapeAABB;
shape->getAabb(obj->getWorldTransform() * shapeloc, shapeAABB.m_min, shapeAABB.m_max);
btCompoundShape also has a dynamic bvh of AABB but im not sure how to travese it with the collision info from btPersistentManifold http://bulletphysics.org/Bullet/BulletF ... tDbvt.html
felixes_jo wrote:I'm also curious about what do you mean with sphere packed together to approximate my object. Is this technique make a compound object of spheres, and calculate the intersection volume with sphere-to-sphere intersection?
I haven't tried it but i think there is a few libraries for packing spheres to approximate meshes libigl or cgal might have it ? I thought sphere intersection would be cheap and more accurate, AABB overlap volume would correlate more with shape and orientation of objects than their penetration.

edit:
yade has sphere packing https://yade-dem.org/doc/user.html#sphere-packings
Post Reply