Problem with Display Lists + Link

I get that exception when trying to use static Shape3Ds in SharedGroups (referenced by a Link) :


Exception in thread "main" java.lang.NullPointerException
	at com.xith3d.render.prerender.FrustumCuller.cullNodeAtoms(FrustumCuller.java:192)
	at com.xith3d.render.prerender.FrustumCuller.cullGroupAtoms(FrustumCuller.java:145)
	at com.xith3d.render.prerender.FrustumCuller.cullNodeAtoms(FrustumCuller.java:186)
	at com.xith3d.render.prerender.FrustumCuller.cullLinkAtoms(FrustumCuller.java:91)
	at com.xith3d.render.prerender.FrustumCuller.cullNodeAtoms(FrustumCuller.java:167)
	at com.xith3d.render.prerender.FrustumCuller.cullGroupAtoms(FrustumCuller.java:145)
	at com.xith3d.render.prerender.FrustumCuller.cullNodeAtoms(FrustumCuller.java:186)
	at com.xith3d.render.prerender.FrustumCuller.cullGroupAtoms(FrustumCuller.java:145)
	at com.xith3d.render.prerender.FrustumCuller.cullNodeAtoms(FrustumCuller.java:186)
	at com.xith3d.render.prerender.FrustumCuller.cullGroupAtoms(FrustumCuller.java:145)
	at com.xith3d.render.prerender.FrustumCuller.cullNodeAtoms(FrustumCuller.java:186)
	at com.xith3d.render.prerender.FrustumCuller.cullGroupAtoms(FrustumCuller.java:145)
	at com.xith3d.render.prerender.FrustumCuller.cullNodeAtoms(FrustumCuller.java:186)
	at com.xith3d.render.prerender.FrustumCuller.cullGroupAtoms(FrustumCuller.java:145)
	at com.xith3d.render.prerender.FrustumCuller.cullNodeAtoms(FrustumCuller.java:186)
	at com.xith3d.render.prerender.FrustumCuller.cullGroupAtoms(FrustumCuller.java:145)
	at com.xith3d.render.prerender.FrustumCuller.cullNodeAtoms(FrustumCuller.java:186)
	at com.xith3d.render.prerender.FrustumCuller.cullGroupAtoms(FrustumCuller.java:145)
	at com.xith3d.render.prerender.FrustumCuller.cullNodeAtoms(FrustumCuller.java:186)
	at com.xith3d.render.prerender.FrustumCuller.cullGroupAtoms(FrustumCuller.java:145)
	at com.xith3d.render.prerender.FrustumCuller.cullNodeAtoms(FrustumCuller.java:186)
	at com.xith3d.render.prerender.FrustumCuller.cullAtoms(FrustumCuller.java:210)
	at com.xith3d.render.prerender.FrustumCuller.cullAtoms(FrustumCuller.java:241)
	at com.xith3d.render.prerender.FrustumCuller.cullAtoms(FrustumCuller.java:261)
	at com.xith3d.render.Renderer.renderOnce(Renderer.java:426)
	at com.xith3d.scenegraph.VirtualUniverse.renderOnce(VirtualUniverse.java:79)
	at org.xith3d.render.base.ExtXith3DEnvironment.render(ExtXith3DEnvironment.java:245)
	at org.stratagem.apps.Stratagem.runGame(Stratagem.java:218)
	at org.stratagem.apps.Stratagem.run(Stratagem.java:146)
	at org.stratagem.apps.Stratagem.main(Stratagem.java:50)

It seems that the Atom of the Shape3D is null…

Marvin, any idea ?

I’ll investigate it.

OK, thanks.

I’m currently digging a bit the rendering code.

Would be good to know a second pair of eyes having a look at it :).

This piece of code retained my interest :


            // if the universe is dirty (e.g. before the first frame) --> collect atoms, cull and sort
            if ((universe.modListener == null) || (universe.isDirty()))
            {
                // decrement the frame-id, since not all atoms might be refilled and get the new frame id.
                currentFrameId--;
                
                universe.modListener = modManager;
                
                canvas.getView().getPosition( oldViewPos );
                
                // colect atoms, cull and sort
                modManager.getAtomsCollector().collectAtoms(universe, canvas.getView(), modManager, this, canvas, canvas.getView().getSoundProcessor(), currentFrameId);
                
                modManager.resetAnythingChanged();
            }
            // otherwise just cull and resort
            else
            {
                modManager.getFrustumCuller().cullAtoms(universe, this, canvas, currentFrameId);
                
                canvas.getView().getTransform().get( currViewPos );
                currViewPos.sub( oldViewPos );
                
                final float viewDelta = Math.abs( (float)Math.sqrt(currViewPos.x * currViewPos.x + currViewPos.y * currViewPos.y + currViewPos.z * currViewPos.z) );
                
                if ((modManager.hasAnythingChanged()) || (viewDelta >= maxViewDelta))
                {
                    sortAllAtoms( universe, canvas.getView().getPosition() );
                    
                    canvas.getView().getTransform().get( oldViewPos );
                    modManager.resetAnythingChanged();
                }
            }


