Culling problem, everything is culled

Please check my problem with culling. Two nodes with a common parent are used. One of the node is detached from most of its children when needed, and the other node has many children. Both with dynamic culling. If the node with very few children is the first in its parent child arraylist in certain cases the whole scenario under the other node with many children is culled too! What the heck? If I change the order in the parent arraylist of the two nodes the culling problem goes away, so if the child with many nodes is the first, culling is good, if the one with few or no children is the first, culling is wrong. I have to use a workaround:



"I've found a culling problem when externalRootNode's children are in very low number (when player is inside the cave), the whole internal scene was culled for no apparent reason. May be a JME bug, or what the heck! Anyway the solution is that when moving to internal parts from outside or back the order of internal root node and external root node are exchanged in its parent's child list (parent is the so called groundRootNode), and thus the problem goes away…maybe this is indicating a JMonkeyEngine bug or something I don't know about culling and node order?"



      c = world.getCube(newCoords[0], newCoords[1], newCoords[2]);
      if (c.internalLight)
      {
         System.out.println("Moved: INTERNAL");
         insideArea = true;
         groundParentNode.detachAllChildren(); // workaround for culling
         groundParentNode.attachChild(intRootNode);
         groundParentNode.attachChild(extRootNode);
      } else
      {
         System.out.println("Moved: EXTERNAL");
         insideArea = false;
         groundParentNode.detachAllChildren(); // workaround for culling
         groundParentNode.attachChild(extRootNode);
         groundParentNode.attachChild(intRootNode);
      }



You can see the magic which solved the problem with culling. Detach and reorder. If both of the nodes have more children the culling problem is not present.

http://jcrpg.blogspot.com/2007/08/optimization-for-caves.html

i have a similar problem.

if i spawn 100+ enemies in my level and look at specific directions (which seem to be random with every run), the whole scene is culled. if i move the mouse a bit, i can see everything again. more enemies, more culling. less enemies, no culling. my guess is that one of my enemies is in a "evil state", and the more entities i spawn, the bigger the chance that one of them gets "evil", whatever that is.



no idea what's causing it yet.

Try disabling culling on the node that the entities are attached to.

Disabling culling is not really acceptable for performance in most cases.



Make sure all your geometries have a model bound. You can watch the bounding by pressing if you extend SimpleGame.

Yes but if culling is disabled on the node then the child nodes can still have dynamic culling.

Cull mode is inherit by default, so setting the parent to never cull would also make the children never cull.

Well, the main problem is that everything is set up correctly theoretically. Parents are set to dynamic culling, the children of both parents are set to inherit. At some strange points in the game, where correctly bounded nodes are present all around, the whole scene is culled. Moving a bit elsewhere results the correct culling again… but it must be related to some bug and the problem with the fact that the other brother node has very few and maybe out of view distance nodes. The culling of the second node shouldn't affect the other node's children. I think the fact that swapping the order of the two parent nodes solves the problem (until the proportion of nodes turns reverse, then again the problem occurs) indicates some bug in culling (in JME?). I'm using JME 1.0rc1, and tried to solve this with using older lwjgl releases too with no success.

To me it sounds like the node you are rendering is not getting bounds updated for some reason…  I'd turn on bounds rendering and see if you can notice a particular bounding that leaves the screen just before the scene is culled.