/**
   * Check the two triangles of a given grid space for intersection.
   *
   * @param gridX grid row
   * @param gridY grid column
   * @param pick our pick ray
   * @param intersection the store variable
   * @param block the terrain block we are currently testing against.
   * @return true if a pick was found on these triangles.
   */
  protected boolean checkTriangles(
      float gridX, float gridY, Ray pick, Vector3f intersection, TerrainBlock block) {
    if (!getTriangles(gridX, gridY, block)) return false;

    if (!pick.intersectWhere(_gridTriA, intersection)) {
      return pick.intersectWhere(_gridTriB, intersection);
    } else {
      return true;
    }
  }
  /** {@inheritDoc} */
  public Vector3f getIntersection(Ray ray, Spatial parent, Vector3f store, boolean local) {
    if (store == null) {
      store = new Vector3f();
    }

    TrianglePickResults results = new TrianglePickResults();
    results.setCheckDistance(true);
    Vector3f[] vertices = new Vector3f[3];
    parent.findPick(ray, results);
    boolean hit = false;
    if (results.getNumber() > 0) {
      PickData data = results.getPickData(0);
      ArrayList<Integer> triangles = data.getTargetTris();
      if (!triangles.isEmpty()) {
        TriMesh mesh = (TriMesh) data.getTargetMesh();
        mesh.getTriangle(triangles.get(0).intValue(), vertices);
        for (int j = 0; j < vertices.length; j++) {
          mesh.localToWorld(vertices[j], vertices[j]);
        }
        hit = ray.intersectWhere(vertices[0], vertices[1], vertices[2], store);
        if (hit && local) {
          parent.worldToLocal(store, store);
          return store;
        } else if (hit && !local) {
          return store;
        }
      }
    }

    return null;
  }