GithubHelp home page GithubHelp logo

jbox2d / jbox2d Goto Github PK

View Code? Open in Web Editor NEW
1.1K 1.1K 208.0 26.61 MB

a 2d Java physics engine, native java port of the C++ physics engines Box2D and LiquidFun

Home Page: http://www.jbox2d.org

License: BSD 2-Clause "Simplified" License

C++ 4.42% Java 94.84% sed 0.20% C 0.55%

jbox2d's Introduction

jbox2d

Please see the project's BountySource page to vote on issues that matter to you. Commenting/voting on issues helps me prioritize the small amount of time I have to maintain this library :)

JBox2d is a Java port of the C++ physics engines LiquidFun and Box2d.

If you're looking for help, see the wiki or come visit us at the Java Box2d subforum. Please post bugs here on the issues page.

If you're planning on maintaining/customizing your own copy of the code, please join our group so we can keep you updated.

If you're looking to deploy on the web, see PlayN, which compiles JBox2d through GWT so it runs in the browser. The JBox2d library has GWT support out of the box. Also, TeaVM support jbox2d in the browser as well.

If you've downloaded this as an archive, you should find the built java jars in the 'target' directories of each project.

======

jbox2d-library - this is the main physics library. The only dependency is the SLF4J logging library.

jbox2d-serialization - this adds serialization tools. Requires google's protocol buffer library installed to fully build (http://code.google.com/p/protobuf/), but this is optional, as the generated sources are included.

jbox2d-testbed - A simple framework for creating and running physics tests.

jbox2d-testbed-jogl - The testbed with OpenGL rendering.

jbox2d-jni-broadphase - Experiment with moving parts of the engine to C++. Not faster.

jbox2d's People

Contributors

alyphen avatar badlogic avatar boop5 avatar christopwner avatar deecewan avatar deepsnowneel avatar dependabot[bot] avatar dmurph avatar dontpanic345 avatar ewjordan avatar formula1 avatar hallvard avatar jayh5 avatar jlleitschuh avatar kelunik avatar mobidevelop avatar samskivert avatar tulsidas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jbox2d's Issues

Compiling error

When I'm trying to compile sources with Maven, I got the error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project jbox2d-testbed-jogl: Compilation failure:

Compilation failure:
[ERROR] /C:/.../jbox2d-master/jbox2d-testbed-jogl/src/main/java/org/jbox2d/testbed/framework/jogl/JoglTestbedMain.java:[37,54] 
import requires canonical name for org.jbox2d.testbed.framework.AbstractTestbedController.MouseBehavior

[ERROR] /C:/.../jbox2d-master/jbox2d-testbed-jogl/src/main/java/org/jbox2d/testbed/framework/jogl/JoglTestbedMain.java:[38,54] 
import requires canonical name for org.jbox2d.testbed.framework.AbstractTestbedController.UpdateBehavior

I use jdk1.8.0_102.
How should I compile it correctly?

I hava a error for runing testbed

DEBUG TestPanelJ2D - dbImage is null, creating a new one
Exception in thread "Testbed" java.lang.UnsatisfiedLinkError: org.jbox2d.common.StrictMath.sqrt(D)D
        at org.jbox2d.common.StrictMath.sqrt(Native Method)
        at org.jbox2d.common.MathUtils.sqrt(MathUtils.java:316)
        at org.jbox2d.dynamics.contacts.Contact.mixFriction(Contact.java:351)
        at org.jbox2d.dynamics.contacts.Contact.init(Contact.java:125)
        at org.jbox2d.dynamics.World.popContact(World.java:261)
        at org.jbox2d.dynamics.ContactManager.addPair(ContactManager.java:117)
        at org.jbox2d.collision.broadphase.DefaultBroadPhaseBuffer.updatePairs(DefaultBroadPhaseBuffer.java:178)
        at org.jbox2d.dynamics.ContactManager.findNewContacts(ContactManager.java:172)
        at org.jbox2d.dynamics.World.solve(World.java:1222)
        at org.jbox2d.dynamics.World.step(World.java:635)
        at org.jbox2d.testbed.framework.TestbedTest.step(TestbedTest.java:447)
        at org.jbox2d.testbed.tests.BulletTest.step(BulletTest.java:96)
        at org.jbox2d.testbed.framework.AbstractTestbedController.updateTest(AbstractTestbedController.java:274)
        at org.jbox2d.testbed.framework.AbstractTestbedController.render(AbstractTestbedController.java:406)
        at org.jbox2d.testbed.framework.AbstractTestbedController.stepAndRender(AbstractTestbedController.java:392)
        at org.jbox2d.testbed.framework.TestbedController.stepAndRender(TestbedController.java:68)
        at org.jbox2d.testbed.framework.TestbedController.run(TestbedController.java:62)
        at java.lang.Thread.run(Thread.java:745)

