[SOLVED] GImpact shape creation crash in native code when Spatial are only Nodes

I am not sure, if this is a bug, but I saw nowhere mentioned that it won’t work. Found randomly when used a Node as placeholder.

import com.jme3.app.SimpleApplication;
import com.jme3.bullet.util.CollisionShapeFactory;
import com.jme3.scene.Node;
import com.jme3.system.JmeContext.Type;

public final class GImpactNodeTest extends SimpleApplication {
	
	@Override
	public void simpleInitApp() {
		final Node node = new Node();
		node.attachChild(new Node());
		CollisionShapeFactory.createGImpactShape(node);
	}
	
	public static void main(final String[] args) {
		new GImpactNodeTest().start(Type.OffscreenSurface);
	}
}
j  com.jme3.bullet.collision.shapes.GImpactCollisionShape.recalcAabb(J)V+0
j  com.jme3.bullet.collision.shapes.GImpactCollisionShape.recalculateAabb()V+6
j  com.jme3.bullet.collision.shapes.GImpactCollisionShape.setScale(Lcom/jme3/math/Vector3f;)V+6
j  com.jme3.bullet.collision.shapes.GImpactCollisionShape.createShape()V+31
j  com.jme3.bullet.collision.shapes.GImpactCollisionShape.<init>([Lcom/jme3/scene/Mesh;)V+17
j  com.jme3.bullet.util.CollisionShapeFactory.createGImpactShape(Lcom/jme3/scene/Spatial;)Lcom/jme3/bullet/collision/shapes/GImpactCollisionShape;+24

I used Minie 8.1 this time. ^^"

2 Likes

Thanks for bringing this case to my attention.

It’s quite reasonable for createGImpactShape() to fail on a Node containing zero vertices. However, it shouldn’t crash the Java Virtual Machine!

Minie could (and should) detect the zero-vertex condition at runtime and throw an exception with an helpful diagnostic message. I’ll add appropriate error checking to the next release of Minie.

Thanks again!

5 Likes

You’re welcome.

4 Likes

The new release (v8.2.0) throws an IllegalArgumentException if you try to create a GImpact shape with zero vertices.

2 Likes