# OBBTree.createTree dropping triangles?

Here is the current code (as of yesterday atleast) for the createTree method in the OBBTree.

```     /**      * Creates an OBB tree recursivly from the tris's array of triangles.      *      * @param start      *            The start index of the tris array, inclusive.      * @param end      *            The end index of the tris array, exclusive.      */     public void createTree(int start, int end) {         myStart = start;         myEnd = end;             if (bounds == null)                bounds = new OrientedBoundingBox();             if (worldBounds == null)                worldBounds = new OrientedBoundingBox();         bounds.computeFromTris(tris, start, end);         if (myEnd - myStart + 1 <= maxPerLeaf) {             return;         } else {             splitTris(start, end);                   if (this.left == null)                      this.left = new OBBTree();             this.left.tris = this.tris;             this.left.myParent = this.myParent;             this.left.createTree(start, (start + end) / 2);                   if (this.right == null)                      this.right = new OBBTree();             this.right.tris = this.tris;             this.right.myParent = this.myParent;             this.right.createTree((start + end) / 2 + 1, end);         }     } ```

It uses the start index inclusively, and the end index exclusively.  When the split occurs, it moves half of the triangles into the left side (lets say triangles 0 through X/2).  It then moves triangles to the right side (X/2 + 1 through X).  The problem is that triangle #X/2 is not included in either set, and is therefore never used in collision detection.  This may be what is causing the problem with terrains where collisions dont occur on certain triangles.  The fix is straight forward:

Replace:

```  this.right.createTree((start + end) / 2 + 1, end); ```

with

```  this.right.createTree((start + end) / 2, end); ```

checked in. Did improve the accuracy of TestObbPick, thanks.

Hehe, whoops, was just doing this too.  Beat me to it.