New 2.1.2 release, Updating, and Info

Hey guys,

So some of you might have noticed that the trunk isn't as stable as it usually is. This is because I'm doing the update to 2.3.0 (edit: 2.2.2 w/ tangent force), and it's quite a lot of changes. In the meantime, I fixed a couple bugs and did a few more optimizations on a 2.1.2.2 snapshot build. Hooray!

As you may expect, updating something this can be a bit tricky, as small errors can ruin the whole engine. Thankfully, I have it *somewhat* working. I have yet to fully include chain and loop shapes (the shapes are in there but there are no contacts for them yet). Collisions look good, and TOI looks good, joints are tricky still.

If you would like to help out on this update, the best way would be to make testcases that shows a single bug (think as simple as possible, yet still showing the bug). This helps a lot. Feel free to contact me about general contribution as well, the repository is feeling awfully lonely 😢

Anyways, thanks for all your support!

Daniel



Edit: Current known bugs in trunk version (updating):
  • Revolute joint isn't completely normal (pull on chain)
  • Contact points are generated too far forward when circle is moving through a static object (so it keeps going through)
  • Vertical stack still falls down

Fixed:
  • Prismatic not quite right w/limits and motor (prismatic)
  • Strange collision with prismatic jointed objects (collision filtering)
  • Static object is being rotated in apply force test
  • Mouse joint sometimes binding to wrong spot
  • Distance joint going crazy
  • Revolute joint going crazy
  • Strange collision with compound shapes that intersect (compound shapes test)
Will there be support for ovals? (not just circles)
Some tests capturing the big problem I'm seeing:

Code:
package org.jbox2d.testbed.tests;

import org.jbox2d.collision.shapes.CircleShape;
import org.jbox2d.collision.shapes.Shape;
import org.jbox2d.common.Vec2;
import org.jbox2d.dynamics.Body;
import org.jbox2d.dynamics.BodyDef;
import org.jbox2d.dynamics.BodyType;
import org.jbox2d.dynamics.joints.RevoluteJointDef;
import org.jbox2d.testbed.framework.TestbedTest;

public class FixedPendulumTest extends TestbedTest
{
   private final boolean switchBodiesInJoint;

   public FixedPendulumTest(boolean switchBodiesInJoint)
   {
      this.switchBodiesInJoint = switchBodiesInJoint;
   }
   
   @Override
   public void initTest(boolean argDeserialized)
   {
      Body pendulum;
      Body ground;

      {
         CircleShape circleShape = new CircleShape();
         circleShape.m_radius = 1;
         Shape shape = circleShape;
   
         BodyDef bodyDef = new BodyDef();
         bodyDef.type = BodyType.DYNAMIC;
         bodyDef.position.set(-5, 0);
         bodyDef.allowSleep = false;
         pendulum = getWorld().createBody(bodyDef);
         pendulum.createFixture(shape, 1);
      }
      
      {
         BodyDef bodyDef = new BodyDef();
         bodyDef.type = BodyType.STATIC;
         ground = getWorld().createBody(bodyDef);
      }
      
      RevoluteJointDef jointDef = new RevoluteJointDef();
      
      if (switchBodiesInJoint)
         jointDef.initialize(pendulum, ground, new Vec2(0, 0));
      else
         jointDef.initialize(ground, pendulum, new Vec2(0, 0));
      
      getWorld().createJoint(jointDef);
   }

   @Override
   public String getTestName()
   {
      return "Fixed Pendulum " + (switchBodiesInJoint ? "1" : "0");
   }
}


Code:
package org.jbox2d.testbed.tests;

import org.jbox2d.collision.shapes.CircleShape;
import org.jbox2d.collision.shapes.PolygonShape;
import org.jbox2d.collision.shapes.Shape;
import org.jbox2d.common.Vec2;
import org.jbox2d.dynamics.Body;
import org.jbox2d.dynamics.BodyDef;
import org.jbox2d.dynamics.BodyType;
import org.jbox2d.dynamics.joints.RevoluteJointDef;
import org.jbox2d.testbed.framework.TestbedTest;

