Fix/improve rendering again
This commit is contained in:
+21
-9
@@ -15,7 +15,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.seibel.lod.objects;
|
||||
package com.seibel.lod;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
@@ -30,6 +30,7 @@ import java.awt.event.ActionListener;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -39,6 +40,9 @@ import javax.swing.SwingUtilities;
|
||||
import javax.swing.Timer;
|
||||
|
||||
import com.seibel.lod.enums.DistanceGenerationMode;
|
||||
import com.seibel.lod.objects.LodDataPoint;
|
||||
import com.seibel.lod.objects.LodQuadTreeDimension;
|
||||
import com.seibel.lod.objects.LodQuadTreeNode;
|
||||
import com.seibel.lod.util.BiomeColorsUtils;
|
||||
|
||||
import kaptainwutax.biomeutils.source.OverworldBiomeSource;
|
||||
@@ -51,18 +55,21 @@ public class QuadTreeImage extends JPanel
|
||||
private static final int PREF_H = PREF_W;
|
||||
private List<MyDrawable> drawables = new ArrayList<>();
|
||||
|
||||
public QuadTreeImage() {
|
||||
public QuadTreeImage()
|
||||
{
|
||||
setBackground(Color.white);
|
||||
}
|
||||
|
||||
public void addMyDrawable(MyDrawable myDrawable) {
|
||||
public void addMyDrawable(MyDrawable myDrawable)
|
||||
{
|
||||
drawables.add(myDrawable);
|
||||
repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
// make it bigger
|
||||
public Dimension getPreferredSize() {
|
||||
public Dimension getPreferredSize()
|
||||
{
|
||||
if (isPreferredSizeSet()) {
|
||||
return super.getPreferredSize();
|
||||
}
|
||||
@@ -70,7 +77,8 @@ public class QuadTreeImage extends JPanel
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
protected void paintComponent(Graphics g)
|
||||
{
|
||||
super.paintComponent(g);
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
@@ -80,12 +88,14 @@ public class QuadTreeImage extends JPanel
|
||||
}
|
||||
}
|
||||
|
||||
public void clearAll() {
|
||||
public void clearAll()
|
||||
{
|
||||
drawables.clear();
|
||||
repaint();
|
||||
}
|
||||
|
||||
private static void createAndShowGui() {
|
||||
private static void createAndShowGui()
|
||||
{
|
||||
|
||||
final QuadTreeImage quadTreeImage = new QuadTreeImage();
|
||||
|
||||
@@ -106,7 +116,8 @@ public class QuadTreeImage extends JPanel
|
||||
//SIMULATING A PLAYER MOVING,
|
||||
int[] playerXs = {0, 100, 200, 300, 400, 1000};
|
||||
int[] playerZs = {0, 100, 200, 300, 400, 500};
|
||||
for (int pos = 0; pos < 1; pos++) {
|
||||
for (int pos = 0; pos < 1; pos++)
|
||||
{
|
||||
int playerX = 0 + playerXs[pos]; //2097152
|
||||
int playerZ = 0 + playerZs[pos]/2;
|
||||
|
||||
@@ -266,7 +277,8 @@ public class QuadTreeImage extends JPanel
|
||||
}).start();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
/*
|
||||
LodQuadTreeDimension dim2 = new LodQuadTreeDimension(null, null, 1);
|
||||
dim2.move(10000000,10000000);
|
||||
@@ -29,7 +29,6 @@ import com.seibel.lod.handlers.LodConfig;
|
||||
import com.seibel.lod.objects.LodQuadTreeDimension;
|
||||
import com.seibel.lod.objects.LodQuadTreeNode;
|
||||
import com.seibel.lod.objects.NearFarBuffer;
|
||||
import com.seibel.lod.proxy.ClientProxy;
|
||||
import com.seibel.lod.render.LodNodeRenderer;
|
||||
import com.seibel.lod.util.LodUtil;
|
||||
|
||||
@@ -174,9 +173,11 @@ public class LodNodeBufferBuilder
|
||||
|
||||
// set where this square will be drawn in the world
|
||||
double xOffset = (LodQuadTreeNode.CHUNK_WIDTH * i) + // offset by the number of LOD blocks
|
||||
startX; // offset so the center LOD block is centered underneath the player
|
||||
double yOffset = 0;
|
||||
double zOffset = (LodQuadTreeNode.CHUNK_WIDTH * j) + startZ;
|
||||
startX + // offset so the center LOD block is centered underneath the player
|
||||
8; // I'm not sure what this is correcting exactly but with it the chunks line up.
|
||||
// 8 works for LODs the size of chunks
|
||||
double yOffset = 1;
|
||||
double zOffset = (LodQuadTreeNode.CHUNK_WIDTH * j) + startZ + 8;
|
||||
|
||||
LodQuadTreeNode lod = lodDim.getLodFromCoordinates(chunkX, chunkZ, LodQuadTreeNode.CHUNK_LEVEL);
|
||||
|
||||
@@ -189,6 +190,7 @@ public class LodNodeBufferBuilder
|
||||
ChunkPos pos = new ChunkPos(chunkX, chunkZ);
|
||||
|
||||
|
||||
// alternate determining logic that
|
||||
// can be used for debugging
|
||||
// if (chunksToGen == null)
|
||||
// {
|
||||
@@ -272,6 +274,7 @@ public class LodNodeBufferBuilder
|
||||
chunkGenIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
} // lod null and can generate more chunks
|
||||
|
||||
// don't render this null/empty chunk
|
||||
@@ -294,7 +297,7 @@ public class LodNodeBufferBuilder
|
||||
}
|
||||
}
|
||||
|
||||
ClientProxy.LOGGER.info(numberOfChunksWaitingToGenerate.get());
|
||||
//ClientProxy.LOGGER.info(numberOfChunksWaitingToGenerate.get());
|
||||
|
||||
// issue #19
|
||||
// TODO add a way for a server side mod to generate chunks requested here
|
||||
|
||||
@@ -20,7 +20,6 @@ package com.seibel.lod.util;
|
||||
import java.awt.Color;
|
||||
import java.io.File;
|
||||
|
||||
import com.seibel.lod.objects.LodQuadTreeNode;
|
||||
import com.seibel.lod.objects.RegionPos;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -96,21 +95,18 @@ public class LodUtil
|
||||
public static RegionPos convertChunkPosToRegionPos(ChunkPos pos)
|
||||
{
|
||||
RegionPos rPos = new RegionPos();
|
||||
// rPos.x = pos.x / 512;
|
||||
// rPos.z = pos.z / 512;
|
||||
//
|
||||
// // prevent issues if X/Z is negative and less than 16
|
||||
// if (pos.x < 0)
|
||||
// {
|
||||
// rPos.x = (Math.abs(rPos.x) * -1) - 1;
|
||||
// }
|
||||
// if (pos.z < 0)
|
||||
// {
|
||||
// rPos.z = (Math.abs(rPos.z) * -1) - 1;
|
||||
// }
|
||||
rPos.x = pos.x / 512;
|
||||
rPos.z = pos.z / 512;
|
||||
|
||||
rPos.x = (Math.floorDiv(pos.x, (int) (512/Math.pow(LodQuadTreeNode.CHUNK_LEVEL,2))));
|
||||
rPos.z = (Math.floorDiv(pos.z, (int) (512/Math.pow(LodQuadTreeNode.CHUNK_LEVEL,2))));
|
||||
// prevent issues if X/Z is negative and less than 16
|
||||
if (pos.x < 0)
|
||||
{
|
||||
rPos.x = (Math.abs(rPos.x) * -1) - 1;
|
||||
}
|
||||
if (pos.z < 0)
|
||||
{
|
||||
rPos.z = (Math.abs(rPos.z) * -1) - 1;
|
||||
}
|
||||
|
||||
return rPos;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user