stephengold / jme-vehicles

A tech demo and library for simulating vehicles in jMonkeyEngine
BSD 3-Clause "New" or "Revised" License
17 stars 7 forks source link

IndexOutOfBoundsException while loading a vehicle #2

Closed stephengold closed 3 years ago

stephengold commented 3 years ago

Perhaps this is related to issue #1, since it happens about the same time as adding a vehicle to the scene. However, the stack trace is quite different:

Libbulletjme version 9.2.2 initializing
Nov 21, 2020 5:29:40 PM com.jme3.material.Material checkSetParam
WARNING: Material parameter being set: Texture with type Texture2D doesn't match definition types TextureCubeMap
Nov 21, 2020 5:29:54 PM com.jme3.app.LegacyApplication handleError
SEVERE: Uncaught exception thrown in Thread[main,5,main]
java.lang.IndexOutOfBoundsException
    at java.nio.Buffer.checkIndex(Buffer.java:540)
    at java.nio.DirectFloatBufferU.get(DirectFloatBufferU.java:253)
    at com.jme3.collision.bih.BIHTree.initTriList(BIHTree.java:97)
    at com.jme3.collision.bih.BIHTree.<init>(BIHTree.java:135)
    at com.jme3.collision.bih.BIHTree.<init>(BIHTree.java:139)
    at com.jme3.scene.Mesh.createCollisionData(Mesh.java:991)
    at com.jme3.scene.Mesh.collideWith(Mesh.java:1032)
    at com.jme3.scene.Geometry.collideWith(Geometry.java:472)
    at com.jme3.scene.Node.collideWith(Node.java:615)
    at com.jme3.scene.Node.collideWith(Node.java:615)
    at com.simsilica.lemur.event.PickEventSession.cursorMoved(PickEventSession.java:567)
    at com.simsilica.lemur.event.MouseAppState.dispatchMotion(MouseAppState.java:94)
    at com.simsilica.lemur.event.BasePickState.update(BasePickState.java:239)
    at com.jme3.app.state.AppStateManager.update(AppStateManager.java:356)
    at com.jme3.app.SimpleApplication.update(SimpleApplication.java:255)
    at com.jme3.system.lwjgl.LwjglWindow.runLoop(LwjglWindow.java:530)
    at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:632)
    at com.jme3.system.lwjgl.LwjglWindow.create(LwjglWindow.java:466)
    at com.jme3.app.LegacyApplication.start(LegacyApplication.java:463)
    at com.jme3.app.LegacyApplication.start(LegacyApplication.java:424)
    at com.jme3.app.SimpleApplication.start(SimpleApplication.java:127)
    at com.jayfella.jme.vehicle.Main.main(Main.java:85)
stephengold commented 3 years ago

I think this is caused by an invalid mesh somewhere in the scene.

stephengold commented 3 years ago

I never figured out a way to reproduce this issue every time, however it happened frequently as of e6ac179 (22 November) and I'm fairly sure it hasn't been seen since a55ea38 (also 22 November).

Until I see it again, I'll assume a55ea38 solved this issue.

stephengold commented 3 years ago

JME could be more cautious when it comes to picking custom meshes. If the custom mesh doesn't invoke updateCounts() then its vertex count is -1, a value which the BIHTree constructor accepts uncritically and passes to the VirtualIndexBuffer constructor, which also does no range checking.

I'm not saying that's the root cause of this issue in all cases, but it seems a plausible scenario.