Skip to content

Commit

Permalink
refractoring
Browse files Browse the repository at this point in the history
  • Loading branch information
rpereira-dev committed Apr 3, 2018
1 parent f947c4f commit 520d73e
Show file tree
Hide file tree
Showing 89 changed files with 2,078 additions and 1,118 deletions.
1 change: 1 addition & 0 deletions .recommenders/caches/identified-project-coordinates.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[[{"location":"/usr/lib/jvm/java-8-openjdk-amd64","type":"JRE","hints":{"EXECUTION_ENVIRONMENT":"JavaSE-1.8"}},"jre:jre:1.8.0"],[{"location":"/home/rpereira/VoxelEngine/VoxelEngine","type":"PROJECT","hints":{"PROJECT_NAME":"VoxelEngine-VoxelEngine"}},"ABSENT"]]
1 change: 1 addition & 0 deletions .recommenders/caches/manual-mappings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
����
coordinate fingerprintssymbolic-names
classifierselfccallovrdselfmovrpovrmstaticsctor

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import com.grillecube.client.opengl.window.GLFWWindow;
import com.grillecube.common.Logger;
import com.grillecube.common.Taskable;
import com.grillecube.common.world.Timer;
import com.grillecube.common.Timer;

public abstract class Renderer implements Taskable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@

import java.util.ArrayList;

import com.grillecube.client.renderer.world.BlockFace;
import com.grillecube.client.renderer.world.TerrainMeshTriangle;
import com.grillecube.client.renderer.world.TerrainMesher;
import com.grillecube.client.renderer.world.flat.BlockFace;
import com.grillecube.client.resources.BlockRendererManager;
import com.grillecube.common.faces.Face;
import com.grillecube.common.maths.Vector3i;
import com.grillecube.common.world.Terrain;
import com.grillecube.common.world.block.Block;
import com.grillecube.common.world.terrain.WorldObjectTerrain;

