jMonkeyEngine / sdk

The jMonkeyEngine3 Software Development Kit based on Netbeans
BSD 3-Clause "New" or "Revised" License
315 stars 100 forks source link

Mouse Picking sometimes leads to a NPE #80

Open MeFisto94 opened 8 years ago

MeFisto94 commented 8 years ago

I don't know what I did, I just tried to use the Scene Composer with this lousy touchpad and then... bam!

java.lang.NullPointerException
    at com.jme3.math.Vector3f.subtract(Vector3f.java:683)
    at com.jme3.gde.scenecomposer.tools.PickManager.getTranslation(PickManager.java:176)
    at com.jme3.gde.scenecomposer.tools.PickManager.getTranslation(PickManager.java:186)
    at com.jme3.gde.scenecomposer.tools.shortcuts.MoveShortcut.mouseMoved(MoveShortcut.java:160)
    at com.jme3.gde.scenecomposer.SceneComposerToolController.doEditToolMoved(SceneComposerToolController.java:218)
    at com.jme3.gde.scenecomposer.ComposerCameraController.checkMoved(ComposerCameraController.java:105)
    at com.jme3.gde.core.scene.controller.AbstractCameraController.update(AbstractCameraController.java:514)

It doesn't know the end position

dokthar commented 8 years ago

I think I'll have to take a look at this.

dokthar commented 8 years ago

How do you encounter this issue, does it happen every time ? try inserting this line : if(startPickLoc == null) startPickLoc = SceneEditTool.pickWorldLocation(camera, screenCoord, plane, null); at L.82 in updatePick(...) in PickManager

if this solve the issue i'll do some refactor to make sure the first pick position is set when initializing the pick manager.

MeFisto94 commented 8 years ago

No, I have no clue, it 'just' happened when I was trying to set the motionPath. Afterwards I didn't have any problems anymore.

It's hard to reproduce though, so could the startPickLoc by any chance be set wrongly (e.g. I clicked outside of the window?)

dokthar commented 8 years ago

It's hard to reproduce though, so could the startPickLoc by any chance be set wrongly (e.g. I clicked outside of the window?)

This is what i thought.