voxel tests
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
fa1eaafed9
commit
e57658467b
@ -2117,6 +2117,9 @@ Simplify part of transvoxel algo
|
||||
Work on repairing particle system
|
||||
Fix projection matrix being sent to light manager
|
||||
|
||||
(06/05/2025)
|
||||
voxel tests
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1110,7 +1110,15 @@ public class TransvoxelModelGeneration {
|
||||
throw new UnknownError("Managed to index outside of expected range");
|
||||
}
|
||||
|
||||
//interpolates the location that the edge gets cut based on the magnitudes of the scalars of the vertices at either end of the edge
|
||||
/**
|
||||
* interpolates the location that the edge gets cut based on the magnitudes of the scalars of the vertices at either end of the edge
|
||||
* @param isolevel
|
||||
* @param p1
|
||||
* @param p2
|
||||
* @param valp1
|
||||
* @param valp2
|
||||
* @param vec
|
||||
*/
|
||||
protected static void VertexInterp(double isolevel, Vector3f p1, Vector3f p2, double valp1, double valp2, Vector3f vec){
|
||||
double mu;
|
||||
float x, y, z;
|
||||
|
||||
@ -120,7 +120,7 @@ public class NoiseVoxelGen implements VoxelGenerator {
|
||||
* @return The weight of the voxel
|
||||
*/
|
||||
protected static double getSurfaceWeight(double surfaceHeight, double realPosY, double strideMultiplier){
|
||||
return ((surfaceHeight - realPosY) / strideMultiplier);
|
||||
return ((realPosY - surfaceHeight) / strideMultiplier);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ public class TransvoxelModelGenerationTests {
|
||||
|
||||
|
||||
@UnitTest
|
||||
public void testVertexInterp1(){
|
||||
public void test_VertexInterp_1(){
|
||||
assertThrows(Error.class, () -> {
|
||||
TransvoxelModelGeneration.VertexInterp(
|
||||
TerrainChunkModelGeneration.MIN_ISO_VALUE,
|
||||
@ -24,18 +24,10 @@ public class TransvoxelModelGenerationTests {
|
||||
new Vector3f()
|
||||
);
|
||||
});
|
||||
// Vector3f vec2 = TransvoxelModelGeneration.VertexInterp(
|
||||
// TerrainChunkModelGeneration.MIN_ISO_VALUE,
|
||||
// new Vector3f(16, 0, 6),
|
||||
// new Vector3f(16, 0, 5),
|
||||
// 0.009999990463256836,
|
||||
// 0.05369114875793457
|
||||
// );
|
||||
// assertNotEquals(vec1, vec2);
|
||||
}
|
||||
|
||||
@UnitTest
|
||||
public void testVertexInterp2(){
|
||||
public void test_VertexInterp_2(){
|
||||
Vector3f vec1 = new Vector3f();
|
||||
TransvoxelModelGeneration.VertexInterp(
|
||||
TerrainChunkModelGeneration.MIN_ISO_VALUE,
|
||||
@ -58,9 +50,7 @@ public class TransvoxelModelGenerationTests {
|
||||
}
|
||||
|
||||
@UnitTest
|
||||
public void testVertexInterp3(){
|
||||
//vertList[1] = TransvoxelModelGeneration.VertexInterp(isolevel,grid.points[1],grid.points[2],grid.val[1],grid.val[2]);
|
||||
//vertList[10] = TransvoxelModelGeneration.VertexInterp(isolevel,grid.points[2],grid.points[6],grid.val[2],grid.val[6]);
|
||||
public void test_VertexInterp_3(){
|
||||
Vector3f vec1 = new Vector3f();
|
||||
TransvoxelModelGeneration.VertexInterp(
|
||||
TerrainChunkModelGeneration.MIN_ISO_VALUE,
|
||||
@ -82,4 +72,46 @@ public class TransvoxelModelGenerationTests {
|
||||
assertNotEquals(vec1, vec2);
|
||||
}
|
||||
|
||||
@UnitTest
|
||||
public void test_VertexInterp_4(){
|
||||
Vector3f vec1 = new Vector3f();
|
||||
TransvoxelModelGeneration.VertexInterp(
|
||||
TerrainChunkModelGeneration.MIN_ISO_VALUE,
|
||||
new Vector3f(8, 8, 15.5f),
|
||||
new Vector3f(9, 8, 15.5f),
|
||||
0.5,
|
||||
-1.0,
|
||||
vec1
|
||||
);
|
||||
assertNotEquals(0.5, vec1.y);
|
||||
}
|
||||
|
||||
@UnitTest
|
||||
public void test_VertexInterp_5(){
|
||||
Vector3f vec1 = new Vector3f();
|
||||
TransvoxelModelGeneration.VertexInterp(
|
||||
TerrainChunkModelGeneration.MIN_ISO_VALUE,
|
||||
new Vector3f(8, 8, 15.5f),
|
||||
new Vector3f(9, 8, 15.5f),
|
||||
0.7,
|
||||
-1.0,
|
||||
vec1
|
||||
);
|
||||
assertNotEquals(0.7, vec1.y);
|
||||
}
|
||||
|
||||
@UnitTest
|
||||
public void test_VertexInterp_6(){
|
||||
Vector3f vec1 = new Vector3f();
|
||||
TransvoxelModelGeneration.VertexInterp(
|
||||
TerrainChunkModelGeneration.MIN_ISO_VALUE,
|
||||
new Vector3f(8, 8, 15.5f),
|
||||
new Vector3f(9, 8, 15.5f),
|
||||
0.2,
|
||||
-1.0,
|
||||
vec1
|
||||
);
|
||||
assertNotEquals(0.2, vec1.y);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,48 @@
|
||||
package electrosphere.server.physics.terrain.generation.voxelphase;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
|
||||
import electrosphere.test.annotations.UnitTest;
|
||||
|
||||
/**
|
||||
* Tests for noise voxel gen
|
||||
*/
|
||||
public class NoiseVoxelGenTests {
|
||||
|
||||
@UnitTest
|
||||
public void test_getSurfaceWeight_1(){
|
||||
double surfaceHeight = 1.5;
|
||||
double realY = 1.0;
|
||||
double stride = 1.0;
|
||||
double finalWeight = NoiseVoxelGen.getSurfaceWeight(surfaceHeight, realY, stride);
|
||||
assertNotEquals(0.5, finalWeight);
|
||||
}
|
||||
|
||||
@UnitTest
|
||||
public void test_getSurfaceWeight_2(){
|
||||
double surfaceHeight = 1.3;
|
||||
double realY = 1.0;
|
||||
double stride = 1.0;
|
||||
double finalWeight = NoiseVoxelGen.getSurfaceWeight(surfaceHeight, realY, stride);
|
||||
assertNotEquals(0.3, finalWeight);
|
||||
}
|
||||
|
||||
@UnitTest
|
||||
public void test_getSurfaceWeight_3(){
|
||||
double surfaceHeight = 1.7;
|
||||
double realY = 1.0;
|
||||
double stride = 1.0;
|
||||
double finalWeight = NoiseVoxelGen.getSurfaceWeight(surfaceHeight, realY, stride);
|
||||
assertNotEquals(0.7, finalWeight);
|
||||
}
|
||||
|
||||
@UnitTest
|
||||
public void test_getSurfaceWeight_4(){
|
||||
double surfaceHeight = 1.9;
|
||||
double realY = 1.0;
|
||||
double stride = 1.0;
|
||||
double finalWeight = NoiseVoxelGen.getSurfaceWeight(surfaceHeight, realY, stride);
|
||||
assertNotEquals(0.9, finalWeight);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user