Fix arena mode
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
15e10ad83e
commit
41f2675e43
@ -1,3 +1,3 @@
|
||||
#maven.buildNumber.plugin properties file
|
||||
#Tue Mar 12 21:28:50 EDT 2024
|
||||
buildNumber=46
|
||||
#Tue Mar 12 22:56:01 EDT 2024
|
||||
buildNumber=47
|
||||
|
||||
20
docs/src/highlevel-design/puzzles/puzzlespells.md
Normal file
20
docs/src/highlevel-design/puzzles/puzzlespells.md
Normal 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
|
||||
@ -151,15 +151,28 @@ De-dupe render calls via doing mutations in render pipeline status and dont call
|
||||
Foliage Manager upgrades
|
||||
- Place foliage intelligently
|
||||
|
||||
Fix arena mode (terrain be crazy)
|
||||
|
||||
|
||||
|
||||
|
||||
# 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 Frustum Culling for skybox
|
||||
|
||||
Fix Character creation preview not working
|
||||
|
||||
|
||||
Clean up main method/class
|
||||
|
||||
|
||||
@ -206,10 +219,6 @@ Generate Tree Entities
|
||||
- Cubic function for limb dispersion over 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
|
||||
- Wind system (environment ubi that defines wind that is lookup'd by individual blades)
|
||||
|
||||
|
||||
4
docs/src/rendering/instancing/instanceindex.md
Normal file
4
docs/src/rendering/instancing/instanceindex.md
Normal file
@ -0,0 +1,4 @@
|
||||
@page instanceindex Instancing
|
||||
|
||||
[TOC]
|
||||
- @subpage instancingarch
|
||||
7
docs/src/rendering/instancing/instancingarch.md
Normal file
7
docs/src/rendering/instancing/instancingarch.md
Normal 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
|
||||
@ -53,9 +53,9 @@ public class ClientFoliageManager {
|
||||
//The maximum distance a cell can be away from the player before being destroyed
|
||||
static final float CELL_DISTANCE_MAX = 25f;
|
||||
//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
|
||||
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
|
||||
//the amount of frames that must pass before they are considered valid to evaluate
|
||||
Map<String,Integer> locationEvaluationCooldownMap = new ConcurrentHashMap<String,Integer>();
|
||||
@ -301,7 +301,12 @@ public class ClientFoliageManager {
|
||||
ChunkData data = Globals.clientTerrainManager.getChunkDataAtWorldPoint(worldPos);
|
||||
List<String> foliageTypesSupported = Globals.gameConfigCurrent.getVoxelData().getTypeFromId(data.getType(voxelPos)).getAmbientFoliage();
|
||||
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
|
||||
for(int i = 0; i < TARGET_FOLIAGE_PER_CELL; i++){
|
||||
//get type
|
||||
@ -309,7 +314,7 @@ public class ClientFoliageManager {
|
||||
FoliageType foliageType = Globals.gameConfigCurrent.getFoliageMap().getFoliage(foliageTypeName);
|
||||
//get position to place
|
||||
double offsetX = placementRandomizer.nextDouble() - 0.5;
|
||||
double offsetY = 2;
|
||||
double offsetY = 0;
|
||||
double offsetZ = placementRandomizer.nextDouble() - 0.5;
|
||||
// double offsetY = placeFoliage(dataToConsider, offsetX, offsetZ, 0.2, 0.5, 0.15, 0.2+0.6);
|
||||
Vector3d testPosition = new Vector3d(
|
||||
@ -317,12 +322,12 @@ public class ClientFoliageManager {
|
||||
worldPos.y * ChunkData.CHUNK_SIZE + voxelPos.y + offsetY,
|
||||
worldPos.z * ChunkData.CHUNK_SIZE + voxelPos.z + offsetZ
|
||||
);
|
||||
Vector3d placementPos = Globals.clientSceneWrapper.getCollisionEngine().rayCastPosition(testPosition, new Vector3d(0,-1,0), 2.5);
|
||||
if(placementPos != null){
|
||||
// Vector3d placementPos = Globals.clientSceneWrapper.getCollisionEngine().rayCastPosition(testPosition, new Vector3d(0,-1,0), 2.5);
|
||||
if(testPosition != null){
|
||||
//create entity
|
||||
Entity grassEntity = EntityCreationUtils.createClientSpatialEntity();
|
||||
makeEntityInstancedFoliage(grassEntity, foliageType.getModelPath(), grassCapacity);
|
||||
EntityUtils.getPosition(grassEntity).set(placementPos);
|
||||
EntityUtils.getPosition(grassEntity).set(testPosition);
|
||||
EntityUtils.getRotation(grassEntity).set(getNewRotation());
|
||||
EntityUtils.getScale(grassEntity).set(new Vector3d(2.0, 2.0, 2.0));
|
||||
//add ambient foliage behavior tree
|
||||
|
||||
@ -6,6 +6,7 @@ import java.util.Set;
|
||||
import org.joml.Matrix4d;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Quaterniond;
|
||||
import org.joml.Sphered;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.Vector3i;
|
||||
@ -15,6 +16,7 @@ import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.foliage.AmbientFoliage;
|
||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||
import electrosphere.renderer.RenderPipelineState;
|
||||
import electrosphere.renderer.actor.instance.InstancedActor;
|
||||
import electrosphere.renderer.buffer.ShaderAttribute;
|
||||
|
||||
@ -26,17 +28,23 @@ public class FoliageCell {
|
||||
protected Vector3i worldPosition;
|
||||
//position of the foliage cell in local coordinates
|
||||
protected Vector3i voxelPosition;
|
||||
//the real position of this cell, stored so we don't constantly have to recalculate
|
||||
protected Vector3d realPosition;
|
||||
//constituent entities
|
||||
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
|
||||
* @param worldPos The position of the foliage cell in world 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.voxelPosition = voxelPos;
|
||||
this.realPosition = realPos;
|
||||
this.containedEntities = new HashSet<Entity>();
|
||||
}
|
||||
|
||||
@ -73,24 +81,35 @@ public class FoliageCell {
|
||||
Matrix4d modelMatrix = new Matrix4d();
|
||||
Vector3f cameraCenter = CameraEntityUtils.getCameraCenter(Globals.playerCamera);
|
||||
Vector3d playerPosition = EntityUtils.getPosition(Globals.playerEntity);
|
||||
for(Entity entity : containedEntities){
|
||||
Vector3d grassPosition = EntityUtils.getPosition(entity);
|
||||
Quaterniond grassRotation = EntityUtils.getRotation(entity);
|
||||
InstancedActor instancedActor = InstancedActor.getInstancedActor(entity);
|
||||
|
||||
modelMatrix = modelMatrix.identity();
|
||||
Vector3f cameraModifiedPosition = new Vector3f((float)grassPosition.x,(float)grassPosition.y,(float)grassPosition.z).sub(cameraCenter);
|
||||
modelMatrix.translate(cameraModifiedPosition);
|
||||
modelMatrix.rotate(new Quaterniond(grassRotation));
|
||||
modelMatrix.scale(new Vector3d(EntityUtils.getScale(entity)));
|
||||
RenderPipelineState renderPipelineState = Globals.renderingEngine.getRenderPipelineState();
|
||||
|
||||
instancedActor.setAttribute(modelMatrixAttribute, new Matrix4f(modelMatrix));
|
||||
//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){
|
||||
Vector3d grassPosition = EntityUtils.getPosition(entity);
|
||||
Quaterniond grassRotation = EntityUtils.getRotation(entity);
|
||||
InstancedActor instancedActor = InstancedActor.getInstancedActor(entity);
|
||||
|
||||
//set priority equal to distance
|
||||
instancedActor.setPriority((int)grassPosition.distance(playerPosition));
|
||||
modelMatrix = modelMatrix.identity();
|
||||
Vector3f cameraModifiedPosition = new Vector3f((float)grassPosition.x,(float)grassPosition.y,(float)grassPosition.z).sub(cameraCenter);
|
||||
modelMatrix.translate(cameraModifiedPosition);
|
||||
modelMatrix.rotate(new Quaterniond(grassRotation));
|
||||
modelMatrix.scale(new Vector3d(EntityUtils.getScale(entity)));
|
||||
|
||||
//draw
|
||||
instancedActor.draw(Globals.renderingEngine.getRenderPipelineState(), new Vector3d(cameraModifiedPosition));
|
||||
instancedActor.setAttribute(modelMatrixAttribute, new Matrix4f(modelMatrix));
|
||||
|
||||
//set priority equal to distance
|
||||
instancedActor.setPriority((int)grassPosition.distance(playerPosition));
|
||||
|
||||
//draw
|
||||
instancedActor.draw(renderPipelineState, new Vector3d(0,0,0));
|
||||
}
|
||||
renderPipelineState.setFrustumCheck(currentFrustumCheckState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,9 +27,7 @@ public class ClientSimulation {
|
||||
Globals.clientSceneWrapper.getCollisionEngine().simulatePhysics((float)Globals.timekeeper.getSimFrameTime());
|
||||
//update actor animations
|
||||
for(Entity currentEntity : Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.DRAWABLE)){
|
||||
//fetch actor
|
||||
Actor currentActor = EntityUtils.getActor(currentEntity);
|
||||
//increment animations
|
||||
if(currentActor.isPlayingAnimation()){
|
||||
currentActor.incrementAnimationTime((float)Globals.timekeeper.getSimFrameTime());
|
||||
}
|
||||
@ -40,8 +38,6 @@ public class ClientSimulation {
|
||||
}
|
||||
//particle state updates
|
||||
for(Entity particle : Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.PARTICLE)){
|
||||
// ParticleTree tree = ParticleUtils.getParticleTree(particle);
|
||||
// tree.simulate(Main.deltaFrames);
|
||||
ParticleUtils.makeParticleBillboardFaceCamera(particle);
|
||||
}
|
||||
//update attached entity positions
|
||||
|
||||
@ -122,7 +122,7 @@ public class DrawCell {
|
||||
} else {
|
||||
for(int i = 0; i < ChunkData.CHUNK_SIZE; i++){
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -139,7 +139,7 @@ public class DrawCell {
|
||||
} else {
|
||||
for(int i = 0; i < ChunkData.CHUNK_SIZE; i++){
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -156,7 +156,7 @@ public class DrawCell {
|
||||
} else {
|
||||
for(int i = 0; i < ChunkData.CHUNK_SIZE; i++){
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -173,7 +173,7 @@ public class DrawCell {
|
||||
}
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -189,7 +189,7 @@ public class DrawCell {
|
||||
}
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -205,7 +205,7 @@ public class DrawCell {
|
||||
}
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -220,7 +220,7 @@ public class DrawCell {
|
||||
types[ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE] = currentChunk.getType(0, 0, 0);
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -241,10 +241,16 @@ public class Main {
|
||||
///
|
||||
/// 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){
|
||||
LoggerInterface.loggerEngine.DEBUG("Begin load assets");
|
||||
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
|
||||
///
|
||||
if(!Globals.HEADLESS && captureFramerate){
|
||||
functionTrackTimeStart = glfwGetTime();
|
||||
}
|
||||
//Why is this its own function? Just to get the networking code out of main()
|
||||
if(Globals.clientConnection != null){
|
||||
LoggerInterface.loggerEngine.DEBUG("Begin parse client messages");
|
||||
Globals.clientConnection.parseMessages();
|
||||
}
|
||||
if(!Globals.HEADLESS && captureFramerate){
|
||||
ImGuiWindowMacros.addGlobalFramerateDatapoint("clientNetwork",(glfwGetTime()-functionTrackTimeStart)*1000);
|
||||
}
|
||||
|
||||
|
||||
//handle framestep
|
||||
@ -270,9 +282,15 @@ public class Main {
|
||||
///
|
||||
//Poll controls
|
||||
if(Globals.RUN_CLIENT){
|
||||
if(!Globals.HEADLESS && captureFramerate){
|
||||
functionTrackTimeStart = glfwGetTime();
|
||||
}
|
||||
LoggerInterface.loggerEngine.DEBUG("Begin recapture screen");
|
||||
Globals.controlHandler.pollControls();
|
||||
RenderingEngine.recaptureIfNecessary();
|
||||
if(!Globals.HEADLESS && captureFramerate){
|
||||
ImGuiWindowMacros.addGlobalFramerateDatapoint("controls",(glfwGetTime()-functionTrackTimeStart)*1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -56,6 +56,9 @@ public class RenderPipelineState {
|
||||
//The pointer to the current shader program bound
|
||||
int currentShaderPointer;
|
||||
|
||||
//Should actors frustum check (should be turned off in instancing for instance)
|
||||
boolean frustumCheck = true;
|
||||
|
||||
//JOML-provided object to perform frustum culling
|
||||
FrustumIntersection frustumInt = new FrustumIntersection();
|
||||
|
||||
@ -167,4 +170,20 @@ public class RenderPipelineState {
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -259,7 +259,7 @@ public class RenderingEngine {
|
||||
glfwInit();
|
||||
//Gives hints to glfw to control how opengl will be used
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
glslVersion = "#version 410";
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
// glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE); Allows you to make the background transparent
|
||||
|
||||
@ -49,10 +49,14 @@ public class InstancedActor implements Comparable<InstancedActor> {
|
||||
public void draw(RenderPipelineState renderPipelineState, Vector3d position){
|
||||
Model model = Globals.assetManager.fetchModel(modelPath);
|
||||
if(model != null){
|
||||
Sphered boundingSphere = model.getBoundingSphere();
|
||||
//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);
|
||||
if(frustumCheck){
|
||||
boolean shouldRender = true;
|
||||
if(renderPipelineState.shouldFrustumCheck()){
|
||||
Sphered boundingSphere = model.getBoundingSphere();
|
||||
//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);
|
||||
shouldRender = shouldRender && frustumCheck;
|
||||
}
|
||||
if(shouldRender){
|
||||
Globals.clientInstanceManager.addToQueue(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import imgui.ImGui;
|
||||
import imgui.type.ImBoolean;
|
||||
|
||||
/**
|
||||
* 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
|
||||
ImGuiWindowCallback callback = null;
|
||||
|
||||
//window boolean
|
||||
ImBoolean open;
|
||||
|
||||
/**
|
||||
* Creates the window
|
||||
*/
|
||||
public ImGuiWindow(String windowName){
|
||||
open = new ImBoolean(true);
|
||||
this.windowName = windowName;
|
||||
}
|
||||
|
||||
@ -53,17 +58,27 @@ public class ImGuiWindow {
|
||||
* Draws this window
|
||||
*/
|
||||
public void draw(){
|
||||
ImGui.begin(windowName);
|
||||
if(open.getData()[0]){
|
||||
ImGui.begin(windowName,open);
|
||||
|
||||
for(ImGuiElement element : elements){
|
||||
element.draw();
|
||||
for(ImGuiElement element : elements){
|
||||
element.draw();
|
||||
}
|
||||
|
||||
if(callback != null){
|
||||
callback.exec();
|
||||
}
|
||||
|
||||
ImGui.end();
|
||||
}
|
||||
}
|
||||
|
||||
if(callback != null){
|
||||
callback.exec();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -56,15 +56,11 @@ public class ImGuiWindowMacros {
|
||||
initFramerateGraphSeries("serversim");
|
||||
initFramerateGraphSeries("clientsim");
|
||||
initFramerateGraphSeries("render");
|
||||
initFramerateGraphSeries("assetLoad");
|
||||
initFramerateGraphSeries("clientNetwork");
|
||||
initFramerateGraphSeries("controls");
|
||||
globalFrametimeWindow.addElement(globalFrametimePlot);
|
||||
globalFrametimeWindow.setCallback(new ImGuiWindowCallback() {
|
||||
@Override
|
||||
public void exec() {
|
||||
if(ImGui.button("Close")){
|
||||
RenderingEngine.removeImGuiWindow(globalFrametimeWindow);
|
||||
}
|
||||
}
|
||||
});
|
||||
RenderingEngine.addImGuiWindow(globalFrametimeWindow);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -98,14 +94,8 @@ public class ImGuiWindowMacros {
|
||||
serverFrametimeWindow = new ImGuiWindow("Server Frametime Graph");
|
||||
serverFrametimePlot = new ImGuiBarPlot("Server Frametime plot");
|
||||
serverFrametimeWindow.addElement(serverFrametimePlot);
|
||||
serverFrametimeWindow.setCallback(new ImGuiWindowCallback() {
|
||||
@Override
|
||||
public void exec() {
|
||||
if(ImGui.button("Close")){
|
||||
RenderingEngine.removeImGuiWindow(serverFrametimeWindow);
|
||||
}
|
||||
}
|
||||
});
|
||||
serverFrametimeWindow.setOpen(false);
|
||||
RenderingEngine.addImGuiWindow(serverFrametimeWindow);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -184,13 +174,10 @@ public class ImGuiWindowMacros {
|
||||
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() {
|
||||
//show global framerate line graph
|
||||
if(ImGui.button("Show Overall Frametime")){
|
||||
RenderingEngine.addImGuiWindow(globalFrametimeWindow);
|
||||
globalFrametimeWindow.setOpen(true);
|
||||
}
|
||||
//show server frametime bar graph
|
||||
if(ImGui.button("Show Server Frametime Breakdown")){
|
||||
RenderingEngine.addImGuiWindow(serverFrametimeWindow);
|
||||
serverFrametimeWindow.setOpen(true);
|
||||
}
|
||||
//show audio debug
|
||||
if(ImGui.button("Show Audio Debug Menu")){
|
||||
RenderingEngine.addImGuiWindow(audioDebugMenu);
|
||||
audioDebugMenu.setOpen(true);
|
||||
}
|
||||
//close button
|
||||
if(ImGui.button("Close")){
|
||||
RenderingEngine.removeImGuiWindow(mainDebugWindow);
|
||||
mainDebugWindow.setOpen(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -13,19 +13,19 @@ public class ArenaChunkGenerator implements ChunkGenerator {
|
||||
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.
|
||||
//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];
|
||||
int[][][] values = new int[ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE][ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE][ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE];
|
||||
for(int inc = 0; inc < ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE; inc++){
|
||||
for(int weightX = 0; weightX < ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE; weightX++){
|
||||
for(int weightZ = 0; weightZ < ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE; weightZ++){
|
||||
float[][][] weights = new float[ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION];
|
||||
int[][][] values = new int[ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION];
|
||||
for(int inc = 0; inc < ServerTerrainChunk.CHUNK_DIMENSION; inc++){
|
||||
for(int weightX = 0; weightX < ServerTerrainChunk.CHUNK_DIMENSION; weightX++){
|
||||
for(int weightZ = 0; weightZ < ServerTerrainChunk.CHUNK_DIMENSION; weightZ++){
|
||||
weights[weightX][inc][weightZ] = -1;
|
||||
values[weightX][inc][weightZ] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(worldY < 1){
|
||||
for(int weightX = 0; weightX < ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE; weightX++){
|
||||
for(int weightZ = 0; weightZ < ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE; weightZ++){
|
||||
for(int weightX = 0; weightX < ServerTerrainChunk.CHUNK_DIMENSION; weightX++){
|
||||
for(int weightZ = 0; weightZ < ServerTerrainChunk.CHUNK_DIMENSION; weightZ++){
|
||||
weights[weightX][0][weightZ] = 0.1f;
|
||||
values[weightX][0][weightZ] = 2;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user