diff --git a/DelvEdit/src/com/interrupt/dungeoneer/editor/EditorFrame.java b/DelvEdit/src/com/interrupt/dungeoneer/editor/EditorFrame.java index d9326b21..ff0af0e7 100644 --- a/DelvEdit/src/com/interrupt/dungeoneer/editor/EditorFrame.java +++ b/DelvEdit/src/com/interrupt/dungeoneer/editor/EditorFrame.java @@ -17,7 +17,6 @@ import com.badlogic.gdx.graphics.g3d.decals.Decal; import com.badlogic.gdx.graphics.g3d.decals.DecalBatch; import com.badlogic.gdx.graphics.glutils.FrameBuffer; -import com.badlogic.gdx.graphics.glutils.ShaderProgram; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; import com.badlogic.gdx.math.*; @@ -51,7 +50,10 @@ import com.interrupt.dungeoneer.game.Level.Source; import com.interrupt.dungeoneer.generator.DungeonGenerator; import com.interrupt.dungeoneer.generator.GenInfo.Markers; -import com.interrupt.dungeoneer.gfx.*; +import com.interrupt.dungeoneer.gfx.GlRenderer; +import com.interrupt.dungeoneer.gfx.SpriteGroupStrategy; +import com.interrupt.dungeoneer.gfx.TextureAtlas; +import com.interrupt.dungeoneer.gfx.WorldChunk; import com.interrupt.dungeoneer.gfx.drawables.DrawableMesh; import com.interrupt.dungeoneer.gfx.drawables.DrawableSprite; import com.interrupt.dungeoneer.interfaces.Directional; @@ -205,8 +207,6 @@ public boolean isWestFloor() { } } - private JFrame window = null; - private GameInput input; public EditorInput editorInput; private InputMultiplexer inputMultiplexer; @@ -241,13 +241,11 @@ public boolean isWestFloor() { double rotya = 0; float rotYClamp = 1.571f; - double walkVel = 0.05; double walkSpeed = 0.15; double rotSpeed = 0.009; double maxRot = 0.8; - boolean readFloorMove, readCeilMove, readRotate; - private int readFloorMoveCount, readCeilMoveCount; + boolean readRotate; Mesh cubeMesh; Mesh gridMesh; @@ -329,11 +327,8 @@ protected Decal newObject () { Color selectedColor = new Color(1f, 0.5f, 0.5f, 1f); Vector3 intersection = new Vector3(); - Vector3 testPos = new Vector3(); Vector3 tempVector1 = new Vector3(); - Color tempColor = new Color(); - DrawableSprite unknownEntityMarker = new DrawableSprite(); Array controlPoints = new Array(); @@ -356,15 +351,12 @@ protected Decal newObject () { Vector3 rayOutVector = new Vector3(); - private boolean isOnWindows = System.getProperty("os.name").startsWith("Windows"); - public Editor editor; /** * @wbp.parser.entryPoint */ public EditorFrame(JFrame window, Editor editor) { - this.window = window; this.editor = editor; } @@ -1986,8 +1978,6 @@ public void tick() { // get picked entity Ray ray = camera.getPickRay(Gdx.input.getX(), Gdx.input.getY()); - float worldHitDistance = 10000000f; - // get plane intersection if(intpos != null) { if (!Gdx.input.isTouched()) { @@ -2002,7 +1992,6 @@ public void tick() { if (Collidor.intersectRayForwardFacingTriangles(camera.getPickRay(Gdx.input.getX(), Gdx.input.getY()), camera, GlRenderer.triangleSpatialHash.getAllTriangles(), intpos, intersectNormal)) { intersectTemp.set(intpos).sub(camera.position).nor(); intpos.add(intersectTemp.x * -0.05f, 0.0001f, intersectTemp.z * -0.05f); - worldHitDistance = intersectTemp.set(intpos).sub(camera.position).len(); } if(tileDragging) { @@ -2570,7 +2559,7 @@ public Mesh genGrid (int height, int width) { indices[i++] = (short)(i - 1); } - Mesh mesh = new Mesh(true, vertices.length, indices.length, new VertexAttribute(Usage.Position, 3, "a_position"), new VertexAttribute(Usage.ColorUnpacked, 4, "a_color")); + Mesh mesh = new Mesh(false, vertices.length, indices.length, new VertexAttribute(Usage.Position, 3, "a_position"), new VertexAttribute(Usage.ColorUnpacked, 4, "a_color")); mesh.setVertices(vertices); mesh.setIndices(indices); @@ -3310,7 +3299,7 @@ public void paste() { level.setTile(x + selX, y + selY, t); } - markWorldAsDirty(x, y, 1); + markWorldAsDirty(x + selX, y + selY, 1); } } @@ -3802,159 +3791,6 @@ public TextureRegion[] loadAtlas(String texture, int spritesHorizontal, boolean return region; } - public Color GetLightmapAt(float posx, float posy, float posz) { - Color t = level.GetLightmapAt(posx, posz, posz); - - if(t == null) { - return Color.BLACK; - } - - return level.GetLightmapAt(posx, posy, posz); - } - - Array t_collisionTriangles = new Array(); - VertexAttributes t_staticMeshVertexAttributes = new VertexAttributes(new VertexAttribute(VertexAttributes.Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE), - new VertexAttribute(VertexAttributes.Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE), - new VertexAttribute(VertexAttributes.Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + "0")); - - public Array mergeStaticMeshes(Level level, Array entities) { - short indexOffset = 0; - int vertexCount = 0; - - ShortArray indices = new ShortArray(500); - FloatArray vertices = new FloatArray(500); - - Array created = new Array(); - - for(Entity e : entities) { - if(e.drawable != null && e.drawable instanceof DrawableMesh) { - DrawableMesh drbl = (DrawableMesh)e.drawable; - - if(drbl.loadedMesh != null && drbl.isStaticMesh) { - - // may need to chunk up the meshes - if(drbl.loadedMesh.getNumIndices() + indexOffset >= 32000 && vertexCount > 0) { - - Mesh m = EditorCachePools.getStaticMesh(t_staticMeshVertexAttributes, vertexCount, indices.size, true); - - // pack the array - indices.shrink(); - vertices.shrink(); - - m.setIndices(indices.toArray()); - m.setVertices(vertices.toArray()); - - indices = new ShortArray(500); - vertices = new FloatArray(500); - - vertexCount = 0; - indexOffset = 0; - - created.add(m); - } - - VertexAttributes attributes = drbl.loadedMesh.getVertexAttributes(); - - int positionOffset = 0; - int uvOffset = 0; - int attSize = 0; - - for(int i = 0; i < attributes.size(); i++) { - VertexAttribute attrib = attributes.get(i); - - if(attrib.usage == VertexAttribute.Position().usage) { - positionOffset = attSize; - } - else if(attrib.usage == VertexAttribute.TexCoords(0).usage) { - uvOffset = attSize; - } - - attSize += attrib.numComponents; - } - - short[] ind = new short[drbl.loadedMesh.getNumIndices()]; - float[] verts = new float[drbl.loadedMesh.getNumVertices() * attSize]; - - if(ind.length > 0) - drbl.loadedMesh.getIndices(ind); - else { - ind = new short[drbl.loadedMesh.getNumVertices()]; - - for(int i = 0; i < drbl.loadedMesh.getNumVertices(); i++) { - ind[i] = (short)i; - } - } - - drbl.loadedMesh.getVertices(verts); - - Matrix4 matrix = new Matrix4().setToTranslation(e.x, e.z - 0.5f, e.y); - matrix.scale(drbl.scale, drbl.scale, drbl.scale); - matrix.mul(new Matrix4().setToRotation(Vector3.X, drbl.dir.y * -90f)); - - matrix.rotate(Vector3.Y, drbl.rotZ); - matrix.rotate(Vector3.X, drbl.rotX); - matrix.rotate(Vector3.Z, drbl.rotY); - - // translate the vertices by the model matrix - Matrix4.mulVec(matrix.val, verts, 0, drbl.loadedMesh.getNumVertices(), attSize); - - if(ind != null && verts != null) { - for(int i = 0; i < ind.length; i++) { - indices.add((short)(ind[i] + indexOffset)); - } - indexOffset += ind.length; - - for(int i = 0; i < drbl.loadedMesh.getNumVertices() * attSize; i+= attSize) { - - vertices.add(verts[i + positionOffset]); - vertices.add(verts[i + positionOffset + 1]); - vertices.add(verts[i + positionOffset + 2]); - - if (e.isSolid) { - t_collisionTriangles.add(EditorCachePools.getCollisionVector(verts[i + positionOffset], verts[i + positionOffset + 1], verts[i + positionOffset + 2])); - } - - float c = Color.WHITE.toFloatBits(); - if(!e.fullbrite && showLights) { - c = level.getLightColorAt(verts[i + positionOffset], verts[i + positionOffset + 2], verts[i + positionOffset + 1], null, new Color()).toFloatBits(); - } - - vertices.add(c); - vertices.add(verts[i + uvOffset]); - vertices.add(verts[i + uvOffset + 1]); - - vertexCount++; - } - } - } - } - } - - if(vertexCount == 0) return null; - - for (int i = 0; i < t_collisionTriangles.size; i += 3) { - Triangle triangle = EditorCachePools.getTriangle(); - triangle.v1.set(t_collisionTriangles.get(i + 2)); - triangle.v2.set(t_collisionTriangles.get(i + 1)); - triangle.v3.set(t_collisionTriangles.get(i)); - - staticMeshCollisionTriangles.add(triangle); - } - t_collisionTriangles.clear(); - - Mesh m = EditorCachePools.getStaticMesh(t_staticMeshVertexAttributes, vertexCount, indices.size, true); - - // pack the array - indices.shrink(); - vertices.shrink(); - - m.setIndices(indices.toArray()); - m.setVertices(vertices.toArray()); - - created.add(m); - return created; - } - public void doCarve() { if(pickedEntity != null) return;