Doubt about ScreenGraphAdaptor

Hi. I was reading about traversing the screengraph using an adapter. I saw the following example at github:

     SceneGraphVisitorAdapter myEmitterVisitor =new SceneGraphVisitorAdapter() {
    public void visit(Geometry geom) {
        searchForEmitter(geom); // trigger custom test

        public void visit(Node node) {            
        searchForEmitter(node); // trigger custom test

    private void searchForEmitter(Spatial spatial) {
         // specify search criteria, e.g. class, name, properties
        if (spatial instanceof ParticleEmitter) {
          System.out.println("Emitter in "+ spatial.getName());
        // modify the found node:

My doubt is why is the visit method is called on super? Shouldn’t the code work without this step?

Well its not needed, but you never know what a super implementation does.
In that case it does nothing so calling it does nothing.
So it’s safe to remove it here.

1 Like

Yeah, my guess is that someone let the IDE generate those methods or something.

Usually you don’t have to call super on adapter methods.

1 Like