Convex hull projection

Post Reply
czgz
Posts: 3
Joined: Thu Aug 24, 2017 7:49 am

Convex hull projection

Post by czgz »

Hi.
I'm new in bullet physics and I'm using these libraries to perform collision detection.
Response is performed by an external code, so I need to export, for each collision pair, the bodies convex hull projections onto the plane with the normal represented by the bodies relative velocity.

Is there any similar function already implemented in bullet?

Thanks in advance for any help.
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Convex hull projection

Post by drleviathan »

I don't think there is any code that does exactly what you want, however the GJK algorithm (used for collision detection between convex shapes) needs to be able to compute the surface point on shapes in arbitrary directions, and this projection utility could be used generate approximate 2D contour projections.

In particular I'm talking about btConveShape::localGetSupportingVertex(const btVector3 &vec). I believe it provides the local surface point on the shape in the direction of vec. So, if you transform your 2D plane into the local frame of the shape you could supply a list of vectors in the plane and then compute the corresponding points on the surface of the shape along those directions: effectively computing a chain of points that represent the cross-section of the shape. You would then have to transform those points back into the world-frame (using the RigidBody's transform) or into your collision-frame.

Note, if you're using simple convex shapes then localGetSupportingVertex() would be available, but if you're using something more complicated (btCompoundShape or a non-convex shape) then I'm sure it gets more complicated.
czgz
Posts: 3
Joined: Thu Aug 24, 2017 7:49 am

Re: Convex hull projection

Post by czgz »

Thanks for your help drleviathan.

I have one more question.
Ho can I get contact point coordinates at time of impact?
I have a system with rigid bodies moving fastly so I set CCD thresholds.
After performing stepSimulation I check for collisions getting contact points in Persistent Manifolds. Contact points coordinates are given at the end of the timestep (or am I wrong?)
Are they local? Is it possible to have those coordinates at toi?
I found toi by setting a custom dispatcher NearCallback function with toi calculation.
Is this the right procedure?

Many thanks for any help.

czgz
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Convex hull projection

Post by drleviathan »

I don't know for sure when exactly the btContactManifoldPoint data is captured: at time of impact (TOI) or at end of substep. Probably at TOI but that is just a guess. To know for sure one would have to read and understand the code.

The btContactManifoldPoint stores several properties of the contact including the local points: m_localPointA and m_localPointB. These are in the local-frame of objectA and objectB respectively. After transforming these points into the world-frame they will not necessarily be at the same point: the discrepancy would represent the current penetration of the two objects if they overlap, or the gap between the them if they don't.
czgz
Posts: 3
Joined: Thu Aug 24, 2017 7:49 am

Re: Convex hull projection

Post by czgz »

Thanks again for your help drleviathan.
I think contact points info are given at the end of the timestep and not at the time of impact.
Anyway, I have some problems with toi. I tried to get toi by using calculateTimeOfImpact after finding collision algoritm and settings ccd thresholds for three "different" cases:
1. collision between 2 boxes
2. collision between 2 spheres
3. collision between a box and a sphere
objects have the same dimensions/position/velocities in all cases and I expected to get the same toi but I obtained toi=1 in the first two cases and a reliable toi (different from 1 and comparable to my calculations) in the third case.
I think it depends from the collision algorithm found.
Having a look to the src cpp code (e.g. http://bulletphysics.org/Bullet/BulletF ... ource.html) it seems that toi calculation is not available. Is the code reported in bullet-physics Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp not fully working? Am I missing something?
Is there an alternative way to get toi using bullet?
I'm using v. 2.83.

Thanks.

czgz
Post Reply