(self, contact, old_manifold)
This is a critical function when there are many contacts in the world.
        It should be optimized as much as possible.
This is a critical function when there are many contacts in the world.
        It should be optimized as much as possible.
This is a critical function when there are many contacts in the world . It should be optimized as much as possible .
def PreSolve(self, contact, old_manifold):
        """
        This is a critical function when there are many contacts in the world.
        It should be optimized as much as possible.
        """
        if not (self.settings.drawContactPoints or
                self.settings.drawContactNormals or self.using_contacts):
            return
        elif len(self.points) > self.settings.maxContactPoints:
            return

        manifold = contact.manifold
        if manifold.pointCount == 0:
            return

        _, state2 = b2.b2GetPointStates(old_manifold, manifold)
        if not state2:
            return

        worldManifold = contact.worldManifold

        for i, _ in enumerate(state2):
            self.points.append(
                {
                    'fixtureA' : contact.fixtureA,
                    'fixtureB' : contact.fixtureB,
                    'position' : worldManifold.points[i],
                    'normal' : worldManifold.normal,
                    'state' : state2[i]
                })
def PreSolve ( self , contact , old_manifold ) : if not ( self . settings . drawContactPoints or self . settings . drawContactNormals or self . using_contacts ) : return elif len ( self . points ) > self . settings . maxContactPoints : return manifold = contact . manifold if manifold . pointCount == 0 : return _ , state2 = b2 . b2GetPointStates ( old_manifold , manifold ) if not state2 : return worldManifold = contact . worldManifold for i , _ in enumerate ( state2 ) : self . points . append ( { 'fixtureA' : contact . fixtureA , 'fixtureB' : contact . fixtureB , 'position' : worldManifold . points [ i ] , 'normal' : worldManifold . normal , 'state' : state2 [ i ] } )