Author Topic: NullPointerException in collision checking  (Read 1855 times)

Offline kiffa

  • long
  • ***
  • Posts: 199
    • View Profile
NullPointerException in collision checking
« on: April 19, 2013, 05:38:51 am »
codes:

Code: [Select]
mObject3d.checkForCollisionSpherical(step, r);
Exception:

Code: [Select]
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12297
    • View Profile
    • http://www.jpct.net
Re: NullPointerException in collision checking
« Reply #1 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).

Offline kiffa

  • long
  • ***
  • Posts: 199
    • View Profile
Re: NullPointerException in collision checking
« Reply #2 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.