public class FreePendulumTest extends TestbedTest
{
   private final boolean switchBodiesInJoint;

   public FreePendulumTest(boolean switchBodiesInJoint)
   {
      this.switchBodiesInJoint = switchBodiesInJoint;
   }
   
   @Override
   public void initTest(boolean argDeserialized)
   {
      Body pendulum;
      Body base;
      Body ground;

      {
         CircleShape circleShape = new CircleShape();
         circleShape.m_radius = 1;
         Shape shape = circleShape;
   
         BodyDef bodyDef = new BodyDef();
         bodyDef.type = BodyType.DYNAMIC;
         bodyDef.position.set(-5, 0);
         bodyDef.allowSleep = false;
         pendulum = getWorld().createBody(bodyDef);
         pendulum.createFixture(shape, 1);
      }
      
      {
         PolygonShape shape = new PolygonShape();
         shape.setAsBox(1, 1);
         
         BodyDef bodyDef = new BodyDef();
         bodyDef.type = BodyType.DYNAMIC;
         bodyDef.position.set(0, 2);
         bodyDef.allowSleep = false;
         base = getWorld().createBody(bodyDef);
         base.createFixture(shape, 1);
      }
      
      {
         PolygonShape shape = new PolygonShape();
         shape.setAsBox(3, 1);
         
         BodyDef bodyDef = new BodyDef();
         bodyDef.type = BodyType.STATIC;
         ground = getWorld().createBody(bodyDef);
         ground.createFixture(shape, 0);
      }
      
      RevoluteJointDef jointDef = new RevoluteJointDef();
      
      if (switchBodiesInJoint)
         jointDef.initialize(pendulum, base, new Vec2(0, 0));
      else
         jointDef.initialize(base, pendulum, new Vec2(0, 0));
      
      getWorld().createJoint(jointDef);
   }

   @Override
   public String getTestName()
   {
      return "Free Pendulum " + (switchBodiesInJoint ? "1" : "0");
   }
}


Use the construction arguments to turn these two tests into four. Of the four, only Fixed Pendulum 0 fails to show obvious errors.
MJW, thanks a bunch, fixed two bugs in the revolute joint.

I'll keep a list of current known bugs in the first post
That helps. A further problem:

Code:
package org.jbox2d.testbed.tests;

import org.jbox2d.collision.shapes.PolygonShape;
import org.jbox2d.common.Vec2;
import org.jbox2d.dynamics.Body;
import org.jbox2d.dynamics.BodyDef;
import org.jbox2d.dynamics.BodyType;
import org.jbox2d.testbed.framework.TestbedTest;

public class SetAsRotatedBoxTest extends TestbedTest
{
   @Override
   public void initTest(boolean argDeserialized)
   {
      {
         PolygonShape shape = new PolygonShape();
         shape.setAsBox(1, 1, new Vec2(0, 0), .5f * 3.1416f);
   
         BodyDef bodyDef = new BodyDef();
         bodyDef.type = BodyType.DYNAMIC;
         bodyDef.position.set(0, 3);
         bodyDef.angle = 3;
         bodyDef.allowSleep = false;
         Body body = getWorld().createBody(bodyDef);
         body.createFixture(shape, 1);
      }
      
      {
         PolygonShape shape = new PolygonShape();
         shape.setAsBox(1, 1);
         
         BodyDef bodyDef = new BodyDef();
         bodyDef.type = BodyType.STATIC;
         Body ground = getWorld().createBody(bodyDef);
         ground.createFixture(shape, 0);
      }
   }

   @Override
   public String getTestName()
   {
      return "Set as Rotated Box";
   }
}
Awesome, that fixed a couple issues (body types test, compound shapes)
maybe a bug in all 2.1 version: in all testbed body never go to sleep.

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