Fixtures not Generating Contacts or Collisions

I have fixtures within a compound body that are not generating contacts or collisions of any kind.

I have created long bodies comprised of 80-150 4-vertex-fixtures as static collision geometry. My problem is that blocks of 2-10 fixtures within the strip are not colliding or generating contacts of any kind, while the rest of the fixtures are colliding correctly.

-The debug rendering is showing the fixtures are there.
-I've counted the size of the fixtureList to verify they are all loaded.
-I checked the filter data of every fixture in the body: categoryBits=1, maskBits=65535, groupIndex=0 (as expected)
-I printed out the IsSensor() of each fixture, none of them are sensors.
-I verified the body IsAwake() and IsActive() == 1
-I verified that the polygon winding is correct.
-Raycasts go right through the offending fixtures.

Now things are getting weird 😕 :

-The SAME geometry DOES collide properly in different levels.
-When a copy of the body is made, this usually causes a DIFFERENT block of fixtures in the copy to stop colliding.
-Sometimes, ALL the fixtures stop colliding.

I'm pulling my hair out here. Can anyone recommend a course of action to debug this further? I've been using Box2d for a year now and I've created bodies with 300+ fixtures and never had a problem. 🙁

EDIT: In playing with it further, I made one of my strips dynamic and that made all three previously broken strips in my level behave correctly. Reverting that strip back to being static causes them all to revert to containing contiguous blocks of broken fixtures. Is someone playing a terrible joke on me?

EDIT 2: I upgraded the code to use the latest drop from SVN (as of Sept30 2010). So far I am unable to reproduce the this behavior exactly. Instead of blocks of fixtures not colliding, now I get all or nothing. Either all fixtures collide, or none do (in the entire world).
I would love it if somebody could explain where in the Box2d codebase I could check to see why these particular fixtures are getting skipped in the collisions/contacts.
Just on the off chance.... I have seen some really wacky stuff happening occasionally until I noticed that b2Vec2() does not set its members to zero in the constructor. If you are relying on that in your code anywhere as I was, you might want to change all occurrences of it to b2Vec2(0,0)
Sorry can't help any more than that...!
Quote:
I noticed that b2Vec2() does not set its members to zero in the constructor


I can see how that might cause undefined behavior.

I tried initializing it to 0,0 in the constructor, recompiled and the problem persists. Thanks for the suggestion though.
b2ContactManager::Collide is where all the filtering occurs.
Thanks Erin.

I've ruled out filtering as the cause.

I went into b2ContactManager::Collide() and verified that my test bodies are making it all the way to the bottom of the function without having their contact filtered.

Then I went into b2Contact::Update() and found that, for my test bodies, the manifold point count is always equal to 0, so the bool "touching" is always false. In this case, it is two polygon shapes colliding (b2PolygonContact). But for this particular case, b2PolygonContact::Evaluate() refuses to create a manifold with >0 points.

Maybe I'm wrong, and my polygon winding is broken... what else could cause the polygon contact manifold to do this?
Are you using the Box2D debug draw? Perhaps your shapes are not where you think they are.
Hello,

I was also experiencing this trouble since upgrading.

Symptoms were "everything else working" but my contact listener methods were not being fired. I set breakpoints at every possible junction in the Box2D code until I discovered the virtual methods were being invoked instead.

My prototypes were not correct for the contact listener. I had used consts where they shouldn't be:

Code:
   // WRONG CODE!!!
   class Grid_Map_Listener : public b2ContactListener
   {
   public:
      Contact_Vector contacts;

      Grid_Map_Listener()
      {
         this->contacts.clear();
      }

      ~Grid_Map_Listener()
      {
         this->contacts.clear();
      }

        void BeginContact(const b2Contact* contact); // Bad
        void EndContact(const b2Contact* contact); // Bad
        void PreSolve(const b2Contact* contact, const b2Manifold* oldManifold); // Bad
        void PostSolve(const b2Contact* contact, const b2ContactImpulse* impulse); // Bad
   };


MSVC 2003 did not complain when compiling. Here is the correct proto:

Code:
   class Grid_Map_Listener : public b2ContactListener
   {
   public:
      Contact_Vector contacts;

      Grid_Map_Listener()
      {
         this->contacts.clear();
      }

      ~Grid_Map_Listener()
      {
         this->contacts.clear();
      }

        void BeginContact(b2Contact* contact);
        void EndContact(b2Contact* contact);
        void PreSolve(b2Contact* contact, const b2Manifold* oldManifold);
        void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse);
   };


Hopefully this information will save a bunch of headaches for someone else.

Thank you for the upgrade. Box2D now runs extremely fast and no longer seems to be a significant performance consideration.
I just wanted to mention that after 2 days of messing around, what finally fixed this problem was to simply upgrade the physics engine to the latest from google code.

I still have no idea what happened... don't you just love mystery bugs like that? 😀
Ediut: Duplicate.

Original thread: https://box2d.org/forum/viewtopic.php?t=5657