/** the block renderer class */
public abstract class BlockRenderer {
Expand Down Expand Up @@ -297,7 +297,7 @@ public abstract class BlockRenderer {
* If the block has a special rendering, add the vertices directly onto the
* stack
*/
public abstract void generateBlockVertices(TerrainMesher terrainMesher, Terrain terrain, Block block, int x, int y,
public abstract void generateBlockVertices(TerrainMesher terrainMesher, WorldObjectTerrain terrain, Block block, int x, int y,
int z, BlockFace[][][][] faces, ArrayList<TerrainMeshTriangle> stack);

/** return the x texture coodinates for this textureID */
Expand All @@ -311,7 +311,7 @@ public static final int getAtlasY(int textureID) {
}

/** get block light by getting the average of neighboors blocks */
public static final float getBlockLight(Terrain terrain, int x, int y, int z, Vector3i... neighboors) {
public static final float getBlockLight(WorldObjectTerrain terrain, int x, int y, int z, Vector3i... neighboors) {
float blockLight = 0.0f;
for (Vector3i n : neighboors) {
blockLight += terrain.getBlockLight(x + n.x, y + n.y, z + n.z);
Expand All @@ -320,12 +320,12 @@ public static final float getBlockLight(Terrain terrain, int x, int y, int z, Ve
}

/** get block light by getting the average of neighboors blocks */
public static final float getBlockLight(Terrain terrain, int x, int y, int z, int faceID, int faceVertexID) {
public static final float getBlockLight(WorldObjectTerrain terrain, int x, int y, int z, int faceID, int faceVertexID) {
return (getBlockLight(terrain, x, y, z, getNeighboors(faceID, faceVertexID)));
}

/** get block light by getting the average of neighboors blocks */
public static final float getSunLight(Terrain terrain, int x, int y, int z, Vector3i... neighboors) {
public static final float getSunLight(WorldObjectTerrain terrain, int x, int y, int z, Vector3i... neighboors) {
float sunLight = 0.0f;
for (Vector3i n : neighboors) {
sunLight += terrain.getSunLight(x + n.x, y + n.y, z + n.z);
Expand All @@ -334,7 +334,7 @@ public static final float getSunLight(Terrain terrain, int x, int y, int z, Vect
}

/** get block light by getting the average of neighboors blocks */
public static final float getSunLight(Terrain terrain, int x, int y, int z, int faceID, int vertexID) {
public static final float getSunLight(WorldObjectTerrain terrain, int x, int y, int z, int faceID, int vertexID) {
return (getSunLight(terrain, x, y, z, getNeighboors(faceID, vertexID)));
}

Expand All @@ -345,7 +345,7 @@ public static final float getSunLight(Terrain terrain, int x, int y, int z, int

public static final float AO_UNIT = 0.06f;

public static final float getAmbiantOcclusion(Terrain terrain, int x, int y, int z, Vector3i... neighboors) {
public static final float getAmbiantOcclusion(WorldObjectTerrain terrain, int x, int y, int z, Vector3i... neighboors) {
Block side1 = terrain.getBlock(x + neighboors[0].x, y + neighboors[0].y, z + neighboors[0].z);
Block side2 = terrain.getBlock(x + neighboors[1].x, y + neighboors[1].y, z + neighboors[1].z);
Block corner = terrain.getBlock(x + neighboors[2].x, y + neighboors[2].y, z + neighboors[2].z);
Expand All @@ -363,7 +363,7 @@ public static final float getAmbiantOcclusion(Terrain terrain, int x, int y, int
return (c ? AO_UNIT : 0.0f);
}

public static final float getAmbiantOcclusion(Terrain terrain, int x, int y, int z, int faceID, int vertexID) {
public static final float getAmbiantOcclusion(WorldObjectTerrain terrain, int x, int y, int z, int faceID, int vertexID) {
return (getAmbiantOcclusion(terrain, x, y, z, getNeighboors(faceID, vertexID)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import java.util.ArrayList;

import com.grillecube.client.renderer.world.BlockFace;
import com.grillecube.client.renderer.world.TerrainMeshTriangle;
import com.grillecube.client.renderer.world.TerrainMeshVertex;
import com.grillecube.client.renderer.world.TerrainMesher;
import com.grillecube.client.renderer.world.flat.BlockFace;
import com.grillecube.common.Logger;
import com.grillecube.common.faces.Face;
import com.grillecube.common.maths.Vector3i;
import com.grillecube.common.world.Terrain;
import com.grillecube.common.world.block.Block;
import com.grillecube.common.world.terrain.WorldObjectTerrain;

/** the default cube renderer */
public class BlockRendererCube extends BlockRenderer {
Expand Down Expand Up @@ -83,15 +83,15 @@ public int getTextureID(Face face) {
}

@Override
public void generateBlockVertices(TerrainMesher terrainMesher, Terrain terrain, Block block, int x, int y, int z,
public void generateBlockVertices(TerrainMesher terrainMesher, WorldObjectTerrain terrain, Block block, int x, int y, int z,
BlockFace[][][][] faces, ArrayList<TerrainMeshTriangle> stack) {

for (Face face : Face.faces) {
faces[face.getID()][x][y][z] = this.createBlockFace(terrain, block, face, x, y, z);
}
}

private final BlockFace createBlockFace(Terrain terrain, Block block, Face face, int x, int y, int z) {
private final BlockFace createBlockFace(WorldObjectTerrain terrain, Block block, Face face, int x, int y, int z) {

// if the face-neighboor block is visible isnt transparent
if (!this.canRenderFace(terrain, block, face, x, y, z)) {
Expand All @@ -111,7 +111,7 @@ private final BlockFace createBlockFace(Terrain terrain, Block block, Face face,

}

protected boolean canRenderFace(Terrain terrain, Block block, Face face, int x, int y, int z) {
protected boolean canRenderFace(WorldObjectTerrain terrain, Block block, Face face, int x, int y, int z) {
Vector3i vec = face.getVector();

// get the neighbor of this face
Expand All @@ -124,7 +124,7 @@ protected boolean canRenderFace(Terrain terrain, Block block, Face face, int x,
* return the vertex for the given face at the given coordinates, for it given
* id
*/
public TerrainMeshVertex createBlockFaceVertex(Terrain terrain, Face face, int x, int y, int z, int faceVertexID) {
public TerrainMeshVertex createBlockFaceVertex(WorldObjectTerrain terrain, Face face, int x, int y, int z, int faceVertexID) {

int vertexID = FACES_VERTICES[face.getID()][faceVertexID];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import java.util.ArrayList;

import com.grillecube.client.renderer.world.BlockFace;
import com.grillecube.client.renderer.world.TerrainMeshTriangle;
import com.grillecube.client.renderer.world.TerrainMeshVertex;
import com.grillecube.client.renderer.world.TerrainMesher;
import com.grillecube.client.renderer.world.flat.BlockFace;
import com.grillecube.common.world.Terrain;
import com.grillecube.common.world.block.Block;
import com.grillecube.common.world.terrain.WorldObjectTerrain;

/** the default cube renderer */
public class BlockRendererJSON extends BlockRenderer {
Expand All @@ -21,7 +21,7 @@ public BlockRendererJSON(String filepath) {
}

@Override
public void generateBlockVertices(TerrainMesher terrainMesher, Terrain terrain, Block block, int x, int y, int z,
public void generateBlockVertices(TerrainMesher terrainMesher, WorldObjectTerrain terrain, Block block, int x, int y, int z,
BlockFace[][][][] faces, ArrayList<TerrainMeshTriangle> stack) {
for (TerrainMeshTriangle triangle : this.triangles) {
TerrainMeshTriangle clone = (TerrainMeshTriangle) triangle.clone();
Expand All @@ -34,9 +34,9 @@ public void generateBlockVertices(TerrainMesher terrainMesher, Terrain terrain,

private final void offsetVertex(TerrainMeshVertex v, int x, int y, int z) {
// offset position
v.posx = (v.posx + x) * Terrain.BLOCK_SIZE;
v.posy = (v.posy + y) * Terrain.BLOCK_SIZE;
v.posz = (v.posz + z) * Terrain.BLOCK_SIZE;
v.posx = (v.posx + x) * WorldObjectTerrain.BLOCK_SIZE;
v.posy = (v.posy + y) * WorldObjectTerrain.BLOCK_SIZE;
v.posz = (v.posz + z) * WorldObjectTerrain.BLOCK_SIZE;

// TODO : light (using vertex normal)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.grillecube.common.faces.Face;
import com.grillecube.common.maths.Vector3i;
import com.grillecube.common.world.Terrain;
import com.grillecube.common.world.block.Block;
import com.grillecube.common.world.terrain.WorldObjectTerrain;

public class BlockRendererLeaves extends BlockRendererCube {

Expand All @@ -12,7 +12,7 @@ public BlockRendererLeaves(int textureID) {
}

@Override
protected boolean canRenderFace(Terrain terrain, Block block, Face face, int x, int y, int z) {
protected boolean canRenderFace(WorldObjectTerrain terrain, Block block, Face face, int x, int y, int z) {
Vector3i vec = face.getVector();
// get the neighbor of this face
Block neighbor = terrain.getBlock(x + vec.x, y + vec.y, z + vec.z);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

import java.util.ArrayList;

import com.grillecube.client.renderer.world.BlockFace;
import com.grillecube.client.renderer.world.TerrainMeshTriangle;
import com.grillecube.client.renderer.world.TerrainMeshVertex;
import com.grillecube.client.renderer.world.TerrainMesher;
import com.grillecube.client.renderer.world.flat.BlockFace;
import com.grillecube.common.faces.Face;
import com.grillecube.common.maths.Vector3i;
import com.grillecube.common.world.Terrain;
import com.grillecube.common.world.block.Block;
import com.grillecube.common.world.block.BlockLiquid;
import com.grillecube.common.world.block.Blocks;
import com.grillecube.common.world.block.instances.BlockInstanceLiquid;
import com.grillecube.common.world.terrain.WorldObjectTerrain;

public class BlockRendererLiquid extends BlockRendererCube {

Expand All @@ -21,7 +21,7 @@ public BlockRendererLiquid(int textureID) {
}

@Override
public void generateBlockVertices(TerrainMesher terrainMesher, Terrain terrain, Block block, int x, int y, int z,
public void generateBlockVertices(TerrainMesher terrainMesher, WorldObjectTerrain terrain, Block block, int x, int y, int z,
BlockFace[][][][] faces, ArrayList<TerrainMeshTriangle> stack) {
for (Face face : Face.values()) {
Vector3i vec = face.getVector();
Expand All @@ -37,7 +37,7 @@ public void generateBlockVertices(TerrainMesher terrainMesher, Terrain terrain,
}

/** push vertices for a liquid */
private void pushFaceVertices(TerrainMesher mesher, Terrain terrain, Block neighbor,
private void pushFaceVertices(TerrainMesher mesher, WorldObjectTerrain terrain, Block neighbor,
ArrayList<TerrainMeshTriangle> stack, int x, int y, int z, Face face) {

// get the instance for this block
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

import java.util.ArrayList;

import com.grillecube.client.renderer.world.BlockFace;
import com.grillecube.client.renderer.world.TerrainMeshTriangle;
import com.grillecube.client.renderer.world.TerrainMeshVertex;
import com.grillecube.client.renderer.world.TerrainMesher;
import com.grillecube.client.renderer.world.flat.BlockFace;
import com.grillecube.common.faces.Face;
import com.grillecube.common.maths.Maths;
import com.grillecube.common.maths.Vector3i;
import com.grillecube.common.world.Terrain;
import com.grillecube.common.world.World;
import com.grillecube.common.world.block.Block;
import com.grillecube.common.world.terrain.WorldObjectTerrain;

/** the default cube renderer */
public class BlockRendererPlant extends BlockRenderer {
Expand All @@ -37,7 +37,7 @@ public final int getTextureID() {
}

@Override
public void generateBlockVertices(TerrainMesher terrainMesher, Terrain terrain, Block block, int x, int y, int z,
public void generateBlockVertices(TerrainMesher terrainMesher, WorldObjectTerrain terrain, Block block, int x, int y, int z,
BlockFace[][][][] faces, ArrayList<TerrainMeshTriangle> stack) {
for (Face face : Face.faces) {
Vector3i vec = face.getVector();
Expand All @@ -49,7 +49,7 @@ public void generateBlockVertices(TerrainMesher terrainMesher, Terrain terrain,
}
}

private final void createPlantVertices(Terrain terrain, Block block, int x, int y, int z,
private final void createPlantVertices(WorldObjectTerrain terrain, Block block, int x, int y, int z,
ArrayList<TerrainMeshTriangle> stack) {
TerrainMeshVertex v0 = this.createBlockFaceVertex(terrain, Face.F_RIGHT, x, y, z, 0);
TerrainMeshVertex v1 = this.createBlockFaceVertex(terrain, Face.F_RIGHT, x, y, z, 1);
Expand All @@ -70,7 +70,7 @@ private final void createPlantVertices(Terrain terrain, Block block, int x, int
/**
* return the vertex for the given vertex ID at the given coordinates
*/
public TerrainMeshVertex createBlockFaceVertex(Terrain terrain, Face face, int x, int y, int z, int vertexID) {
public TerrainMeshVertex createBlockFaceVertex(WorldObjectTerrain terrain, Face face, int x, int y, int z, int vertexID) {
Vector3i[] neighboors = FACES_NEIGHBORS[face.getID()][vertexID];

// position
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import com.grillecube.common.Logger;
import com.grillecube.common.maths.Matrix4f;
import com.grillecube.common.maths.Vector3f;
import com.grillecube.common.world.Terrain;
import com.grillecube.common.world.terrain.WorldObjectTerrain;

public class CameraPerspectiveWorld extends CameraProjectiveWorld {

public static final int TERRAIN_RENDER_DISTANCE = 32;
public static final float RENDER_DISTANCE = Terrain.DIMX_SIZE * TERRAIN_RENDER_DISTANCE;
public static final float RENDER_DISTANCE = WorldObjectTerrain.DIMX_SIZE * TERRAIN_RENDER_DISTANCE;
public static final float FAR_DISTANCE = RENDER_DISTANCE * 1.2f;
/** planes attributes */
private float fov;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import com.grillecube.client.opengl.window.GLFWWindow;
import com.grillecube.common.maths.Vector3f;
import com.grillecube.common.maths.Vector3i;
import com.grillecube.common.world.Terrain;
import com.grillecube.common.world.World;
import com.grillecube.common.world.block.Block;
import com.grillecube.common.world.terrain.WorldObjectTerrain;

public abstract class CameraProjectiveWorld extends CameraProjective implements RaycastingCallback {

Expand Down Expand Up @@ -78,7 +78,7 @@ public void setBlock(Block block, Vector3f pos) {
return;
}

Terrain terrain = this.getWorld().setBlock(block, pos.x, pos.y, pos.z);
WorldObjectTerrain terrain = this.getWorld().setBlock(block, pos.x, pos.y, pos.z);

if (terrain == null) {
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.grillecube.client.renderer.gui.animations;

import com.grillecube.client.renderer.gui.components.Gui;
import com.grillecube.common.world.Timer;
import com.grillecube.common.Timer;

public abstract class GuiAnimation<T extends Gui> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import com.grillecube.client.renderer.gui.GuiRenderer;
import com.grillecube.client.renderer.gui.event.GuiEventAspectRatio;
import com.grillecube.client.renderer.gui.event.GuiListener;
import com.grillecube.client.renderer.world.flat.WorldFlatRenderer;
import com.grillecube.client.renderer.world.WorldFlatRenderer;

public class GuiViewWorld extends GuiView {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.grillecube.client.renderer.model.editor;

import com.grillecube.common.world.Terrain;
import com.grillecube.common.world.WorldFlat;
import com.grillecube.common.world.terrain.WorldObjectTerrain;

public class ModelEditorWorld extends WorldFlat {

Expand All @@ -14,7 +14,7 @@ public void onLoaded() {
this.setWorldGenerator(new ModelEditorWorldGenerator());
for (int x = -4; x < 4; x++) {
for (int y = -4; y < 4; y++) {
Terrain terrain = this.spawnTerrain(new Terrain(x, y, -1));
WorldObjectTerrain terrain = this.spawnTerrain(new WorldObjectTerrain(this, x, y, -1));
this.generateTerrain(terrain);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package com.grillecube.client.renderer.model.editor;

import com.grillecube.common.world.Terrain;
import com.grillecube.common.world.block.Blocks;
import com.grillecube.common.world.generator.WorldGenerator;
import com.grillecube.common.world.terrain.WorldObjectTerrain;

public class ModelEditorWorldGenerator extends WorldGenerator {

@Override
public void generate(Terrain terrain) {
for (int x = 0; x < Terrain.DIMX; x++) {
for (int y = 0; y < Terrain.DIMY; y++) {
public void generate(WorldObjectTerrain terrain) {
for (int x = 0; x < WorldObjectTerrain.DIMX; x++) {
for (int y = 0; y < WorldObjectTerrain.DIMY; y++) {
// terrain.setBlockAt((x + z) % 2 == 0 ? Blocks.GRASS :
// Blocks.LOG, x, 4, z);
terrain.setBlockAt(Blocks.GRASS, x, y, Terrain.DIMZ - 1);
terrain.setBlockAt(Blocks.STONE, x, y, Terrain.DIMZ - 2);
terrain.setBlockAt(Blocks.STONE, x, y, Terrain.DIMZ - 3);
terrain.setBlockAt(Blocks.STONE, x, y, Terrain.DIMZ - 4);
terrain.setBlockAt(Blocks.STONE, x, y, Terrain.DIMZ - 5);
terrain.setBlockAt(Blocks.GRASS, x, y, WorldObjectTerrain.DIMZ - 1);
terrain.setBlockAt(Blocks.STONE, x, y, WorldObjectTerrain.DIMZ - 2);
terrain.setBlockAt(Blocks.STONE, x, y, WorldObjectTerrain.DIMZ - 3);
terrain.setBlockAt(Blocks.STONE, x, y, WorldObjectTerrain.DIMZ - 4);
terrain.setBlockAt(Blocks.STONE, x, y, WorldObjectTerrain.DIMZ - 5);
}
}

Expand Down
Loading

0 comments on commit 520d73e

Please sign in to comment.