Java Doc is Missing?

Hello,

I tried to find JavaDoc for JBox2D on GitHub, but I was not able to locate it. Eventually, I found JBox 2.2.1.1 JavaDoc in the old Google Code location:

https://code.google.com/p/jbox2d/downloads/detail?name=jbox2d-2.2.1.1.zip

I unzipped it and hosted it at a repository here:

Repo: https://github.com/TrentCoder/jbox2d-2.2.1.1-API-Java-Doc (EDIT: Deleted)
GitHub Page to Browse JavaDoc: http://trentcoder.github.io/jbox2d-2.2.1.1-API-Java-Doc/ (EDIT: Deleted)

My question is: do you plan to host it on the jbox2d repo? And will JavaDoc be generated for JBox2D 2.3.1?

UPDATED (August 2, 2014): I generated Java Doc from the latest JBox2D (retrieved on August 2, 2014). I am hosting it here:

http://trentcoder.github.io/JBox2D_JavaDoc/

https://github.com/TrentCoder/JBox2D_JavaDoc

Thanks,
Trent

No Compiling Instructions

How is this supposed to be compiled? The Google Code wiki has information that is extremely outdated. Is there a compiled jar I can use instead?

Website: bad link

At http://www.jbox2d.org/, the following line has a broken link; it uses the URL hhttps://github.com/jbox2d/jbox2d/releases, with too many h's.

Grab the executable testbed jar from one of the releases for a current demo.

Applying a force to a ParticleGroup

It seems like JBox2d is missing the API from liquidfun to apply a force to a ParticleGroup. How could I do it with the current JBox2D API? Alternatively, is there any workaround? If not, how would I go about adding support for this?

Thx.

Settings.maxPolygonVertices is a constant

In older version of JBox2D I could alter the maximum number of vertices per polygon. Sometimes it is really necessary to have large polygons. With the number of vertices limited to 8 I have to split my polygons and encounter performance loss. But in general, I don't understand reason of having the same number of vertices allocated by all polygons. Why do you allocate array of maxPolygonVertices vertices for every PolygonShape? Could you just allocate as much vertices as needed in the PolygonShape.set method and get rid of this constant?

Serialization BUG

I am running a world which uses body.applyForce() to push bodies, I deserialize my world, then something really strange happened -- the bodies are forced faster several times than before. I didn't find where is wrong. So I run the Apply Force Test in JBox2D Testbed to just click button 'Save' and 'Load'. Then same strange thing happened, When I pressed the key 'w', 'a', 's', 'd', the body controlled by me moved faster several times than before, it is too fast to be manipulated.
My jre/jdk is 1.8.0_112 and I have tried jbox2d-2.1.2.3, 2.2.1.1 and master. Have you met anything like this? Where on earth is wrong?

I got the following error in Bubble-Picker using jbox2d.

When removing items from bubble-picker by using Jbox2d.

