Skip to content

Commit

Permalink
Textures are set when creating new lines and sectors
Browse files Browse the repository at this point in the history
  • Loading branch information
Interrupt committed Jul 12, 2016
1 parent ba7eed6 commit 72b13fb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
14 changes: 10 additions & 4 deletions core/src/com/interrupt/doomtest/DoomTestEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,8 @@ public void finishSector() {

if (parent != null) {
parent.addSubSector(current);
current.ceilHeight = parent.ceilHeight;
current.match(parent);
if(editHeight != null) current.floorHeight = editHeight;

// parent's sectors might now be contained by this new sector
editor.refreshSectorParents(current, parent);
Expand All @@ -480,20 +481,25 @@ public void finishSector() {

if (i > 0) {
Vector2 prev = points.get(i - 1);
editor.addLine(current, prev, p);
editor.addLine(current, prev, p, currentTexture);
}
}

// close the loop, if it isn't
Vector2 startPoint = points.first();
Vector2 lastPoint = points.get(points.size - 1);
if (!lastPoint.equals(startPoint)) {
editor.addLine(current, lastPoint, startPoint);
editor.addLine(current, lastPoint, startPoint, currentTexture);
}

if (parent == null)
if (parent == null) {
level.sectors.add(current);

// set texture
current.floorMaterial.set(TextureAttribute.createDiffuse(currentTexture));
current.ceilingMaterial.set(TextureAttribute.createDiffuse(currentTexture));
}


// solid parents mean line solidity might change now
if (parent != null && parent.isSolid) {
Expand Down
1 change: 1 addition & 0 deletions core/src/com/interrupt/doomtest/levels/Sector.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,5 +229,6 @@ public void match(Sector other) {
ceilHeight = other.ceilHeight;

floorMaterial.set((other.floorMaterial.get(TextureAttribute.Diffuse)));
ceilingMaterial.set((other.ceilingMaterial.get(TextureAttribute.Diffuse)));
}
}
7 changes: 6 additions & 1 deletion core/src/com/interrupt/doomtest/levels/editor/Editor.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.interrupt.doomtest.levels.editor;

import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute;
import com.badlogic.gdx.math.Intersector;
import com.badlogic.gdx.math.Plane;
import com.badlogic.gdx.math.Vector2;
Expand Down Expand Up @@ -123,6 +125,8 @@ public void addPointToLine(Line l, Vector2 point) {
l.end = point;

Line newLine = new Line(point, oldEnd, l.solid, l.left, l.right);
newLine.match(l);

level.lines.add(newLine);

addNewPointToSector(new Line(l.start, oldEnd, l.solid, l.left, l.right), point, level.sectors);
Expand Down Expand Up @@ -211,7 +215,7 @@ public void addVertex(Vector2 vertex) {
if(existing == null) level.vertices.add(vertex);
}

public void addLine(Sector current, Vector2 start, Vector2 end) {
public void addLine(Sector current, Vector2 start, Vector2 end, TextureRegion texture) {

// don't duplicate verts
Vector2 existingStart = getExistingVertex(start);
Expand All @@ -230,6 +234,7 @@ public void addLine(Sector current, Vector2 start, Vector2 end) {

if(existing == null) {
level.lines.add(line);
line.lowerMaterial.set(TextureAttribute.createDiffuse(texture));
}
else {
if(existing.left == current.parent) {
Expand Down

0 comments on commit 72b13fb

Please sign in to comment.