Skip to content

Commit

Permalink
Make to work not on java 1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
macbury committed Nov 17, 2014
1 parent 3e3e035 commit f96667e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
4 changes: 1 addition & 3 deletions core/src/macbury/forge/blocks/BlocksProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.badlogic.gdx.utils.Disposable;
import com.badlogic.gdx.utils.GdxRuntimeException;
import com.badlogic.gdx.utils.Json;
import com.sun.deploy.util.StringUtils;

import java.io.File;
import java.io.FilenameFilter;
Expand Down Expand Up @@ -43,8 +42,7 @@ public boolean accept(File dir, String name) {
for (FileHandle blockFile : blocksFiles) {
Block block = json.fromJson(Block.class, blockFile.readString());
String[] nameParts = blockFile.nameWithoutExtension().split("_");

block.name = StringUtils.join(Arrays.asList(Arrays.copyOfRange(nameParts, 1, nameParts.length)), " ");
block.name = String.join(" ", Arrays.asList(Arrays.copyOfRange(nameParts, 1, nameParts.length)));
block.id = Byte.valueOf(nameParts[0]);
if (this.blocks[block.id] != null) {
throw new GdxRuntimeException("Block with id "+block.id+" already added!");
Expand Down
7 changes: 6 additions & 1 deletion core/src/macbury/forge/terrain/TerrainEngine.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package macbury.forge.terrain;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Matrix4;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.math.collision.BoundingBox;
import com.badlogic.gdx.utils.Array;
Expand Down Expand Up @@ -36,6 +37,7 @@ public class TerrainEngine implements Disposable, ActionTimer.TimerListener, Bas
public final Array<Chunk> chunks;
public final Array<VoxelFaceRenderable> visibleFaces;
public final Array<OctreeObject> tempObjects;
public final Matrix4 tempMat = new Matrix4();
public final Vector3 tempA = new Vector3();
public final Vector3 tempC = new Vector3();
public final Vector3 tempD = new Vector3();
Expand Down Expand Up @@ -99,14 +101,17 @@ private void occulsion() {
frustrumOctreeQuery.setFrustum(camera.normalOrDebugFrustrum());
octree.retrieve(tempObjects, frustrumOctreeQuery);

tempC.set(camera.normalOrDebugPosition());

while(tempObjects.size > 0) {
Chunk visibleChunk = (Chunk) tempObjects.pop();
if (visibleChunk.renderables.size > 0) {
visibleChunks.add(visibleChunk);
for (int i = 0; i < visibleChunk.renderables.size; i++) {
VoxelFaceRenderable renderable = visibleChunk.renderables.get(i);
//http://www.gamasutra.com/view/feature/131773/a_compact_method_for_backface_.php?print=1
if (camera.boundsInFrustum(renderable.boundingBox) && tempA.set(camera.normalOrDebugPosition()).sub(visibleChunk.worldPosition).dot(renderable.direction) >= 0f) {
//tempA.set(renderable.boundingBox.getCenter());
if (camera.boundsInFrustum(renderable.boundingBox) /*&& tempA.sub(tempC).scl(camera.direction).nor().dot(renderable.direction) >= 0f*/) {
visibleFaces.add(renderable);
}
}
Expand Down
2 changes: 2 additions & 0 deletions editor/src/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Manifest-Version: 1.0
Classpath: com.sun.net
Class-Path: com.sun.net
Main-Class: macbury.forge.editor.DesktopLauncher

26 changes: 23 additions & 3 deletions editor/src/macbury/forge/editor/windows/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
import java.awt.*;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowFocusListener;

public class MainWindow extends JFrame implements ForgEBootListener, FocusListener {
public class MainWindow extends JFrame implements ForgEBootListener, FocusListener, WindowFocusListener {
private static final String WINDOW_MAIN_NAME = "ForgE";
private final BlocksController blocksController;
private final DirectoryWatcher directoryWatcher;
Expand Down Expand Up @@ -53,6 +55,7 @@ public class MainWindow extends JFrame implements ForgEBootListener, FocusListen
public JSplitPane mainSplitPane;
private JPanel panelPrimaryBlock;
private JPanel panelSecondaryBlock;
private boolean bruteFocus;

public MainWindow() {
super();
Expand All @@ -64,8 +67,8 @@ public MainWindow() {
setSize(1360, 760);
setExtendedState(JFrame.MAXIMIZED_BOTH);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setTitle(null);

setTitle(null);
setVisible(true);

this.inputProcessor = new GdxSwingInputProcessor();
Expand Down Expand Up @@ -102,6 +105,7 @@ public MainWindow() {

mapSettingsPanel.add(inspectorSheetPanel);
openGlContainer.add(openGLCanvas.getCanvas(), BorderLayout.CENTER);

projectController.setStatusLabel(statusFpsLabel, statusMemoryLabel, statusRenderablesLabel, mapCursorPositionLabel, statusTriangleCountLabel);

projectController.addOnMapChangeListener(mainMenu);
Expand All @@ -110,11 +114,13 @@ public MainWindow() {
projectController.addOnMapChangeListener(blocksController);

invalidate();
addWindowFocusListener(this);
}

@Override
public void afterEngineCreate(ForgE engine) {
Gdx.graphics.setVSync(true);
mainSplitPane.setVisible(false);
ForgE.input.addProcessor(inputProcessor);
projectController.setMainWindow(this);
directoryWatcher.start();
Expand Down Expand Up @@ -149,7 +155,21 @@ public void focusGained(FocusEvent e) {

@Override
public void focusLost(FocusEvent e) {
mainContentPane.grabFocus();
if (bruteFocus) {
mainContentPane.grabFocus();
}

//mainContentPane.setFocusable(true);
}

@Override
public void windowGainedFocus(WindowEvent e) {
bruteFocus = true;
//mainContentPane.grabFocus();
}

@Override
public void windowLostFocus(WindowEvent e) {
bruteFocus = false;
}
}

0 comments on commit f96667e

Please sign in to comment.