NullPointerException in Geometry.applyStates()

Created a quad, did NOT set any render states, placed it in the ortho queue.

I got

   at com.jme.scene.Geometry.applyStates(
   at com.jme.scene.Geometry.draw(
   at com.jme.scene.TriMesh.draw(
   at com.jme.renderer.RenderQueue.renderOrthoBucket(
   at com.jme.renderer.RenderQueue.renderBuckets(
   at com.jme.renderer.lwjgl.LWJGLRenderer.displayBackBuffer(
   at yourobot.core.StateBasedGameEngine.start(
   at yourobot.test.CircuitTest.main(

Looking at the code, I'd say that under these circumstances the states array is initialized to all null references. Just a minor bug though. No one is likely adding quads without any render states.

Try calling updateRenderState on the root node.

Yes Badmi, I noticed that this works.

I just thought, even if I don’t do this, it should not throw a NullPointerException.

Good point. I’ll look into it. One arguement is though that it forces you to be aware of the update RS method and the need to call it… But on the other hand, it’s an ugly result.

Update: I’ve removed the possibility of getting an NPE in Geometry.applyStates. if your state is null, it is ignored and currentState is also made null.