Logo Search packages:      
Sourcecode: earth3d version File versions  Download package

void MapTileTreeNode::informNeighborNodes (  ) 

Inform the direct neighbors that this node has changed and been selected for drawing and that they need to adjust their heightfield borders

Definition at line 293 of file mapTileTreeNode.cpp.

References getSelectedNeighbor().

                                          {
//   printf("node %li changed\n", this);
  assert(getSelectedForDrawing());
  if (getCore(1)==NULL) return; // needs heightfield

  float cornerValue = 0;
  /* first correct the right down corner */
  MapPart cornerNeighbor = getCornerNeighbor();
  if (cornerNeighbor.node) {
    HeightfieldTreeNodeCore *hcore = (HeightfieldTreeNodeCore *) cornerNeighbor.node->getCore(1);
    if (hcore) {
      cornerValue = hcore->getCorner(0,0);
    }
  }

  HeightfieldTreeNodeCore *thiscore = (HeightfieldTreeNodeCore *) getCore(1);

  for(int direction=0; direction<4; direction++) {

    if (thiscore) {
//       printf("this: %li cornerValue: %f\n", thiscore, cornerValue);
//       thiscore->setCorner(1,1,cornerValue);
    }

    /* regenerate the smaller, deeper node to fit the higher, set the border element distance,
     * restore the higher node and copy the right and bottom values from the neighbor node
     */
    MapPart neighbor = getSelectedNeighbor(direction);
    if (neighbor.node) {
      if (neighbor.node->getCore(1)!=NULL) { // needs heightfield
      if (neighbor.level==0) {
        assert(neighbor.node->getSelectedNeighbor((direction+2) % 4).node==this);
      }
      if (neighbor.level>0) {
        assert(neighbor.node->getSelectedForDrawing());
      }
      assert(neighbor.level>=0);
      
      // if the other tile is larger than this one we have to adjust
      // if the other tile has children, they need to adjust
      if (depth>2 && direction==0 && neighbor.level==1) {
        //  MapPart downneighbor = getSelectedNeighbor(1);
        //  if (downneighbor.level==1 && downneighbor.node->getSelectedForDrawing()) {
        ((HeightfieldTreeNodeCore *)neighbor.node->getCore(1))->markedfordebug=true;
      }
      
      neighbor.node->regenerateHeightfield(this, (direction+2) % 4, -neighbor.level, neighbor.offset);
      //       regenerateHeightfield(neighbor.node, direction, neighbor.level, neighbor.offset);
      }
    }
    else {
      assert(false);
      printf("no neighbor\n");
    }
  }
}


Generated by  Doxygen 1.6.0   Back to index