Author Topic: ArrayOutofBounds exception probelm  (Read 5320 times)

Offline JavaMan

  • long
  • ***
  • Posts: 231
    • View Profile
ArrayOutofBounds exception probelm
« on: January 20, 2008, 10:17:24 pm »
Hi, In my Object3DEditor program I am getting a strange problem when I add triangles to objects in the program. The probelm doesn't always happen just here and there, but it when it happens, it happens after adding a triangle to an object3d in the world. Here is the exception

Exception in thread "Thread-2" java.lang.ArrayIndexOutOfBoundsException: 11
        at com.threed.jpct.Object3D.render(Unknown Source)
        at com.threed.jpct.World.renderScene(Unknown Source)
        at Object3Ds.run(Object3DEditor.java:65)
        at java.lang.Thread.run(Unknown Source)

Any ideas as to what is happening here? The Thread-2 is the Thread that is rendering the world into a JPanel.
thanks v

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: ArrayOutofBounds exception probelm
« Reply #1 on: January 20, 2008, 11:28:00 pm »
So you are adding data in another thread then rendering? If so, synchronize the two operations. jPCT isn't thread safe, i.e. if you render something while adding data, funny things may happen.

Offline JavaMan

  • long
  • ***
  • Posts: 231
    • View Profile
Re: ArrayOutofBounds exception probelm
« Reply #2 on: January 21, 2008, 05:14:08 am »
Hi, I made sure the renderer thread and the thread ( which is actually a handler for a button click ) do not access the Object3D at the same time. Unfortunately, I am still getting the OutOfBoundsException. Thanks for the help though. I keep on working at it.
JMan

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: ArrayOutofBounds exception probelm
« Reply #3 on: January 21, 2008, 10:21:29 am »
Are you really sure? I'm pretty sure that the problem is related to concurrent access...similar problems always were.

Offline JavaMan

  • long
  • ***
  • Posts: 231
    • View Profile
Re: ArrayOutofBounds exception probelm
« Reply #4 on: January 21, 2008, 03:31:50 pm »
Ok, I will look again. I am actually going to combine the two threads into one, so that won't ( I hope ) be a problem. Maybe in the many lines of code, I didn't realize there was something going on that I didn't no about. Thanks for the help!  ;D
Jman