Page 1 of 1

BallAndStickFactory incompatibe with GeometryEventMulticaste

Posted: Tue 26. Oct 2010, 17:03
by sechel
I'm using a BallAndStickFactory to display some vectors. When I then remove the SceneGraphComponent produced by the Factory from the scene graph I get a

Code: Select all

Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
	at de.jreality.scene.event.GeometryEventMulticaster.remove(GeometryEventMulticaster.java:55)
	at de.jreality.scene.event.GeometryEventMulticaster.remove(GeometryEventMulticaster.java:74)
	at de.jreality.scene.event.GeometryEventMulticaster.remove(GeometryEventMulticaster.java:57)...
This I due to the JOGL Renderer that registeres a GeometryListener on every Geometry in the scene graph. This is fine as long as a geometry does not occur to often in the scene graph. Here the result is a chain of GeometryEventMulticasters which is as long the number of occurrences of that specific geometry in the graph. So for the BallAndStickFactory we get a very long chain as it recycles it's tube geometry for every stick.
Any idea how to resove this?

Re: BallAndStickFactory incompatibe with GeometryEventMultic

Posted: Sat 26. Nov 2011, 11:29
by gunn
I would like to bring attention to his bug again. I encounter it regularly with my discrete group software, and it's aggravating.
It looks straightforward to rewrite the code to avoid the stack overflow. Is there any reason not to use a list of some kind to handle the set of geometry listeners (this applies to the other kinds of standard listeners also)? For those interested: look at the code for de.jreality.scene.event.Geometry.addGeometryListener(), for example, as a starting point.