a source with a bug: https://github.com/tuxxon/Bubble-Picker

    Process: com.touchizen.bubblepicker, PID: 30187
    java.lang.AssertionError
        at org.jbox2d.collision.broadphase.DynamicTree.destroyProxy(DynamicTree.java:115)
        at org.jbox2d.collision.broadphase.BroadPhase.destroyProxy(BroadPhase.java:104)
        at org.jbox2d.dynamics.Fixture.destroyProxy(Fixture.java:314)
        at org.jbox2d.dynamics.World.destroyBody(World.java:344)
        at com.igalata.bubblepicker.physics.Engine.move(Engine.kt:66)
        at com.igalata.bubblepicker.rendering.PickerRenderer.onDrawFrame(PickerRenderer.kt:75)
        at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1571)
        at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1270)

More detail = https://stackoverflow.com/questions/65137339/when-removing-items-on-bubble-picker-the-following-errors-occur

Does anyone help me?

Maybe remove .classpath/.project files?

Hi,

i noticed that you have commited .classpath and .project files. On further inspection, it appears that the .classpath file is referencing the Maven container anyways. Not commiting the .classpath and .project files to the repository and importing the project into Eclipse via the "Existing Maven Project" would generate those files just fine. I'd suggest removing those files from the repo.

Maybe i've overlooked a reason why those are in the repo though!

ciao,
Mario

Inverted gravity problem

Hello, I'm using jbox2d 2.2.1.1 in Android, I found all the examples on the web have a negative gravity(-9.8), but in my version, I have to set it to a positive value so that body can be pulled down by gravity, a negative value makes it goes upward.and I have to set it bigger than others.

Vec2 gravity = new Vec2(0, 50f);

Is there any problem with my download version?

Thanks.

Extreme unstable of particles

I am playing around with the particles in jbox2d.
At first glance it was working fine, creating a few particles for one group works and was running stable.
Now i creating more groups, but joining it together and even with two groups, it gets unstable very fast - particles jump like crazy.

I am creating particles like this, doing nothing special and later render it using opengl.
And yes i am creating particle groups for every lava tile in my map.

        world.setParticleRadius(0.1f * worldScale);
        world.setParticleDamping(0.2f);
        world.setParticleDensity(0.1f);

        ParticleGroup lastGroup = null;
        Vec2f tileFluidExt = new Vec2f(1f * worldScale * 0.5f, 1f * worldScale * 0.5f);
        Transform pxf = new Transform();
        pxf.setIdentity();
        CircleShape pshape = new CircleShape();
        for (int y = 0; y < tileFluidsLayer.getHeight(); y++) {
            for (int x = 0; x < tileFluidsLayer.getWidth()-1; x++) {
                int tile = tileFluidsLayer.getTile(x, y);
                if (tile == tileFluidsSet.getFirstId() + TileFluid.LAVA) {
                    final Vec2f fluidPos = createTilePosition(new Vec2f(x + 0.5f, y + 0.5f), tileFluidExt);
                    ParticleGroupDef pgf = new ParticleGroupDef();
                    pshape = new CircleShape();
                    pshape.m_radius = (1f - 0.2f) * worldScale;
                    pxf.setIdentity();
                    world.destroyParticlesInShape(pshape, pxf);
                    pgf.shape = pshape;
                    pgf.flags = ParticleType.b2_viscousParticle;
                    pgf.position.set(fluidPos.getX(), fluidPos.getY());
                    ParticleGroup newGroup = world.createParticleGroup(pgf);
                    if (lastGroup != null) {
                        world.joinParticleGroups(lastGroup, newGroup);
                    }
                    lastGroup = newGroup;
                }
            }
        }

update mvn repo

Hello, could you please update maven repo with latest stable version?
As I can see, maven repo contain 5-years old version.

Currently I'm trying to pull changes from jitpack, but I'm waiting more than hour and dependencies still not resolved. Have no idea what is going wrong there, but most probably I will pull repo as archive.

PolygonShape Moment of inertia calculation is incorrect

Hi Daniel,

I think that the calculation of the moment of inertia is incorrect. The last line where you correct to make the MI relative to the center of mass should shift the MI calculation from the average of the coordinates (point s) to the center of mass

In other words I think the last two lines (replacing the last line) of org.jbox2d.collision.shapes.PolygonShape.computeMass should be:
s.subLocal(massData.center);
massData.I -= massData.mass * (Vec2.dot(s, s));

One easy way to validate that is to check it with the same polygon that you move from one location to another. For example a Pentagon with vertices at: (2, 0), (0, 2), (-2, 0), (-1, -1), (1, -1) has coordinate average (point s) = (0, 0) and center of mass at (0, 0.19...). The MI relative to point s is 8.66. With center of rotation set at the center of mass the MI should be 8.41 (Note the MI relative to the center of mass is the smallest of all MI values).

If you now move that pentagon around (e.g. (3, 0), (1, 2), (-1, 0), (0, -1), (2, -1) you should get the same moments of inertia: 8.66 around point s (1, 0) and 8.41 around center of mass (1, 0.19)

Hopefully my calculations are right... :)
Vihren

BTW I think this calculation appears to be incorrect in the original Box2D code as well even though it is a different error

ConstantVolumeJointDef breaks when bodies are far from the origin

(jbox2d-library-2.2.1.1.jar -- if this has been fixed in later versions, my apologies)

In order to embed JBox2D into an existing simulation system, I have to translate all the bodies (or body defs, it doesn't matter) approximately 100 units in both X and Y. I have discovered that in the BlobTest4 example if you translate the blob circles so that their ring is (say) centered around [100, 100] rather than [0,0], they immediately collapse rather than maintaining their volume. Indeed, the larger the translation, the stronger the collapse.

It appears that the further the group of objects is from the origin, the less force the ConstantVolumeJoint has. I think this bug wasn't tickled in the demo because the objects are close to [0,0] in the demo.

Any ideas?

Swimming WeldJoint when high distance on impact

weldjoints are soft which is good and this issue doesn't happen when all bodies are connected to eachother by weldjoints

But this issue is particularly relevant attempting to take advantage of a weldjoints softness


Reasoned Hypothesis
-Collision is registered by the body a
--passes collision information to body main
-nobody else gets the memo (which is fine, everything will get figured out)

Next TimeStep -This may be where the issue is
-main is in incorrect location according to body b
--applys impulse to account for that
-main is in incorrect location according to body c
--applys impulse to account for that

Next Time step
-main is in incorrect location according to body a
--applys impulse to account for that

the loop begins

Possible Solution(s)

==Down the Chain==
On impact
-Solve velocities, if body b has Weldjoints
-for(weldjoint w :body.jointList())
When Solving WeldJoints


this can be recreated with....

private Body function createGenericBody(float x, float y){
BodyDef bd = new BodyDef();
bd.bodytype = BodyType.DYNAMIC;
bd.position.set(new Vec2(x,y));
Body b = wold.createBody(bd);

CircleShape c = new CircleShape();
c.setRadius(5);

FixtureDef fd = new FixtureDef();
fd.shape = c;
fd.friction = .3;
fd.density = 1;

}

public void createSwimmingWeldJoints(){

Body main = createGenericBody(0,100);
Body a = createGenericBody(0,60);
Body b = createGenericBody(40,100);
Body c = createGenericBody(0,140);

WeldJointDef wjd =new WeldJointDef();
wjd.initialize(main, a, main.getPosition());
world.createJoint(wjd);

wjd =new WeldJointDef();
wjd.initialize(main, b, main.getPosition());
world.createJoint(wjd);

wjd =new WeldJointDef();
wjd.initialize(main, c, main.getPosition());
world.createJoint(wjd);

}

RevoluteJoint weird movement

I am trying to use body and joint to build robot and found that if 2 bodies are connected by 2 joint, revolutejoint, then this robot will move in a strange way. It will rotate by itself without any force or motors involved. But if the 2 bodies are just connected by 1 joint, then it is fine and the robot will just stay on the ground without any weird movements. I am not sure if this is an issue or reasonable in physics.

WeldJoint dynamic-static body

Weld joints do not appear to work when connecting dynamic and static bodies. They seem to be created and visible in the debug renderer, but the actual physics simulation is ignored.

Test code I use to create the joints:

// Creating the static body.
CircleShape circleShape = new CircleShape();
circleShape.setRadius(1f);

BodyDef bodyDef = new BodyDef();
bodyDef.position.set(1f, 1f);
bodyDef.type = BodyType.STATIC;

FixtureDef fixtureDef = new FixtureDef();
fixtureDef.density = 1f;
fixtureDef.shape = circleShape;

Body staticBody = world.createBody(bodyDef);
staticBody.createFixture(fixtureDef);

// Creating the joint.
WeldJointDef jointDef = new WeldJointDef();
jointDef.initialize(dynamic, staticBody, dynamic.worldCenter);
jointDef.collideConnected = true;
world.createJoint(jointDef);

Weird particle behavior colliding "short" chain segments

Particles colliding with "short" chain segments seem to gain a lot of force. This modified version of the DamBreak replaces the rectangular outer chain with a round one. The particles gain force when colliding with the shorter chain segments, the result looks like a show globe:

public class DamBreak extends TestbedTest {

    @Override
    public void initTest(boolean deserialized) {
        {
            BodyDef bd = new BodyDef();
            Body ground = m_world.createBody(bd);

            ChainShape shape = new ChainShape();

            final int SEGMENTS = 90;
            final float RADIUS = 20;

            Vec2[] vertices = new Vec2[SEGMENTS];

            for (int i = 0; i < SEGMENTS; i++)
            {
                float radians = (MathUtils.TWOPI * i) / SEGMENTS;
                vertices[i] = new Vec2((float) Math.sin(radians) * RADIUS, ((float) Math.cos(radians) * RADIUS) + 10);
            }

            shape.createLoop(vertices, SEGMENTS);
            ground.createFixture(shape, 0.0f);
        }

        m_world.setParticleRadius(0.15f);
        m_world.setParticleDamping(0.2f);
        {
            CircleShape shape = new CircleShape();
            shape.setRadius(4);
            shape.m_p.set(-13, 13);

            ParticleGroupDef pd = new ParticleGroupDef();
            pd.shape = shape;

            m_world.createParticleGroup(pd);
        }
    }

    @Override
    public String getTestName() {
        return "Dam Break";
    }
}

The effect can be reduced by setting SEGMENTS to 20 but it is still visible. This is reproducible with the current 2.3.1-SNAPSHOT.

Kind regards,
Manfred

PolygonShape.set() calculates vertex uniqueness incorrectly

Condition implemented as:
if (MathUtils.distanceSquared(v, ps[j]) < 0.5f * Settings.linearSlop)
should be:
if (MathUtils.distanceSquared(v, ps[j]) < (0.5f * Settings.linearSlop)*(0.5f * Settings.linearSlop))

Existing implementation leads to confusion.

confuse about ContactFilter class

ContactFilter Code:
`
public class ContactFilter {

/**
 * Return true if contact calculations should be performed between these two shapes.
 * @warning for performance reasons this is only called when the AABBs begin to overlap.
 * @param fixtureA
 * @param fixtureB
 * @return
 */
public boolean shouldCollide(Fixture fixtureA, Fixture fixtureB){
    Filter filterA = fixtureA.getFilterData();
    Filter filterB = fixtureB.getFilterData();

    if (filterA.groupIndex == filterB.groupIndex && filterA.groupIndex != 0){
        return filterA.groupIndex > 0;
    }

    boolean collide = (filterA.maskBits & filterB.categoryBits) != 0 &&
                      (filterA.categoryBits & filterB.maskBits) != 0;
    return collide;
}

}
`
When fixtureA and fixtureB have same groupIndex, and the groupIndex > 0.
fixtureA and fixtureB can perform contact calculations?

JavaFX support

I want to use JBox2D in a JavaFX environment, and my initial experiments are successful. As part of understanding various issues, I looked at the testbed, but I couldn't find a JavaFX port. I ended up doing it myself, so now I both have a testbed running and a better understanding of JBox2D. The question is, how should it be packaged/contributed? I had to make some changes to the testbed.framework package, as well as the j2d version, to make the javafx version cleaner. Currently it's in the same project, should it be a separate one like the one for jogl, like jbox2d-testbed-javafx?

ArrayIndexOutOfBoundsException when using RopeJoints

Hi,

I have already been working quite a bit with JBox2d (2.2.1.1) in my Android app and all was working fine so far (thanks for this great library!)

However, when I started to use RopeJoint in my app, it starts to crash.

java.lang.ArrayIndexOutOfBoundsException: length=100; index=100
        at org.jbox2d.pooling.normal.OrderedStack.pop(OrderedStack.java:52)
        at org.jbox2d.pooling.normal.DefaultWorldPool.popRot(DefaultWorldPool.java:226)
        at org.jbox2d.dynamics.joints.RopeJoint.solvePositionConstraints(RopeJoint.java:194)
        at org.jbox2d.dynamics.Island.solve(Island.java:371)
        at org.jbox2d.dynamics.World.solve(World.java:1085)
        at org.jbox2d.dynamics.World.step(World.java:598)

It does not occur all the time, but often enough to easily reproduce it and I am have no clue what I can do about it.

I am running JBox2D on Android (5.1.1), all operations are executed on a single thread:

My programm only has 2 bodies (static + dynamic) and one joint. Before each step I apply a force to the body. After a few rounds of iterations (like 20-30) my app crashes (not always, but well reproduceable)

world = new World(new Vec2(0.0f, 0.0f));

// create dynamic object

final BodyDef bd = new BodyDef();
bd.type = BodyType.DYNAMIC;

CircleShape cs = new CircleShape();
cs.m_radius = radiusWorld;

FixtureDef fd = new FixtureDef();
fd.shape = cs;
fd.density = 0.2f;
fd.friction = 0.0f;
fd.restitution = 1.0f;

Body dynBody = world.createBody(bd);
dynBody.setLinearDamping(0.01f);
dynBody.createFixture(fd);


// create static body

BodyDef bd = new BodyDef();
bd.type = BodyType.STATIC;
Body staticBody = world.createBody(bd);


// create joint

RopeJointDef joint = new RopeJointDef();
joint.bodyA = staticBody;
joint.bodyB = dynBody;
joint.collideConnected = false;
joint.maxLength = ropeLength;
joint.localAnchorA.set(staticBody.getLocalCenter());
joint.localAnchorB.set(dynBody.getLocalCenter());
world.createJoint(joint);

...

// calculate

dynBody.applyForceToCenter(...)
world.step(dt, 6, 3)

Can this be caused by a programming error? If yes, any tips what I might be doing wrong? Or can this possibly be a problem in the library. If yes, any fixes/workarounds or how I can debug this for certain.

I would really appreciate if someone can help me out here.

Thanks,
Flo

sinLUT created even if the SINCOS_LUT_ENABLED==false

Hi

There is an issue in the MathUtils.java

Current code creates sinLUT array even if the Settings.SINCOS_LUT_ENABLED is false;

Should be:

public static float[] sinLUT = setupSinLUT();

static final float[] setupSinLUT()
{
        if (Settings.SINCOS_LUT_ENABLED) {
            float[] sinLUT = new float[Settings.SINCOS_LUT_LENGTH];
            for (int i = 0; i < Settings.SINCOS_LUT_LENGTH; i++) {
                sinLUT[i] = (float)Math.sin(i * Settings.SINCOS_LUT_PRECISION);
            }
            return sinLUT;
        }
        return null;
}

Switch to strict floating point math?

Lately, I have been concerned about the cross-platform capabilities of my program and thus added the strictfp tag to all float-calculating functions (except for rendering) and switched from using Math to StrictMath. This is not triggered by default as it made a fairly large difference on old systems, but now, my testing shows < 1% difference. It is difficult to allow the user to choose without using some Reflection madness.

Spelling Mistake in Sweep class

There is a spelling mistake on line 30.
"the body origin, which may no coincide with the center of mass. However, to support dynamics we"
should be changed to:
"the body origin, which may not coincide with the center of mass. However, to support dynamics we"

sweep spelling mistake

NaN on particles at high speeds

https://github.com/formula1/jbox2d/blob/d8b11344998ffdf41ffa3d9d3f37d3a6ed1cf22f/jbox2d-testbed/src/main/java/org/jbox2d/testbed/tests/DeadParticle.java

https://github.com/dmurph/jbox2d/blob/master/jbox2d-library/src/main/java/org/jbox2d/particle/ParticleSystem.java
On lines 811 and 812 appears to be the first place the NaNs are showing up. This is caused by certian contacts having NaN weight and normal values.

What I know

  1. The NaNs are associated primarilly with ParticleContacts
  2. There is no NaNs on Creation of a Particle Contact
  3. I cannot find where the particle contacts are updating other than indexes
  4. Not all of the contacts are getting NaNs, usually there is a big chunk before and a smaller chunk after the area that has errors
  5. There is a pattern (every 35 or every 5) which may be caused by just the fact that theres a pattern in the particles themselves.
    6a) This pattern is effected by radius increasing the number of errors the smaller it is, and increasing the number contacts between each error contact
    6b) maximum radius errors start to appear is around .4761904

