code cleanup work
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2025-05-29 11:46:59 -04:00
parent 21fb8b0e3a
commit 70142a824d
7 changed files with 68 additions and 80 deletions

View File

@ -2054,6 +2054,7 @@ Properly async-ify inventory/item related tests
Fix viewport interaction with lod emitter service Fix viewport interaction with lod emitter service
Fix most tests Fix most tests
Rendering engine legacy code reorganization Rendering engine legacy code reorganization
Code cleanup work

View File

@ -1,9 +1,5 @@
package electrosphere.client; package electrosphere.client;
import java.util.ArrayList;
import org.joml.Vector3f;
import electrosphere.client.block.ClientBlockManager; import electrosphere.client.block.ClientBlockManager;
import electrosphere.client.block.cells.ClientBlockCellManager; import electrosphere.client.block.cells.ClientBlockCellManager;
import electrosphere.client.chemistry.ClientChemistryCollisionCallback; import electrosphere.client.chemistry.ClientChemistryCollisionCallback;
@ -177,11 +173,6 @@ public class ClientState {
*/ */
public Entity targetContainer = null; public Entity targetContainer = null;
//famous fuckin last words, but temporary solution
//global arraylist of values for the skybox colors
//edit(6/1/21): :upside_down_smile:
public ArrayList<Vector3f> skyboxColors = new ArrayList<Vector3f>();
/** /**
* The number of open inventories * The number of open inventories
*/ */

View File

@ -293,7 +293,7 @@ public class Globals {
//init fluid shader program //init fluid shader program
FluidChunkModelGeneration.fluidChunkShaderProgram = VisualShader.loadSpecificShader("/Shaders/entities/fluid2/fluid2.vs", "/Shaders/entities/fluid2/fluid2.fs"); FluidChunkModelGeneration.fluidChunkShaderProgram = VisualShader.loadSpecificShader("/Shaders/entities/fluid2/fluid2.vs", "/Shaders/entities/fluid2/fluid2.fs");
//init models //init models
assetManager.registerModelWithPath(GeometryModelGen.createUnitsphere(), AssetDataStrings.UNITSPHERE); assetManager.registerModelWithPath(GeometryModelGen.createUnitSphere(), AssetDataStrings.UNITSPHERE);
assetManager.registerModelWithPath(GeometryModelGen.createUnitCylinder(), AssetDataStrings.UNITCYLINDER); assetManager.registerModelWithPath(GeometryModelGen.createUnitCylinder(), AssetDataStrings.UNITCYLINDER);
assetManager.registerModelWithPath(GeometryModelGen.createUnitCube(), AssetDataStrings.UNITCUBE); assetManager.registerModelWithPath(GeometryModelGen.createUnitCube(), AssetDataStrings.UNITCUBE);
assetManager.registerModelWithPath(GeometryModelGen.createBlockSingleModel(), AssetDataStrings.MODEL_BLOCK_SINGLE); assetManager.registerModelWithPath(GeometryModelGen.createBlockSingleModel(), AssetDataStrings.MODEL_BLOCK_SINGLE);

View File

@ -3,7 +3,6 @@ package electrosphere.engine.loadingthreads;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.joml.Vector3d; import org.joml.Vector3d;
import org.joml.Vector3f;
import electrosphere.client.block.cells.ClientBlockCellManager; import electrosphere.client.block.cells.ClientBlockCellManager;
import electrosphere.client.entity.camera.CameraEntityUtils; import electrosphere.client.entity.camera.CameraEntityUtils;
@ -139,7 +138,7 @@ public class ClientLoading {
//initialize the basic graphical entities of the world (skybox, camera) //initialize the basic graphical entities of the world (skybox, camera)
initWorldBaseGraphicalEntities(); initWorldBaseGraphicalEntities();
//init arena specific stuff (ie different skybox colors) //init arena specific stuff (ie different skybox colors)
initArenaGraphicalEntities(); initBaseGraphicalEntities();
//sets micro and macro sims to ready if they exist //sets micro and macro sims to ready if they exist
setSimulationsToReady(); setSimulationsToReady();
//set simulations to ready if they exist //set simulations to ready if they exist
@ -266,25 +265,10 @@ public class ClientLoading {
} }
static void initArenaGraphicalEntities(){ /**
* Initializes the base graphical entities of the engine
float skyR = 150; */
float skyG = 200; static void initBaseGraphicalEntities(){
float skyB = 250;
float groundR = 20;
float groundG = 20;
float groundB = 20;
Globals.clientState.skyboxColors.add(new Vector3f(skyR,skyG,skyB));
Globals.clientState.skyboxColors.add(new Vector3f(skyR,skyG,skyB));
Globals.clientState.skyboxColors.add(new Vector3f(groundR,groundG,groundB));
Globals.clientState.skyboxColors.add(new Vector3f(groundR,groundG,groundB));
Globals.clientState.skyboxColors.add(new Vector3f(skyR,skyG,skyB));
Globals.clientState.skyboxColors.add(new Vector3f(skyR,skyG,skyB));
Globals.clientState.skyboxColors.add(new Vector3f(groundR,groundG,groundB));
Globals.clientState.skyboxColors.add(new Vector3f(groundR,groundG,groundB));
//starry sky true skybox //starry sky true skybox
Entity skybox = EntityCreationUtils.createClientSpatialEntity(); Entity skybox = EntityCreationUtils.createClientSpatialEntity();
EntityCreationUtils.makeEntityDrawable(skybox, "Models/environment/skyboxSphere.fbx"); EntityCreationUtils.makeEntityDrawable(skybox, "Models/environment/skyboxSphere.fbx");
@ -296,33 +280,7 @@ public class ClientLoading {
}); });
Globals.assetManager.queueOverrideMeshShader("Models/environment/skyboxSphere.fbx", "Sphere", "Shaders/entities/skysphere/skysphere.vs", "Shaders/entities/skysphere/skysphere.fs"); Globals.assetManager.queueOverrideMeshShader("Models/environment/skyboxSphere.fbx", "Sphere", "Shaders/entities/skysphere/skysphere.vs", "Shaders/entities/skysphere/skysphere.fs");
//cloud ring pseudo skybox
// Entity cloudRing = EntityCreationUtils.createClientSpatialEntity();
// EntityCreationUtils.makeEntityDrawable(cloudRing, "Models/environment/cloudRing.fbx");
// DrawableUtils.makeEntityTransparent(cloudRing);
// DrawableUtils.disableCulling(cloudRing);
// EntityUtils.getRotation(cloudRing).rotateX((float)(-Math.PI/2.0f));
// EntityUtils.getScale(cloudRing).mul(100000.0f);
// Globals.clientScene.registerBehaviorTree(new ApplyRotationTree(cloudRing,new Quaterniond().rotationZ(0.0001)));
// Globals.assetManager.queueOverrideMeshShader("Models/environment/cloudRing.fbx", "Sphere", "Shaders/skysphere/skysphere.vs", "Shaders/skysphere/skysphere.fs");
CursorState.createCursorEntities(); CursorState.createCursorEntities();
//cloud object
// Entity cloudEnt = EntityCreationUtils.createClientSpatialEntity();
// EntityCreationUtils.makeEntityDrawablePreexistingModel(cloudEnt, Globals.assetManager.queuedAsset(new QueuedModel(() -> {
// Model rVal = new Model();
// Mesh m = GeometryMeshGen.genBox(1, 1, 1);
// //shader logic
// m.setShader(VisualShader.loadSpecificShader("Shaders/entities/clouds/clouds.vs", "Shaders/entities/clouds/clouds.fs"));
// m.setParent(rVal);
// rVal.getMeshes().add(m);
// rVal.setBoundingSphere(0,0,0,2);
// return rVal;
// })));
} }
static final int MAX_DRAW_CELL_WAIT = 1000; static final int MAX_DRAW_CELL_WAIT = 1000;

