porting - LodRenderer
This commit is contained in:
@@ -55,6 +55,8 @@ import com.seibel.lod.util.LodThreadFactory;
|
||||
import com.seibel.lod.util.LodUtil;
|
||||
import com.seibel.lod.util.ThreadMapUtil;
|
||||
import com.seibel.lod.wrappers.MinecraftWrapper;
|
||||
import com.seibel.lod.wrappers.Block.BlockPosWrapper;
|
||||
import com.seibel.lod.wrappers.Chunk.ChunkPosWrapper;
|
||||
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -163,7 +165,7 @@ public class LodBufferBuilder
|
||||
* swapped with the drawable buffers in the LodRenderer to be drawn.
|
||||
*/
|
||||
public void generateLodBuffersAsync(LodRenderer renderer, LodDimension lodDim,
|
||||
BlockPos playerBlockPos, boolean fullRegen)
|
||||
BlockPosWrapper playerBlockPos, boolean fullRegen)
|
||||
{
|
||||
|
||||
// only allow one generation process to happen at a time
|
||||
@@ -965,9 +967,9 @@ public class LodBufferBuilder
|
||||
{
|
||||
public final VertexBuffer[][][] vbos;
|
||||
public final int[][][] storageBufferIds;
|
||||
public final ChunkPos drawableCenterChunkPos;
|
||||
public final ChunkPosWrapper drawableCenterChunkPos;
|
||||
|
||||
public VertexBuffersAndOffset(VertexBuffer[][][] newVbos, int[][][] newStorageBufferIds, ChunkPos newDrawableCenterChunkPos)
|
||||
public VertexBuffersAndOffset(VertexBuffer[][][] newVbos, int[][][] newStorageBufferIds, ChunkPosWrapper newDrawableCenterChunkPos)
|
||||
{
|
||||
vbos = newVbos;
|
||||
storageBufferIds = newStorageBufferIds;
|
||||
|
||||
@@ -118,7 +118,7 @@ public class LodDimension
|
||||
// provider needs a separate variable to prevent
|
||||
// the compiler from complaining
|
||||
ServerChunkCache provider = serverWorld.getChunkSource();
|
||||
saveDir = new File(provider.dataStorage.dataFolder.getCanonicalFile().getPath() + File.separatorChar + "lod");
|
||||
saveDir = new File(provider.getDataStorage().dataFolder.getCanonicalFile().getPath() + File.separatorChar + "lod");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -75,7 +75,7 @@ public class RegionPos
|
||||
}
|
||||
|
||||
/** Returns the BlockPos at the center of this region */
|
||||
public ChunkPosWrapper blockPos()
|
||||
public BlockPosWrapper blockPos()
|
||||
{
|
||||
return chunkPos().getWorldPosition()
|
||||
.offset(LodUtil.CHUNK_WIDTH / 2, 0, LodUtil.CHUNK_WIDTH / 2);
|
||||
|
||||
@@ -19,15 +19,16 @@
|
||||
|
||||
package com.seibel.lod.render;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.lwjgl.opengl.GL15;
|
||||
import org.lwjgl.opengl.GL15C;
|
||||
import org.lwjgl.opengl.NVFogDistance;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexBuffer;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.mojang.math.Vector3f;
|
||||
import com.seibel.lod.builders.bufferBuilding.LodBufferBuilder;
|
||||
import com.seibel.lod.builders.bufferBuilding.LodBufferBuilder.VertexBuffersAndOffset;
|
||||
import com.seibel.lod.config.LodConfig;
|
||||
@@ -46,16 +47,15 @@ import com.seibel.lod.util.DetailDistanceUtil;
|
||||
import com.seibel.lod.util.LevelPosUtil;
|
||||
import com.seibel.lod.util.LodUtil;
|
||||
import com.seibel.lod.wrappers.MinecraftWrapper;
|
||||
import com.seibel.lod.wrappers.Block.BlockPosWrapper;
|
||||
import com.seibel.lod.wrappers.Chunk.ChunkPosWrapper;
|
||||
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.vertex.VertexBuffer;
|
||||
import net.minecraft.potion.Effects;
|
||||
import net.minecraft.profiler.IProfiler;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
|
||||
/**
|
||||
@@ -81,7 +81,7 @@ public class LodRenderer
|
||||
|
||||
private final MinecraftWrapper mc;
|
||||
private final GameRenderer gameRender;
|
||||
private IProfiler profiler;
|
||||
private ProfilerFiller profiler;
|
||||
private int farPlaneBlockDistance;
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ public class LodRenderer
|
||||
*/
|
||||
private int[][][] storageBufferIds;
|
||||
|
||||
private ChunkPos vbosCenter = new ChunkPos(0, 0);
|
||||
private ChunkPosWrapper vbosCenter = new ChunkPosWrapper(0, 0);
|
||||
|
||||
|
||||
/** This is used to determine if the LODs should be regenerated */
|
||||
@@ -152,11 +152,11 @@ public class LodRenderer
|
||||
* Besides drawing the LODs this method also starts
|
||||
* the async process of generating the Buffers that hold those LODs.
|
||||
* @param lodDim The dimension to draw, if null doesn't replace the current dimension.
|
||||
* @param mcMatrixStack This matrix stack should come straight from MC's renderChunkLayer (or future equivalent) method
|
||||
* @param mcModelViewMatrix This matrix stack should come straight from MC's renderChunkLayer (or future equivalent) method
|
||||
* @param partialTicks how far into the current tick this method was called.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void drawLODs(LodDimension lodDim, MatrixStack mcMatrixStack, float partialTicks, IProfiler newProfiler)
|
||||
public void drawLODs(LodDimension lodDim, PoseStack mcModelViewMatrix, float partialTicks, ProfilerFiller newProfiler)
|
||||
{
|
||||
//=================================//
|
||||
// determine if LODs should render //
|
||||
@@ -169,7 +169,7 @@ public class LodRenderer
|
||||
return;
|
||||
}
|
||||
|
||||
if (mc.getPlayer().getActiveEffectsMap().get(Effects.BLINDNESS) != null)
|
||||
if (mc.getPlayer().getActiveEffectsMap().get(MobEffects.BLINDNESS) != null)
|
||||
{
|
||||
// if the player is blind don't render LODs,
|
||||
// and don't change minecraft's fog
|
||||
@@ -205,7 +205,7 @@ public class LodRenderer
|
||||
if ((partialRegen || fullRegen) && !lodBufferBuilder.generatingBuffers && !lodBufferBuilder.newBuffersAvailable())
|
||||
{
|
||||
// generate the LODs on a separate thread to prevent stuttering or freezing
|
||||
lodBufferBuilder.generateLodBuffersAsync(this, lodDim, mc.getPlayer().blockPosition(), true);
|
||||
lodBufferBuilder.generateLodBuffersAsync(this, lodDim, mc.getPlayerBlockPos(), true);
|
||||
|
||||
// the regen process has been started,
|
||||
// it will be done when lodBufferBuilder.newBuffersAvailable()
|
||||
@@ -256,7 +256,7 @@ public class LodRenderer
|
||||
// (or maybe vice versa I have no idea :P)
|
||||
mcProjectionMatrix.transpose();
|
||||
|
||||
Matrix4f modelViewMatrix = offsetTheModelViewMatrix(mcMatrixStack, partialTicks);
|
||||
Matrix4f modelViewMatrix = offsetTheModelViewMatrix(mcModelViewMatrix, partialTicks);
|
||||
vanillaBlockRenderedDistance = mc.getRenderDistance() * LodUtil.CHUNK_WIDTH;
|
||||
// required for setupFog and setupProjectionMatrix
|
||||
if (mc.getClientLevel().dimensionType().hasCeiling())
|
||||
@@ -286,8 +286,8 @@ public class LodRenderer
|
||||
|
||||
if (vbos != null)
|
||||
{
|
||||
ActiveRenderInfo renderInfo = mc.getGameRenderer().getMainCamera();
|
||||
Vector3d cameraDir = new Vector3d(renderInfo.getLookVector());
|
||||
Camera camera = mc.getGameRenderer().getMainCamera();
|
||||
Vector3f cameraDir = camera.getLookVector();
|
||||
|
||||
boolean cullingDisabled = LodConfig.CLIENT.graphics.advancedGraphicsOption.disableDirectionalCulling.get();
|
||||
boolean renderBufferStorage = LodConfig.CLIENT.graphics.advancedGraphicsOption.gpuUploadMethod.get() == GpuUploadMethod.BUFFER_STORAGE && GlProxy.getInstance().bufferStorageSupported;
|
||||
@@ -308,7 +308,7 @@ public class LodRenderer
|
||||
x + vboCenterRegionPos.x - (lodDim.getWidth() / 2),
|
||||
z + vboCenterRegionPos.z - (lodDim.getWidth() / 2));
|
||||
|
||||
if (cullingDisabled || RenderUtil.isRegionInViewFrustum(renderInfo.getBlockPosition(), cameraDir, vboPos.blockPos()))
|
||||
if (cullingDisabled || RenderUtil.isRegionInViewFrustum(camera.getBlockPosition(), cameraDir, vboPos.blockPos()))
|
||||
{
|
||||
if ((x > halfWidth - quarterWidth && x < halfWidth + quarterWidth)
|
||||
&& (z > halfWidth - quarterWidth && z < halfWidth + quarterWidth))
|
||||
@@ -319,10 +319,10 @@ public class LodRenderer
|
||||
|
||||
if (storageBufferIds != null && renderBufferStorage)
|
||||
for (int i = 0; i < storageBufferIds[x][z].length; i++)
|
||||
drawStorageBuffer(vbos[x][z][i], storageBufferIds[x][z][i], modelViewMatrix);
|
||||
drawArrays(modelViewMatrix, storageBufferIds[x][z][i], vbos[x][z][i].indexCount);
|
||||
else
|
||||
for (int i = 0; i < vbos[x][z].length; i++)
|
||||
drawVertexBuffer(vbos[x][z][i], modelViewMatrix);
|
||||
drawArrays(modelViewMatrix, vbos[x][z][i].vertextBufferId, vbos[x][z][i].indexCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -342,7 +342,7 @@ public class LodRenderer
|
||||
// re-enable the lights Minecraft uses
|
||||
GL15.glEnable(GL15.GL_LIGHT0);
|
||||
GL15.glEnable(GL15.GL_LIGHT1);
|
||||
RenderSystem.disableLighting();
|
||||
GL15.glDisable(GL15.GL_LIGHTING);
|
||||
|
||||
// reset the fog settings so the normal chunks
|
||||
// will be drawn correctly
|
||||
@@ -361,39 +361,31 @@ public class LodRenderer
|
||||
profiler.pop();
|
||||
}
|
||||
|
||||
|
||||
/** This is where the actual drawing happens. */
|
||||
private void drawStorageBuffer(VertexBuffer vbo, int bufferStorageId, Matrix4f modelViewMatrix)
|
||||
private void drawArrays(Matrix4f modelViewMatrix, int glBufferId, int vertexCount)
|
||||
{
|
||||
if (vbo == null)
|
||||
if (glBufferId == 0)
|
||||
return;
|
||||
|
||||
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, bufferStorageId);
|
||||
// 0L is the starting pointer
|
||||
LodUtil.LOD_VERTEX_FORMAT.setupBufferState(0L);
|
||||
// pre draw setup
|
||||
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, glBufferId);
|
||||
LodUtil.LOD_VERTEX_FORMAT.setupBufferState();
|
||||
|
||||
vbo.draw(modelViewMatrix, GL15.GL_QUADS);
|
||||
// set up the model view matrix
|
||||
GL15.glPushMatrix();
|
||||
GL15.glLoadIdentity();
|
||||
FloatBuffer matrixBuffer = FloatBuffer.allocate(16);
|
||||
modelViewMatrix.store(matrixBuffer);
|
||||
GL15.glMultMatrixf(matrixBuffer);
|
||||
|
||||
GL15C.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
|
||||
GL15.glDrawArrays(GL15.GL_QUADS, 0, vertexCount);
|
||||
|
||||
// post draw cleanup
|
||||
GL15.glPopMatrix();
|
||||
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
|
||||
LodUtil.LOD_VERTEX_FORMAT.clearBufferState();
|
||||
}
|
||||
|
||||
|
||||
/** This is where the actual drawing happens. */
|
||||
private void drawVertexBuffer(VertexBuffer vbo, Matrix4f modelViewMatrix)
|
||||
{
|
||||
if (vbo == null)
|
||||
return;
|
||||
|
||||
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo.id);
|
||||
// 0L is the starting pointer
|
||||
LodUtil.LOD_VERTEX_FORMAT.setupBufferState(0L);
|
||||
|
||||
vbo.draw(modelViewMatrix, GL15.GL_QUADS);
|
||||
|
||||
GL15C.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
|
||||
LodUtil.LOD_VERTEX_FORMAT.clearBufferState();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -442,38 +434,36 @@ public class LodRenderer
|
||||
{
|
||||
// for more realistic fog when using FAR
|
||||
if (LodConfig.CLIENT.graphics.fogQualityOption.fogDistance.get() == FogDistance.NEAR_AND_FAR)
|
||||
RenderSystem.fogStart(farPlaneBlockDistance * 1.6f * 0.9f);
|
||||
GL15.glFogf(GL15.GL_FOG_START, farPlaneBlockDistance * 1.6f * 0.9f);
|
||||
else
|
||||
RenderSystem.fogStart(Math.min(vanillaBlockRenderedDistance * 1.5f, farPlaneBlockDistance * 0.9f * 1.6f));
|
||||
RenderSystem.fogEnd(farPlaneBlockDistance * 1.6f);
|
||||
GL15.glFogf(GL15.GL_FOG_START, Math.min(vanillaBlockRenderedDistance * 1.5f, farPlaneBlockDistance * 0.9f * 1.6f));
|
||||
GL15.glFogf(GL15.GL_FOG_END, farPlaneBlockDistance * 1.6f);
|
||||
}
|
||||
else if (fogQuality == FogQuality.FAST)
|
||||
{
|
||||
// for the far fog of the normal chunks
|
||||
// to start right where the LODs' end use:
|
||||
// end = 0.8f, start = 1.5f
|
||||
RenderSystem.fogStart(farPlaneBlockDistance * 0.75f);
|
||||
RenderSystem.fogEnd(farPlaneBlockDistance * 1.0f);
|
||||
GL15.glFogf(GL15.GL_FOG_START, farPlaneBlockDistance * 0.75f);
|
||||
GL15.glFogf(GL15.GL_FOG_END, farPlaneBlockDistance * 1.0f);
|
||||
}
|
||||
}
|
||||
else if (fogDistance == FogDistance.NEAR)
|
||||
{
|
||||
if (fogQuality == FogQuality.FANCY)
|
||||
{
|
||||
RenderSystem.fogEnd(vanillaBlockRenderedDistance * 1.41f);
|
||||
RenderSystem.fogStart(vanillaBlockRenderedDistance * 1.6f);
|
||||
GL15.glFogf(GL15.GL_FOG_END, vanillaBlockRenderedDistance * 1.41f);
|
||||
GL15.glFogf(GL15.GL_FOG_START, vanillaBlockRenderedDistance * 1.6f);
|
||||
}
|
||||
else if (fogQuality == FogQuality.FAST)
|
||||
{
|
||||
RenderSystem.fogEnd(vanillaBlockRenderedDistance * 1.0f);
|
||||
RenderSystem.fogStart(vanillaBlockRenderedDistance * 1.5f);
|
||||
GL15.glFogf(GL15.GL_FOG_END, vanillaBlockRenderedDistance * 1.0f);
|
||||
GL15.glFogf(GL15.GL_FOG_START, vanillaBlockRenderedDistance * 1.5f);
|
||||
}
|
||||
}
|
||||
|
||||
GL15.glEnable(GL15.GL_FOG);
|
||||
RenderSystem.enableFog();
|
||||
RenderSystem.setupNvFogDistance();
|
||||
RenderSystem.fogMode(GlStateManager.FogMode.LINEAR);
|
||||
GL15.glFogi(GL15.GL_FOG_MODE, GL15.GL_LINEAR);
|
||||
|
||||
if (GlProxy.getInstance().fancyFogAvailable)
|
||||
GL15.glFogi(NVFogDistance.GL_FOG_DISTANCE_MODE_NV, glFogDistanceMode);
|
||||
@@ -488,9 +478,9 @@ public class LodRenderer
|
||||
float defaultFogStartDist, float defaultFogEndDist,
|
||||
int defaultFogMode, int defaultFogDistance)
|
||||
{
|
||||
RenderSystem.fogStart(defaultFogStartDist);
|
||||
RenderSystem.fogEnd(defaultFogEndDist);
|
||||
RenderSystem.fogMode(defaultFogMode);
|
||||
GL15.glFogf(GL15.GL_FOG_START, defaultFogStartDist);
|
||||
GL15.glFogf(GL15.GL_FOG_END, defaultFogEndDist);
|
||||
GL15.glFogi(GL15.GL_FOG_MODE, defaultFogMode);
|
||||
|
||||
// this setting is only valid if the GPU supports fancy fog
|
||||
if (GlProxy.getInstance().fancyFogAvailable)
|
||||
@@ -509,9 +499,9 @@ public class LodRenderer
|
||||
// we can't disable minecraft's fog outright because by default
|
||||
// minecraft will re-enable the fog after our code
|
||||
|
||||
RenderSystem.fogStart(0.0F);
|
||||
RenderSystem.fogEnd(Float.MAX_VALUE);
|
||||
RenderSystem.fogDensity(0.0F);
|
||||
GL15.glFogf(GL15.GL_FOG_START, 0.0F);
|
||||
GL15.glFogf(GL15.GL_FOG_END, Float.MAX_VALUE);
|
||||
GL15.glFogf(GL15.GL_FOG_DENSITY, Float.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -523,30 +513,30 @@ public class LodRenderer
|
||||
* (since AxisAlignedBoundingBoxes (LODs) use doubles and thus have a higher
|
||||
* accuracy vs the model view matrix, which only uses floats)
|
||||
*/
|
||||
private Matrix4f offsetTheModelViewMatrix(MatrixStack mcMatrixStack, float partialTicks)
|
||||
private Matrix4f offsetTheModelViewMatrix(PoseStack mcModelViewMatrix, float partialTicks)
|
||||
{
|
||||
// duplicate the last matrix
|
||||
mcMatrixStack.pushPose();
|
||||
mcModelViewMatrix.pushPose();
|
||||
|
||||
|
||||
// get all relevant camera info
|
||||
ActiveRenderInfo renderInfo = mc.getGameRenderer().getMainCamera();
|
||||
Vector3d projectedView = renderInfo.getPosition();
|
||||
Camera camera = mc.getGameRenderer().getMainCamera();
|
||||
Vec3 projectedView = camera.getPosition();
|
||||
|
||||
// translate the camera relative to the regions' center
|
||||
// (AxisAlignedBoundingBoxes (LODs) use doubles and thus have a higher
|
||||
// accuracy vs the model view matrix, which only uses floats)
|
||||
BlockPos bufferPos = vbosCenter.getWorldPosition();
|
||||
BlockPosWrapper bufferPos = vbosCenter.getWorldPosition();
|
||||
double xDiff = projectedView.x - bufferPos.getX();
|
||||
double zDiff = projectedView.z - bufferPos.getZ();
|
||||
mcMatrixStack.translate(-xDiff, -projectedView.y, -zDiff);
|
||||
mcModelViewMatrix.translate(-xDiff, -projectedView.y, -zDiff);
|
||||
|
||||
|
||||
|
||||
// get the modified model view matrix
|
||||
Matrix4f lodModelViewMatrix = mcMatrixStack.last().pose();
|
||||
Matrix4f lodModelViewMatrix = mcModelViewMatrix.last().pose();
|
||||
// remove the lod ModelViewMatrix
|
||||
mcMatrixStack.popPose();
|
||||
mcModelViewMatrix.popPose();
|
||||
|
||||
return lodModelViewMatrix;
|
||||
}
|
||||
@@ -569,7 +559,7 @@ public class LodRenderer
|
||||
|
||||
// get Minecraft's un-edited projection matrix
|
||||
// (this is before it is zoomed, distorted, etc.)
|
||||
Matrix4f defaultMcProj = mc.getGameRenderer().getProjectionMatrix(mc.getGameRenderer().getMainCamera(), partialTicks, true);
|
||||
Matrix4f defaultMcProj = mc.getGameRenderer().getProjectionMatrix(getFov(partialTicks, true));
|
||||
// true here means use "use fov setting" (probably)
|
||||
|
||||
|
||||
@@ -805,7 +795,7 @@ public class LodRenderer
|
||||
vanillaRenderedChunks = new boolean[vanillaRenderedChunksWidth][vanillaRenderedChunksWidth];
|
||||
DetailDistanceUtil.updateSettings();
|
||||
fullRegen = true;
|
||||
previousPos = LevelPosUtil.createLevelPos((byte) 4, mc.getPlayer().xChunk, mc.getPlayer().zChunk);
|
||||
previousPos = LevelPosUtil.createLevelPos((byte) 4, mc.getPlayerChunkPos().getZ(), mc.getPlayerChunkPos().getZ());
|
||||
prevFogDistance = LodConfig.CLIENT.graphics.fogQualityOption.fogDistance.get();
|
||||
prevRenderDistance = chunkRenderDistance;
|
||||
}
|
||||
@@ -824,12 +814,12 @@ public class LodRenderer
|
||||
if (newTime - prevPlayerPosTime > LodConfig.CLIENT.advancedModOptions.buffers.rebuildTimes.get().playerMoveTimeout)
|
||||
{
|
||||
if (LevelPosUtil.getDetailLevel(previousPos) == 0
|
||||
|| mc.getPlayer().xChunk != LevelPosUtil.getPosX(previousPos)
|
||||
|| mc.getPlayer().zChunk != LevelPosUtil.getPosZ(previousPos))
|
||||
|| mc.getPlayerChunkPos().getX() != LevelPosUtil.getPosX(previousPos)
|
||||
|| mc.getPlayerChunkPos().getZ() != LevelPosUtil.getPosZ(previousPos))
|
||||
{
|
||||
vanillaRenderedChunks = new boolean[vanillaRenderedChunksWidth][vanillaRenderedChunksWidth];
|
||||
fullRegen = true;
|
||||
previousPos = LevelPosUtil.createLevelPos((byte) 4, mc.getPlayer().xChunk, mc.getPlayer().zChunk);
|
||||
previousPos = LevelPosUtil.createLevelPos((byte) 4, mc.getPlayerChunkPos().getX(), mc.getPlayerChunkPos().getZ());
|
||||
}
|
||||
prevPlayerPosTime = newTime;
|
||||
}
|
||||
@@ -910,15 +900,15 @@ public class LodRenderer
|
||||
//==============//
|
||||
|
||||
// determine which LODs should not be rendered close to the player
|
||||
HashSet<ChunkPos> chunkPosToSkip = LodUtil.getNearbyLodChunkPosToSkip(lodDim, mc.getPlayer().blockPosition());
|
||||
HashSet<ChunkPos> chunkPosToSkip = LodUtil.getNearbyLodChunkPosToSkip(lodDim, mc.getPlayerBlockPos());
|
||||
int xIndex;
|
||||
int zIndex;
|
||||
for (ChunkPos pos : chunkPosToSkip)
|
||||
{
|
||||
vanillaRenderedChunksEmptySkip = false;
|
||||
|
||||
xIndex = (pos.x - mc.getPlayer().xChunk) + (chunkRenderDistance + 1);
|
||||
zIndex = (pos.z - mc.getPlayer().zChunk) + (chunkRenderDistance + 1);
|
||||
xIndex = (pos.x - mc.getPlayerChunkPos().getX()) + (chunkRenderDistance + 1);
|
||||
zIndex = (pos.z - mc.getPlayerChunkPos().getZ()) + (chunkRenderDistance + 1);
|
||||
|
||||
// sometimes we are given chunks that are outside the render distance,
|
||||
// This prevents index out of bounds exceptions
|
||||
|
||||
@@ -19,12 +19,13 @@
|
||||
|
||||
package com.seibel.lod.render;
|
||||
|
||||
import com.mojang.math.Vector3f;
|
||||
import com.seibel.lod.util.LodUtil;
|
||||
import com.seibel.lod.wrappers.MinecraftWrapper;
|
||||
import com.seibel.lod.wrappers.Block.BlockPosWrapper;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
|
||||
/**
|
||||
* This holds miscellaneous helper code
|
||||
@@ -85,22 +86,24 @@ public class RenderUtil
|
||||
* Returns true if one of the region's 4 corners is in front
|
||||
* of the camera.
|
||||
*/
|
||||
public static boolean isRegionInViewFrustum(BlockPos playerBlockPos, Vector3d cameraDir, BlockPos vboCenterPos)
|
||||
public static boolean isRegionInViewFrustum(BlockPos playerBlockPos, Vector3f cameraDir, BlockPosWrapper vboCenterPos)
|
||||
{
|
||||
// convert the vbo position into a direction vector
|
||||
// starting from the player's position
|
||||
Vector3d vboVec = new Vector3d(vboCenterPos.getX(), 0, vboCenterPos.getZ());
|
||||
Vector3d playerVec = new Vector3d(playerBlockPos.getX(), playerBlockPos.getY(), playerBlockPos.getZ());
|
||||
Vector3d vboCenterVec = vboVec.subtract(playerVec);
|
||||
Vector3f vboVec = new Vector3f(vboCenterPos.getX(), 0, vboCenterPos.getZ());
|
||||
Vector3f playerVec = new Vector3f(playerBlockPos.getX(), playerBlockPos.getY(), playerBlockPos.getZ());
|
||||
|
||||
vboVec.sub(playerVec);
|
||||
Vector3f vboCenterVec = vboVec;
|
||||
|
||||
|
||||
int halfRegionWidth = LodUtil.REGION_WIDTH / 2;
|
||||
|
||||
// calculate the 4 corners
|
||||
Vector3d vboSeVec = new Vector3d(vboCenterVec.x + halfRegionWidth, vboCenterVec.y, vboCenterVec.z + halfRegionWidth);
|
||||
Vector3d vboSwVec = new Vector3d(vboCenterVec.x - halfRegionWidth, vboCenterVec.y, vboCenterVec.z + halfRegionWidth);
|
||||
Vector3d vboNwVec = new Vector3d(vboCenterVec.x - halfRegionWidth, vboCenterVec.y, vboCenterVec.z - halfRegionWidth);
|
||||
Vector3d vboNeVec = new Vector3d(vboCenterVec.x + halfRegionWidth, vboCenterVec.y, vboCenterVec.z - halfRegionWidth);
|
||||
Vector3f vboSeVec = new Vector3f(vboCenterVec.x() + halfRegionWidth, vboCenterVec.y(), vboCenterVec.z() + halfRegionWidth);
|
||||
Vector3f vboSwVec = new Vector3f(vboCenterVec.x() - halfRegionWidth, vboCenterVec.y(), vboCenterVec.z() + halfRegionWidth);
|
||||
Vector3f vboNwVec = new Vector3f(vboCenterVec.x() - halfRegionWidth, vboCenterVec.y(), vboCenterVec.z() - halfRegionWidth);
|
||||
Vector3f vboNeVec = new Vector3f(vboCenterVec.x() + halfRegionWidth, vboCenterVec.y(), vboCenterVec.z() - halfRegionWidth);
|
||||
|
||||
// if any corner is visible, this region should be rendered
|
||||
return isNormalizedVectorInViewFrustum(vboSeVec, cameraDir) ||
|
||||
@@ -113,7 +116,7 @@ public class RenderUtil
|
||||
* Currently takes the dot product of the two vectors,
|
||||
* but in the future could do more complicated frustum culling tests.
|
||||
*/
|
||||
private static boolean isNormalizedVectorInViewFrustum(Vector3d objectVector, Vector3d cameraDir)
|
||||
private static boolean isNormalizedVectorInViewFrustum(Vector3f objectVector, Vector3f cameraDir)
|
||||
{
|
||||
// the -0.1 is to offer a slight buffer, so we are
|
||||
// more likely to render LODs and thus, hopefully prevent
|
||||
|
||||
@@ -32,12 +32,15 @@ import com.seibel.lod.enums.VanillaOverdraw;
|
||||
import com.seibel.lod.objects.LodDimension;
|
||||
import com.seibel.lod.objects.RegionPos;
|
||||
import com.seibel.lod.wrappers.MinecraftWrapper;
|
||||
import com.seibel.lod.wrappers.Block.BlockPosWrapper;
|
||||
import com.seibel.lod.wrappers.Chunk.ChunkPosWrapper;
|
||||
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher.CompiledChunk;
|
||||
import net.minecraft.client.server.IntegratedServer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerChunkCache;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
@@ -348,10 +351,10 @@ public class LodUtil
|
||||
* Get a HashSet of all ChunkPos within the normal render distance
|
||||
* that should not be rendered.
|
||||
*/
|
||||
public static HashSet<ChunkPos> getNearbyLodChunkPosToSkip(LodDimension lodDim, BlockPos playerPos)
|
||||
public static HashSet<ChunkPos> getNearbyLodChunkPosToSkip(LodDimension lodDim, BlockPosWrapper blockPosWrapper)
|
||||
{
|
||||
int chunkRenderDist = mc.getRenderDistance();
|
||||
ChunkPos centerChunk = new ChunkPos(playerPos);
|
||||
ChunkPosWrapper centerChunk = new ChunkPosWrapper(blockPosWrapper);
|
||||
|
||||
int skipRadius;
|
||||
VanillaOverdraw overdraw = LodConfig.CLIENT.graphics.advancedGraphicsOption.vanillaOverdraw.get();
|
||||
@@ -425,12 +428,12 @@ public class LodUtil
|
||||
// if the skipRadius is being used
|
||||
if (skipRadius != 0)
|
||||
{
|
||||
for (int x = centerChunk.x - chunkRenderDist; x < centerChunk.x + chunkRenderDist; x++)
|
||||
for (int x = centerChunk.getX() - chunkRenderDist; x < centerChunk.getX() + chunkRenderDist; x++)
|
||||
{
|
||||
for (int z = centerChunk.z - chunkRenderDist; z < centerChunk.z + chunkRenderDist; z++)
|
||||
for (int z = centerChunk.getZ() - chunkRenderDist; z < centerChunk.getZ() + chunkRenderDist; z++)
|
||||
{
|
||||
if (x <= centerChunk.x - skipRadius || x >= centerChunk.x + skipRadius
|
||||
|| z <= centerChunk.z - skipRadius || z >= centerChunk.z + skipRadius)
|
||||
if (x <= centerChunk.getX() - skipRadius || x >= centerChunk.getX() + skipRadius
|
||||
|| z <= centerChunk.getZ() - skipRadius || z >= centerChunk.getZ() + skipRadius)
|
||||
posToSkip.remove(new ChunkPos(x, z));
|
||||
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@ package com.seibel.lod.wrappers.Block;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import com.seibel.lod.wrappers.Chunk.ChunkPosWrapper;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
|
||||
@@ -60,7 +58,7 @@ public class BlockPosWrapper
|
||||
return Objects.hash(blockPos);
|
||||
}
|
||||
|
||||
public ChunkPosWrapper offset(int x, int y, int z)
|
||||
public BlockPosWrapper offset(int x, int y, int z)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
|
||||
@@ -27,6 +27,8 @@ import com.mojang.blaze3d.platform.Window;
|
||||
import com.seibel.lod.ModInfo;
|
||||
import com.seibel.lod.proxy.ClientProxy;
|
||||
import com.seibel.lod.util.LodUtil;
|
||||
import com.seibel.lod.wrappers.Block.BlockPosWrapper;
|
||||
import com.seibel.lod.wrappers.Chunk.ChunkPosWrapper;
|
||||
import com.seibel.lod.wrappers.World.WorldWrapper;
|
||||
|
||||
import net.minecraft.CrashReport;
|
||||
@@ -41,10 +43,12 @@ import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.resources.model.ModelManager;
|
||||
import net.minecraft.client.server.IntegratedServer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
|
||||
/**
|
||||
@@ -170,6 +174,18 @@ public class MinecraftWrapper
|
||||
return mc.player;
|
||||
}
|
||||
|
||||
public BlockPosWrapper getPlayerBlockPos()
|
||||
{
|
||||
BlockPos playerPos = getPlayer().blockPosition();
|
||||
return new BlockPosWrapper(playerPos.getX(), playerPos.getY(), playerPos.getZ());
|
||||
}
|
||||
|
||||
public ChunkPosWrapper getPlayerChunkPos()
|
||||
{
|
||||
ChunkPos playerPos = getPlayer().chunkPosition();
|
||||
return new ChunkPosWrapper(playerPos.x, playerPos.z);
|
||||
}
|
||||
|
||||
public Options getOptions()
|
||||
{
|
||||
return mc.options;
|
||||
@@ -272,6 +288,8 @@ public class MinecraftWrapper
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Crashes Minecraft, displaying the given errorMessage <br> <br>
|
||||
* In the following format: <br>
|
||||
|
||||
@@ -1,56 +1,67 @@
|
||||
# Note: to update code in eclipse run the "eclipse" command in graldew
|
||||
|
||||
|
||||
# used when creating the projection matrix
|
||||
public net.minecraft.client.renderer.GameRenderer func_215311_a(Lnet/minecraft/client/renderer/ActiveRenderInfo;FZ)D # getFOVModifier
|
||||
public net.minecraft.client.renderer.GameRenderer field_78529_t # rendererUpdateCount
|
||||
public net.minecraft.client.renderer.GameRenderer func_228380_a_(Lcom/mojang/blaze3d/matrix/MatrixStack;F)V # hurtCameraEffect
|
||||
public net.minecraft.client.renderer.GameRenderer func_228383_b_(Lcom/mojang/blaze3d/matrix/MatrixStack;F)V # applyBobbing
|
||||
## used when creating the projection matrix
|
||||
#public net.minecraft.client.renderer.GameRenderer func_215311_a(Lnet/minecraft/client/renderer/ActiveRenderInfo;FZ)D # getFOVModifier
|
||||
#public net.minecraft.client.renderer.GameRenderer field_78529_t # rendererUpdateCount
|
||||
#public net.minecraft.client.renderer.GameRenderer func_228380_a_(Lcom/mojang/blaze3d/matrix/MatrixStack;F)V # hurtCameraEffect
|
||||
#public net.minecraft.client.renderer.GameRenderer func_228383_b_(Lcom/mojang/blaze3d/matrix/MatrixStack;F)V # applyBobbing
|
||||
#
|
||||
## used when accessing built byteBuffers
|
||||
#public net.minecraft.client.renderer.BufferBuilder field_179001_a # byteBuffer
|
||||
#
|
||||
## used when generating LodChunks
|
||||
#public net.minecraft.block.AbstractBlock$AbstractBlockState field_235704_h_ # materialColor
|
||||
#
|
||||
## used when determining which chunks Vanilla Minecraft is going to render
|
||||
#public net.minecraft.client.renderer.WorldRenderer$LocalRenderInformationContainer
|
||||
#public net.minecraft.client.renderer.WorldRenderer field_72755_R # renderInfos
|
||||
#public net.minecraft.client.renderer.WorldRenderer$LocalRenderInformationContainer field_178036_a # renderChunk
|
||||
#
|
||||
## used in world generation
|
||||
#public net.minecraft.world.server.ServerWorld field_241106_P_ # structuremanager
|
||||
#public net.minecraft.world.gen.Heightmap func_202267_b(II)I # getDataArrayIndex
|
||||
#public net.minecraft.world.gen.Heightmap func_202272_a(III)V # set
|
||||
#public net.minecraft.world.chunk.Chunk field_76634_f # heightMap
|
||||
#public net.minecraft.world.chunk.Chunk field_76652_q # sections
|
||||
#public net.minecraft.world.chunk.ChunkPrimer field_201661_i # sections
|
||||
#public net.minecraft.world.server.ChunkManager field_219269_w # templateManager
|
||||
#public net.minecraft.world.server.ChunkManager field_219256_j # lightManager
|
||||
#public net.minecraft.world.gen.feature.template.TemplateManager field_186240_a # templates
|
||||
#public net.minecraft.world.biome.Biome field_242424_k # biomeGenerationSettings
|
||||
#public net.minecraft.world.gen.blockstateprovider.WeightedBlockStateProvider field_227406_b_ # weightedStates
|
||||
#public net.minecraft.world.gen.placement.ConfiguredPlacement field_215096_a # decorator
|
||||
#public net.minecraft.world.gen.placement.ConfiguredPlacement field_215097_b # config
|
||||
#public net.minecraft.util.WeightedList field_220658_a # weightedEntries
|
||||
#public net.minecraft.world.gen.feature.FeatureSpread field_242250_b # base
|
||||
#public net.minecraft.world.gen.feature.FeatureSpread field_242251_c # spread
|
||||
#public net.minecraft.world.gen.feature.ConfiguredFeature #func_242765_a(Lnet/minecraft/world/ISeedReader;Lnet/minecraft/world/gen/ChunkGenerator;Ljava/util/Random;Lnet/minecraft/util/math/BlockPos;)Z # place
|
||||
#public net.minecraft.world.server.ServerChunkProvider field_217244_j # dataStorage
|
||||
#public net.minecraft.world.lighting.WorldLightManager field_215576_a # blockEngine
|
||||
#public net.minecraft.world.lighting.WorldLightManager field_215577_b # skyEngine
|
||||
#public net.minecraft.world.gen.feature.Feature field_236290_a_ # configuredCodec
|
||||
#
|
||||
## used for uploading vertex buffers off the render thread
|
||||
#public net.minecraft.client.renderer.vertex.VertexBuffer field_177365_a # id
|
||||
#public net.minecraft.client.renderer.vertex.VertexBuffer field_177363_b # format
|
||||
#public net.minecraft.client.renderer.vertex.VertexBuffer field_177364_c # vertexCount
|
||||
#
|
||||
## used for accessing the lightmap
|
||||
#public net.minecraft.client.renderer.LightTexture field_205111_b # lightPixels
|
||||
|
||||
|
||||
# used when accessing built byteBuffers
|
||||
public net.minecraft.client.renderer.BufferBuilder field_179001_a # byteBuffer
|
||||
|
||||
# used when determining where to save files too
|
||||
public net.minecraft.world.storage.DimensionSavedDataManager field_215759_d # folder
|
||||
public net.minecraft.world.level.storage.DimensionDataStorage f_78146_ # dataFolder
|
||||
|
||||
# used when generating LodChunks
|
||||
public net.minecraft.block.AbstractBlock$AbstractBlockState field_235704_h_ # materialColor
|
||||
# used when rendering
|
||||
public com.mojang.blaze3d.vertex.VertexBuffer f_166863_ # indexCount
|
||||
public com.mojang.blaze3d.vertex.VertexBuffer f_166859_ # vertextBufferId
|
||||
public net.minecraft.client.renderer.GameRenderer m_109141_(Lnet/minecraft/client/Camera;FZ)D # getFov
|
||||
|
||||
# used when determining which chunks Vanilla Minecraft is going to render
|
||||
public net.minecraft.client.renderer.WorldRenderer$LocalRenderInformationContainer
|
||||
public net.minecraft.client.renderer.WorldRenderer field_72755_R # renderInfos
|
||||
public net.minecraft.client.renderer.WorldRenderer$LocalRenderInformationContainer field_178036_a # renderChunk
|
||||
# pre-render setup
|
||||
public net.minecraft.client.renderer.LevelRenderer f_109467_ # renderChunks
|
||||
|
||||
# used in world generation
|
||||
public net.minecraft.world.server.ServerWorld field_241106_P_ # structuremanager
|
||||
public net.minecraft.world.gen.Heightmap func_202267_b(II)I # getDataArrayIndex
|
||||
public net.minecraft.world.gen.Heightmap func_202272_a(III)V # set
|
||||
public net.minecraft.world.chunk.Chunk field_76634_f # heightMap
|
||||
public net.minecraft.world.chunk.Chunk field_76652_q # sections
|
||||
public net.minecraft.world.chunk.ChunkPrimer field_201661_i # sections
|
||||
public net.minecraft.world.server.ChunkManager field_219269_w # templateManager
|
||||
public net.minecraft.world.server.ChunkManager field_219256_j # lightManager
|
||||
public net.minecraft.world.gen.feature.template.TemplateManager field_186240_a # templates
|
||||
public net.minecraft.world.biome.Biome field_242424_k # biomeGenerationSettings
|
||||
public net.minecraft.world.gen.blockstateprovider.WeightedBlockStateProvider field_227406_b_ # weightedStates
|
||||
public net.minecraft.world.gen.placement.ConfiguredPlacement field_215096_a # decorator
|
||||
public net.minecraft.world.gen.placement.ConfiguredPlacement field_215097_b # config
|
||||
public net.minecraft.util.WeightedList field_220658_a # weightedEntries
|
||||
public net.minecraft.world.gen.feature.FeatureSpread field_242250_b # base
|
||||
public net.minecraft.world.gen.feature.FeatureSpread field_242251_c # spread
|
||||
public net.minecraft.world.gen.feature.ConfiguredFeature func_242765_a(Lnet/minecraft/world/ISeedReader;Lnet/minecraft/world/gen/ChunkGenerator;Ljava/util/Random;Lnet/minecraft/util/math/BlockPos;)Z # place
|
||||
public net.minecraft.world.server.ServerChunkProvider field_217244_j # dataStorage
|
||||
public net.minecraft.world.lighting.WorldLightManager field_215576_a # blockEngine
|
||||
public net.minecraft.world.lighting.WorldLightManager field_215577_b # skyEngine
|
||||
public net.minecraft.world.gen.feature.Feature field_236290_a_ # configuredCodec
|
||||
|
||||
# used for uploading vertex buffers off the render thread
|
||||
public net.minecraft.client.renderer.vertex.VertexBuffer field_177365_a # id
|
||||
public net.minecraft.client.renderer.vertex.VertexBuffer field_177363_b # format
|
||||
public net.minecraft.client.renderer.vertex.VertexBuffer field_177364_c # vertexCount
|
||||
|
||||
# used for accessing the lightmap
|
||||
public net.minecraft.client.renderer.LightTexture field_205111_b # lightPixels
|
||||
|
||||
|
||||
#=====================#
|
||||
@@ -58,15 +69,15 @@ public net.minecraft.client.renderer.LightTexture field_205111_b # lightPixels
|
||||
#=====================#
|
||||
|
||||
# Makes public the IScreenFactory class in ScreenManager
|
||||
public net.minecraft.client.gui.ScreenManager$IScreenFactory
|
||||
# public net.minecraft.client.gui.ScreenManager$IScreenFactory
|
||||
|
||||
# Makes protected and removes the final modifier from 'random' in MinecraftServer
|
||||
protected-f net.minecraft.server.MinecraftServer field_147146_q #random
|
||||
# protected-f net.minecraft.server.MinecraftServer field_147146_q #random
|
||||
|
||||
# Makes public the 'createNamedService' method in Util,
|
||||
# accepting a String and returns an ExecutorService
|
||||
public net.minecraft.util.Util func_240979_a_(Ljava/lang/String;)Ljava/util/concurrent/ExecutorService; #createNamedService
|
||||
# public net.minecraft.util.Util func_240979_a_(Ljava/lang/String;)Ljava/util/concurrent/ExecutorService; #createNamedService
|
||||
|
||||
# Makes public the 'func_239776_a_' method in UUIDCodec,
|
||||
# accepting two longs and returning an int[]
|
||||
public net.minecraft.util.UUIDCodec func_239776_a_(JJ)[I #func_239776_a_
|
||||
# public net.minecraft.util.UUIDCodec func_239776_a_(JJ)[I #func_239776_a_
|
||||
Reference in New Issue
Block a user