Skip to content

Commit

Permalink
todos
Browse files Browse the repository at this point in the history
  • Loading branch information
rpereira committed Dec 17, 2017
1 parent 827c59f commit a14e74c
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ public void post(EventLoop event) {

// get tasks
this.registerEventCallback(new Listener<EventGetTasks>() {

@Override
public void pre(EventGetTasks event) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,12 @@ public abstract class BlockRenderer {
/** vertices for a face */
public static final int[][] FACES_VERTICES = new int[Face.faces.length][4];
/**
* lists the index of the endpoint vertices for each of the 12edges of the
* cube
* lists the index of the endpoint vertices for each of the 12edges of the cube
*/
public static final int EDGES[][] = new int[12][2];

/**
* 12x3 : lists the direction vector (vertex1-vertex0) for each edge in the
* cube
* 12x3 : lists the direction vector (vertex1-vertex0) for each edge in the cube
*/
public static final Vector3i[] EDGES_DIRECTIONS = new Vector3i[12];

Expand Down Expand Up @@ -293,8 +291,8 @@ public abstract class BlockRenderer {
public static final float[][] FACES_UV = { { 0, 0 }, { 0, 1 }, { 1, 1 }, { 1, 0 } };

/**
* generate the vertices for the given block, in the given terrain and (x,
* y, z) terrain-relative coordinates.
* generate the vertices for the given block, in the given terrain and (x, y, z)
* terrain-relative coordinates.
*
* If this block has faces (1x1), it should be set: faces[faceID][x][y][z] =
* blockFace, so it can be cull if needed
Expand All @@ -305,10 +303,6 @@ public abstract class BlockRenderer {
public abstract void generateBlockVertices(TerrainMesher terrainMesher, Terrain terrain, Block block, int x, int y,
int z, BlockFace[][][][] faces, ArrayList<TerrainMeshTriangle> stack);

/** return true if this block has transparency */
// public abstract boolean hasTransparency(); //TODO : implement it here,
// instead of #Terrain#opaqueBlockCount and stuff...

/** return the x texture coodinates for this textureID */
public static final int getAtlasX(int textureID) {
return (textureID % BlockRendererManager.TEXTURE_PER_LINE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ private BlockRendererCube() {
* : the face and texture ID's
*
* e.g: new BlockRendererCube(Blocks.GRASS, Face.LEFT,
* ClientBlocks.T_GRASS_SIDE, Face.RIGHT,
* ClientBlocks.T_GRASS_SIDE, Face.FRONT,
* ClientBlocks.T_GRASS_SIDE, Face.BACK,
* ClientBlocks.T_GRASS_SIDE, Face.RIGHT, ClientBlocks.T_GRASS_SIDE,
* Face.FRONT, ClientBlocks.T_GRASS_SIDE, Face.BACK,
* ClientBlocks.T_GRASS_SIDE, Face.TOP, ClientBlocks.T_GRASS_TOP,
* Face.BOT, ClientBlocks.T_DIRT);
*/
Expand Down Expand Up @@ -95,7 +94,6 @@ public void generateBlockVertices(TerrainMesher terrainMesher, Terrain terrain,
private final BlockFace createBlockFace(Terrain terrain, Block block, Face face, int x, int y, int z) {

// if the face-neighboor block is visible isnt transparent
// TODO : find a solution on leaves square
if (!this.canRenderFace(terrain, block, face, x, y, z)) {
// the face isnt visible
return (null);
Expand All @@ -121,8 +119,8 @@ 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
* 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) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.grillecube.client.renderer.gui.components.Gui;
import com.grillecube.client.renderer.gui.components.GuiButton;
import com.grillecube.client.renderer.gui.components.GuiPrompt;
import com.grillecube.client.renderer.gui.event.EventCursorUpdate;
import com.grillecube.client.renderer.gui.event.GuiEventChar;
import com.grillecube.client.renderer.gui.event.GuiEventClick;
import com.grillecube.client.renderer.gui.event.GuiEventKeyPress;
Expand All @@ -29,6 +30,7 @@
import com.grillecube.client.renderer.model.editor.gui.GuiModelView;
import com.grillecube.common.maths.Matrix4f;
import com.grillecube.common.maths.Vector4f;
import com.grillecube.common.resources.EventManager;

/** catch inputs and send them back to a gui */
public class GuiInputManagerDesktop extends GuiInputManager {
Expand All @@ -38,6 +40,7 @@ public class GuiInputManagerDesktop extends GuiInputManager {
private GLFWListener<GLFWEventChar> charListener;
private GLFWListener<GLFWEventMouseScroll> scrollListener;
private Gui topestGui;
private EventCursorUpdate eventCursorUpdate;

/** default cursors */
public GLCursor[] cursor = new GLCursor[6];
Expand Down Expand Up @@ -87,6 +90,8 @@ public void invoke(GLFWEventMouseScroll event) {
this.cursor[HAND] = new GLCursor(GLFW.glfwCreateStandardCursor(GLFW.GLFW_HAND_CURSOR));
this.cursor[HRESIZE] = new GLCursor(GLFW.glfwCreateStandardCursor(GLFW.GLFW_HRESIZE_CURSOR));
this.cursor[VRESIZE] = new GLCursor(GLFW.glfwCreateStandardCursor(GLFW.GLFW_VRESIZE_CURSOR));

this.eventCursorUpdate = new EventCursorUpdate();
}

/** remove listeners from the window */
Expand All @@ -108,15 +113,13 @@ private final void updateCursor() {
cursor = this.cursor[IBEAM];
} else if (this.topestGui instanceof GuiButton) {
cursor = this.cursor[HAND];

} else if (topestGui instanceof GuiModelView) {
cursor = this.cursor[CROSSHAIR];

cursor = this.cursor[CROSSHAIR]; // TODO : move this to model editor
} else {
cursor = this.cursor[ARROW];
}

super.getGLFWWindow().setCursor(cursor);
this.eventCursorUpdate.reset(this.getGLFWWindow(), cursor, this.topestGui);
EventManager.instance().invokeEvent(this.eventCursorUpdate);
}

/** update the given guis, which should be sorted by their layers */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.grillecube.client.renderer.gui.event;

import com.grillecube.client.opengl.GLCursor;
import com.grillecube.client.opengl.window.GLFWWindow;
import com.grillecube.client.renderer.gui.components.Gui;
import com.grillecube.common.event.Event;

public class EventCursorUpdate extends Event {

private GLFWWindow glfwWindow;
private GLCursor nextCursor;
private GLCursor prevCursor;
private Gui topestGui;

public EventCursorUpdate() {
super();
}

@Override
protected void onReset() {
}

@Override
protected void process() {
this.prevCursor = this.glfwWindow.getCursor();
this.glfwWindow.setCursor(this.nextCursor);
}

@Override
protected void unprocess() {
this.glfwWindow.setCursor(this.prevCursor);
}

public final Gui getTopestGui() {
return (this.topestGui);
}

/** return next cursor to be set */
public final GLCursor getCursor() {
return (this.nextCursor);
}

public final void setCursor(GLCursor glCursor) {
this.nextCursor = glCursor;
}

public void reset(GLFWWindow glfwWindow, GLCursor glCursor, Gui topestGui) {
super.reset();
this.glfwWindow = glfwWindow;
this.nextCursor = glCursor;
this.topestGui = topestGui;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public class GuiToolboxModelPanelBuild extends GuiToolboxModelPanel {
/** the building tools list */
private final GuiSpinner tools;

// TODO
private final GuiButton addLayer;
private final GuiSpinnerEditor layersName;
private final GuiButton removeLayer;
Expand Down
29 changes: 27 additions & 2 deletions VoxelEngine/src/com/grillecube/common/event/Event.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.grillecube.common.event;

import java.util.ArrayList;

/** abstract class for an engine event */
public abstract class Event {

Expand All @@ -18,12 +20,35 @@ public final void reset() {
this.onReset();
}

public final void run() {
if (this.hasState(STATE_CANCELLED)) {
@SuppressWarnings({ "unchecked", "rawtypes" })
public final void run(ArrayList<Listener> listeners) {
if (this.isCancelled()) {
return;
}

if (listeners == null) {
this.process();
return;
}

for (Listener listener : listeners) {
listener.pre(this);
if (this.isCancelled()) {
return;
}
}

this.process();

this.setState(STATE_POST);

for (Listener listener : listeners) {
listener.post(this);
if (this.isCancelled()) {
this.unprocess();
return;
}
}
}

/** process this event */
Expand Down
24 changes: 0 additions & 24 deletions VoxelEngine/src/com/grillecube/common/event/EventCursorUpdate.java

This file was deleted.

19 changes: 2 additions & 17 deletions VoxelEngine/src/com/grillecube/common/resources/EventManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,8 @@ public static final EventManager instance() {

/** raise an event */
public void invokeEvent(Event event) {
ArrayList<Listener> callbacks = this.eventListeners.get(event.getClass());
if (callbacks == null) {
event.run();
return;
}

for (Listener callback : callbacks) {
callback.pre(event);
}

event.run();

if (!event.isCancelled()) {
for (Listener callback : callbacks) {
callback.post(event);
}
}
ArrayList<Listener> listeners = this.eventListeners.get(event.getClass());
event.run(listeners);
}

/** a listener to the mouse hovering the gui */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,6 @@ public static final void slide(PhysicObject physicObject, CollisionResponse coll
// TODO
}

// TODO : test 0, 69, 0

@Test
public void collisionFalling() {
Entity entity = new Entity() {
Expand Down

0 comments on commit a14e74c

Please sign in to comment.