www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: kiffa on April 19, 2013, 05:38:51 AM

Title: NullPointerException in collision checking
Post by: kiffa on April 19, 2013, 05:38:51 AM
codes:

mObject3d.checkForCollisionSpherical(step, r);

Exception:

04-19 01:31:19.280: E/AndroidRuntime(3243):       java.lang.NullPointerException
04-19 01:31:19.280: E/AndroidRuntime(3243): at com.threed.jpct.Object3D.collideSpherical(Object3D.java:4284)
04-19 01:31:19.280: E/AndroidRuntime(3243): at com.threed.jpct.World.checkSomeCollisionSpherical(World.java:1650)
04-19 01:31:19.280: E/AndroidRuntime(3243): at com.threed.jpct.World.checkObjCollisionSpherical(World.java:1275)
04-19 01:31:19.280: E/AndroidRuntime(3243): at com.threed.jpct.Object3D.checkForCollisionSpherical(Object3D.java:2865)
04-19 01:31:19.280: E/AndroidRuntime(3243): at com.zwenyu.woo3d.entity.ComMove.checkCollision(ComMove.java:130)
04-19 01:31:19.280: E/AndroidRuntime(3243): at com.zwenyu.woo3d.entity.ComAI.tryMove2(ComAI.java:54)
04-19 01:31:19.280: E/AndroidRuntime(3243): at com.zwenyu.woo3d.entity.ComAI.update(ComAI.java:173)
04-19 01:31:19.280: E/AndroidRuntime(3243): at com.zwenyu.woo3d.entity.GameEntity.update(GameEntity.java:144)
04-19 01:31:19.280: E/AndroidRuntime(3243): at com.zwenyu.woo3d.entity.GameEntityManager.updateAllEntities(GameEntityManager.java:60)
04-19 01:31:19.280: E/AndroidRuntime(3243): at com.zwenyu.woo3d.scene.Scene3D.onLoop(Scene3D.java:209)



Others: 
Hard to reappear the exception. I use octree for collision.
Title: Re: NullPointerException in collision checking
Post by: EgonOlsen on April 19, 2013, 07:22:21 AM
jPCT-AE isn't thread safe. Do not use any thread except for the rendering thread to work on jPCT-AE related instances (unless you synchronize it with the rendering).
Title: Re: NullPointerException in collision checking
Post by: kiffa on April 24, 2013, 11:28:02 AM
Thanks, you are right.

I handled the  collision checking in the method of View.onToch()(for picking) which was running in the UI Thread. Now i corrected this problem.