package electrosphere.renderer.meshgen;

import static org.junit.jupiter.api.Assertions.*;

import org.joml.Vector3f;

import electrosphere.test.annotations.UnitTest;

/**
 * Tests for the transvoxel model generation functions
 */
public class TransvoxelModelGenerationTests {
    

    @UnitTest
    public void testVertexInterp1(){
        assertThrows(Error.class, () -> {
            TransvoxelModelGeneration.VertexInterp(
                TerrainChunkModelGeneration.MIN_ISO_VALUE,
                new Vector3f(15, 0, 6),
                new Vector3f(16, 0, 6),
                0.08262646198272705,
                0.009999990463256836,
                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(){
        Vector3f vec1 = new Vector3f();
        TransvoxelModelGeneration.VertexInterp(
            TerrainChunkModelGeneration.MIN_ISO_VALUE,
            new Vector3f(1, 2, 0),
            new Vector3f(0, 2, 0),
            -0.338376522064209,
            0.0,
            vec1
        );
        Vector3f vec2 = new Vector3f();
        TransvoxelModelGeneration.VertexInterp(
            TerrainChunkModelGeneration.MIN_ISO_VALUE,
            new Vector3f(0, 2, 0),
            new Vector3f(0, 3, 0),
            0,
            -1.0,
            vec2
        );
        assertNotEquals(vec1, vec2);
    }

    @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]);
        Vector3f vec1 = new Vector3f();
        TransvoxelModelGeneration.VertexInterp(
            TerrainChunkModelGeneration.MIN_ISO_VALUE,
            new Vector3f(8, 8, 15.5f),
            new Vector3f(9, 8, 15.5f),
            0.0,
            -1.0,
            vec1
        );
        Vector3f vec2 = new Vector3f();
        TransvoxelModelGeneration.VertexInterp(
            TerrainChunkModelGeneration.MIN_ISO_VALUE,
            new Vector3f(9, 8, 15.5f),
            new Vector3f(9, 9, 15.5f),
            -1.0,
            0.0,
            vec2
        );
        assertNotEquals(vec1, vec2);
    }

}
