Minie v1.7

Version 1.7 of the Minie Physics Library was released on schedule, exactly 7 weeks after version 1.6. It’s feature-packed, and already available from both GitHub and JCenter.

Notable additions to the libraries include:

  1. application-specific data for each collision object
  2. contact tests for collision spaces
  3. ignore lists for collision objects
  4. gravity protection for rigid bodies
  5. velocity visualization
  6. more efficient debug visualization

The v1.7 release also comes with 3 new demo apps, and many new features have been added to the DropTest application.

For details, see the release page at GitHub. For more details, see the release log.

13 Likes

Thanks :slightly_smiling_face:

1 Like

Here’s a quick primer on a few of the new features.

Applicable to all collision objects: rigid bodies, vehicles, ghosts, soft bodies, physics characters, rigid-body controls, character controls, etcetera.

collisionObject.setApplicationData(someData);
//...
Object appData = collisionObject.getApplicationData();

Like “user data”, the data object can be of any type. It gets cloned (if Cloneable) and loaded/saved (if Savable) whenever the collision object gets cloned/loaded/saved.

Aside from cloning/loading/saving, Minie ignores the application data, so you can use it however you like—unlike “user data” which is used by physics controls.

Some of the Minie demo apps (including DropTest) use application data to remember custom debug materials when they’re not in use.

Fully supported in physics spaces and collision spaces. In soft-body spaces, it ignores soft bodies due to a limitation of Bullet.

        PhysicsCollisionListener listener = new PhysicsCollisionListener() {
            @Override
            public void collision(PhysicsCollisionEvent event) {
                //...
            }
        };
        int numContacts = space.contactTest(collisionObject, listener);

In typical applications, the collision-object argument is NOT in any space.

The return value indicates how many “contacts” the object would have IF it were added to the space being tested. If the listener is non-null, it’ll be invoked for each contact to provide details such as penetration depth.

A single collision object can generate multiple contacts. To determine how many OBJECTS would make contact, you’d need to provide a listener that counts distinct objects.

The DropTest demo app uses a contact test to avoid adding drops that might entangle an object already in the PhysicsSpace.

Ignore lists allow you to specify pairs of collision objects whose collisions should be ignored.

Finer grained and simpler to use than collision groups. Applicable to all collision objects: rigid bodies, vehicles, ghosts, soft bodies, physics characters, rigid-body controls, character controls, etcetera.

collisionObject.addToIgnoreList(otherPco);
boolean isIgnored = collisionObject.ignores(otherPco);
int numIgnored = collisionObject.countIgnored();
long[] ingnoredIds = collisionObject.listIgnoredIds();
collisionObject.removeFromIgnoreList(otherPco);

ignores() is completely symmetrical, so a.ignores(b) == b.ignores(a) and it’s unnecessary (but harmless) to add A to B’s ignore list if B is already in A’s list.

No explicit uses yet in applications, though Constraint.setCollisionBetweenLinkedBodies() is now implemented atop this feature.

Enabling gravity protection on a rigid body prevents PhysicsSpace from overwriting the body’s gravity vector when (a) the body is added to a space or (b) something changes the gravity vector of the space the body is in.

I imagine everyone who’s used Bullet physics in an application has been burned by this “feature” at least once. Perhaps gravity protection should someday be enabled by default!

PhysicsRigidBody rigidBody = new PhysicsRigidBody(shape, mass);
assert !rigidBody.isGravityProtected();
rigidBody.protectGravity(true);
//...
Vector3f g = rigidBody.getGravity(null);
space.addCollisionObject(rigidBody);
assert g.equals(rigidBody.getGravity(null));

Gravity protection works on vehicles and rigid-body controls, too.

For soft bodies, gravity is stored in the world info. There’s an analogous feature setProtectWorldInfo(true) to protect the world info from replacement.

This feature requires a BulletAppState with debug visualization enabled.

Enabling velocity visualization causes white arrows to be drawn (for selected bodies) to represent their velocity vectors. Arrow lengths correspond to one second of (projected) motion.

bulletAppState.setDebugEnabled(true);
BulletDebugAppState.DebugAppStateFilter selectAll = new FilterAll(true);
bulletAppState.setDebugVelocityVectorFilter(selectAll);

Many of the Minie demo apps (including DropTest ) include velocity visualization. To toggle this feature on/off, they use the “K” key.

There’s a similar feature to visualize gravity vectors, but it’ll probably get less use (since gravity rarely changes). In DropTest, gravity visualization is toggled using the “J” key.

Versions 0.5.1 through 1.6.1 of Minie avoided issue 1346 by simply rebuilding the debug Spatial for every compound-shaped object on every frame. Version 1.7 determines when a rebuild is required, making such visualizations more efficient.

5 Likes

Great work as always @sgold . I recommend any new project to use this over JME-bullet. When you feel comfortable I suggest we start recommending it officially wherever possible (wiki, front page, etc).

If you want to push a blog entry I’ll happily publish it.

4 Likes

Thank you @jayfella.

I’d like Minie to officially replace jme3-bullet as soon as the v3.3 SDK is out of beta.
(Or when JME 4 is released, if that comes sooner…)

5 Likes

It’s amazing. It seems that you are a physics engine expert!! :boom:

1 Like

Thank you for the great library. 1.7 already placed and working in my app. IgnoreList and setApplicationData are very useful for my project.

1 Like