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
|
.project
|
||||||
.settings
|
.settings
|
||||||
|
|
||||||
.vscode
|
|
||||||
|
|
||||||
.dbeaver
|
.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.*;
|
||||||
import org.lwjgl.openal.ALC10;
|
import org.lwjgl.openal.ALC10;
|
||||||
import org.lwjgl.openal.ALCCapabilities;
|
import org.lwjgl.openal.ALCCapabilities;
|
||||||
import static org.lwjgl.openal.ALC10.alcDestroyContext;
|
import static org.lwjgl.openal.ALC10.alcDestroyContext;
|
||||||
import static org.lwjgl.openal.ALC10.alcCloseDevice;
|
import static org.lwjgl.openal.ALC10.alcCloseDevice;
|
||||||
import static org.lwjgl.system.MemoryUtil.NULL;
|
import static org.lwjgl.system.MemoryUtil.NULL;
|
||||||
|
|
||||||
public class AudioEngine {
|
public class AudioEngine {
|
||||||
@ -72,8 +72,8 @@ public class AudioEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown(){
|
public void shutdown(){
|
||||||
alcDestroyContext(context);
|
alcDestroyContext(context);
|
||||||
alcCloseDevice(device);
|
alcCloseDevice(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -421,7 +421,7 @@ public class ModelUtils {
|
|||||||
quadCurrent = null;
|
quadCurrent = null;
|
||||||
for(int y = 0; y < height - 1; y = y + stride){
|
for(int y = 0; y < height - 1; y = y + stride){
|
||||||
if((x == 5 && y == 2)){
|
if((x == 5 && y == 2)){
|
||||||
System.out.println(quadCurrent);
|
// System.out.println(quadCurrent);
|
||||||
// continue;
|
// continue;
|
||||||
}
|
}
|
||||||
if(quadCurrent == null){
|
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);
|
quadCurrent = new QuadToGenerate(x,y,x+stride,y+stride,maxVal - minVal,minVal,maxVal,textureMatch,texture);
|
||||||
} else {
|
} else {
|
||||||
firstPhaseQuads.add(new QuadToGenerate(x,y,x+stride,y+stride,maxVal - minVal,minVal,maxVal,textureMatch,texture));
|
firstPhaseQuads.add(new QuadToGenerate(x,y,x+stride,y+stride,maxVal - minVal,minVal,maxVal,textureMatch,texture));
|
||||||
quadCurrent = null;
|
// quadCurrent = null;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
float newMin = minVal;
|
float newMin = minVal;
|
||||||
@ -499,10 +499,10 @@ public class ModelUtils {
|
|||||||
}
|
}
|
||||||
if(y+stride < height - 1 && x+stride < width - 1){
|
if(y+stride < height - 1 && x+stride < width - 1){
|
||||||
if(newMax - newMin < MINIMIZATION_DIFF_MAX &&
|
if(newMax - newMin < MINIMIZATION_DIFF_MAX &&
|
||||||
texturemap[quadCurrent.startX][quadCurrent.startY] == texturemap[x+stride][y] &&
|
quadCurrent.texture == texturemap[x+stride][y] &&
|
||||||
texturemap[quadCurrent.startX][quadCurrent.startY] == texturemap[x][y+stride] &&
|
quadCurrent.texture == texturemap[x ][y+stride] &&
|
||||||
texturemap[quadCurrent.startX][quadCurrent.startY] == texturemap[x+stride][y+stride] &&
|
quadCurrent.texture == texturemap[x+stride][y+stride] &&
|
||||||
texturemap[x+stride][y+stride] == quadCurrent.texture
|
quadCurrent.homogeneousTexture
|
||||||
){
|
){
|
||||||
//add to quad
|
//add to quad
|
||||||
quadCurrent.endY = y + stride;
|
quadCurrent.endY = y + stride;
|
||||||
@ -512,6 +512,7 @@ public class ModelUtils {
|
|||||||
} else {
|
} else {
|
||||||
//push quad
|
//push quad
|
||||||
firstPhaseQuads.add(quadCurrent);
|
firstPhaseQuads.add(quadCurrent);
|
||||||
|
firstPhaseQuads.add(new QuadToGenerate(x,y,x+stride,y+stride,maxVal - minVal,minVal,maxVal,false,0));
|
||||||
quadCurrent = null;
|
quadCurrent = null;
|
||||||
// System.out.println("Push");
|
// System.out.println("Push");
|
||||||
}
|
}
|
||||||
@ -537,58 +538,124 @@ public class ModelUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<QuadToGenerate> finalQuads = new LinkedList();
|
List<QuadToGenerate> finalQuads = new LinkedList();
|
||||||
for(QuadToGenerate current : firstPhaseQuads){
|
// for(QuadToGenerate current : firstPhaseQuads){
|
||||||
finalQuads.add(current);
|
// finalQuads.add(current);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// System.out.println(finalQuads.size());
|
// System.out.println(finalQuads.size());
|
||||||
|
|
||||||
//merge along x
|
//merge along x
|
||||||
|
|
||||||
// QuadToGenerate currentQuad = null;
|
// QuadToGenerate currentQuad = null;
|
||||||
// for(QuadToGenerate currentIteration : firstPhaseQuads){
|
List<QuadToGenerate> toSkip = new LinkedList<QuadToGenerate>();
|
||||||
// if(currentQuad == null){
|
for(QuadToGenerate currentQuad : firstPhaseQuads){
|
||||||
// currentQuad = currentIteration;
|
// toRemove.clear();
|
||||||
// } else {
|
if(toSkip.contains(currentQuad)){
|
||||||
// if(currentQuad.min < currentIteration.min && currentQuad.max < currentIteration.max){
|
continue;
|
||||||
// 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);
|
|
||||||
}
|
}
|
||||||
}
|
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.out.println(finalQuads.size());
|
||||||
// System.exit(0);
|
// System.exit(0);
|
||||||
|
|
||||||
@ -801,6 +868,8 @@ public class ModelUtils {
|
|||||||
// incrementer++;
|
// incrementer++;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
System.out.println(incrementer + " quads");
|
||||||
|
|
||||||
vertices.flip();
|
vertices.flip();
|
||||||
normals.flip();
|
normals.flip();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user