work towards automated testing
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
6da4c001fa
commit
71fb248154
@ -1,3 +1,3 @@
|
|||||||
#maven.buildNumber.plugin properties file
|
#maven.buildNumber.plugin properties file
|
||||||
#Wed Jul 03 15:06:42 EDT 2024
|
#Sun Jul 07 21:24:47 EDT 2024
|
||||||
buildNumber=149
|
buildNumber=180
|
||||||
|
|||||||
@ -452,11 +452,10 @@ Refactor menu clases under electrosphere.client package
|
|||||||
|
|
||||||
Allow texture map to bind multiple model paths to a single set of mesh->textures
|
Allow texture map to bind multiple model paths to a single set of mesh->textures
|
||||||
|
|
||||||
|
Rework how chunks are written to disk to make them more cache friendly
|
||||||
|
- IE, write consecutively higher LOD levels the further into the file, so that you can read just the first few bytes if its a far away chunk
|
||||||
|
|
||||||
|
|
||||||
Redo hitboxes to have capsules and also chaining between frames (but not between swinging the camera around)
|
|
||||||
- Introduce block hitbox (blockbox) type
|
|
||||||
|
|
||||||
Fix voxel type selection menu not showing textures
|
Fix voxel type selection menu not showing textures
|
||||||
- The quads are off screen because the calculation for ndcX/ndcY are putting it wayyy to the right -- will need to revisit calcs for all that
|
- The quads are off screen because the calculation for ndcX/ndcY are putting it wayyy to the right -- will need to revisit calcs for all that
|
||||||
|
|
||||||
@ -604,8 +603,6 @@ Documentation
|
|||||||
|
|
||||||
# Eventually
|
# Eventually
|
||||||
|
|
||||||
Generic collision engine to support different instances of engine (eg hitboxes vs terrain vs liquids, etc)
|
|
||||||
- Major refactoring to happen here
|
|
||||||
Procedural Cliff Texture
|
Procedural Cliff Texture
|
||||||
- Uses noise or fractals or something to generate infinite textures in shader
|
- Uses noise or fractals or something to generate infinite textures in shader
|
||||||
Loot Generator
|
Loot Generator
|
||||||
|
|||||||
@ -154,8 +154,9 @@ public class Main {
|
|||||||
new Thread(Globals.initialAssetLoadingThread).start();
|
new Thread(Globals.initialAssetLoadingThread).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Sets a hook that fires when the engine process stops
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||||
System.out.println("Shutdown hook!");
|
LoggerInterface.loggerEngine.INFO("Shutdown hook!");
|
||||||
}));
|
}));
|
||||||
|
|
||||||
//uncomment to test loading a model into engine
|
//uncomment to test loading a model into engine
|
||||||
@ -223,6 +224,7 @@ public class Main {
|
|||||||
*/
|
*/
|
||||||
public static void mainLoop(){
|
public static void mainLoop(){
|
||||||
mainLoop(0);
|
mainLoop(0);
|
||||||
|
shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -231,9 +233,11 @@ public class Main {
|
|||||||
*/
|
*/
|
||||||
public static void mainLoop(long maxFrames){
|
public static void mainLoop(long maxFrames){
|
||||||
|
|
||||||
|
//resets running flag to that we can repeatedly loop (ie in tests)
|
||||||
|
running = true;
|
||||||
|
|
||||||
//main loop
|
//main loop
|
||||||
while (running) {
|
while (running) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Globals.profiler.beginRootCpuSample("frame");
|
Globals.profiler.beginRootCpuSample("frame");
|
||||||
@ -411,6 +415,12 @@ public class Main {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shuts down the engine
|
||||||
|
*/
|
||||||
|
public static void shutdown(){
|
||||||
LoggerInterface.loggerEngine.WARNING("ENGINE SHUTDOWN");
|
LoggerInterface.loggerEngine.WARNING("ENGINE SHUTDOWN");
|
||||||
//
|
//
|
||||||
// S H U T D O W N
|
// S H U T D O W N
|
||||||
|
|||||||
@ -77,15 +77,17 @@ public class AssetManager {
|
|||||||
for(String currentPath : modelsInQueue){
|
for(String currentPath : modelsInQueue){
|
||||||
modelsInQueue.remove(currentPath);
|
modelsInQueue.remove(currentPath);
|
||||||
AIScene aiScene = ModelLoader.loadAIScene(currentPath);
|
AIScene aiScene = ModelLoader.loadAIScene(currentPath);
|
||||||
modelsLoadedIntoMemory.put(currentPath, ModelLoader.createModelFromAiScene(aiScene,currentPath));
|
if(aiScene != null){
|
||||||
for(PhysicsMeshQueueItem physicsMeshQueueItem : physicsMeshesToLoad){
|
modelsLoadedIntoMemory.put(currentPath, ModelLoader.createModelFromAiScene(aiScene,currentPath));
|
||||||
if(physicsMeshQueueItem.modelPath.contains(currentPath)){
|
for(PhysicsMeshQueueItem physicsMeshQueueItem : physicsMeshesToLoad){
|
||||||
//create physics
|
if(physicsMeshQueueItem.modelPath.contains(currentPath)){
|
||||||
physicsMeshesToLoad.remove(physicsMeshQueueItem);
|
//create physics
|
||||||
physicsMeshesLoadedIntoMemory.put(
|
physicsMeshesToLoad.remove(physicsMeshQueueItem);
|
||||||
getCollisionMeshMapKey(physicsMeshQueueItem.collisionEngine,currentPath),
|
physicsMeshesLoadedIntoMemory.put(
|
||||||
CollisionBodyCreation.generateRigidBodyFromAIScene(physicsMeshQueueItem.collisionEngine,aiScene,Collidable.TYPE_STATIC_BIT)
|
getCollisionMeshMapKey(physicsMeshQueueItem.collisionEngine,currentPath),
|
||||||
);
|
CollisionBodyCreation.generateRigidBodyFromAIScene(physicsMeshQueueItem.collisionEngine,aiScene,Collidable.TYPE_STATIC_BIT)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,8 +3,7 @@ package electrosphere.logger;
|
|||||||
import electrosphere.logger.Logger.LogLevel;
|
import electrosphere.logger.Logger.LogLevel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* The list of logging channels available
|
||||||
* @author amaterasu
|
|
||||||
*/
|
*/
|
||||||
public class LoggerInterface {
|
public class LoggerInterface {
|
||||||
|
|
||||||
|
|||||||
@ -1,23 +1,18 @@
|
|||||||
package electrosphere.renderer.framebuffer;
|
package electrosphere.renderer.framebuffer;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.renderer.OpenGLState;
|
import electrosphere.renderer.OpenGLState;
|
||||||
import electrosphere.renderer.RenderingEngine;
|
import electrosphere.renderer.RenderingEngine;
|
||||||
import electrosphere.renderer.texture.Texture;
|
import electrosphere.renderer.texture.Texture;
|
||||||
import electrosphere.util.FileUtils;
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL40;
|
import org.lwjgl.opengl.GL40;
|
||||||
import org.lwjgl.system.MemoryUtil;
|
import org.lwjgl.system.MemoryUtil;
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,16 @@ import java.util.logging.Logger;
|
|||||||
import org.lwjgl.assimp.AIScene;
|
import org.lwjgl.assimp.AIScene;
|
||||||
import static org.lwjgl.assimp.Assimp.*;
|
import static org.lwjgl.assimp.Assimp.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main model loading class
|
||||||
|
*/
|
||||||
public class ModelLoader {
|
public class ModelLoader {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads a model via assimp
|
||||||
|
* @param path The path to the model
|
||||||
|
* @return The model if it exists, null otherwise
|
||||||
|
*/
|
||||||
public static AIScene loadAIScene(String path){
|
public static AIScene loadAIScene(String path){
|
||||||
AIScene rVal;
|
AIScene rVal;
|
||||||
// File file = new File(Thread.currentThread().getContextClassLoader().getResource(fileName).getFile());
|
// File file = new File(Thread.currentThread().getContextClassLoader().getResource(fileName).getFile());
|
||||||
@ -41,15 +50,17 @@ public class ModelLoader {
|
|||||||
aiProcess_GlobalScale
|
aiProcess_GlobalScale
|
||||||
);
|
);
|
||||||
if(rVal == null){
|
if(rVal == null){
|
||||||
throw new IllegalStateException(aiGetErrorString());
|
LoggerInterface.loggerRenderer.ERROR(new IllegalStateException(aiGetErrorString()));
|
||||||
}
|
}
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Model createModelFromAiScene(AIScene scene, String path){
|
public static Model createModelFromAiScene(AIScene scene, String path){
|
||||||
Model rVal;
|
Model rVal = null;
|
||||||
rVal = Model.createModelFromAiscene(path, scene);
|
if(scene != null){
|
||||||
attemptAddTexturesFromPathname(path, rVal);
|
rVal = Model.createModelFromAiscene(path, scene);
|
||||||
|
attemptAddTexturesFromPathname(path, rVal);
|
||||||
|
}
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,22 +8,30 @@ import org.junit.runner.notification.Failure;
|
|||||||
|
|
||||||
import entity.SpawningCreaturesTest;
|
import entity.SpawningCreaturesTest;
|
||||||
import startup.StartupTest;
|
import startup.StartupTest;
|
||||||
|
import testutils.TestEngineUtils;
|
||||||
|
|
||||||
public class TestRunner {
|
public class TestRunner {
|
||||||
|
|
||||||
static final List<Class> classes = Arrays.asList(new Class[]{
|
/**
|
||||||
|
* The list of classes to run tests for
|
||||||
|
*/
|
||||||
|
static final List<Class<?>> classes = Arrays.asList(new Class[]{
|
||||||
StartupTest.class,
|
StartupTest.class,
|
||||||
SpawningCreaturesTest.class,
|
SpawningCreaturesTest.class,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs tests
|
||||||
|
* @param args Args provided
|
||||||
|
*/
|
||||||
public static void main(String[] args){
|
public static void main(String[] args){
|
||||||
|
|
||||||
boolean success = true;
|
boolean success = true;
|
||||||
List<Failure> failures = new LinkedList<Failure>();
|
List<Failure> failures = new LinkedList<Failure>();
|
||||||
|
|
||||||
//run tests
|
//run tests
|
||||||
for(Class classObject : classes){
|
for(Class<?> classObject : classes){
|
||||||
System.out.println("CLASS " + classObject.getCanonicalName());
|
TestEngineUtils.log("CLASS " + classObject.getCanonicalName());
|
||||||
Result result = JUnitCore.runClasses(classObject);
|
Result result = JUnitCore.runClasses(classObject);
|
||||||
for(Failure failure : result.getFailures()){
|
for(Failure failure : result.getFailures()){
|
||||||
failures.add(failure);
|
failures.add(failure);
|
||||||
@ -33,10 +41,10 @@ public class TestRunner {
|
|||||||
|
|
||||||
//print failures
|
//print failures
|
||||||
for(Failure failure : failures){
|
for(Failure failure : failures){
|
||||||
System.out.println(failure);
|
TestEngineUtils.log(failure + "");
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Testing was successful: " + success);
|
TestEngineUtils.log("Testing was successful: " + success);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,52 @@
|
|||||||
|
package electrosphere.renderer.ui.elements;
|
||||||
|
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import electrosphere.engine.Globals;
|
||||||
|
import electrosphere.engine.Main;
|
||||||
|
import electrosphere.menu.WindowUtils;
|
||||||
|
import electrosphere.menu.mainmenu.MenuGeneratorsUITesting;
|
||||||
|
import electrosphere.renderer.RenderingEngine;
|
||||||
|
import testutils.TestEngineUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Integration tests for the window class
|
||||||
|
*/
|
||||||
|
public class WindowIntegrationTest {
|
||||||
|
|
||||||
|
@Before
|
||||||
|
/**
|
||||||
|
* Initializes the engine
|
||||||
|
*/
|
||||||
|
public void initEngine(){
|
||||||
|
TestEngineUtils.initGraphicalEngine();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
/**
|
||||||
|
* Tests creating a window
|
||||||
|
*/
|
||||||
|
public void testCreateWindow(){
|
||||||
|
//create ui testing window
|
||||||
|
TestEngineUtils.simulateFrames(1);
|
||||||
|
WindowUtils.replaceMainMenuContents(MenuGeneratorsUITesting.createUITestMenu());
|
||||||
|
TestEngineUtils.simulateFrames(1);
|
||||||
|
BufferedImage screenshot = RenderingEngine.defaultFramebuffer.getPixels(Globals.renderingEngine.getOpenGLState());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
/**
|
||||||
|
* Shuts down the engine
|
||||||
|
*/
|
||||||
|
public void closeEngine(){
|
||||||
|
Main.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
package electrosphere.renderer.ui.elements;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unit testing the window class
|
||||||
|
*/
|
||||||
|
public class WindowUnitTest {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,22 +1,19 @@
|
|||||||
package entity;
|
package entity;
|
||||||
|
|
||||||
import org.joml.Vector3d;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.engine.Main;
|
import electrosphere.engine.Main;
|
||||||
import electrosphere.engine.profiler.Profiler;
|
import electrosphere.engine.profiler.Profiler;
|
||||||
import electrosphere.entity.types.creature.CreatureUtils;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.net.NetUtils;
|
import electrosphere.net.NetUtils;
|
||||||
import electrosphere.server.datacell.Realm;
|
|
||||||
import testutils.TestEntityUtils;
|
|
||||||
|
|
||||||
public class SpawningCreaturesTest {
|
public class SpawningCreaturesTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void initEngine(){
|
public void initEngine(){
|
||||||
System.out.println("[Test] Spawn many creatures");
|
LoggerInterface.loggerEngine.INFO("[Test] Spawn many creatures");
|
||||||
Globals.RUN_CLIENT = true;
|
Globals.RUN_CLIENT = true;
|
||||||
Globals.RUN_SERVER = true;
|
Globals.RUN_SERVER = true;
|
||||||
Globals.HEADLESS = true;
|
Globals.HEADLESS = true;
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import org.junit.Test;
|
|||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.engine.Main;
|
import electrosphere.engine.Main;
|
||||||
import electrosphere.engine.profiler.Profiler;
|
import electrosphere.engine.profiler.Profiler;
|
||||||
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.net.NetUtils;
|
import electrosphere.net.NetUtils;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
@ -11,7 +12,7 @@ public class StartupTest extends TestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStartupHeadless(){
|
public void testStartupHeadless(){
|
||||||
System.out.println("[Test] Startup Headless");
|
LoggerInterface.loggerEngine.INFO("[Test] Startup Headless");
|
||||||
Globals.RUN_CLIENT = false;
|
Globals.RUN_CLIENT = false;
|
||||||
Globals.RUN_SERVER = true;
|
Globals.RUN_SERVER = true;
|
||||||
Globals.HEADLESS = true;
|
Globals.HEADLESS = true;
|
||||||
@ -23,7 +24,7 @@ public class StartupTest extends TestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEmpty() {
|
public void testEmpty() {
|
||||||
System.out.println("[Test] Empty test");
|
LoggerInterface.loggerEngine.INFO("[Test] Empty test");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
10
src/test/java/testutils/InputAPI.java
Normal file
10
src/test/java/testutils/InputAPI.java
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package testutils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to programmatically send input signals as if a user had
|
||||||
|
*/
|
||||||
|
public class InputAPI {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
60
src/test/java/testutils/TestEngineUtils.java
Normal file
60
src/test/java/testutils/TestEngineUtils.java
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
package testutils;
|
||||||
|
|
||||||
|
import electrosphere.engine.Globals;
|
||||||
|
import electrosphere.engine.Main;
|
||||||
|
import electrosphere.engine.profiler.Profiler;
|
||||||
|
import electrosphere.net.NetUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utils for testing the engine
|
||||||
|
*/
|
||||||
|
public class TestEngineUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the engine
|
||||||
|
*/
|
||||||
|
public static void initHeadlessEngine(){
|
||||||
|
Globals.RUN_CLIENT = true;
|
||||||
|
Globals.RUN_SERVER = true;
|
||||||
|
Globals.RUN_AUDIO = false;
|
||||||
|
Globals.HEADLESS = true;
|
||||||
|
Profiler.PROFILE = false;
|
||||||
|
NetUtils.setPort(0);
|
||||||
|
Main.startUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the engine
|
||||||
|
*/
|
||||||
|
public static void initGraphicalEngine(){
|
||||||
|
Globals.RUN_CLIENT = true;
|
||||||
|
Globals.RUN_SERVER = true;
|
||||||
|
Globals.RUN_AUDIO = true;
|
||||||
|
Globals.HEADLESS = false;
|
||||||
|
Profiler.PROFILE = false;
|
||||||
|
NetUtils.setPort(0);
|
||||||
|
Main.startUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints a logging message
|
||||||
|
* @param log the message to print
|
||||||
|
*/
|
||||||
|
public static void log(String log){
|
||||||
|
System.out.println(log);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simulates a certain number of frames
|
||||||
|
* @param frameCount The number of frames to simulate
|
||||||
|
*/
|
||||||
|
public static void simulateFrames(int frameCount){
|
||||||
|
int i = 0;
|
||||||
|
while(i < frameCount){
|
||||||
|
Main.setFramestep(1);
|
||||||
|
Main.mainLoop(1);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -7,8 +7,10 @@ import electrosphere.entity.Entity;
|
|||||||
import electrosphere.entity.EntityUtils;
|
import electrosphere.entity.EntityUtils;
|
||||||
import electrosphere.server.datacell.Realm;
|
import electrosphere.server.datacell.Realm;
|
||||||
import electrosphere.server.datacell.ServerDataCell;
|
import electrosphere.server.datacell.ServerDataCell;
|
||||||
import electrosphere.server.datacell.utils.DataCellSearchUtils;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utilities for testing
|
||||||
|
*/
|
||||||
public class TestEntityUtils {
|
public class TestEntityUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,5 +0,0 @@
|
|||||||
package ui;
|
|
||||||
|
|
||||||
public class UICreationTest {
|
|
||||||
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user