[SOLVED] Why are so many objects not being culled?

In this scene, I’m looking straight up. I’d expect perhaps 20 objects or so, for the sun & clouds, to be drawn. However, I count over 550 objects:

I’m using this code to count total visible objects in the scene:

public static int getTotalVisibleChildren(Node n) {
    int result = 0;
    for(Spatial s : n.getChildren()) {
        if( s instanceof Node ) {
            result += getTotalVisibleChildren((Node)s);
        } else if( s instanceof Geometry ) {
            Geometry g = (Geometry)s;
            if( g.getCullHint() != CullHint.Always &&
                g.getLastFrustumIntersection() != FrustumIntersect.Outside ) {
                result++;
            }
        }
    }
    return result;
}

… I pass it “rootNode” to get the numbers. I’d expect more things to fall out of the camera’s frustum & not be visible… am I counting things right? Perhaps I have a problem with world bounds…? :confused:

How many objects are rendered when your code isn’t used? I.e. via regular jME3 culling.

I think I was just counting them wrong – I was going into nodes that were culled. Geometry inside culled nodes doesn’t update the LastFrustum info. I changed the counting code to this:

public static int getTotalVisibleChildren(Node n) {
    int result = 0;
    for(Spatial s : n.getChildren()) {
        if( s.getCullHint() == CullHint.Always ||
            s.getLastFrustumIntersection() == FrustumIntersect.Outside ) continue;
        if( s instanceof Node ) {
            result += getTotalVisibleChildren((Node)s);
        } else if( s instanceof Geometry ) {
            result ++;
        }
    }
    return result;
}

…and now I’m getting normal numbers. Sorry for the confusion!