Small Refactors here and there.
This commit is contained in:
parent
6577428b1f
commit
161d2a1022
|
@ -66,5 +66,5 @@ dependencies {
|
||||||
compile 'com.google.code.gson:gson:2.8.6'
|
compile 'com.google.code.gson:gson:2.8.6'
|
||||||
|
|
||||||
//Primitive Collections
|
//Primitive Collections
|
||||||
compile 'de.speiger:Primitive-Collections:0.4.1'
|
compile 'de.speiger:Primitive-Collections:0.4.3'
|
||||||
}
|
}
|
|
@ -88,6 +88,11 @@ public class MathUtils
|
||||||
return value > 0 ? 1D : (value < 0 ? -1D : 0D);
|
return value > 0 ? 1D : (value < 0 ? -1D : 0D);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int sub(int key, int value)
|
||||||
|
{
|
||||||
|
return key - value;
|
||||||
|
}
|
||||||
|
|
||||||
public static int ceil(double value)
|
public static int ceil(double value)
|
||||||
{
|
{
|
||||||
int i = (int)value;
|
int i = (int)value;
|
||||||
|
|
|
@ -11,6 +11,7 @@ import speiger.src.coreengine.rendering.gui.GuiComponent;
|
||||||
import speiger.src.coreengine.rendering.gui.renderer.buffer.RenderBuffer;
|
import speiger.src.coreengine.rendering.gui.renderer.buffer.RenderBuffer;
|
||||||
import speiger.src.coreengine.rendering.tesselation.Tesselator;
|
import speiger.src.coreengine.rendering.tesselation.Tesselator;
|
||||||
import speiger.src.coreengine.rendering.tesselation.VertexType;
|
import speiger.src.coreengine.rendering.tesselation.VertexType;
|
||||||
|
import speiger.src.coreengine.rendering.utils.GLUtils;
|
||||||
|
|
||||||
public class PieComponent extends GuiComponent
|
public class PieComponent extends GuiComponent
|
||||||
{
|
{
|
||||||
|
@ -76,7 +77,11 @@ public class PieComponent extends GuiComponent
|
||||||
{
|
{
|
||||||
float centerX = getBox().getCenterX();
|
float centerX = getBox().getCenterX();
|
||||||
float centerY = getBox().getCenterY();
|
float centerY = getBox().getCenterY();
|
||||||
getRenderer().setBrightness(getActiveBrightness()).translate(centerX, centerY).drawBuffers(buffer, 0F, 0F).translate(-centerX, -centerY).setBrightness(1F);
|
getRenderer().setBrightness(getActiveBrightness()).translate(centerX, centerY).flush();
|
||||||
|
GLUtils.DEBTH_TEST.push(true);
|
||||||
|
getRenderer().drawBuffers(buffer, 0F, 0F).flush();
|
||||||
|
GLUtils.DEBTH_TEST.pop();
|
||||||
|
getRenderer().translate(-centerX, -centerY).setBrightness(1F);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,8 +48,8 @@ public class TreeComponent<T extends ITreeEntry> extends GuiComponent implements
|
||||||
int movement;
|
int movement;
|
||||||
Vec2i lastMouse = Vec2i.newMutable();
|
Vec2i lastMouse = Vec2i.newMutable();
|
||||||
IButtonComponent customButton;
|
IButtonComponent customButton;
|
||||||
protected ObjectSet<T> openNodes = new ObjectOpenHashSet<T>();
|
protected ObjectSet<T> openNodes = new ObjectOpenHashSet<>();
|
||||||
protected ObjectSet<T> selectedNodes = new ObjectOpenHashSet<T>();
|
protected ObjectSet<T> selectedNodes = new ObjectOpenHashSet<>();
|
||||||
protected int selectionMode = 1;
|
protected int selectionMode = 1;
|
||||||
protected int updateMode = 1;
|
protected int updateMode = 1;
|
||||||
T node;
|
T node;
|
||||||
|
@ -304,11 +304,16 @@ public class TreeComponent<T extends ITreeEntry> extends GuiComponent implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openNode(T entry, boolean childrenIncluded)
|
public void openNode(T entry, boolean childrenIncluded)
|
||||||
|
{
|
||||||
|
openNode(entry, childrenIncluded, Integer.MAX_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openNode(T entry, boolean childrenIncluded, int maxLayers)
|
||||||
{
|
{
|
||||||
openNodes.add(entry);
|
openNodes.add(entry);
|
||||||
if(childrenIncluded)
|
if(childrenIncluded)
|
||||||
{
|
{
|
||||||
getNodes(entry, openNodes, false);
|
getNodes(entry, openNodes, false, maxLayers);
|
||||||
}
|
}
|
||||||
listChange = true;
|
listChange = true;
|
||||||
updateScrollBar();
|
updateScrollBar();
|
||||||
|
@ -659,6 +664,22 @@ public class TreeComponent<T extends ITreeEntry> extends GuiComponent implements
|
||||||
return MathUtils.clamp(0, visibleNodes.size(), MathUtils.ceil((getBox().getBaseHeight() - (horizontalBar.getRequiredSpace() / getBox().getScale())) / entryHeight) + 1);
|
return MathUtils.clamp(0, visibleNodes.size(), MathUtils.ceil((getBox().getBaseHeight() - (horizontalBar.getRequiredSpace() / getBox().getScale())) / entryHeight) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void getNodes(T entry, Collection<T> collection, boolean openOnly, int layers)
|
||||||
|
{
|
||||||
|
if(entry != null && layers >= 0)
|
||||||
|
{
|
||||||
|
collection.add(entry);
|
||||||
|
if(!entry.isLeaf() && (!openOnly || openNodes.contains(entry)))
|
||||||
|
{
|
||||||
|
for(int i = 0,m=entry.getChildCount();i<m;i++)
|
||||||
|
{
|
||||||
|
getNodes((T)entry.getChild(i), collection, openOnly, layers-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void getNodes(T entry, Collection<T> collection, boolean openOnly)
|
protected void getNodes(T entry, Collection<T> collection, boolean openOnly)
|
||||||
{
|
{
|
||||||
if(entry != null)
|
if(entry != null)
|
||||||
|
|
|
@ -3,16 +3,16 @@ package speiger.src.coreengine.rendering.gui.components.list;
|
||||||
import speiger.src.coreengine.rendering.gui.components.TextComponent;
|
import speiger.src.coreengine.rendering.gui.components.TextComponent;
|
||||||
import speiger.src.coreengine.rendering.gui.helper.Align;
|
import speiger.src.coreengine.rendering.gui.helper.Align;
|
||||||
|
|
||||||
public class TextEntry extends BaseListEntry
|
public class TextListEntry extends BaseListEntry
|
||||||
{
|
{
|
||||||
TextComponent text = addComponent(new TextComponent().setLimitedBounds(false).setAlignment(Align.LEFT_TOP, Align.LEFT_TOP).setSpecialRendering(true).setComponentPosition(0F, 0F).cast());
|
TextComponent text = addComponent(new TextComponent().setLimitedBounds(false).setAlignment(Align.LEFT_TOP, Align.LEFT_TOP).setSpecialRendering(true).setComponentPosition(0F, 0F).cast());
|
||||||
|
|
||||||
public TextEntry(String s)
|
public TextListEntry(String s)
|
||||||
{
|
{
|
||||||
text.setText(s);
|
text.setText(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextEntry setScale(float scale)
|
public TextListEntry setScale(float scale)
|
||||||
{
|
{
|
||||||
text.setTextScale(scale);
|
text.setTextScale(scale);
|
||||||
return this;
|
return this;
|
|
@ -12,7 +12,7 @@ import speiger.src.coreengine.rendering.gui.base.IKeyComponent;
|
||||||
import speiger.src.coreengine.rendering.gui.components.ListComponent;
|
import speiger.src.coreengine.rendering.gui.components.ListComponent;
|
||||||
import speiger.src.coreengine.rendering.gui.components.ScrollBarComponent;
|
import speiger.src.coreengine.rendering.gui.components.ScrollBarComponent;
|
||||||
import speiger.src.coreengine.rendering.gui.components.TextFieldComponent;
|
import speiger.src.coreengine.rendering.gui.components.TextFieldComponent;
|
||||||
import speiger.src.coreengine.rendering.gui.components.list.TextEntry;
|
import speiger.src.coreengine.rendering.gui.components.list.TextListEntry;
|
||||||
import speiger.src.coreengine.rendering.gui.helper.constrains.ComponentConstrains;
|
import speiger.src.coreengine.rendering.gui.helper.constrains.ComponentConstrains;
|
||||||
import speiger.src.coreengine.rendering.gui.helper.constrains.ParentConstrain;
|
import speiger.src.coreengine.rendering.gui.helper.constrains.ParentConstrain;
|
||||||
import speiger.src.coreengine.rendering.gui.helper.constrains.PixelConstrain;
|
import speiger.src.coreengine.rendering.gui.helper.constrains.PixelConstrain;
|
||||||
|
@ -204,7 +204,7 @@ public class ConsoleComponent extends GuiComponent implements IKeyComponent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class MessageEntry extends TextEntry
|
private static class MessageEntry extends TextListEntry
|
||||||
{
|
{
|
||||||
int messageId;
|
int messageId;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
|
||||||
|
package speiger.src.coreengine.rendering.gui.components.tree;
|
||||||
|
|
||||||
|
import speiger.src.coreengine.rendering.gui.components.TextComponent;
|
||||||
|
import speiger.src.coreengine.rendering.gui.helper.Align;
|
||||||
|
|
||||||
|
public class TextTreeEntry extends BaseTreeEntry
|
||||||
|
{
|
||||||
|
TextComponent text = addComponent(new TextComponent().setLimitedBounds(false).setAlignment(Align.LEFT_TOP, Align.LEFT_TOP).setSpecialRendering(true).setComponentPosition(0F, 0F).cast());
|
||||||
|
|
||||||
|
public TextTreeEntry(String s)
|
||||||
|
{
|
||||||
|
text.setText(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextTreeEntry setScale(float scale)
|
||||||
|
{
|
||||||
|
text.setTextScale(scale);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getText()
|
||||||
|
{
|
||||||
|
return text.getText();
|
||||||
|
}
|
||||||
|
}
|
|
@ -37,13 +37,18 @@ public class Constraints
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ComponentConstrains getSideConstraint(float size, Facing side)
|
public static ComponentConstrains getSideConstraint(float size, Facing side)
|
||||||
|
{
|
||||||
|
return getSideConstraint(size, side, 0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ComponentConstrains getSideConstraint(float size, Facing side, float offset)
|
||||||
{
|
{
|
||||||
switch(side)
|
switch(side)
|
||||||
{
|
{
|
||||||
case NORTH: return new ComponentConstrains(new ParentConstrain(), new ParentConstrain(), new ParentConstrain(), new PixelConstrain(size));
|
case NORTH: return new ComponentConstrains(new ParentConstrain(), new ParentConstrain(offset), new ParentConstrain(), new PixelConstrain(size));
|
||||||
case EAST: return new ComponentConstrains(new ParentConstrain(size).invert(), new ParentConstrain(), new PixelConstrain(size), new ParentConstrain());
|
case EAST: return new ComponentConstrains(new ParentConstrain(size+offset).invert(), new ParentConstrain(), new PixelConstrain(size), new ParentConstrain());
|
||||||
case SOUTH: return new ComponentConstrains(new ParentConstrain(), new ParentConstrain(size).invert(), new ParentConstrain(), new PixelConstrain(size));
|
case SOUTH: return new ComponentConstrains(new ParentConstrain(), new ParentConstrain(size+offset).invert(), new ParentConstrain(), new PixelConstrain(size));
|
||||||
case WEST: return new ComponentConstrains(new ParentConstrain(), new ParentConstrain(), new PixelConstrain(size), new ParentConstrain());
|
case WEST: return new ComponentConstrains(new ParentConstrain(offset), new ParentConstrain(), new PixelConstrain(size), new ParentConstrain());
|
||||||
default: return null;
|
default: return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ public class FontRenderer implements IFontRenderer
|
||||||
bufferBuilder.finishData();
|
bufferBuilder.finishData();
|
||||||
if(bufferBuilder.getVertexCount() > 0)
|
if(bufferBuilder.getVertexCount() > 0)
|
||||||
{
|
{
|
||||||
drawCalls.add(bufferBuilder.getDrawCall(getTexture().getTextureID()));
|
drawCalls.add(bufferBuilder.getDrawCall(getTexture().getTextureId()));
|
||||||
}
|
}
|
||||||
bufferBuilder.setOffset(0F, 0F, 0F);
|
bufferBuilder.setOffset(0F, 0F, 0F);
|
||||||
return drawCalls;
|
return drawCalls;
|
||||||
|
@ -192,7 +192,7 @@ public class FontRenderer implements IFontRenderer
|
||||||
component.getMetadata().addLine(lines.get(i));
|
component.getMetadata().addLine(lines.get(i));
|
||||||
}
|
}
|
||||||
maxWidth /= 2;
|
maxWidth /= 2;
|
||||||
buffer.finishShape(getTexture().getTextureID(), bufferBuilder);
|
buffer.finishShape(getTexture().getTextureId(), bufferBuilder);
|
||||||
if(lineBuffer.hasData())
|
if(lineBuffer.hasData())
|
||||||
{
|
{
|
||||||
Tesselator tes = buffer.start(GL11.GL_TRIANGLES, VertexType.UI).offset(0F, 0F, 0.001F);
|
Tesselator tes = buffer.start(GL11.GL_TRIANGLES, VertexType.UI).offset(0F, 0F, 0.001F);
|
||||||
|
|
|
@ -707,6 +707,6 @@ public class UIRenderer implements IReloadableResource
|
||||||
|
|
||||||
private int getTextureId(ITexture texture)
|
private int getTextureId(ITexture texture)
|
||||||
{
|
{
|
||||||
return texture == null ? 0 : texture.getTextureID();
|
return texture == null ? 0 : texture.getTextureId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@ public class MergedModelData extends SimpleModelData
|
||||||
|
|
||||||
public static MergedModelData merge(String newName, int vertexBytes, List<SimpleModelData> data)
|
public static MergedModelData merge(String newName, int vertexBytes, List<SimpleModelData> data)
|
||||||
{
|
{
|
||||||
System.out.println("Test: "+data.size()+", Name="+newName);
|
|
||||||
ByteList byteData = new ByteArrayList();
|
ByteList byteData = new ByteArrayList();
|
||||||
IntList indeciesData = new IntArrayList();
|
IntList indeciesData = new IntArrayList();
|
||||||
int[] offsets = new int[data.size() * 2];
|
int[] offsets = new int[data.size() * 2];
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class UniformTexture extends UniformInt
|
||||||
disable();
|
disable();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
storeTexture(textureID.getTextureID());
|
storeTexture(textureID.getTextureId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disable()
|
public void disable()
|
||||||
|
|
|
@ -17,7 +17,7 @@ public abstract class AbstractTexture implements ITexture
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTextureID()
|
public int getTextureId()
|
||||||
{
|
{
|
||||||
return textureID;
|
return textureID;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import speiger.src.coreengine.rendering.textures.stb.STBTexture;
|
||||||
|
|
||||||
public interface ITexture extends IReloadableResource
|
public interface ITexture extends IReloadableResource
|
||||||
{
|
{
|
||||||
public int getTextureID();
|
public int getTextureId();
|
||||||
|
|
||||||
public void bindTexture();
|
public void bindTexture();
|
||||||
public void deleteTexture();
|
public void deleteTexture();
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class TextureManager implements IReloadableResource
|
||||||
{
|
{
|
||||||
if(texture != null)
|
if(texture != null)
|
||||||
{
|
{
|
||||||
GL11.glDeleteTextures(texture.getTextureID());
|
GL11.glDeleteTextures(texture.getTextureId());
|
||||||
reloader.removeReloadableResource(texture);
|
reloader.removeReloadableResource(texture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class WrappedTexture implements ITexture
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTextureID()
|
public int getTextureId()
|
||||||
{
|
{
|
||||||
return textureId;
|
return textureId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ package speiger.src.coreengine.rendering.textures.normal;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.concurrent.locks.Lock;
|
||||||
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
import org.lwjgl.system.MemoryStack;
|
import org.lwjgl.system.MemoryStack;
|
||||||
|
@ -29,6 +31,7 @@ public class DynamicTexture extends AbstractTexture implements IDynamicTexture
|
||||||
public static final int B = 0xFF;
|
public static final int B = 0xFF;
|
||||||
public static final int A = 0xFF << 24;
|
public static final int A = 0xFF << 24;
|
||||||
Int2ObjectMap<IntSet> dirtyChunks = new Int2ObjectLinkedOpenHashMap<IntSet>();
|
Int2ObjectMap<IntSet> dirtyChunks = new Int2ObjectLinkedOpenHashMap<IntSet>();
|
||||||
|
Lock lock = new ReentrantLock();
|
||||||
int[] data;
|
int[] data;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
@ -56,6 +59,7 @@ public class DynamicTexture extends AbstractTexture implements IDynamicTexture
|
||||||
@Override
|
@Override
|
||||||
public void markDirty(int x, int z)
|
public void markDirty(int x, int z)
|
||||||
{
|
{
|
||||||
|
lock.lock();
|
||||||
int chunkIndex = BitUtil.toInt(x >> 4, z >> 4);
|
int chunkIndex = BitUtil.toInt(x >> 4, z >> 4);
|
||||||
IntSet set = dirtyChunks.get(chunkIndex);
|
IntSet set = dirtyChunks.get(chunkIndex);
|
||||||
if(set == null)
|
if(set == null)
|
||||||
|
@ -64,6 +68,7 @@ public class DynamicTexture extends AbstractTexture implements IDynamicTexture
|
||||||
dirtyChunks.put(chunkIndex, set);
|
dirtyChunks.put(chunkIndex, set);
|
||||||
}
|
}
|
||||||
set.add((x & 15) << 4 | (z & 15));
|
set.add((x & 15) << 4 | (z & 15));
|
||||||
|
lock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -144,6 +149,7 @@ public class DynamicTexture extends AbstractTexture implements IDynamicTexture
|
||||||
@Override
|
@Override
|
||||||
public void processChanges(boolean full)
|
public void processChanges(boolean full)
|
||||||
{
|
{
|
||||||
|
lock.lock();
|
||||||
if(full)
|
if(full)
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = MemoryUtil.memAlloc(data.length * 4);
|
ByteBuffer buffer = MemoryUtil.memAlloc(data.length * 4);
|
||||||
|
@ -206,12 +212,13 @@ public class DynamicTexture extends AbstractTexture implements IDynamicTexture
|
||||||
{
|
{
|
||||||
((ITrimmable)dirtyChunks).trim();
|
((ITrimmable)dirtyChunks).trim();
|
||||||
}
|
}
|
||||||
|
lock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reload()
|
public void reload()
|
||||||
{
|
{
|
||||||
int old = getTextureID();
|
int old = getTextureId();
|
||||||
setTextureID(GL11.glGenTextures());
|
setTextureID(GL11.glGenTextures());
|
||||||
TextureManager.INSTANCE.removeTexture(old);
|
TextureManager.INSTANCE.removeTexture(old);
|
||||||
processChanges(true);
|
processChanges(true);
|
||||||
|
|
|
@ -83,8 +83,8 @@ public class GPUProfilerEntry implements IProfilerEntry
|
||||||
currentTime = 0;
|
currentTime = 0;
|
||||||
if(end && totalTicks++ >= 10)
|
if(end && totalTicks++ >= 10)
|
||||||
{
|
{
|
||||||
minTime = Long.MAX_VALUE;
|
minTime = currentTime;
|
||||||
maxTime = Long.MIN_VALUE;
|
maxTime = currentTime;
|
||||||
totalTicks = 0;
|
totalTicks = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,8 +84,8 @@ public class ProfilerEntry implements IProfilerEntry
|
||||||
currentTime = 0;
|
currentTime = 0;
|
||||||
if(end && totalTicks++ >= 10)
|
if(end && totalTicks++ >= 10)
|
||||||
{
|
{
|
||||||
minTime = Long.MAX_VALUE;
|
minTime = currentTime;
|
||||||
maxTime = Long.MIN_VALUE;
|
maxTime = currentTime;
|
||||||
totalTicks = 0;
|
totalTicks = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue