From f96667e8fda331e23444134888435cc63d2498f8 Mon Sep 17 00:00:00 2001 From: Arkadiusz Buras Date: Mon, 17 Nov 2014 12:26:13 +0100 Subject: [PATCH] Make to work not on java 1.8 --- .../macbury/forge/blocks/BlocksProvider.java | 4 +-- .../macbury/forge/terrain/TerrainEngine.java | 7 ++++- editor/src/META-INF/MANIFEST.MF | 2 ++ .../forge/editor/windows/MainWindow.java | 26 ++++++++++++++++--- 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/core/src/macbury/forge/blocks/BlocksProvider.java b/core/src/macbury/forge/blocks/BlocksProvider.java index dc7c31c..523532e 100644 --- a/core/src/macbury/forge/blocks/BlocksProvider.java +++ b/core/src/macbury/forge/blocks/BlocksProvider.java @@ -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; @@ -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!"); diff --git a/core/src/macbury/forge/terrain/TerrainEngine.java b/core/src/macbury/forge/terrain/TerrainEngine.java index a1b981d..09204c3 100644 --- a/core/src/macbury/forge/terrain/TerrainEngine.java +++ b/core/src/macbury/forge/terrain/TerrainEngine.java @@ -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; @@ -36,6 +37,7 @@ public class TerrainEngine implements Disposable, ActionTimer.TimerListener, Bas public final Array chunks; public final Array visibleFaces; public final Array 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(); @@ -99,6 +101,8 @@ 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) { @@ -106,7 +110,8 @@ private void occulsion() { 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); } } diff --git a/editor/src/META-INF/MANIFEST.MF b/editor/src/META-INF/MANIFEST.MF index 7b97c93..9724d66 100644 --- a/editor/src/META-INF/MANIFEST.MF +++ b/editor/src/META-INF/MANIFEST.MF @@ -1,3 +1,5 @@ Manifest-Version: 1.0 +Classpath: com.sun.net +Class-Path: com.sun.net Main-Class: macbury.forge.editor.DesktopLauncher diff --git a/editor/src/macbury/forge/editor/windows/MainWindow.java b/editor/src/macbury/forge/editor/windows/MainWindow.java index a04657d..f3e8357 100644 --- a/editor/src/macbury/forge/editor/windows/MainWindow.java +++ b/editor/src/macbury/forge/editor/windows/MainWindow.java @@ -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; @@ -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(); @@ -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(); @@ -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); @@ -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(); @@ -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; + } }