AABB overlap bugs?

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Re: AABB overlap bugs?

Postby aitzolmuelas » Wed Jun 10, 2015 10:27 am

I finally had some time to play around with the demo, and I think I can reproduce the problem: using the advanced character controller demo, I add the following:

Code: Select all
#define PLAYER_CALL_FERRY_DRIVER      4
#define PLAYER_BOARDED_FERRY_DRIVER      5

/*ADDED*/static int OnAABBOverlap (const NewtonMaterial* const material, const NewtonBody* const body0, const NewtonBody* const body1, int threadIndex) {
/*ADDED*/  return 0;
/*ADDED*/}
/*ADDED*/static void OnContactsProcess (const NewtonJoint* const contactJoint, dFloat timestep, int threadIndex) {
/*ADDED*/}

class PlaformEntityEntity;
class AdvancePlayerControllerManager;

// this demo use a trigger and player controller to automate the operation of a mini game environment
class TriggerManager: public CustomTriggerManager
{
   public:
   TriggerManager(NewtonWorld* const world, AdvancePlayerControllerManager* const playerManager)
      :CustomTriggerManager(world)
      ,m_playerManager(playerManager)
   {
/*ADDED*/      int material = NewtonMaterialGetDefaultGroupID (world);
/*ADDED*/      NewtonMaterialSetCollisionCallback (world, material, material, nullptr, OnAABBOverlap, OnContactsProcess);
   }

   virtual void EventCallback (const CustomTriggerController* const me, TriggerEventType event, NewtonBody* const visitor) const
   {

It's a very simple test, but I assume it should prevent contacts between everything (character still works fine because it uses convex casting, I guess).
As one would expect, in older revisions, this is what happens, and the triggers atop the ramps do not work. However, If I apply this change in the latest revision, the trigger turns on but then it turns off if the character is moved within the trigger.
I guess it is a good example of the weird behaviour I was trying to describe (I don't know if it's the best way to test it for debugging, but this is as far as I have been able to get today with the sandbox).
aitzolmuelas
 
Posts: 78
Joined: Wed Mar 25, 2015 1:10 pm

Re: AABB overlap bugs?

Postby aitzolmuelas » Wed Jun 10, 2015 10:31 am

Also, I reverted to the latest stable revision I found, so no hurry :)
aitzolmuelas
 
Posts: 78
Joined: Wed Mar 25, 2015 1:10 pm

Re: AABB overlap bugs?

Postby Julio Jerez » Wed Jun 10, 2015 11:49 am

ha ok excellent, I will test that.
I did not have time to check anything today, I will do so tonight.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: AABB overlap bugs?

Postby Julio Jerez » Thu Jun 11, 2015 10:24 am

ha I see what is wrong, yes I intrude a behavioral change.

in the old broad phase pair where created fro all bodies that came in close proximity,
there each pair set intimal values to false and the narrow phase update then every single time.

the new system releases there if tow bodies are close, then there is not need to make a new pair.
if just need to validate the joint. This is part of what make the new system much faster.

there are two conditions,
-if contact need nee recalculation in each case it calls contact calculation with a local pair, no storage.
-if the contact did not changed, and here is where the Bug is, when that happen sI do no know the flags, for that contact, so I need to cache those as well.

I naively set it to true, that was a bug because eactivacet contacts. The I set to conditional if it has contact or not, but that is also a mistake. I have to think how to get the state of the contact

the bug is in the funtion

Code: Select all
void dgBroadPhase::AddPair (dgBody* const body0, dgBody* const body1, const dgFloat32 timestep, dgInt32 threadID)
{
   if (TestOverlaping (body0, body1, timestep)) {

      dgAssert ((body0->GetInvMass().m_w != dgFloat32 (0.0f)) || (body1->GetInvMass().m_w != dgFloat32 (0.0f)) || (body0->IsRTTIType(dgBody::m_kinematicBodyRTTI | dgBody::m_deformableBodyRTTI)) || (body1->IsRTTIType(dgBody::m_kinematicBodyRTTI | dgBody::m_deformableBodyRTTI)));

      // add all pairs
      bool isCollidable = true;
      dgContact* contact = m_world->FindContactJoint (body0, body1);
      if (!contact) {
         const dgBilateralConstraint* const bilateral = m_world->FindBilateralJoint (body0, body1);
         isCollidable = bilateral ? bilateral->IsCollidable() : true;
      }

      if (isCollidable) {
         if (contact) {
            contact->m_broadphaseLru = m_lru;
            contact->m_timeOfImpact = dgFloat32(1.0e10f);
            if (ValidateContactCache (contact, timestep)) {
// this is a bug , I need to save the state form last call.
               contact->m_contactActive = contact->GetCount() ? true : false;
            } else {
               dgCollidingPairCollector* const contactPairs = m_world;
               contact->m_contactActive = 0;
               contact->m_positAcc = dgVector::m_zero;
               contact->m_rotationAcc = dgQuaternion();
               contactPairs->AddPair(contact, threadID);
            }

         } else {
            dgUnsigned32 group0_ID = dgUnsigned32 (body0->m_bodyGroupId);


Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: AABB overlap bugs?

Postby Julio Jerez » Thu Jun 11, 2015 11:19 am

Ha I think I have it, it was so simple, the active state should be the same as it was before because nothing was changes.

Please try again see if this fixed.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: AABB overlap bugs?

Postby aitzolmuelas » Fri Jun 12, 2015 4:38 am

Thanks, I have tested only a bit, but it seems fixed.
aitzolmuelas
 
Posts: 78
Joined: Wed Mar 25, 2015 1:10 pm

Previous

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 1 guest

cron