Author Topic: Calling Object3D.cloneObject() causes NullPointerException  (Read 8032 times)

Offline QuirB

  • byte
  • *
  • Posts: 7
    • View Profile
Trying to clone an Object3D causes a NullPointerException. The object on which cloneObject() is called is definitely not null itself (see stacktrace below).
The strange thing is, the very same object is beeing cloned multiple times at an earlier stage of the game without any problems. Am I missing something, wich causes this behavior?

Device:
Samsung Galaxy TabPRO 10 (SM-T520)
Android 4.4.2 (KitKat)


Code: [Select]
05-29 01:33:46.491: E/AndroidRuntime(14875): FATAL EXCEPTION: GLThread 61362
05-29 01:33:46.491: E/AndroidRuntime(14875): Process: minigame.earthdefender, PID: 14875
05-29 01:33:46.491: E/AndroidRuntime(14875): java.lang.NullPointerException
05-29 01:33:46.491: E/AndroidRuntime(14875): at com.threed.jpct.Object3D.copy(Object3D.java:723)
05-29 01:33:46.491: E/AndroidRuntime(14875): at com.threed.jpct.Object3D.<init>(Object3D.java:698)
05-29 01:33:46.491: E/AndroidRuntime(14875): at com.threed.jpct.Object3D.cloneObject(Object3D.java:2552)
05-29 01:33:46.491: E/AndroidRuntime(14875): at minigame.earthdefender.weapons.Bullet.<init>(Bullet.java:16)
05-29 01:33:46.491: E/AndroidRuntime(14875): at minigame.earthdefender.weapons.ProjectilePool.fireBullet(ProjectilePool.java:99)
05-29 01:33:46.491: E/AndroidRuntime(14875): at minigame.earthdefender.weapons.AttackQueue.dequeueAttack(AttackQueue.java:84)
05-29 01:33:46.491: E/AndroidRuntime(14875): at minigame.earthdefender.state.Running.launchProjectiles(Running.java:64)
05-29 01:33:46.491: E/AndroidRuntime(14875): at minigame.earthdefender.state.Running.onUpdate(Running.java:35)
05-29 01:33:46.491: E/AndroidRuntime(14875): at minigame.earthdefender.state.GameState.update(GameState.java:138)
05-29 01:33:46.491: E/AndroidRuntime(14875): at minigame.earthdefender.render.SmartRenderer.onDrawFrame(SmartRenderer.java:90)
05-29 01:33:46.491: E/AndroidRuntime(14875): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1531)
05-29 01:33:46.491: E/AndroidRuntime(14875): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1248)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Calling Object3D.cloneObject() causes NullPointerException
« Reply #1 on: May 29, 2014, 08:35:58 am »
You can't clone stripped objects. If you are using strip on a cloned object that shares the mesh with the one that should be cloned, you can call setLocked on the initial object's mesh to prevent the mesh from being stripped.

Offline QuirB

  • byte
  • *
  • Posts: 7
    • View Profile
Re: Calling Object3D.cloneObject() causes NullPointerException
« Reply #2 on: May 29, 2014, 11:55:29 am »
Thanks for the fast response. Problem is solved.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Calling Object3D.cloneObject() causes NullPointerException
« Reply #3 on: May 29, 2014, 12:37:20 pm »
....i should mention it in the docs.... ;)