The universe is not set as dirty when a Link node is added ?

How is it possible that a Shape3D has it atom being null ?

Some tricks puzzle me a bit but I’m gonna look further… it’s not as complicated as I thought.

No. It’s quite easy after I simplified and streamlined it :wink:

The universe is only set dirty, when a Group is removed. And I’ll change this behaviour tomorrow or so. When a Node is added, it is added to the Atoms list or traversed in ase it is a Group. But the already existing Atoms don’t need to be rebuilt. When a Node is removed, I’ve set the universe dirty and it is completely retraversed. The universe doesn’t need to be retraversed even in case of a removed Group. But the Atoms must be removed one by one. I’ll implement this behaviour tomorrow.

Ah! A thought is coming to my mind: The universe needs to be set dirty in case a Link is removed. I’ll change that.

Done. Please check, if it works now.

Marvin

Grunt… >:( Even worse. Now just my terrain (static shape3d in a regular group) gets drawn. Units (links to sharedgroups) and unit circles (static shape3ds in a regular group) are invisible…

I guess some hard work is coming… (deserving a full @author tag, of course… ok just joking ^^)

Maybe you could post a sample code. I can only guess, how you’re using them.

If you ever worked on a big game project, you would know that “a sample code” is really hard to get… :smiley:
Okay, trying some tests.

Yes, I know it is ;D. But I guess a simple one would be sufficient, where you show, how you create two or three of these Links (and ShapredGroups) and how you maybe add/remove them at runtime.

I traced the Link / SharedGroup problem a little further and found some bug, that made it not work. But now I face a problem, why it even can’t work. And I can’t see why they worked before.

Amos, please have a look at AtomsCollector’s / FrustumCuller’s collectLinkAtoms methods. They’re taken from the previous version as is. The problem is, that the shared shapes will always be drawn at the exact same place, because the shape’s localtovworld is updated in each SharedGroup. And I don’t have an aidea at the moment, how this can be solved. And as I sayd, I couldn’t have worked before.

Marvin

New rendering code, new problems… ;D


Exception in thread "main" java.lang.NullPointerException
	at com.xith3d.render.prerender.AtomsRemover.removeShapeAtom(AtomsRemover.java:172)
	at com.xith3d.render.prerender.AtomsRemover.removeNodeAtoms(AtomsRemover.java:224)
	at com.xith3d.render.prerender.AtomsRemover.removeGroupAtoms(AtomsRemover.java:135)
	at com.xith3d.render.prerender.AtomsRemover.removeNodeAtoms(AtomsRemover.java:220)
	at com.xith3d.render.prerender.AtomsRemover.removeLinkAtoms(AtomsRemover.java:115)
	at com.xith3d.render.prerender.AtomsRemover.removeNodeAtoms(AtomsRemover.java:199)
	at com.xith3d.render.prerender.AtomsRemover.removeAtom(AtomsRemover.java:260)
	at com.xith3d.render.ScenegraphModificationsManager.onChildRemovedFromGroup(ScenegraphModificationsManager.java:213)
	at com.xith3d.scenegraph.GroupNode.removeChild(GroupNode.java:258)
	at com.xith3d.scenegraph.GroupNode.removeAllChildren(GroupNode.java:273)
	at org.xith3d.loaders.precomputed.PrecomputedAnimatedModel.setCurrentFrame(PrecomputedAnimatedModel.java:210)
	at org.xith3d.loaders.precomputed.PrecomputedAnimatedModel.update(PrecomputedAnimatedModel.java:93)
	at org.stratagem.ui.gfx.CalAnimatedModelUnitRepresentation.updateAnim(CalAnimatedModelUnitRepresentation.java:59)
	at org.stratagem.ui.gfx.UnitRepresentation.update(UnitRepresentation.java:115)
	at org.stratagem.ui.gfx.WorldRepresentation.update(WorldRepresentation.java:97)
	at org.stratagem.apps.Stratagem.runGame(Stratagem.java:218)
	at org.stratagem.apps.Stratagem.run(Stratagem.java:148)
	at org.stratagem.apps.Stratagem.main(Stratagem.java:50)

I’ll take a look at it.

Argh! Goddammed links! :slight_smile: Please recheckout and retry. Should be solved.

Other bug :


Exception in thread "main" java.lang.NullPointerException
	at com.xith3d.render.prerender.FrustumCuller.addShapeAtom(FrustumCuller.java:187)
	at com.xith3d.render.prerender.FrustumCuller.cullNodeAtoms(FrustumCuller.java:241)
	at com.xith3d.render.prerender.FrustumCuller.cullGroupAtoms(FrustumCuller.java:166)
	at com.xith3d.render.prerender.FrustumCuller.cullNodeAtoms(FrustumCuller.java:233)
	at com.xith3d.render.prerender.FrustumCuller.cullLinkAtoms(FrustumCuller.java:108)
	at com.xith3d.render.prerender.FrustumCuller.cullNodeAtoms(FrustumCuller.java:212)
	at com.xith3d.render.prerender.FrustumCuller.cullGroupAtoms(FrustumCuller.java:166)
	at com.xith3d.render.prerender.FrustumCuller.cullNodeAtoms(FrustumCuller.java:233)
	at com.xith3d.render.prerender.FrustumCuller.cullGroupAtoms(FrustumCuller.java:166)
	at com.xith3d.render.prerender.FrustumCuller.cullNodeAtoms(FrustumCuller.java:233)
	at com.xith3d.render.prerender.FrustumCuller.cullGroupAtoms(FrustumCuller.java:166)
	at com.xith3d.render.prerender.FrustumCuller.cullNodeAtoms(FrustumCuller.java:233)
	at com.xith3d.render.prerender.FrustumCuller.cullGroupAtoms(FrustumCuller.java:166)
	at com.xith3d.render.prerender.FrustumCuller.cullNodeAtoms(FrustumCuller.java:233)
	at com.xith3d.render.prerender.FrustumCuller.cullGroupAtoms(FrustumCuller.java:166)
	at com.xith3d.render.prerender.FrustumCuller.cullNodeAtoms(FrustumCuller.java:233)
	at com.xith3d.render.prerender.FrustumCuller.cullGroupAtoms(FrustumCuller.java:166)
	at com.xith3d.render.prerender.FrustumCuller.cullNodeAtoms(FrustumCuller.java:233)
	at com.xith3d.render.prerender.FrustumCuller.cullAtoms(FrustumCuller.java:260)
	at com.xith3d.render.prerender.FrustumCuller.cullAtoms(FrustumCuller.java:294)
	at com.xith3d.render.prerender.FrustumCuller.cullAtoms(FrustumCuller.java:322)
	at com.xith3d.render.Renderer.renderOnce(Renderer.java:404)
	at com.xith3d.scenegraph.VirtualUniverse.renderOnce(VirtualUniverse.java:130)
	at org.xith3d.render.base.ExtXith3DEnvironment.render(ExtXith3DEnvironment.java:245)
	at org.stratagem.apps.Stratagem.runGame(Stratagem.java:220)
	at org.stratagem.apps.Stratagem.run(Stratagem.java:148)
	at org.stratagem.apps.Stratagem.main(Stratagem.java:50)

Sgrunt… it works not really well now… but don’t give up ! :slight_smile:

I’ll look at it later. But I do have the idea to solve the problem for links drawn at the same place. Do you remember the RenderBucket class. It was exactly to handle this problem. Well, I can’t easily reactivate them, since they would produce a lot of garbage. But I’ll find a solution. But it could be tomorrow, not today, ok?

Marvin

OK for now I’ll provide an option in PrecomputedAnimation to not use Display LIsts.

I found the solution for the problem to draw shared Shape3Ds on the right places and it works. But I need to further test it before I commit it to avoid sidekicks, since it is one little deeper change. Please have a littel more patience. I’m very tired now and had a hard day at work. I’ll hopefully comit it tomorrow.

Marvin

PS: I’ve changed the org.xith3d.test.etc.SharedGroupTest to test Link removal. When you hit SPACE, one of the Links is removed from the scenegraph and it is properly removed without problems (even if you won’t see it, since the patch is not committed). Please check, if it is the same test case as in your game.

Maybe I’ve forgotton to mention, that I don’t remove Link from the sg anymore. Instead, I use setSharedGroup().
However, your test seems correct. I hope the solution you’ve found to draw shared Shape3Ds will be fine, thanks again for your work.

I’ve changed the SharedGroupTest to behave exactly like you described and it runs without any problems.

And I’ve commited the patch. Now Links work properly again :).

Marvin