• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Main repository of MikuMikuStudio


Commit MetaInfo

Revisão37baed2a93582e687cf8d7a2436e514e8c1814ce (tree)
Hora2013-04-25 09:40:25
AutorshadowisLORD <shadowisLORD@75d0...>
CommitershadowisLORD

Mensagem de Log

  • Fix PerspectiveLodCalculator by not caching entropies in object (since they vary per block)

git-svn-id: http://jmonkeyengine.googlecode.com/svn/trunk@10573 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

Mudança Sumário

Diff

--- a/engine/src/terrain/com/jme3/terrain/geomipmap/lodcalc/PerspectiveLodCalculator.java
+++ b/engine/src/terrain/com/jme3/terrain/geomipmap/lodcalc/PerspectiveLodCalculator.java
@@ -45,12 +45,12 @@ import java.util.List;
4545 public class PerspectiveLodCalculator implements LodCalculator {
4646
4747 private Camera cam;
48- private float[] entropyDistances;
4948 private float pixelError;
49+ private boolean turnOffLod = false;
5050
5151 public PerspectiveLodCalculator() {}
5252
53- public PerspectiveLodCalculator(Camera cam, float pixelError){
53+ public PerspectiveLodCalculator(Camera cam, float pixelError) {
5454 this.cam = cam;
5555 this.pixelError = pixelError;
5656 }
@@ -73,16 +73,23 @@ public class PerspectiveLodCalculator implements LodCalculator {
7373 }
7474
7575 public boolean calculateLod(TerrainPatch patch, List<Vector3f> locations, HashMap<String, UpdatedTerrainPatch> updates) {
76- if (entropyDistances == null){
77- // compute entropy distances
78- float[] lodEntropies = patch.getLodEntropies();
79- entropyDistances = new float[lodEntropies.length];
80- float cameraConstant = getCameraConstant(cam, pixelError);
81- for (int i = 0; i < lodEntropies.length; i++){
82- entropyDistances[i] = lodEntropies[i] * cameraConstant;
76+ if (turnOffLod) {
77+ // set to full detail
78+ int prevLOD = patch.getLod();
79+ UpdatedTerrainPatch utp = updates.get(patch.getName());
80+ if (utp == null) {
81+ utp = new UpdatedTerrainPatch(patch);
82+ updates.put(utp.getName(), utp);
8383 }
84+ utp.setNewLod(0);
85+ utp.setPreviousLod(prevLOD);
86+ //utp.setReIndexNeeded(true);
87+ return true;
8488 }
85-
89+
90+ float[] lodEntropies = patch.getLodEntropies();
91+ float cameraConstant = getCameraConstant(cam, pixelError);
92+
8693 Vector3f patchPos = getCenterLocation(patch);
8794
8895 // vector from camera to patch
@@ -92,7 +99,7 @@ public class PerspectiveLodCalculator implements LodCalculator {
9299
93100 // go through each lod level to find the one we are in
94101 for (int i = 0; i <= patch.getMaxLod(); i++) {
95- if (distance < entropyDistances[i] || i == patch.getMaxLod()){
102+ if (distance < lodEntropies[i] * cameraConstant || i == patch.getMaxLod()){
96103 boolean reIndexNeeded = false;
97104 if (i != patch.getLod()) {
98105 reIndexNeeded = true;
@@ -133,6 +140,7 @@ public class PerspectiveLodCalculator implements LodCalculator {
133140 }
134141
135142 public void write(JmeExporter ex) throws IOException {
143+
136144 }
137145
138146 public void read(JmeImporter im) throws IOException {
@@ -155,15 +163,15 @@ public class PerspectiveLodCalculator implements LodCalculator {
155163 }
156164
157165 public void turnOffLod() {
158- //TODO
166+ turnOffLod = true;
159167 }
160-
168+
161169 public boolean isLodOff() {
162- return false; //TODO
170+ return turnOffLod;
163171 }
164172
165173 public void turnOnLod() {
166- //TODO
174+ turnOffLod = false;
167175 }
168176
169177 }