Fix arena mode
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2024-03-13 17:47:21 -04:00
parent 15e10ad83e
commit 41f2675e43
16 changed files with 188 additions and 85 deletions

View File

@ -1,3 +1,3 @@
#maven.buildNumber.plugin properties file #maven.buildNumber.plugin properties file
#Tue Mar 12 21:28:50 EDT 2024 #Tue Mar 12 22:56:01 EDT 2024
buildNumber=46 buildNumber=47

View File

@ -0,0 +1,20 @@
@page puzzlespells Puzzle Spells
Ideas for spells that should be used to construct puzzles
### Manipulate
Picks up an object and can move it around
### Summon
Summons a creature that can do a task
In regular gameplay with would be fighting enemies
Lets say there are special pads you can stand on that change the type of summon
It then summons ie electric spirits that can power objects
### Create Water
### Create Fire
### Create Electricity
### Create/Remove Earth

View File

@ -151,15 +151,28 @@ De-dupe render calls via doing mutations in render pipeline status and dont call
Foliage Manager upgrades Foliage Manager upgrades
- Place foliage intelligently - Place foliage intelligently
Fix arena mode (terrain be crazy)
# TODO # TODO
Optimize instance logic (currently sorting the list of objects to push to buffer each frame nukes the cpu)
sort nukes cpu because capacity logic is after sort, so it tries to sort ~600k items every frame before caping
The way to optimize this is to completely gut existing code. One draw call per tile. Draw call calles drawInstanced for all blades within that cell.
Provide a texture that contains data per blade of grass to the cell on draw. Store positions in that once at creation.
For dynamic wind later will need to use UBOs or something like that.
Fix grass flickering (it's frustum culling being inconsistent, try commenting it out in InstancedActor and see what happens :| )
Fix character movement Fix character movement
Fix Frustum Culling for skybox Fix Frustum Culling for skybox
Fix Character creation preview not working
Clean up main method/class Clean up main method/class
@ -206,10 +219,6 @@ Generate Tree Entities
- Cubic function for limb dispersion over length - Cubic function for limb dispersion over length
- Generate branch starters from trunk that are not full length - Generate branch starters from trunk that are not full length
Fix Character creation preview not working
Fix grass flickering (it's frustum culling being inconsistent, try commenting it out in InstancedActor and see what happens :| )
Foliage Manager upgrades Foliage Manager upgrades
- Wind system (environment ubi that defines wind that is lookup'd by individual blades) - Wind system (environment ubi that defines wind that is lookup'd by individual blades)

View File

@ -0,0 +1,4 @@
@page instanceindex Instancing
[TOC]
- @subpage instancingarch

View File

@ -0,0 +1,7 @@
@page instancingarch Instancing Architecture
Idea is to have two parallel approaches to buffers that are pushed into gpu
One is traditional actor architecture where you call draw on an actor and it puts just its info into InstanceData object (think close trees, rocks, etc)
Other approach is to have an object that represents a bucket of data. You call draw on the bucket and it pushes an array of info into the InstanceData (think grass)
Both push data into InstanceData, which is then iterated over in draw calls by instanceManager

View File

@ -53,9 +53,9 @@ public class ClientFoliageManager {
//The maximum distance a cell can be away from the player before being destroyed //The maximum distance a cell can be away from the player before being destroyed
static final float CELL_DISTANCE_MAX = 25f; static final float CELL_DISTANCE_MAX = 25f;
//The maximum number of foliage cells //The maximum number of foliage cells
static final int CELL_COUNT_MAX = 100; static final int CELL_COUNT_MAX = 25;
//The target number of foliage to place per cell //The target number of foliage to place per cell
static final int TARGET_FOLIAGE_PER_CELL = 200; static final int TARGET_FOLIAGE_PER_CELL = 10;
//Stores a list of all locations that are currently invalid which map to //Stores a list of all locations that are currently invalid which map to
//the amount of frames that must pass before they are considered valid to evaluate //the amount of frames that must pass before they are considered valid to evaluate
Map<String,Integer> locationEvaluationCooldownMap = new ConcurrentHashMap<String,Integer>(); Map<String,Integer> locationEvaluationCooldownMap = new ConcurrentHashMap<String,Integer>();
@ -301,7 +301,12 @@ public class ClientFoliageManager {
ChunkData data = Globals.clientTerrainManager.getChunkDataAtWorldPoint(worldPos); ChunkData data = Globals.clientTerrainManager.getChunkDataAtWorldPoint(worldPos);
List<String> foliageTypesSupported = Globals.gameConfigCurrent.getVoxelData().getTypeFromId(data.getType(voxelPos)).getAmbientFoliage(); List<String> foliageTypesSupported = Globals.gameConfigCurrent.getVoxelData().getTypeFromId(data.getType(voxelPos)).getAmbientFoliage();
if(foliageTypesSupported != null){ if(foliageTypesSupported != null){
FoliageCell cell = new FoliageCell(worldPos, voxelPos); Vector3d realPos = new Vector3d(
worldPos.x * ChunkData.CHUNK_SIZE + voxelPos.x,
worldPos.y * ChunkData.CHUNK_SIZE + voxelPos.y,
worldPos.z * ChunkData.CHUNK_SIZE + voxelPos.z
);
FoliageCell cell = new FoliageCell(worldPos, voxelPos, realPos);
//create center foliage //create center foliage
for(int i = 0; i < TARGET_FOLIAGE_PER_CELL; i++){ for(int i = 0; i < TARGET_FOLIAGE_PER_CELL; i++){
//get type //get type
@ -309,7 +314,7 @@ public class ClientFoliageManager {
FoliageType foliageType = Globals.gameConfigCurrent.getFoliageMap().getFoliage(foliageTypeName); FoliageType foliageType = Globals.gameConfigCurrent.getFoliageMap().getFoliage(foliageTypeName);
//get position to place //get position to place
double offsetX = placementRandomizer.nextDouble() - 0.5; double offsetX = placementRandomizer.nextDouble() - 0.5;
double offsetY = 2; double offsetY = 0;
double offsetZ = placementRandomizer.nextDouble() - 0.5; double offsetZ = placementRandomizer.nextDouble() - 0.5;
// double offsetY = placeFoliage(dataToConsider, offsetX, offsetZ, 0.2, 0.5, 0.15, 0.2+0.6); // double offsetY = placeFoliage(dataToConsider, offsetX, offsetZ, 0.2, 0.5, 0.15, 0.2+0.6);
Vector3d testPosition = new Vector3d( Vector3d testPosition = new Vector3d(
@ -317,12 +322,12 @@ public class ClientFoliageManager {
worldPos.y * ChunkData.CHUNK_SIZE + voxelPos.y + offsetY, worldPos.y * ChunkData.CHUNK_SIZE + voxelPos.y + offsetY,
worldPos.z * ChunkData.CHUNK_SIZE + voxelPos.z + offsetZ worldPos.z * ChunkData.CHUNK_SIZE + voxelPos.z + offsetZ
); );
Vector3d placementPos = Globals.clientSceneWrapper.getCollisionEngine().rayCastPosition(testPosition, new Vector3d(0,-1,0), 2.5); // Vector3d placementPos = Globals.clientSceneWrapper.getCollisionEngine().rayCastPosition(testPosition, new Vector3d(0,-1,0), 2.5);
if(placementPos != null){ if(testPosition != null){
//create entity //create entity
Entity grassEntity = EntityCreationUtils.createClientSpatialEntity(); Entity grassEntity = EntityCreationUtils.createClientSpatialEntity();
makeEntityInstancedFoliage(grassEntity, foliageType.getModelPath(), grassCapacity); makeEntityInstancedFoliage(grassEntity, foliageType.getModelPath(), grassCapacity);
EntityUtils.getPosition(grassEntity).set(placementPos); EntityUtils.getPosition(grassEntity).set(testPosition);
EntityUtils.getRotation(grassEntity).set(getNewRotation()); EntityUtils.getRotation(grassEntity).set(getNewRotation());
EntityUtils.getScale(grassEntity).set(new Vector3d(2.0, 2.0, 2.0)); EntityUtils.getScale(grassEntity).set(new Vector3d(2.0, 2.0, 2.0));
//add ambient foliage behavior tree //add ambient foliage behavior tree

View File

@ -6,6 +6,7 @@ import java.util.Set;
import org.joml.Matrix4d; import org.joml.Matrix4d;
import org.joml.Matrix4f; import org.joml.Matrix4f;
import org.joml.Quaterniond; import org.joml.Quaterniond;
import org.joml.Sphered;
import org.joml.Vector3d; import org.joml.Vector3d;
import org.joml.Vector3f; import org.joml.Vector3f;
import org.joml.Vector3i; import org.joml.Vector3i;
@ -15,6 +16,7 @@ import electrosphere.entity.Entity;
import electrosphere.entity.EntityUtils; import electrosphere.entity.EntityUtils;
import electrosphere.entity.state.foliage.AmbientFoliage; import electrosphere.entity.state.foliage.AmbientFoliage;
import electrosphere.entity.types.camera.CameraEntityUtils; import electrosphere.entity.types.camera.CameraEntityUtils;
import electrosphere.renderer.RenderPipelineState;
import electrosphere.renderer.actor.instance.InstancedActor; import electrosphere.renderer.actor.instance.InstancedActor;
import electrosphere.renderer.buffer.ShaderAttribute; import electrosphere.renderer.buffer.ShaderAttribute;
@ -26,17 +28,23 @@ public class FoliageCell {
protected Vector3i worldPosition; protected Vector3i worldPosition;
//position of the foliage cell in local coordinates //position of the foliage cell in local coordinates
protected Vector3i voxelPosition; protected Vector3i voxelPosition;
//the real position of this cell, stored so we don't constantly have to recalculate
protected Vector3d realPosition;
//constituent entities //constituent entities
protected Set<Entity> containedEntities; protected Set<Entity> containedEntities;
//template bounding shere used for checking frustum for this cell
static Sphered boundingSphere = new Sphered(0.5,0.5,0.5,2);
/** /**
* Constructor * Constructor
* @param worldPos The position of the foliage cell in world coordinates * @param worldPos The position of the foliage cell in world coordinates
* @param voxelPos The position of the foliage cell in voxel coordinates * @param voxelPos The position of the foliage cell in voxel coordinates
*/ */
protected FoliageCell(Vector3i worldPos, Vector3i voxelPos){ protected FoliageCell(Vector3i worldPos, Vector3i voxelPos, Vector3d realPos){
this.worldPosition = worldPos; this.worldPosition = worldPos;
this.voxelPosition = voxelPos; this.voxelPosition = voxelPos;
this.realPosition = realPos;
this.containedEntities = new HashSet<Entity>(); this.containedEntities = new HashSet<Entity>();
} }
@ -73,6 +81,15 @@ public class FoliageCell {
Matrix4d modelMatrix = new Matrix4d(); Matrix4d modelMatrix = new Matrix4d();
Vector3f cameraCenter = CameraEntityUtils.getCameraCenter(Globals.playerCamera); Vector3f cameraCenter = CameraEntityUtils.getCameraCenter(Globals.playerCamera);
Vector3d playerPosition = EntityUtils.getPosition(Globals.playerEntity); Vector3d playerPosition = EntityUtils.getPosition(Globals.playerEntity);
RenderPipelineState renderPipelineState = Globals.renderingEngine.getRenderPipelineState();
//frustum check entire cell
boolean shouldRender = renderPipelineState.getFrustumIntersection().testSphere((float)(realPosition.x + boundingSphere.x), (float)(realPosition.y + boundingSphere.y), (float)(realPosition.z + boundingSphere.z), (float)(boundingSphere.r));
if(shouldRender){
//disable frustum check and instead perform at cell level
boolean currentFrustumCheckState = renderPipelineState.shouldFrustumCheck();
renderPipelineState.setFrustumCheck(false);
for(Entity entity : containedEntities){ for(Entity entity : containedEntities){
Vector3d grassPosition = EntityUtils.getPosition(entity); Vector3d grassPosition = EntityUtils.getPosition(entity);
Quaterniond grassRotation = EntityUtils.getRotation(entity); Quaterniond grassRotation = EntityUtils.getRotation(entity);
@ -90,7 +107,9 @@ public class FoliageCell {
instancedActor.setPriority((int)grassPosition.distance(playerPosition)); instancedActor.setPriority((int)grassPosition.distance(playerPosition));
//draw //draw
instancedActor.draw(Globals.renderingEngine.getRenderPipelineState(), new Vector3d(cameraModifiedPosition)); instancedActor.draw(renderPipelineState, new Vector3d(0,0,0));
}
renderPipelineState.setFrustumCheck(currentFrustumCheckState);
} }
} }
} }

View File

@ -27,9 +27,7 @@ public class ClientSimulation {
Globals.clientSceneWrapper.getCollisionEngine().simulatePhysics((float)Globals.timekeeper.getSimFrameTime()); Globals.clientSceneWrapper.getCollisionEngine().simulatePhysics((float)Globals.timekeeper.getSimFrameTime());
//update actor animations //update actor animations
for(Entity currentEntity : Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.DRAWABLE)){ for(Entity currentEntity : Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.DRAWABLE)){
//fetch actor
Actor currentActor = EntityUtils.getActor(currentEntity); Actor currentActor = EntityUtils.getActor(currentEntity);
//increment animations
if(currentActor.isPlayingAnimation()){ if(currentActor.isPlayingAnimation()){
currentActor.incrementAnimationTime((float)Globals.timekeeper.getSimFrameTime()); currentActor.incrementAnimationTime((float)Globals.timekeeper.getSimFrameTime());
} }
@ -40,8 +38,6 @@ public class ClientSimulation {
} }
//particle state updates //particle state updates
for(Entity particle : Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.PARTICLE)){ for(Entity particle : Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.PARTICLE)){
// ParticleTree tree = ParticleUtils.getParticleTree(particle);
// tree.simulate(Main.deltaFrames);
ParticleUtils.makeParticleBillboardFaceCamera(particle); ParticleUtils.makeParticleBillboardFaceCamera(particle);
} }
//update attached entity positions //update attached entity positions

View File

@ -122,7 +122,7 @@ public class DrawCell {
} else { } else {
for(int i = 0; i < ChunkData.CHUNK_SIZE; i++){ for(int i = 0; i < ChunkData.CHUNK_SIZE; i++){
for(int j = 0; j < ChunkData.CHUNK_SIZE; j++){ for(int j = 0; j < ChunkData.CHUNK_SIZE; j++){
weights[ChunkData.CHUNK_SIZE][i][j] = 0; weights[ChunkData.CHUNK_SIZE][i][j] = -1;
types[ChunkData.CHUNK_SIZE][i][j] = 0; types[ChunkData.CHUNK_SIZE][i][j] = 0;
} }
} }
@ -139,7 +139,7 @@ public class DrawCell {
} else { } else {
for(int i = 0; i < ChunkData.CHUNK_SIZE; i++){ for(int i = 0; i < ChunkData.CHUNK_SIZE; i++){
for(int j = 0; j < ChunkData.CHUNK_SIZE; j++){ for(int j = 0; j < ChunkData.CHUNK_SIZE; j++){
weights[i][ChunkData.CHUNK_SIZE][j] = 0; weights[i][ChunkData.CHUNK_SIZE][j] = -1;
types[i][ChunkData.CHUNK_SIZE][j] = 0; types[i][ChunkData.CHUNK_SIZE][j] = 0;
} }
} }
@ -156,7 +156,7 @@ public class DrawCell {
} else { } else {
for(int i = 0; i < ChunkData.CHUNK_SIZE; i++){ for(int i = 0; i < ChunkData.CHUNK_SIZE; i++){
for(int j = 0; j < ChunkData.CHUNK_SIZE; j++){ for(int j = 0; j < ChunkData.CHUNK_SIZE; j++){
weights[i][j][ChunkData.CHUNK_SIZE] = 0; weights[i][j][ChunkData.CHUNK_SIZE] = -1;
types[i][j][ChunkData.CHUNK_SIZE] = 0; types[i][j][ChunkData.CHUNK_SIZE] = 0;
} }
} }
@ -173,7 +173,7 @@ public class DrawCell {
} }
} else { } else {
for(int i = 0; i < ChunkData.CHUNK_SIZE; i++){ for(int i = 0; i < ChunkData.CHUNK_SIZE; i++){
weights[ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE][i] = 0; weights[ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE][i] = -1;
types [ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE][i] = 0; types [ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE][i] = 0;
} }
} }
@ -189,7 +189,7 @@ public class DrawCell {
} }
} else { } else {
for(int i = 0; i < ChunkData.CHUNK_SIZE; i++){ for(int i = 0; i < ChunkData.CHUNK_SIZE; i++){
weights[ChunkData.CHUNK_SIZE][i][ChunkData.CHUNK_SIZE] = 0; weights[ChunkData.CHUNK_SIZE][i][ChunkData.CHUNK_SIZE] = -1;
types [ChunkData.CHUNK_SIZE][i][ChunkData.CHUNK_SIZE] = 0; types [ChunkData.CHUNK_SIZE][i][ChunkData.CHUNK_SIZE] = 0;
} }
} }
@ -205,7 +205,7 @@ public class DrawCell {
} }
} else { } else {
for(int i = 0; i < ChunkData.CHUNK_SIZE; i++){ for(int i = 0; i < ChunkData.CHUNK_SIZE; i++){
weights[i][ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE] = 0; weights[i][ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE] = -1;
types [i][ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE] = 0; types [i][ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE] = 0;
} }
} }
@ -220,7 +220,7 @@ public class DrawCell {
types[ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE] = currentChunk.getType(0, 0, 0); types[ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE] = currentChunk.getType(0, 0, 0);
} }
} else { } else {
weights[ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE] = 0; weights[ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE] = -1;
types[ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE] = 0; types[ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE] = 0;
} }
} }