in addition solveSpring also has a division by 0 problem, but I believe thats more due to the NaNs showing up than anything else.

org.jbox2d.dynamics.joints RopeJoint.java maybe has an error

on the method : initVelocityConstraints(final SolverData data)
your has pop two Rot and one Vec2 from the pool. but the push statement is on the last of this method.
Before that your has a if() statement and it will return on some case, your hasn't push Rot and Vec2.And it cause leak and the world break.
I change it to :
if (m_length > Settings.linearSlop) {
m_u.mulLocal(1.0f / m_length);
} else {
m_u.setZero();
m_mass = 0.0f;
m_impulse = 0.0f;

//that's what I add, release the Rot and Vec2 before return.

  pool.pushRot(2);
  pool.pushVec2(1);

  return;
}

ParticleType.b2_colorMixingParticle

Incorrect results when Particles are flagged as b2_colorMixingParticle:

Error: bytewise color-difference
https://github.com/jbox2d/jbox2d/blob/master/jbox2d-library/src/main/java/org/jbox2d/particle/ParticleSystem.java#L1178

Fix: & 0xFF before subtraction

        int dr = (colorMixing256 * ((colorB.r & 0xFF) - (colorA.r & 0xFF))) >> 8;
        int dg = (colorMixing256 * ((colorB.g & 0xFF) - (colorA.g & 0xFF))) >> 8;
        int db = (colorMixing256 * ((colorB.b & 0xFF) - (colorA.b & 0xFF))) >> 8;
        int da = (colorMixing256 * ((colorB.a & 0xFF) - (colorA.a & 0xFF))) >> 8;

can we create a polygonshape-world?

The version of the lib is 2.2.1.1. Can we create a polygonshape-world? Here is the constructor.
World(Vec2 gravity)
World(Vec2 gravity, IWorldPool pool)
World(Vec2 gravity, IWorldPool argPool, BroadPhaseStrategy broadPhaseStrategy)

Show me a demo please. I'll appreciate it very much.

No Target in the builds

In the README it says: "If you've downloaded this an archive, you should find the built java jars in the 'target' directories of each project."
But in the 2.3-BETA or 2.2.1 there is no target directory. If I download the 2.2.1 build from google code, there is a target directory.

'target' directories missing?

I downloaded the archive and the target directory which contains the jars appears to be missing, are they supposed to be included?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.