I have the following code to create boxes with a physics node from JMEphysics. I use a simple nested for loop to draw/place a 32x32 grid of these boxes on a textured 1000x1000 floor.
The first row of boxes is placed lightning fast, as expected. The second slows down, the third one crawls, and the fourth one is like molasses through a straw. If I wait long enough, it even crashes. What am I doing wrong here? Am I leaking something?
public void createCube(int x, int y) {
Box b = new Box("My Box", new Vector3f(0,0,0), new Vector3f(1,1,1));
b.rotateUpTo(new Vector3f(0,0,-1));
b.setModelBound(new BoundingSphere());
b.updateModelBound();
PhysicsNode box = getPhysicsSpace().createStaticNode();
box.attachChild(b);
box.setMaterial(Material.CONCRETE);
box.setLocalScale(5);
box.setLocalTranslation(new Vector3f(x,0,y)); // middle one is vertical?!! WTF
box.createBox("falling box"); //simple physicsbox
rootNode.attachChild(box);
}