public static void returnNode(BSPNode node) {
    cache[tail++] = node;
    if (tail == CACHE_SIZE) {
      tail = 0;
    }
    size = Math.min(size + 1, CACHE_SIZE);

    if (node.getLeft() != null || node.getRight() != null) {
      throw new RuntimeException("HHHHH!");
    }
  }
  public static BSPNode getBSPNode() {
    if (size == 0) {
      return new BSPNode(new Rect(0, 0, 0, 0), 0, 0);
    } else {
      int ppos = tail - size;
      if (ppos < 0) {
        ppos += CACHE_SIZE;
      }

      BSPNode node = cache[ppos];
      node.setParent(null);
      size--;
      return node;
    }
  }
Example #3
0
 /**
  * Store the content of a leaf node, in particular its list of segments. All entries carry the
  * number of the node as an index and each segment has an additional second index for the segment
  * number.
  *
  * @param doc document to add data to
  * @param mazeXML element to add data to
  * @param number is an index number for this node in the XML format
  * @return the highest used index number, in this case the given number
  */
 int store(Document doc, Element mazeXML, int number) {
   super.store(doc, mazeXML, number); // leaves number unchanged
   if (isleaf == false) System.out.println("WARNING: isleaf flag and class are inconsistent!");
   // store list of segments, store total number of elements first
   MazeFileWriter.appendChild(doc, mazeXML, "numSeg_" + number, slist.size());
   int i = 0;
   for (Seg s : slist) {
     s.storeSeg(doc, mazeXML, number, i);
     i++;
   }
   return number;
 }
Example #4
0
 /**
  * Remove this actor node. The node is removed from both the BSPNode which contains it, and the
  * linked list of actor nodes for the actor.
  */
 public void remove() {
   removed();
   node.actorRemoved(actor);
 }