View File

@ -241,10 +241,16 @@ public class Main {
/// ///
/// A S S E T M A N A G E R S T U F F /// A S S E T M A N A G E R S T U F F
/// ///
if(!Globals.HEADLESS && captureFramerate){
functionTrackTimeStart = glfwGetTime();
}
if(Globals.RUN_CLIENT){ if(Globals.RUN_CLIENT){
LoggerInterface.loggerEngine.DEBUG("Begin load assets"); LoggerInterface.loggerEngine.DEBUG("Begin load assets");
Globals.assetManager.loadAssetsInQueue(); Globals.assetManager.loadAssetsInQueue();
} }
if(!Globals.HEADLESS && captureFramerate){
ImGuiWindowMacros.addGlobalFramerateDatapoint("assetLoad",(glfwGetTime()-functionTrackTimeStart)*1000);
}
@ -252,11 +258,17 @@ public class Main {
/// ///
/// C L I E N T N E T W O R K I N G S T U F F /// C L I E N T N E T W O R K I N G S T U F F
/// ///
if(!Globals.HEADLESS && captureFramerate){
functionTrackTimeStart = glfwGetTime();
}
//Why is this its own function? Just to get the networking code out of main() //Why is this its own function? Just to get the networking code out of main()
if(Globals.clientConnection != null){ if(Globals.clientConnection != null){
LoggerInterface.loggerEngine.DEBUG("Begin parse client messages"); LoggerInterface.loggerEngine.DEBUG("Begin parse client messages");
Globals.clientConnection.parseMessages(); Globals.clientConnection.parseMessages();
} }
if(!Globals.HEADLESS && captureFramerate){
ImGuiWindowMacros.addGlobalFramerateDatapoint("clientNetwork",(glfwGetTime()-functionTrackTimeStart)*1000);
}
//handle framestep //handle framestep
@ -270,9 +282,15 @@ public class Main {
/// ///
//Poll controls //Poll controls
if(Globals.RUN_CLIENT){ if(Globals.RUN_CLIENT){
if(!Globals.HEADLESS && captureFramerate){
functionTrackTimeStart = glfwGetTime();
}
LoggerInterface.loggerEngine.DEBUG("Begin recapture screen"); LoggerInterface.loggerEngine.DEBUG("Begin recapture screen");
Globals.controlHandler.pollControls(); Globals.controlHandler.pollControls();
RenderingEngine.recaptureIfNecessary(); RenderingEngine.recaptureIfNecessary();
if(!Globals.HEADLESS && captureFramerate){
ImGuiWindowMacros.addGlobalFramerateDatapoint("controls",(glfwGetTime()-functionTrackTimeStart)*1000);
}
} }

View File

@ -56,6 +56,9 @@ public class RenderPipelineState {
//The pointer to the current shader program bound //The pointer to the current shader program bound
int currentShaderPointer; int currentShaderPointer;
//Should actors frustum check (should be turned off in instancing for instance)
boolean frustumCheck = true;
//JOML-provided object to perform frustum culling //JOML-provided object to perform frustum culling
FrustumIntersection frustumInt = new FrustumIntersection(); FrustumIntersection frustumInt = new FrustumIntersection();
@ -167,4 +170,20 @@ public class RenderPipelineState {
return frustumInt; return frustumInt;
} }
/**
* Sets whether actors should frustum check or not
* @param frustumCheck if true, will frustum check, otherwise will not
*/
public void setFrustumCheck(boolean frustumCheck){
this.frustumCheck = frustumCheck;
}
/**
* Returns whether actors should frustum check or not
* @return If true, frustum check, otherwise do not
*/
public boolean shouldFrustumCheck(){
return this.frustumCheck;
}
} }

View File

@ -259,7 +259,7 @@ public class RenderingEngine {
glfwInit(); glfwInit();
//Gives hints to glfw to control how opengl will be used //Gives hints to glfw to control how opengl will be used
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glslVersion = "#version 410"; glslVersion = "#version 410";
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE); Allows you to make the background transparent // glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE); Allows you to make the background transparent

View File

@ -49,10 +49,14 @@ public class InstancedActor implements Comparable<InstancedActor> {
public void draw(RenderPipelineState renderPipelineState, Vector3d position){ public void draw(RenderPipelineState renderPipelineState, Vector3d position){
Model model = Globals.assetManager.fetchModel(modelPath); Model model = Globals.assetManager.fetchModel(modelPath);
if(model != null){ if(model != null){
boolean shouldRender = true;
if(renderPipelineState.shouldFrustumCheck()){
Sphered boundingSphere = model.getBoundingSphere(); Sphered boundingSphere = model.getBoundingSphere();
//frustum check if the model matrix exists (and we therefore can get position) //frustum check if the model matrix exists (and we therefore can get position)
boolean frustumCheck = renderPipelineState.getFrustumIntersection().testSphere((float)(position.x + boundingSphere.x), (float)(position.y + boundingSphere.y), (float)(position.z + boundingSphere.z), (float)boundingSphere.r); boolean frustumCheck = renderPipelineState.getFrustumIntersection().testSphere((float)(position.x + boundingSphere.x), (float)(position.y + boundingSphere.y), (float)(position.z + boundingSphere.z), (float)boundingSphere.r);
if(frustumCheck){ shouldRender = shouldRender && frustumCheck;
}
if(shouldRender){
Globals.clientInstanceManager.addToQueue(this); Globals.clientInstanceManager.addToQueue(this);
} }
} }

View File

@ -4,6 +4,7 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import imgui.ImGui; import imgui.ImGui;
import imgui.type.ImBoolean;
/** /**
* A window in ImGui. The window can contain any number of controls and information. * A window in ImGui. The window can contain any number of controls and information.
@ -19,10 +20,14 @@ public class ImGuiWindow {
//Optional callback for the window //Optional callback for the window
ImGuiWindowCallback callback = null; ImGuiWindowCallback callback = null;
//window boolean
ImBoolean open;
/** /**
* Creates the window * Creates the window
*/ */
public ImGuiWindow(String windowName){ public ImGuiWindow(String windowName){
open = new ImBoolean(true);
this.windowName = windowName; this.windowName = windowName;
} }
@ -53,7 +58,8 @@ public class ImGuiWindow {
* Draws this window * Draws this window
*/ */
public void draw(){ public void draw(){
ImGui.begin(windowName); if(open.getData()[0]){
ImGui.begin(windowName,open);
for(ImGuiElement element : elements){ for(ImGuiElement element : elements){
element.draw(); element.draw();
@ -65,6 +71,15 @@ public class ImGuiWindow {
ImGui.end(); ImGui.end();
} }
}
/**
* Sets the open status of the window
* @param open if true will be open, if false will be closed
*/
public void setOpen(boolean open){
this.open.set(open);
}
/** /**

View File

@ -56,15 +56,11 @@ public class ImGuiWindowMacros {
initFramerateGraphSeries("serversim"); initFramerateGraphSeries("serversim");
initFramerateGraphSeries("clientsim"); initFramerateGraphSeries("clientsim");
initFramerateGraphSeries("render"); initFramerateGraphSeries("render");
initFramerateGraphSeries("assetLoad");
initFramerateGraphSeries("clientNetwork");
initFramerateGraphSeries("controls");
globalFrametimeWindow.addElement(globalFrametimePlot); globalFrametimeWindow.addElement(globalFrametimePlot);
globalFrametimeWindow.setCallback(new ImGuiWindowCallback() { RenderingEngine.addImGuiWindow(globalFrametimeWindow);
@Override
public void exec() {
if(ImGui.button("Close")){
RenderingEngine.removeImGuiWindow(globalFrametimeWindow);
}
}
});
} }
/** /**
@ -98,14 +94,8 @@ public class ImGuiWindowMacros {
serverFrametimeWindow = new ImGuiWindow("Server Frametime Graph"); serverFrametimeWindow = new ImGuiWindow("Server Frametime Graph");
serverFrametimePlot = new ImGuiBarPlot("Server Frametime plot"); serverFrametimePlot = new ImGuiBarPlot("Server Frametime plot");
serverFrametimeWindow.addElement(serverFrametimePlot); serverFrametimeWindow.addElement(serverFrametimePlot);
serverFrametimeWindow.setCallback(new ImGuiWindowCallback() { serverFrametimeWindow.setOpen(false);
@Override RenderingEngine.addImGuiWindow(serverFrametimeWindow);
public void exec() {
if(ImGui.button("Close")){
RenderingEngine.removeImGuiWindow(serverFrametimeWindow);
}
}
});
} }
/** /**
@ -184,13 +174,10 @@ public class ImGuiWindowMacros {
showAllVirtualAudioChildren = true; showAllVirtualAudioChildren = true;
} }
} }
//close button
if(ImGui.button("Close")){
RenderingEngine.removeImGuiWindow(audioDebugMenu);
}
} }
}; };
audioDebugMenu.setOpen(false);
RenderingEngine.addImGuiWindow(audioDebugMenu);
} }
@ -204,19 +191,19 @@ public class ImGuiWindowMacros {
public void exec() { public void exec() {
//show global framerate line graph //show global framerate line graph
if(ImGui.button("Show Overall Frametime")){ if(ImGui.button("Show Overall Frametime")){
RenderingEngine.addImGuiWindow(globalFrametimeWindow); globalFrametimeWindow.setOpen(true);
} }
//show server frametime bar graph //show server frametime bar graph
if(ImGui.button("Show Server Frametime Breakdown")){ if(ImGui.button("Show Server Frametime Breakdown")){
RenderingEngine.addImGuiWindow(serverFrametimeWindow); serverFrametimeWindow.setOpen(true);
} }
//show audio debug //show audio debug
if(ImGui.button("Show Audio Debug Menu")){ if(ImGui.button("Show Audio Debug Menu")){
RenderingEngine.addImGuiWindow(audioDebugMenu); audioDebugMenu.setOpen(true);
} }
//close button //close button
if(ImGui.button("Close")){ if(ImGui.button("Close")){
RenderingEngine.removeImGuiWindow(mainDebugWindow); mainDebugWindow.setOpen(false);
} }
} }
}; };

View File

@ -13,19 +13,19 @@ public class ArenaChunkGenerator implements ChunkGenerator {
public ServerTerrainChunk generateChunk(int worldX, int worldY, int worldZ) { public ServerTerrainChunk generateChunk(int worldX, int worldY, int worldZ) {
//Each chunk also needs custody of the next chunk's first values so that they can perfectly overlap. //Each chunk also needs custody of the next chunk's first values so that they can perfectly overlap.
//Hence, width should actually be chunk dimension + 1 //Hence, width should actually be chunk dimension + 1
float[][][] weights = new float[ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE][ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE][ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE]; float[][][] weights = new float[ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION];
int[][][] values = new int[ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE][ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE][ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE]; int[][][] values = new int[ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION];
for(int inc = 0; inc < ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE; inc++){ for(int inc = 0; inc < ServerTerrainChunk.CHUNK_DIMENSION; inc++){
for(int weightX = 0; weightX < ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE; weightX++){ for(int weightX = 0; weightX < ServerTerrainChunk.CHUNK_DIMENSION; weightX++){
for(int weightZ = 0; weightZ < ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE; weightZ++){ for(int weightZ = 0; weightZ < ServerTerrainChunk.CHUNK_DIMENSION; weightZ++){
weights[weightX][inc][weightZ] = -1; weights[weightX][inc][weightZ] = -1;
values[weightX][inc][weightZ] = 0; values[weightX][inc][weightZ] = 0;
} }
} }
} }
if(worldY < 1){ if(worldY < 1){
for(int weightX = 0; weightX < ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE; weightX++){ for(int weightX = 0; weightX < ServerTerrainChunk.CHUNK_DIMENSION; weightX++){
for(int weightZ = 0; weightZ < ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE; weightZ++){ for(int weightZ = 0; weightZ < ServerTerrainChunk.CHUNK_DIMENSION; weightZ++){
weights[weightX][0][weightZ] = 0.1f; weights[weightX][0][weightZ] = 0.1f;
values[weightX][0][weightZ] = 2; values[weightX][0][weightZ] = 2;
} }