* Fix PerspectiveLodCalculator by not caching entropies in object (since they vary per block)
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10573 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
cfb9c7e1a3
commit
199378ca2f
@ -45,12 +45,12 @@ import java.util.List;
|
|||||||
public class PerspectiveLodCalculator implements LodCalculator {
|
public class PerspectiveLodCalculator implements LodCalculator {
|
||||||
|
|
||||||
private Camera cam;
|
private Camera cam;
|
||||||
private float[] entropyDistances;
|
|
||||||
private float pixelError;
|
private float pixelError;
|
||||||
|
private boolean turnOffLod = false;
|
||||||
|
|
||||||
public PerspectiveLodCalculator() {}
|
public PerspectiveLodCalculator() {}
|
||||||
|
|
||||||
public PerspectiveLodCalculator(Camera cam, float pixelError){
|
public PerspectiveLodCalculator(Camera cam, float pixelError) {
|
||||||
this.cam = cam;
|
this.cam = cam;
|
||||||
this.pixelError = pixelError;
|
this.pixelError = pixelError;
|
||||||
}
|
}
|
||||||
@ -73,15 +73,22 @@ public class PerspectiveLodCalculator implements LodCalculator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean calculateLod(TerrainPatch patch, List<Vector3f> locations, HashMap<String, UpdatedTerrainPatch> updates) {
|
public boolean calculateLod(TerrainPatch patch, List<Vector3f> locations, HashMap<String, UpdatedTerrainPatch> updates) {
|
||||||
if (entropyDistances == null){
|
if (turnOffLod) {
|
||||||
// compute entropy distances
|
// set to full detail
|
||||||
|
int prevLOD = patch.getLod();
|
||||||
|
UpdatedTerrainPatch utp = updates.get(patch.getName());
|
||||||
|
if (utp == null) {
|
||||||
|
utp = new UpdatedTerrainPatch(patch);
|
||||||
|
updates.put(utp.getName(), utp);
|
||||||
|
}
|
||||||
|
utp.setNewLod(0);
|
||||||
|
utp.setPreviousLod(prevLOD);
|
||||||
|
//utp.setReIndexNeeded(true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
float[] lodEntropies = patch.getLodEntropies();
|
float[] lodEntropies = patch.getLodEntropies();
|
||||||
entropyDistances = new float[lodEntropies.length];
|
|
||||||
float cameraConstant = getCameraConstant(cam, pixelError);
|
float cameraConstant = getCameraConstant(cam, pixelError);
|
||||||
for (int i = 0; i < lodEntropies.length; i++){
|
|
||||||
entropyDistances[i] = lodEntropies[i] * cameraConstant;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector3f patchPos = getCenterLocation(patch);
|
Vector3f patchPos = getCenterLocation(patch);
|
||||||
|
|
||||||
@ -92,7 +99,7 @@ public class PerspectiveLodCalculator implements LodCalculator {
|
|||||||
|
|
||||||
// go through each lod level to find the one we are in
|
// go through each lod level to find the one we are in
|
||||||
for (int i = 0; i <= patch.getMaxLod(); i++) {
|
for (int i = 0; i <= patch.getMaxLod(); i++) {
|
||||||
if (distance < entropyDistances[i] || i == patch.getMaxLod()){
|
if (distance < lodEntropies[i] * cameraConstant || i == patch.getMaxLod()){
|
||||||
boolean reIndexNeeded = false;
|
boolean reIndexNeeded = false;
|
||||||
if (i != patch.getLod()) {
|
if (i != patch.getLod()) {
|
||||||
reIndexNeeded = true;
|
reIndexNeeded = true;
|
||||||
@ -133,6 +140,7 @@ public class PerspectiveLodCalculator implements LodCalculator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void write(JmeExporter ex) throws IOException {
|
public void write(JmeExporter ex) throws IOException {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void read(JmeImporter im) throws IOException {
|
public void read(JmeImporter im) throws IOException {
|
||||||
@ -155,15 +163,15 @@ public class PerspectiveLodCalculator implements LodCalculator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void turnOffLod() {
|
public void turnOffLod() {
|
||||||
//TODO
|
turnOffLod = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLodOff() {
|
public boolean isLodOff() {
|
||||||
return false; //TODO
|
return turnOffLod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void turnOnLod() {
|
public void turnOnLod() {
|
||||||
//TODO
|
turnOffLod = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user