void Triangle::merge( VertexArray& va ) { free = dirty = true; parent->dirty = true; VertexArray::index_t* indices = va.triangle( index ); VertexArray::index_t* pindices = va.triangle( parent->index ); va.update_triangle( parent->index, pindices[2], pindices[0], indices[0] ); va.update_triangle( index, 0, 0, 0 ); parent->set_neighbors( parent->neighbors[2], neighbors[2], neighbors[0] ); parent->priority_data.midpoint_vector = Vector3f( va.vertex( pindices[0] ) ); parent->priority_data.depth /= split_size; if( neighbors[2]->neighbors[2] == this ) neighbors[2]->neighbors[2] = parent; else if( neighbors[2]->neighbors[1] == this ) neighbors[2]->neighbors[1] = parent; else neighbors[2]->neighbors[0] = parent; //va.remove_triangle( index ); }