www.jpct.net
jPCT-AE - a 3d engine for Android => Support => Topic started by: jd on December 22, 2015, 10:34:10 pm
-
Hi,
I'm creating a complex GUI with jpct and need to use multi threading in many parts.
When multiple threads then try to calculate the normals of objects at the same time I get an exception like:
java.lang.ArrayIndexOutOfBoundsException: index=40 length=29
at com.threed.jpct.Mesh.calcNormalsFast(Mesh.java:988)
at com.threed.jpct.Mesh.calcNormals(Mesh.java:543)
at com.threed.jpct.Object3D.calcNormals(Object3D.java:3336)
It would really great if you could modify it to allow multi threading!
Thanks!
J. D.
-
jPCT-AE isn't thread safe, so you are actually not supposed to do this. However, in this particular case, I guess I can make it thread safe without causing too much trouble or overhead. But why are you doing this in this first place? If normal calculations are an issue, it's usually better to use serialized objects (http://www.jpct.net/wiki/index.php?title=Differences_between_jPCT_and_jPCT-AE#Performance_and_memory_issues.2C_serialized_objects (http://www.jpct.net/wiki/index.php?title=Differences_between_jPCT_and_jPCT-AE#Performance_and_memory_issues.2C_serialized_objects)) if applicable.
-
BTW: I've moved this thread. It's neither a bug nor does it belong in the desktop jPCT section... ;)
-
Try this jar and see if it helps: http://jpct.de/download/beta/jpct_ae.jar (http://jpct.de/download/beta/jpct_ae.jar)
-
Thank you very much. I didn't know it's not made to be thread safe, good to know for future use to look out for it. And especially the tip about serializing is great!