protected void setHeight(List<Vector2f> xz, List<Float> height, boolean overrideHeight) { if (xz.size() != height.size()) throw new IllegalArgumentException("Both lists must be the same length!"); int halfSize = totalSize / 2; List<LocationHeight> locations = new ArrayList<LocationHeight>(); // offset for (int i=0; i<xz.size(); i++) { int x = Math.round((xz.get(i).x / getWorldScale().x) + halfSize); int z = Math.round((xz.get(i).y / getWorldScale().z) + halfSize); if (!isInside(x, z)) continue; locations.add(new LocationHeight(x,z,height.get(i))); } setHeight(locations, overrideHeight); // adjust height of the actual mesh // signal that the normals need updating for (int i=0; i<xz.size(); i++) setNormalRecalcNeeded(xz.get(i) ); }
/** * update the normals if there were any height changes recently. * Should only be called on the root quad */ protected void updateNormals() { if (needToRecalculateNormals()) { //TODO background-thread this if it ends up being expensive fixNormals(affectedAreaBBox); // the affected patches fixNormalEdges(affectedAreaBBox); // the edges between the patches setNormalRecalcNeeded(null); // set to false } }
protected void setHeight(List<Vector2f> xz, List<Float> height, boolean overrideHeight) { if (xz.size() != height.size()) throw new IllegalArgumentException("Both lists must be the same length!"); int halfSize = totalSize / 2; List<LocationHeight> locations = new ArrayList<LocationHeight>(); // offset for (int i=0; i<xz.size(); i++) { int x = Math.round((xz.get(i).x / getWorldScale().x) + halfSize); int z = Math.round((xz.get(i).y / getWorldScale().z) + halfSize); if (!isInside(x, z)) continue; locations.add(new LocationHeight(x,z,height.get(i))); } setHeight(locations, overrideHeight); // adjust height of the actual mesh // signal that the normals need updating for (int i=0; i<xz.size(); i++) setNormalRecalcNeeded(xz.get(i) ); }
/** * update the normals if there were any height changes recently. * Should only be called on the root quad */ protected void updateNormals() { if (needToRecalculateNormals()) { //TODO background-thread this if it ends up being expensive fixNormals(affectedAreaBBox); // the affected patches fixNormalEdges(affectedAreaBBox); // the edges between the patches setNormalRecalcNeeded(null); // set to false } }