Int vs. enums in CollisionTreeManager

This function in jME 2 seems to call itself infinitely:


    public void generateCollisionTree(int type, Spatial object, boolean protect) {
        if (object instanceof Node) {
            Node n = (Node) object;
            for (int i = n.getQuantity() - 1; i >= 0; i--) {
                generateCollisionTree(type, n.getChild(i), protect);
            }
        } else if (object instanceof TriMesh) {
            generateCollisionTree(type, (TriMesh) object, protect);
        }
    }


I think this was introduced with a change to enums and the above function looks like it was left unchanged.

It's the type of the arguments that causes a loop. The other generate functions use the enum Type. Furthermore there are no types defined as int anymore.



I use this function now:


   public static void generateCollisionTree(CollisionTree.Type type,
            Spatial mesh, boolean protect) {
      if (mesh instanceof TriMesh)
         CollisionTreeManager.getInstance().generateCollisionTree(type, (TriMesh)mesh, protect);
      if (mesh instanceof Node) {
         for (Spatial sp : ((Node)mesh).getChildren())
            generateCollisionTree(type, sp, protect);
      }
   }


my guess: your scenegraph is messed up. you have:

node a -> node b -> node c -> node a

or something like this

HamsterofDeath said:

my guess: your scenegraph is messed up. you have:
node a -> node b -> node c -> node a
or something like this


I don't think that is possible, because in Jme1.0 when you add a Node to another one, it detach it from this parent, so you cannot loop.

Galun is right. There's a method signature problem, the paremeterization is the same, calling same function on the same object endlessly.



public void generateCollisionTree(int type, Spatial object, boolean protect) {

...
generateCollisionTree(type, (TriMesh) object, protect);



This is not good now. Someone should create a patch for this to correct.