View File

@ -8,7 +8,6 @@ import java.util.Random;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.joml.Vector3d; import org.joml.Vector3d;
import org.joml.Vector3f;
import org.joml.Vector3i; import org.joml.Vector3i;
import electrosphere.auth.AuthenticationManager; import electrosphere.auth.AuthenticationManager;
@ -113,30 +112,10 @@ public class LoadingUtils {
/** /**
* Loads graphics assets necessary for the client of the game engine. This should be stuff that is used essentially universally (ie textures for debugging). * Loads graphics assets necessary for the client of the game engine. This should be stuff that is used essentially universally (ie textures for debugging).
*/ */
static void initGameGraphicalEntities(){ protected static void initGameGraphicalEntities(){
Globals.assetManager.addTexturePathtoQueue("Textures/transparent_red.png"); Globals.assetManager.addTexturePathtoQueue("Textures/transparent_red.png");
Globals.assetManager.addTexturePathtoQueue("Textures/transparent_blue.png"); Globals.assetManager.addTexturePathtoQueue("Textures/transparent_blue.png");
Globals.assetManager.addTexturePathtoQueue("Textures/transparent_grey.png"); Globals.assetManager.addTexturePathtoQueue("Textures/transparent_grey.png");
float skyR = 100;
float skyG = 150;
float skyB = 200;
float groundR = 50;
float groundG = 100;
float groundB = 150;
Globals.clientState.skyboxColors.add(new Vector3f(skyR,skyG,skyB));
Globals.clientState.skyboxColors.add(new Vector3f(skyR,skyG,skyB));
Globals.clientState.skyboxColors.add(new Vector3f(groundR,groundG,groundB));
Globals.clientState.skyboxColors.add(new Vector3f(groundR,groundG,groundB));
Globals.clientState.skyboxColors.add(new Vector3f(skyR,skyG,skyB));
Globals.clientState.skyboxColors.add(new Vector3f(skyR,skyG,skyB));
Globals.clientState.skyboxColors.add(new Vector3f(groundR,groundG,groundB));
Globals.clientState.skyboxColors.add(new Vector3f(groundR,groundG,groundB));
} }

View File

@ -9,11 +9,19 @@ import org.joml.Vector2f;
import org.joml.Vector3d; import org.joml.Vector3d;
import org.joml.Vector3f; import org.joml.Vector3f;
import org.lwjgl.BufferUtils; import org.lwjgl.BufferUtils;
import org.lwjgl.util.par.ParShapes;
import org.lwjgl.util.par.ParShapesMesh;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.assetmanager.AssetDataStrings;
import electrosphere.renderer.OpenGLState; import electrosphere.renderer.OpenGLState;
import electrosphere.renderer.model.Material;
import electrosphere.renderer.model.Mesh; import electrosphere.renderer.model.Mesh;
import electrosphere.renderer.shader.VisualShader;
/**
* Routines for generating meshes of basic geometry
*/
public class GeometryMeshGen { public class GeometryMeshGen {
/** /**
@ -453,4 +461,55 @@ public class GeometryMeshGen {
return mesh; return mesh;
} }
/**
* Generates a unit sphere model
* @param slices The number of slices of the sphere
* @param stacks The number of stacks of the sphere
* @return The model
*/
public static Mesh createUnitSphere(int slices, int stacks){
Mesh sphereMesh = new Mesh("sphere");
OpenGLState openGLState = Globals.renderingEngine.getOpenGLState();
sphereMesh.generateVAO(openGLState);
//buffer coords
ParShapesMesh data = ParShapes.par_shapes_create_parametric_sphere(slices, stacks);
int numPoints = data.npoints();
//verts
{
FloatBuffer verts = data.points(numPoints * 3);
FloatBuffer vertsFinal = BufferUtils.createFloatBuffer(verts.limit()); //reallocating to BufferUtils buffer to help minimize memory errors
vertsFinal.put(verts);
vertsFinal.flip();
sphereMesh.bufferVertices(vertsFinal, 3);
}
//indices
{
IntBuffer indices = data.triangles(data.ntriangles() * 3);
IntBuffer indicesFinal = BufferUtils.createIntBuffer(indices.limit()); //reallocating to BufferUtils buffer to help minimize memory errors
indicesFinal.put(indices);
indicesFinal.flip();
sphereMesh.bufferFaces(indicesFinal, data.ntriangles() * 3);
}
//texture coords
{
FloatBuffer texCoords = data.tcoords(numPoints * 2);
FloatBuffer texCoordsFinal = BufferUtils.createFloatBuffer(texCoords.limit()); //reallocating to BufferUtils buffer to help minimize memory errors
texCoordsFinal.put(texCoords);
texCoordsFinal.flip();
sphereMesh.bufferTextureCoords(texCoordsFinal, 2);
}
//setup extra structures
Material mat = Material.createExisting(AssetDataStrings.TEXTURE_TEAL_TRANSPARENT);
sphereMesh.setMaterial(mat);
sphereMesh.setShader(VisualShader.smartAssembleShader());
return sphereMesh;
}
} }

View File

@ -121,7 +121,7 @@ public class GeometryModelGen {
* Generates a unit sphere model * Generates a unit sphere model
* @return The model * @return The model
*/ */
public static Model createUnitsphere(){ public static Model createUnitSphere(){
Model model = new Model(); Model model = new Model();
Mesh sphereMesh = new Mesh("sphere"); Mesh sphereMesh = new Mesh("sphere");
OpenGLState openGLState = Globals.renderingEngine.getOpenGLState(); OpenGLState openGLState = Globals.renderingEngine.getOpenGLState();