Fix terrain mesh simplification + vscode tasks
This commit is contained in:
parent
fac9c5f41b
commit
96d2fdf474
2
.gitignore
vendored
2
.gitignore
vendored
@ -16,6 +16,4 @@
|
||||
.project
|
||||
.settings
|
||||
|
||||
.vscode
|
||||
|
||||
.dbeaver
|
||||
44
.vscode/tasks.json
vendored
Normal file
44
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
{
|
||||
"tasks": [
|
||||
{
|
||||
"label": "Build",
|
||||
"type": "shell",
|
||||
"command": "mvn process-classes",
|
||||
"windows": {
|
||||
"command": "mvn process-classes"
|
||||
},
|
||||
"group": "build",
|
||||
"presentation": {
|
||||
"reveal": "silent",
|
||||
"panel": "shared",
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Clean and Build",
|
||||
"type": "shell",
|
||||
"command": "mvn clean package",
|
||||
"windows": {
|
||||
"command": "mvn clean package"
|
||||
},
|
||||
"group": "build",
|
||||
"presentation": {
|
||||
"reveal": "silent",
|
||||
"panel": "shared",
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Run",
|
||||
"type": "shell",
|
||||
"command": "mvn process-classes exec:java -Dexec.mainClass=\"electrosphere.main.Main\"",
|
||||
"windows": {
|
||||
"command": "mvn process-classes exec:java -Dexec.mainClass=\"electrosphere.main.Main\""
|
||||
},
|
||||
"group": "test",
|
||||
"presentation": {
|
||||
"reveal": "silent",
|
||||
"panel": "shared",
|
||||
}
|
||||
},
|
||||
|
||||
]
|
||||
}
|
||||
@ -15,8 +15,8 @@ import org.lwjgl.openal.ALC;
|
||||
//import org.lwjgl.openal.*;
|
||||
import org.lwjgl.openal.ALC10;
|
||||
import org.lwjgl.openal.ALCCapabilities;
|
||||
import static org.lwjgl.openal.ALC10.alcDestroyContext;
|
||||
import static org.lwjgl.openal.ALC10.alcCloseDevice;
|
||||
import static org.lwjgl.openal.ALC10.alcDestroyContext;
|
||||
import static org.lwjgl.openal.ALC10.alcCloseDevice;
|
||||
import static org.lwjgl.system.MemoryUtil.NULL;
|
||||
|
||||
public class AudioEngine {
|
||||
@ -72,8 +72,8 @@ public class AudioEngine {
|
||||
}
|
||||
|
||||
public void shutdown(){
|
||||
alcDestroyContext(context);
|
||||
alcCloseDevice(device);
|
||||
alcDestroyContext(context);
|
||||
alcCloseDevice(device);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -421,7 +421,7 @@ public class ModelUtils {
|
||||
quadCurrent = null;
|
||||
for(int y = 0; y < height - 1; y = y + stride){
|
||||
if((x == 5 && y == 2)){
|
||||
System.out.println(quadCurrent);
|
||||
// System.out.println(quadCurrent);
|
||||
// continue;
|
||||
}
|
||||
if(quadCurrent == null){
|
||||
@ -478,7 +478,7 @@ public class ModelUtils {
|
||||
quadCurrent = new QuadToGenerate(x,y,x+stride,y+stride,maxVal - minVal,minVal,maxVal,textureMatch,texture);
|
||||
} else {
|
||||
firstPhaseQuads.add(new QuadToGenerate(x,y,x+stride,y+stride,maxVal - minVal,minVal,maxVal,textureMatch,texture));
|
||||
quadCurrent = null;
|
||||
// quadCurrent = null;
|
||||
}
|
||||
} else {
|
||||
float newMin = minVal;
|
||||
@ -499,10 +499,10 @@ public class ModelUtils {
|
||||
}
|
||||
if(y+stride < height - 1 && x+stride < width - 1){
|
||||
if(newMax - newMin < MINIMIZATION_DIFF_MAX &&
|
||||
texturemap[quadCurrent.startX][quadCurrent.startY] == texturemap[x+stride][y] &&
|
||||
texturemap[quadCurrent.startX][quadCurrent.startY] == texturemap[x][y+stride] &&
|
||||
texturemap[quadCurrent.startX][quadCurrent.startY] == texturemap[x+stride][y+stride] &&
|
||||
texturemap[x+stride][y+stride] == quadCurrent.texture
|
||||
quadCurrent.texture == texturemap[x+stride][y] &&
|
||||
quadCurrent.texture == texturemap[x ][y+stride] &&
|
||||
quadCurrent.texture == texturemap[x+stride][y+stride] &&
|
||||
quadCurrent.homogeneousTexture
|
||||
){
|
||||
//add to quad
|
||||
quadCurrent.endY = y + stride;
|
||||
@ -512,6 +512,7 @@ public class ModelUtils {
|
||||
} else {
|
||||
//push quad
|
||||
firstPhaseQuads.add(quadCurrent);
|
||||
firstPhaseQuads.add(new QuadToGenerate(x,y,x+stride,y+stride,maxVal - minVal,minVal,maxVal,false,0));
|
||||
quadCurrent = null;
|
||||
// System.out.println("Push");
|
||||
}
|
||||
@ -537,58 +538,124 @@ public class ModelUtils {
|
||||
}
|
||||
|
||||
List<QuadToGenerate> finalQuads = new LinkedList();
|
||||
for(QuadToGenerate current : firstPhaseQuads){
|
||||
finalQuads.add(current);
|
||||
}
|
||||
// for(QuadToGenerate current : firstPhaseQuads){
|
||||
// finalQuads.add(current);
|
||||
// }
|
||||
|
||||
// System.out.println(finalQuads.size());
|
||||
|
||||
//merge along x
|
||||
|
||||
// QuadToGenerate currentQuad = null;
|
||||
// for(QuadToGenerate currentIteration : firstPhaseQuads){
|
||||
// if(currentQuad == null){
|
||||
// currentQuad = currentIteration;
|
||||
// } else {
|
||||
// if(currentQuad.min < currentIteration.min && currentQuad.max < currentIteration.max){
|
||||
// float min = currentQuad.min;
|
||||
// float max = currentIteration.max;
|
||||
// if(max - min < MINIMIZATION_DIFF_MAX){
|
||||
// currentQuad.endX = currentIteration.endX;
|
||||
// currentQuad.max = currentIteration.max;
|
||||
// } else {
|
||||
// finalQuads.add(currentQuad);
|
||||
// currentQuad = currentIteration;
|
||||
// }
|
||||
// } else if(currentQuad.min > currentIteration.min && currentQuad.max > currentIteration.max){
|
||||
// float min = currentIteration.min;
|
||||
// float max = currentQuad.max;
|
||||
// if(max - min < MINIMIZATION_DIFF_MAX){
|
||||
// currentQuad.endX = currentIteration.endX;
|
||||
// currentQuad.min = currentIteration.min;
|
||||
// } else {
|
||||
// finalQuads.add(currentQuad);
|
||||
// currentQuad = currentIteration;
|
||||
// }
|
||||
// } else {
|
||||
// if(currentQuad.min < currentIteration.min){
|
||||
// currentQuad.endX = currentIteration.endX;
|
||||
// } else {
|
||||
// currentQuad.endX = currentIteration.endX;
|
||||
// currentQuad.min = currentIteration.min;
|
||||
// currentQuad.max = currentIteration.max;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// finalQuads.add(currentQuad);
|
||||
|
||||
for(QuadToGenerate current : finalQuads){
|
||||
if(current.startX > 0 && current.startY > 0 && current.endX < 99 && current.endY < 99){
|
||||
System.out.println(current.startX + " " + current.startY + " " + current.endX + " " + current.endY);
|
||||
// QuadToGenerate currentQuad = null;
|
||||
List<QuadToGenerate> toSkip = new LinkedList<QuadToGenerate>();
|
||||
for(QuadToGenerate currentQuad : firstPhaseQuads){
|
||||
// toRemove.clear();
|
||||
if(toSkip.contains(currentQuad)){
|
||||
continue;
|
||||
}
|
||||
for(QuadToGenerate currentPotentialMatch : firstPhaseQuads){
|
||||
if(currentPotentialMatch.startX <= currentQuad.startX){
|
||||
continue;
|
||||
}
|
||||
if(currentPotentialMatch.startX > currentQuad.endX){
|
||||
break;
|
||||
}
|
||||
if(currentPotentialMatch.startY != currentQuad.startY){
|
||||
continue;
|
||||
}
|
||||
if(currentPotentialMatch.endY != currentQuad.endY){
|
||||
continue;
|
||||
}
|
||||
if(
|
||||
!(currentQuad.homogeneousTexture &&
|
||||
currentPotentialMatch.homogeneousTexture &&
|
||||
currentQuad.texture == currentPotentialMatch.texture)
|
||||
){
|
||||
continue;
|
||||
}
|
||||
if(currentQuad.min < currentPotentialMatch.min && currentQuad.max < currentPotentialMatch.max){
|
||||
float min = currentQuad.min;
|
||||
float max = currentPotentialMatch.max;
|
||||
if(max - min < MINIMIZATION_DIFF_MAX){
|
||||
currentQuad.endX = currentPotentialMatch.endX;
|
||||
currentQuad.max = currentPotentialMatch.max;
|
||||
toSkip.add(currentPotentialMatch);
|
||||
}
|
||||
} else if(currentQuad.min > currentPotentialMatch.min && currentQuad.max > currentPotentialMatch.max){
|
||||
float min = currentPotentialMatch.min;
|
||||
float max = currentQuad.max;
|
||||
if(max - min < MINIMIZATION_DIFF_MAX){
|
||||
currentQuad.endX = currentPotentialMatch.endX;
|
||||
currentQuad.min = currentPotentialMatch.min;
|
||||
toSkip.add(currentPotentialMatch);
|
||||
}
|
||||
} else {
|
||||
if(currentQuad.min < currentPotentialMatch.min){
|
||||
currentQuad.endX = currentPotentialMatch.endX;
|
||||
} else {
|
||||
currentQuad.endX = currentPotentialMatch.endX;
|
||||
currentQuad.min = currentPotentialMatch.min;
|
||||
currentQuad.max = currentPotentialMatch.max;
|
||||
}
|
||||
toSkip.add(currentPotentialMatch);
|
||||
}
|
||||
}
|
||||
finalQuads.add(currentQuad);
|
||||
}
|
||||
// for(QuadToGenerate currentIteration : firstPhaseQuads){
|
||||
// if(currentQuad == null){
|
||||
// currentQuad = currentIteration;
|
||||
// } else {
|
||||
// //if should merge:
|
||||
// if(
|
||||
// currentQuad.homogeneousTexture &&
|
||||
// currentIteration.homogeneousTexture &&
|
||||
// currentQuad.texture == currentIteration.texture
|
||||
// ){
|
||||
// if(currentQuad.min < currentIteration.min && currentQuad.max < currentIteration.max){
|
||||
// float min = currentQuad.min;
|
||||
// float max = currentIteration.max;
|
||||
// if(max - min < MINIMIZATION_DIFF_MAX){
|
||||
// currentQuad.endX = currentIteration.endX;
|
||||
// currentQuad.max = currentIteration.max;
|
||||
// } else {
|
||||
// finalQuads.add(currentQuad);
|
||||
// currentQuad = currentIteration;
|
||||
// }
|
||||
// } else if(currentQuad.min > currentIteration.min && currentQuad.max > currentIteration.max){
|
||||
// float min = currentIteration.min;
|
||||
// float max = currentQuad.max;
|
||||
// if(max - min < MINIMIZATION_DIFF_MAX){
|
||||
// currentQuad.endX = currentIteration.endX;
|
||||
// currentQuad.min = currentIteration.min;
|
||||
// } else {
|
||||
// finalQuads.add(currentQuad);
|
||||
// currentQuad = currentIteration;
|
||||
// }
|
||||
// } else {
|
||||
// if(currentQuad.min < currentIteration.min){
|
||||
// currentQuad.endX = currentIteration.endX;
|
||||
// } else {
|
||||
// currentQuad.endX = currentIteration.endX;
|
||||
// currentQuad.min = currentIteration.min;
|
||||
// currentQuad.max = currentIteration.max;
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// finalQuads.add(currentQuad);
|
||||
// currentQuad = currentIteration;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// finalQuads.add(currentQuad);
|
||||
|
||||
// for(QuadToGenerate current : finalQuads){
|
||||
// if(current.startX > 0 && current.startY > 0 && current.endX < 99 && current.endY < 99){
|
||||
// System.out.println(current.startX + " " + current.startY + " " + current.endX + " " + current.endY);
|
||||
// }
|
||||
// }
|
||||
|
||||
// System.out.println("AAAAAAAAAAAAAAAAAA");
|
||||
// System.out.println(finalQuads.size());
|
||||
// System.exit(0);
|
||||
|
||||
@ -802,6 +869,8 @@ public class ModelUtils {
|
||||
// }
|
||||
// }
|
||||
|
||||
System.out.println(incrementer + " quads");
|
||||
|
||||
vertices.flip();
|
||||
normals.flip();
|
||||
faces.flip();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user