Renderer/src/test/java/electrosphere/client/terrain/cells/ClientDrawCellManagerTests.java
austin d2ccf3c479
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
rewrite client side chunks + transvoxel integration
2024-11-04 13:51:04 -05:00

52 lines
1.6 KiB
Java

package electrosphere.client.terrain.cells;
import static org.junit.jupiter.api.Assertions.*;
import org.joml.Vector3d;
import org.joml.Vector3f;
import org.joml.Vector3i;
import org.junit.jupiter.api.extension.ExtendWith;
import electrosphere.client.scene.ClientWorldData;
import electrosphere.engine.Globals;
import electrosphere.engine.Main;
import electrosphere.server.terrain.manager.ServerTerrainChunk;
import electrosphere.test.annotations.UnitTest;
import electrosphere.test.template.extensions.StateCleanupCheckerExtension;
import electrosphere.util.ds.octree.WorldOctTree.FloatingChunkTreeNode;
/**
* Tests for the client draw cell manager
*/
@ExtendWith(StateCleanupCheckerExtension.class)
public class ClientDrawCellManagerTests {
/**
* Test creating a manager
*/
@UnitTest
public void testCreation(){
assertDoesNotThrow(() -> {
new ClientDrawCellManager(null, 64);
});
}
@UnitTest
public void testJoinCase(){
int worldDiscreteSize = 64;
Globals.clientWorldData = new ClientWorldData(new Vector3f(0), new Vector3f(worldDiscreteSize * ServerTerrainChunk.CHUNK_DIMENSION), 0, worldDiscreteSize);
ClientDrawCellManager manager = new ClientDrawCellManager(null, 64);
Vector3d playerPos = new Vector3d(0,0,0);
FloatingChunkTreeNode<DrawCell> node = FloatingChunkTreeNode.constructorForTests(manager.chunkTree, 1, new Vector3i(16,0,0), new Vector3i(32,16,16));
node.convertToLeaf(DrawCell.generateTerrainCell(new Vector3i(0,0,0)));
assertFalse(manager.shouldSplit(playerPos, node));
//cleanup
Main.shutdown();
}
}