Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Sun Jul 22, 2012 5:04 am 
Offline

Joined: Thu Sep 09, 2010 4:44 pm
Posts: 3
I'm working with a btCollisionWorld->ConvexSweepTest() and a custom callback which stores the btCollisionWorld::LocalConvexResult in the addSingleResult method. The test is being executed with a capsule shape vs a triangle mesh shape. During the normal update all triangle mesh part and triangle index int's are being returned correctly in the manifold, however after that things seem to get a little funny. It appears to get the correct triangle at times and invalid ones at other times. This is very inconsistent. Periodically it also returns an invalid convexResult.m_localShapeInfo pointer when the convexResult.m_hitCollisionObject->getCollisionShape()->getShapeType() returns 21 ( TRIANGLE_MESH_SHAPE_PROXYTYPE ).

I must have missed something, has anyone else experienced this? I am not calling stepSimulation again between the broadphase result and running the Convex Sweep (Multiple times from different positions for the same object). I would prefer not to if at all possible, as I thought convex sweep was supposed to help circumvent the need for a full update.

Thanks in advance!

Code:
  btScalar SingleExclusionAllConvexResultCallback::addSingleResult( btCollisionWorld::LocalConvexResult& convexResult, bool normalInWorldSpace)
  {
    //caller already does the filter on the m_closestHitFraction
    btAssert(convexResult.m_hitFraction <= m_closestHitFraction);
    if (convexResult.m_hitCollisionObject != m_singleExclude)
    {
      m_closestHitFraction = convexResult.m_hitFraction;

      AllConvexResultInformation info;
      //Check if the hit normal is in world space
      info.m_hitNormalWorld = normalInWorldSpace ? convexResult.m_hitNormalLocal :
                                                   convexResult.m_hitCollisionObject->getWorldTransform().getBasis() * convexResult.m_hitNormalLocal;
      info.m_hitPointWorld = convexResult.m_hitPointLocal;
      info.m_collisionObject = convexResult.m_hitCollisionObject;
      info.m_localShapeInfo = convexResult.m_localShapeInfo;

      m_hits.push_back(info);
    }


Top
 Profile  
 
PostPosted: Sun Jul 22, 2012 11:30 pm 
Offline

Joined: Thu Sep 09, 2010 4:44 pm
Posts: 3
To update, it appears that the ConvexSweep is returning the triangle face normal I was trying to get manually.

Broadphase results vs a BVH force you to locate the triangle and calculate the normal yourself, as the normal returned in the manifold is the "Separating" normal in world space.

ConvexSweep results appear to return the actual surface normal of the contact, on the object collided with, in world space, so this is not necessary. Though would still be nice if that was documented somewhere.


Top
 Profile  
 
PostPosted: Mon Jul 23, 2012 9:41 am 
Offline

Joined: Sat Nov 26, 2011 5:41 pm
Posts: 22
XypherOrion wrote:
To update, it appears that the ConvexSweep is returning the triangle face normal I was trying to get manually.

Broadphase results vs a BVH force you to locate the triangle and calculate the normal yourself, as the normal returned in the manifold is the "Separating" normal in world space.

ConvexSweep results appear to return the actual surface normal of the contact, on the object collided with, in world space, so this is not necessary. Though would still be nice if that was documented somewhere.


I'm just sitting with convexSweepTest myself right now with a bunch of small problems, and it does not return the true normals either. It returns the separating axis which sometimes is the right normal, sometimes it is completely off, and most of the times it's the right normal but slightly off numerically. (Bullet 2.79, but I don't think there is any change in this code in 2.80 ?)

Haven't seen the corrupt LocalInfo you're talking about though! Be careful that you don't sweep into your own player character object or other non-triangle-mesh objects.


Top
 Profile  
 
PostPosted: Sun Aug 05, 2012 9:42 pm 
Offline

Joined: Thu Sep 09, 2010 4:44 pm
Posts: 3
monkeyman: Thanks for the reply. As far as I've found thus far my suspicions were correct, at least its giving me normals correct enough to work with. I've had to change my navigation method for the Controller I'm working on due to the narrow margins of collision i'm working with, which sweeps until it "can't sweep no' mo'." Constrained by distance, or attempt distance, and I have yet for it to infinite loop on me, thankfully...


Top
 Profile  
 
PostPosted: Mon Aug 06, 2012 1:08 am 
Offline

Joined: Sat Nov 26, 2011 5:41 pm
Posts: 22
XypherOrion wrote:
monkeyman: Thanks for the reply. As far as I've found thus far my suspicions were correct, at least its giving me normals correct enough to work with. I've had to change my navigation method for the Controller I'm working on due to the narrow margins of collision i'm working with, which sweeps until it "can't sweep no' mo'." Constrained by distance, or attempt distance, and I have yet for it to infinite loop on me, thankfully...


Good.. I also found that it helps to go double-precision when dealing with the small adjustments if you want high precision in the sweeps. But to do that "globally" in Bullet costs some performance of course.

My main problem was that the convexSweep does get stuck most of the time - i.e. it says the distance is clear up to 0.5 for example, and when you move there, the next sweep can't go anywhere.

Simply reducing the returned distance is not good enough I think since if your vector is almost parallel to a surface you can still accidentally get numerically too close to something.

So it seems the recoverFromPenetration (or similar) is crucial for stable operation, but that runs into the problem that you then rely on two quite different collision-detection methods (for the sweep and for the discrete collision-tests in recover) which have different numerical margins. This is a horrible can of worms. You need severe worm-poison.


Top
 Profile  
 
PostPosted: Sun Sep 30, 2012 10:56 pm 
Offline

Joined: Sun Sep 30, 2012 10:45 pm
Posts: 1
monkeyman wrote:
I'm just sitting with convexSweepTest myself right now with a bunch of small problems, and it does not return the true normals either. It returns the separating axis which sometimes is the right normal, sometimes it is completely off, and most of the times it's the right normal but slightly off numerically. (Bullet 2.79, but I don't think there is any change in this code in 2.80 ?)

Haven't seen the corrupt LocalInfo you're talking about though! Be careful that you don't sweep into your own player character object or other non-triangle-mesh objects. The user manual is also in Spanish so I am not sure how to read it, unless somebody here that speaks Spanish could volunteer their translation services. If anybody do that, it would be appreciated.


Hi monkeyman,

I am also having a bunch of problems, one of which is i am not getting the true normals. I am not sure if you ever found a solution. If you did, I would appreciate it if you could share it here. Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group