Search code examples
box2djbox2d

JBox2D Hangs On world.step()


A serious bug has popped up and I don't have a clue why. Not long after I start my game, the game freezes. All I know is that the program execution goes into world.step(1.0f/30.0f, 5, 2); and never exits, thus freezing the game (By never, I mean no visible change has occurred for more than a minute, and for this application it may as well be forever). I've been working on this for a while and this hasn't happened before, but now it happens every time within seconds of starting.

Anyone have any idea why this might happen?

Sadly, in an event like this, I kinda wish I was using version control.


Solution

  • I found the problem. For some reason it was this method (And another like it) that caused the problem.

        public Vec2 getRWallCenter()
        {
            Vec2 v = rWall.getPosition();
            float scale = purpleRadius / 2;
            v.set(v.x * scale, v.y * scale);
    
            return v;
        }
    

    Could it be that when I tried to scale v to screen coordinates, I was actually modifying the wall's vector? Perhaps I could try cloning the vector.