mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-26 15:13:01 +00:00
Moves CapturingTesselator, JSON Models, and misc utility classes to GTNHlib (#587)
* Moves CapturingTesselator, JSON Models, and misc utility classes to GTNHlib * Switch to separate source set for mixins - faster incremental builds
This commit is contained in:
1 parent
1315d8971a
commit
558ea0fe12
404 files changed
+631
-5190
No files matched your search
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.gl.attribute;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.VertexFormat;
|
||||
|
||||
public interface BufferVertexFormat {
|
||||
static BufferVertexFormat from(VertexFormat format) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.model.light;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.BlockPosImpl;
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.world.EnumSkyBlock;
|
||||
@@ -14,30 +14,30 @@ public class EntityLighter {
|
||||
private static final double MAX_LIGHTMAP_COORD = 240.0D;
|
||||
|
||||
public static int getBlendedLight(Entity entity, float tickDelta) {
|
||||
boolean calcBlockLight = !entity.isBurning();
|
||||
final boolean calcBlockLight = !entity.isBurning();
|
||||
|
||||
// Find the interpolated position of the entity
|
||||
double x1 = lerp(entity.prevPosX, entity.posX, tickDelta);
|
||||
double y1 = lerp(entity.prevPosY, entity.posY, tickDelta);
|
||||
double z1 = lerp(entity.prevPosZ, entity.posZ, tickDelta);
|
||||
final double x1 = lerp(entity.prevPosX, entity.posX, tickDelta);
|
||||
final double y1 = lerp(entity.prevPosY, entity.posY, tickDelta);
|
||||
final double z1 = lerp(entity.prevPosZ, entity.posZ, tickDelta);
|
||||
|
||||
// Bounding boxes with no volume cause issues, ensure they're non-zero
|
||||
// Notably, armor stands in "Marker" mode decide this is a cute thing to do
|
||||
// https://github.com/jellysquid3/sodium-fabric/issues/60
|
||||
double width = Math.max(entity.width, MIN_BOX_SIZE);
|
||||
double height = Math.max(entity.height, MIN_BOX_SIZE);
|
||||
final double width = Math.max(entity.width, MIN_BOX_SIZE);
|
||||
final double height = Math.max(entity.height, MIN_BOX_SIZE);
|
||||
|
||||
double x2 = x1 + width;
|
||||
double y2 = y1 + height;
|
||||
double z2 = z1 + width;
|
||||
final double x2 = x1 + width;
|
||||
final double y2 = y1 + height;
|
||||
final double z2 = z1 + width;
|
||||
|
||||
// The sampling volume of blocks which could possibly contribute light to this entity
|
||||
int bMinX = MathHelper.floor_double(x1);
|
||||
int bMinY = MathHelper.floor_double(y1);
|
||||
int bMinZ = MathHelper.floor_double(z1);
|
||||
int bMaxX = MathHelper.ceiling_double_int(x2);
|
||||
int bMaxY = MathHelper.ceiling_double_int(y2);
|
||||
int bMaxZ = MathHelper.ceiling_double_int(z2);
|
||||
final int bMinX = MathHelper.floor_double(x1);
|
||||
final int bMinY = MathHelper.floor_double(y1);
|
||||
final int bMinZ = MathHelper.floor_double(z1);
|
||||
final int bMaxX = MathHelper.ceiling_double_int(x2);
|
||||
final int bMaxY = MathHelper.ceiling_double_int(y2);
|
||||
final int bMaxZ = MathHelper.ceiling_double_int(z2);
|
||||
|
||||
// The maximum amount of light that could be contributed
|
||||
double max = 0.0D;
|
||||
@@ -46,16 +46,16 @@ public class EntityLighter {
|
||||
double sl = 0;
|
||||
double bl = 0;
|
||||
|
||||
BlockPosImpl pos = new BlockPosImpl();
|
||||
final BlockPos pos = new BlockPos();
|
||||
|
||||
// Iterate over every block in the sampling volume
|
||||
for (int bX = bMinX; bX < bMaxX; bX++) {
|
||||
double ix1 = Math.max(bX, x1);
|
||||
double ix2 = Math.min(bX + 1, x2);
|
||||
final double ix1 = Math.max(bX, x1);
|
||||
final double ix2 = Math.min(bX + 1, x2);
|
||||
|
||||
for (int bY = bMinY; bY < bMaxY; bY++) {
|
||||
double iy1 = Math.max(bY, y1);
|
||||
double iy2 = Math.min(bY + 1, y2);
|
||||
final double iy1 = Math.max(bY, y1);
|
||||
final double iy2 = Math.min(bY + 1, y2);
|
||||
|
||||
for (int bZ = bMinZ; bZ < bMaxZ; bZ++) {
|
||||
pos.set(bX, bY, bZ);
|
||||
@@ -67,11 +67,11 @@ public class EntityLighter {
|
||||
}
|
||||
|
||||
// Find the intersecting volume between the entity box and the block's bounding box
|
||||
double iz1 = Math.max(bZ, z1);
|
||||
double iz2 = Math.min(bZ + 1, z2);
|
||||
final double iz1 = Math.max(bZ, z1);
|
||||
final double iz2 = Math.min(bZ + 1, z2);
|
||||
|
||||
// The amount of light this block can contribute is the volume of the intersecting box
|
||||
double weight = (ix2 - ix1) * (iy2 - iy1) * (iz2 - iz1);
|
||||
final double weight = (ix2 - ix1) * (iy2 - iy1) * (iz2 - iz1);
|
||||
|
||||
// Keep count of how much light could've been contributed
|
||||
max += weight;
|
||||
@@ -93,8 +93,8 @@ public class EntityLighter {
|
||||
}
|
||||
|
||||
// The final light value is calculated from the percentage of light contributed out of the total maximum
|
||||
int bli = MathHelper.floor_double((bl / max) * MAX_LIGHTMAP_COORD);
|
||||
int sli = MathHelper.floor_double((sl / max) * MAX_LIGHTMAP_COORD);
|
||||
final int bli = MathHelper.floor_double((bl / max) * MAX_LIGHTMAP_COORD);
|
||||
final int sli = MathHelper.floor_double((sl / max) * MAX_LIGHTMAP_COORD);
|
||||
|
||||
return ((sli & 0xFFFF) << 16) | (bli & 0xFFFF);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package me.jellysquid.mods.sodium.client.model.light;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.BlockPosImpl;
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.ModelQuadView;
|
||||
import me.jellysquid.mods.sodium.client.model.light.data.QuadLightData;
|
||||
import me.jellysquid.mods.sodium.client.model.quad.ModelQuadView;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
@@ -18,5 +18,5 @@ public interface LightPipeline {
|
||||
* @param face The pre-computed facing vector of the quad
|
||||
* @param shade True if the block is shaded by ambient occlusion
|
||||
*/
|
||||
void calculate(ModelQuadView quad, BlockPosImpl pos, QuadLightData out, ForgeDirection cullFace, ForgeDirection face, boolean shade);
|
||||
void calculate(ModelQuadView quad, BlockPos pos, QuadLightData out, ForgeDirection cullFace, ForgeDirection face, boolean shade);
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.model.light.cache;
|
||||
|
||||
import com.gtnewhorizons.angelica.api.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.IBlockPos;
|
||||
import it.unimi.dsi.fastutil.longs.Long2LongLinkedOpenHashMap;
|
||||
import me.jellysquid.mods.sodium.client.model.light.data.LightDataAccess;
|
||||
import me.jellysquid.mods.sodium.client.world.WorldSlice;
|
||||
@@ -19,7 +19,7 @@ public class HashLightDataCache extends LightDataAccess {
|
||||
@Override
|
||||
public long get(int x, int y, int z) {
|
||||
DynamicLightsPos.get().set(x, y, z);
|
||||
long key = BlockPos.asLong(x, y, z);
|
||||
long key = IBlockPos.asLong(x, y, z);
|
||||
long word = this.map.getAndMoveToFirst(key);
|
||||
|
||||
if (word == 0) {
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.model.light.data;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.BlockPosImpl;
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
|
||||
import me.jellysquid.mods.sodium.client.util.StateUtil;
|
||||
import me.jellysquid.mods.sodium.client.world.WorldSlice;
|
||||
@@ -23,7 +23,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
* You can use the various static pack/unpack methods to extract these values in a usable format.
|
||||
*/
|
||||
public abstract class LightDataAccess {
|
||||
public static final ThreadLocal<BlockPosImpl> DynamicLightsPos = ThreadLocal.withInitial(BlockPosImpl::new);
|
||||
public static final ThreadLocal<BlockPos> DynamicLightsPos = ThreadLocal.withInitial(BlockPos::new);
|
||||
protected WorldSlice world;
|
||||
|
||||
public long get(int x, int y, int z, ForgeDirection d1, ForgeDirection d2) {
|
||||
@@ -34,11 +34,11 @@ public abstract class LightDataAccess {
|
||||
return this.get(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
|
||||
}
|
||||
|
||||
public long get(BlockPosImpl pos, ForgeDirection dir) {
|
||||
public long get(BlockPos pos, ForgeDirection dir) {
|
||||
return this.get(pos.x, pos.y, pos.z, dir);
|
||||
}
|
||||
|
||||
public long get(BlockPosImpl pos) {
|
||||
public long get(BlockPos pos) {
|
||||
return this.get(pos.x, pos.y, pos.getZ());
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -1,12 +1,12 @@
|
||||
package me.jellysquid.mods.sodium.client.model.light.flat;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.BlockPosImpl;
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.ModelQuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFlags;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import me.jellysquid.mods.sodium.client.model.light.LightPipeline;
|
||||
import me.jellysquid.mods.sodium.client.model.light.data.LightDataAccess;
|
||||
import me.jellysquid.mods.sodium.client.model.light.data.QuadLightData;
|
||||
import me.jellysquid.mods.sodium.client.model.quad.ModelQuadView;
|
||||
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadFlags;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@@ -27,7 +27,7 @@ public class FlatLightPipeline implements LightPipeline {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate(ModelQuadView quad, BlockPosImpl pos, QuadLightData out, ForgeDirection cullFace, ForgeDirection face, boolean shade) {
|
||||
public void calculate(ModelQuadView quad, BlockPos pos, QuadLightData out, ForgeDirection cullFace, ForgeDirection face, boolean shade) {
|
||||
int lightmap;
|
||||
|
||||
// To match vanilla behavior, use the cull face if it exists/is available
|
||||
@@ -57,7 +57,7 @@ public class FlatLightPipeline implements LightPipeline {
|
||||
* behind tinted glass. {@link LightDataAccess} cannot efficiently store lightmaps computed with
|
||||
* inconsistent values so this method exists to mirror vanilla behavior as closely as possible.
|
||||
*/
|
||||
private int getOffsetLightmap(BlockPosImpl pos, ForgeDirection face) {
|
||||
private int getOffsetLightmap(BlockPos pos, ForgeDirection face) {
|
||||
int lightmap = LightDataAccess.getLightMap(this.lightCache.get(pos, face));
|
||||
// If the block light is not 15 (max)...
|
||||
if ((lightmap & 0xF0) != 0xF0) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.model.light.smooth;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.BlockPosImpl;
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import me.jellysquid.mods.sodium.client.model.light.data.LightDataAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@@ -18,7 +18,7 @@ class AoFaceData {
|
||||
|
||||
private int flags;
|
||||
|
||||
public void initLightData(LightDataAccess cache, BlockPosImpl pos, ForgeDirection direction, boolean offset) {
|
||||
public void initLightData(LightDataAccess cache, BlockPos pos, ForgeDirection direction, boolean offset) {
|
||||
final int x = pos.x;
|
||||
final int y = pos.y;
|
||||
final int z = pos.z;
|
||||
|
||||
+12
-12
@@ -1,13 +1,13 @@
|
||||
package me.jellysquid.mods.sodium.client.model.light.smooth;
|
||||
|
||||
import com.google.common.math.DoubleMath;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.BlockPosImpl;
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.ModelQuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFlags;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import me.jellysquid.mods.sodium.client.model.light.LightPipeline;
|
||||
import me.jellysquid.mods.sodium.client.model.light.data.LightDataAccess;
|
||||
import me.jellysquid.mods.sodium.client.model.light.data.QuadLightData;
|
||||
import me.jellysquid.mods.sodium.client.model.quad.ModelQuadView;
|
||||
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadFlags;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@@ -71,7 +71,7 @@ public class SmoothLightPipeline implements LightPipeline {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate(ModelQuadView quad, BlockPosImpl pos, QuadLightData out, ForgeDirection cullFace, ForgeDirection face, boolean shade) {
|
||||
public void calculate(ModelQuadView quad, BlockPos pos, QuadLightData out, ForgeDirection cullFace, ForgeDirection face, boolean shade) {
|
||||
this.updateCachedData(pos.asLong());
|
||||
|
||||
final int flags = quad.getFlags();
|
||||
@@ -107,7 +107,7 @@ public class SmoothLightPipeline implements LightPipeline {
|
||||
* have two contributing sides.
|
||||
* Flags: IS_ALIGNED, !IS_PARTIAL
|
||||
*/
|
||||
private void applyAlignedFullFace(AoNeighborInfo neighborInfo, BlockPosImpl pos, ForgeDirection dir, QuadLightData out) {
|
||||
private void applyAlignedFullFace(AoNeighborInfo neighborInfo, BlockPos pos, ForgeDirection dir, QuadLightData out) {
|
||||
final AoFaceData faceData = this.getCachedFaceData(pos, dir, true);
|
||||
neighborInfo.mapCorners(faceData.lm, faceData.ao, out.lm, out.br);
|
||||
}
|
||||
@@ -116,7 +116,7 @@ public class SmoothLightPipeline implements LightPipeline {
|
||||
* Calculates the light data for a grid-aligned quad that does not cover the entire block volume's face.
|
||||
* Flags: IS_ALIGNED, IS_PARTIAL
|
||||
*/
|
||||
private void applyAlignedPartialFace(AoNeighborInfo neighborInfo, ModelQuadView quad, BlockPosImpl pos, ForgeDirection dir, QuadLightData out) {
|
||||
private void applyAlignedPartialFace(AoNeighborInfo neighborInfo, ModelQuadView quad, BlockPos pos, ForgeDirection dir, QuadLightData out) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
// Clamp the vertex positions to the block's boundaries to prevent weird errors in lighting
|
||||
final float cx = clamp(quad.getX(i));
|
||||
@@ -130,13 +130,13 @@ public class SmoothLightPipeline implements LightPipeline {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is the same as {@link #applyNonParallelFace(AoNeighborInfo, ModelQuadView, BlockPosImpl, ForgeDirection,
|
||||
* This method is the same as {@link #applyNonParallelFace(AoNeighborInfo, ModelQuadView, BlockPos, ForgeDirection,
|
||||
* QuadLightData)} but with the check for a depth of approximately 0 removed. If the quad is parallel but not
|
||||
* aligned, all of its vertices will have the same depth and this depth must be approximately greater than 0,
|
||||
* meaning the check for 0 will always return false.
|
||||
* Flags: !IS_ALIGNED, IS_PARALLEL
|
||||
*/
|
||||
private void applyParallelFace(AoNeighborInfo neighborInfo, ModelQuadView quad, BlockPosImpl pos, ForgeDirection dir, QuadLightData out) {
|
||||
private void applyParallelFace(AoNeighborInfo neighborInfo, ModelQuadView quad, BlockPos pos, ForgeDirection dir, QuadLightData out) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
// Clamp the vertex positions to the block's boundaries to prevent weird errors in lighting
|
||||
final float cx = clamp(quad.getX(i));
|
||||
@@ -163,7 +163,7 @@ public class SmoothLightPipeline implements LightPipeline {
|
||||
/**
|
||||
* Flags: !IS_ALIGNED, !IS_PARALLEL
|
||||
*/
|
||||
private void applyNonParallelFace(AoNeighborInfo neighborInfo, ModelQuadView quad, BlockPosImpl pos, ForgeDirection dir, QuadLightData out) {
|
||||
private void applyNonParallelFace(AoNeighborInfo neighborInfo, ModelQuadView quad, BlockPos pos, ForgeDirection dir, QuadLightData out) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
// Clamp the vertex positions to the block's boundaries to prevent weird errors in lighting
|
||||
final float cx = clamp(quad.getX(i));
|
||||
@@ -188,7 +188,7 @@ public class SmoothLightPipeline implements LightPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
private void applyAlignedPartialFaceVertex(BlockPosImpl pos, ForgeDirection dir, float[] w, int i, QuadLightData out, boolean offset) {
|
||||
private void applyAlignedPartialFaceVertex(BlockPos pos, ForgeDirection dir, float[] w, int i, QuadLightData out, boolean offset) {
|
||||
final AoFaceData faceData = this.getCachedFaceData(pos, dir, offset);
|
||||
|
||||
if (!faceData.hasUnpackedLightData()) {
|
||||
@@ -203,7 +203,7 @@ public class SmoothLightPipeline implements LightPipeline {
|
||||
out.lm[i] = getLightMapCoord(sl, bl);
|
||||
}
|
||||
|
||||
private void applyInsetPartialFaceVertex(BlockPosImpl pos, ForgeDirection dir, float n1d, float n2d, float[] w, int i, QuadLightData out) {
|
||||
private void applyInsetPartialFaceVertex(BlockPos pos, ForgeDirection dir, float n1d, float n2d, float[] w, int i, QuadLightData out) {
|
||||
final AoFaceData n1 = this.getCachedFaceData(pos, dir, false);
|
||||
|
||||
if (!n1.hasUnpackedLightData()) {
|
||||
@@ -241,7 +241,7 @@ public class SmoothLightPipeline implements LightPipeline {
|
||||
/**
|
||||
* Returns the cached data for a given facing or calculates it if it hasn't been cached.
|
||||
*/
|
||||
private AoFaceData getCachedFaceData(BlockPosImpl pos, ForgeDirection face, boolean offset) {
|
||||
private AoFaceData getCachedFaceData(BlockPos pos, ForgeDirection face, boolean offset) {
|
||||
|
||||
final AoFaceData data = this.cachedFaceData[offset ? face.ordinal() : face.ordinal() + 6];
|
||||
|
||||
|
||||
@@ -1,162 +0,0 @@
|
||||
package me.jellysquid.mods.sodium.client.model.quad;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import static me.jellysquid.mods.sodium.client.util.ModelQuadUtil.COLOR_INDEX;
|
||||
import static me.jellysquid.mods.sodium.client.util.ModelQuadUtil.LIGHT_INDEX;
|
||||
import static me.jellysquid.mods.sodium.client.util.ModelQuadUtil.NORMAL_INDEX;
|
||||
import static me.jellysquid.mods.sodium.client.util.ModelQuadUtil.POSITION_INDEX;
|
||||
import static me.jellysquid.mods.sodium.client.util.ModelQuadUtil.TEXTURE_INDEX;
|
||||
import static me.jellysquid.mods.sodium.client.util.ModelQuadUtil.VERTEX_SIZE;
|
||||
import static me.jellysquid.mods.sodium.client.util.ModelQuadUtil.vertexOffset;
|
||||
|
||||
/**
|
||||
* A simple implementation of the {@link ModelQuadViewMutable} interface which can provide an on-heap scratch area
|
||||
* for storing quad vertex data.
|
||||
*/
|
||||
public class ModelQuad implements ModelQuadViewMutable {
|
||||
private final int[] data = new int[VERTEX_SIZE * 4];
|
||||
private int flags;
|
||||
|
||||
private TextureAtlasSprite sprite;
|
||||
private int colorIdx;
|
||||
|
||||
@Override
|
||||
public void setX(int idx, float x) {
|
||||
this.data[vertexOffset(idx) + POSITION_INDEX] = Float.floatToRawIntBits(x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setY(int idx, float y) {
|
||||
this.data[vertexOffset(idx) + POSITION_INDEX + 1] = Float.floatToRawIntBits(y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setZ(int idx, float z) {
|
||||
this.data[vertexOffset(idx) + POSITION_INDEX + 2] = Float.floatToRawIntBits(z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(int idx, int color) {
|
||||
this.data[vertexOffset(idx) + COLOR_INDEX] = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTexU(int idx, float u) {
|
||||
this.data[vertexOffset(idx) + TEXTURE_INDEX] = Float.floatToRawIntBits(u);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTexV(int idx, float v) {
|
||||
this.data[vertexOffset(idx) + TEXTURE_INDEX + 1] = Float.floatToRawIntBits(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLight(int idx, int light) {
|
||||
this.data[vertexOffset(idx) + LIGHT_INDEX] = light;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNormal(int idx, int norm) {
|
||||
this.data[vertexOffset(idx) + NORMAL_INDEX] = norm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlags(int flags) {
|
||||
this.flags = flags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSprite(TextureAtlasSprite sprite) {
|
||||
this.sprite = sprite;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorIndex(int index) {
|
||||
this.colorIdx = index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Doesn't do anything useful, but I'm not sure if it has to.
|
||||
*/
|
||||
@Override
|
||||
public void setCullFace(ForgeDirection f) {}
|
||||
|
||||
@Override
|
||||
public int getLight(int idx) {
|
||||
return this.data[vertexOffset(idx) + LIGHT_INDEX];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNormal(int idx) {
|
||||
return this.data[vertexOffset(idx) + NORMAL_INDEX];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColorIndex() {
|
||||
return this.colorIdx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Doesn't do anything useful, but I'm not sure if it has to.
|
||||
*/
|
||||
@Override
|
||||
public ForgeDirection getLightFace() {
|
||||
return ForgeDirection.UP;
|
||||
}
|
||||
|
||||
/**
|
||||
* Doesn't do anything useful, but I'm not sure if it has to.
|
||||
*/
|
||||
@Override
|
||||
public ForgeDirection getCullFace() {
|
||||
return ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getX(int idx) {
|
||||
return Float.intBitsToFloat(this.data[vertexOffset(idx) + POSITION_INDEX]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getY(int idx) {
|
||||
return Float.intBitsToFloat(this.data[vertexOffset(idx) + POSITION_INDEX + 1]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getZ(int idx) {
|
||||
return Float.intBitsToFloat(this.data[vertexOffset(idx) + POSITION_INDEX + 2]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor(int idx) {
|
||||
if(vertexOffset(idx) + COLOR_INDEX < data.length) {
|
||||
return this.data[vertexOffset(idx) + COLOR_INDEX];
|
||||
}
|
||||
else {
|
||||
return data.length;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTexU(int idx) {
|
||||
return Float.intBitsToFloat(this.data[vertexOffset(idx) + TEXTURE_INDEX]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTexV(int idx) {
|
||||
return Float.intBitsToFloat(this.data[vertexOffset(idx) + TEXTURE_INDEX + 1]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return this.flags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite rubidium$getSprite() {
|
||||
return this.sprite;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
package me.jellysquid.mods.sodium.client.model.quad;
|
||||
|
||||
import com.gtnewhorizons.angelica.models.NdQuadBuilder;
|
||||
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadFlags;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
* Provides a read-only view of a model quad. For mutable access to a model quad, see {@link ModelQuadViewMutable}.
|
||||
*/
|
||||
public interface ModelQuadView {
|
||||
/**
|
||||
* @return The x-position of the vertex at index {@param idx}
|
||||
*/
|
||||
float getX(int idx);
|
||||
|
||||
/**
|
||||
* @return The y-position of the vertex at index {@param idx}
|
||||
*/
|
||||
float getY(int idx);
|
||||
|
||||
/**
|
||||
* @return The z-position of the vertex at index {@param idx}
|
||||
*/
|
||||
float getZ(int idx);
|
||||
|
||||
/**
|
||||
* @return The integer-encoded color (ABGR?) of the vertex at index {@param idx}
|
||||
*/
|
||||
int getColor(int idx);
|
||||
|
||||
/**
|
||||
* @return The texture x-coordinate for the vertex at index {@param idx}
|
||||
*/
|
||||
float getTexU(int idx);
|
||||
|
||||
/**
|
||||
* @return The texture y-coordinate for the vertex at index {@param idx}
|
||||
*/
|
||||
float getTexV(int idx);
|
||||
|
||||
/**
|
||||
* @return The integer bit flags containing the {@link ModelQuadFlags} for this quad
|
||||
*/
|
||||
int getFlags();
|
||||
|
||||
/**
|
||||
* @return The lightmap texture coordinates for the vertex at index {@param idx}
|
||||
*/
|
||||
int getLight(int idx);
|
||||
|
||||
/**
|
||||
* @return The integer-encoded normal vector for the vertex at index {@param idx}
|
||||
*/
|
||||
int getNormal(int idx);
|
||||
|
||||
/**
|
||||
* @return The color index of this quad.
|
||||
*/
|
||||
int getColorIndex();
|
||||
|
||||
/**
|
||||
* If not {@link ForgeDirection#UNKNOWN}, quad should not be rendered in-world if the
|
||||
* opposite face of a neighbor block occludes it.
|
||||
*
|
||||
* @see NdQuadBuilder#cullFace(ForgeDirection)
|
||||
*/
|
||||
ForgeDirection getCullFace();
|
||||
|
||||
/**
|
||||
* This is the face used for vanilla lighting calculations and will be the block face
|
||||
* to which the quad is most closely aligned. Always the same as cull face for quads
|
||||
* that are on a block face, but never {@link ForgeDirection#UNKNOWN} or null.
|
||||
*/
|
||||
ForgeDirection getLightFace();
|
||||
|
||||
/**
|
||||
* Copies this quad's data into the specified buffer starting at the given position.
|
||||
* @param buf The buffer to write this quad's data to
|
||||
* @param position The starting byte index to write to
|
||||
*/
|
||||
default void copyInto(ByteBuffer buf, int position) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
buf.putFloat(position, this.getX(i));
|
||||
buf.putFloat(position + 4, this.getY(i));
|
||||
buf.putFloat(position + 8, this.getZ(i));
|
||||
buf.putInt(position + 12, this.getColor(i));
|
||||
buf.putFloat(position + 16, this.getTexU(i));
|
||||
buf.putFloat(position + 20, this.getTexV(i));
|
||||
buf.putInt(position + 24, this.getLight(i));
|
||||
|
||||
position += 28;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The sprite texture used by this quad, or null if none is attached
|
||||
*/
|
||||
TextureAtlasSprite rubidium$getSprite();
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
package me.jellysquid.mods.sodium.client.model.quad;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadFlags;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Provides a mutable view to a model quad.
|
||||
*/
|
||||
public interface ModelQuadViewMutable extends ModelQuadView {
|
||||
/**
|
||||
* Sets the x-position of the vertex at index {@param idx} to the value {@param x}
|
||||
*/
|
||||
void setX(int idx, float x);
|
||||
|
||||
/**
|
||||
* Sets the y-position of the vertex at index {@param idx} to the value {@param y}
|
||||
*/
|
||||
void setY(int idx, float y);
|
||||
|
||||
/**
|
||||
* Sets the z-position of the vertex at index {@param idx} to the value {@param z}
|
||||
*/
|
||||
void setZ(int idx, float z);
|
||||
|
||||
/**
|
||||
* Sets the integer-encoded color of the vertex at index {@param idx} to the value {@param color}
|
||||
*/
|
||||
void setColor(int idx, int color);
|
||||
|
||||
/**
|
||||
* Convenience: set vertex color for all vertices at once.
|
||||
*/
|
||||
default void setColors(int abgr) {
|
||||
this.setColor(0, abgr);
|
||||
this.setColor(1, abgr);
|
||||
this.setColor(2, abgr);
|
||||
this.setColor(3, abgr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the texture x-coordinate of the vertex at index {@param idx} to the value {@param u}
|
||||
*/
|
||||
void setTexU(int idx, float u);
|
||||
|
||||
/**
|
||||
* Sets the texture y-coordinate of the vertex at index {@param idx} to the value {@param v}
|
||||
*/
|
||||
void setTexV(int idx, float v);
|
||||
|
||||
/**
|
||||
* Sets the light map texture coordinate of the vertex at index {@param idx} to the value {@param light}
|
||||
*/
|
||||
void setLight(int idx, int light);
|
||||
|
||||
/**
|
||||
* Sets the integer-encoded normal vector of the vertex at index {@param idx} to the value {@param light}
|
||||
*/
|
||||
void setNormal(int idx, int norm);
|
||||
|
||||
/**
|
||||
* Sets the bit-flag field which contains the {@link ModelQuadFlags} for this quad
|
||||
*/
|
||||
void setFlags(int flags);
|
||||
|
||||
/**
|
||||
* Sets the sprite used by this quad
|
||||
*/
|
||||
void setSprite(TextureAtlasSprite sprite);
|
||||
|
||||
/**
|
||||
* Sets the color index used by this quad
|
||||
*/
|
||||
void setColorIndex(int index);
|
||||
|
||||
/**
|
||||
* If not {@link ForgeDirection#UNKNOWN}, quad is coplanar with a block face which, if known, simplifies
|
||||
* or shortcuts geometric analysis that might otherwise be needed.
|
||||
* Set to {@link ForgeDirection#UNKNOWN} if quad is not coplanar or if this is not known.
|
||||
* Also controls face culling during block rendering.
|
||||
*
|
||||
* <p>{@link ForgeDirection#UNKNOWN} by default.
|
||||
*
|
||||
* <p>This is different from the value reported by {@link Quad#getLightFace()}. That value
|
||||
* is computed based on face geometry and must be non-{@link ForgeDirection#UNKNOWN} in vanilla quads.
|
||||
* That computed value is returned by {@link #getLightFace()}.
|
||||
*/
|
||||
void setCullFace(ForgeDirection dir);
|
||||
}
|
||||
@@ -1,325 +0,0 @@
|
||||
package me.jellysquid.mods.sodium.client.model.quad;
|
||||
|
||||
import com.gtnewhorizons.angelica.api.QuadView;
|
||||
import lombok.Getter;
|
||||
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadFlags;
|
||||
import me.jellysquid.mods.sodium.client.render.pipeline.BlockRenderer;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import org.joml.Vector3f;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Roughly equivalent to 16.5's BakedQuadView and BakedQuadMixin
|
||||
*/
|
||||
public class Quad implements QuadView {
|
||||
// Adapted from Neodymium
|
||||
|
||||
public static final int VERTEX_STRIDE = 8;
|
||||
public static final int QUAD_STRIDE = VERTEX_STRIDE * 4;
|
||||
public static final int X_INDEX = 0;
|
||||
public static final int Y_INDEX = 1;
|
||||
public static final int Z_INDEX = 2;
|
||||
public static final int U_INDEX = 3;
|
||||
public static final int V_INDEX = 4;
|
||||
public static final int COLOR_INDEX = 5;
|
||||
public static final int NORMAL_INDEX = 6;
|
||||
public static final int LIGHTMAP_INDEX = 7;
|
||||
|
||||
private final static int DEFAULT_LIGHTMAP = 15 << 20 | 15 << 4;
|
||||
private final static int DEFAULT_COLOR = 0xFFFFFFFF;
|
||||
|
||||
protected final int[] data = new int[QUAD_STRIDE];
|
||||
|
||||
@Getter
|
||||
private boolean deleted = false;
|
||||
|
||||
private final Vector3f vectorA = new Vector3f(), vectorB = new Vector3f(), vectorC = new Vector3f();
|
||||
|
||||
@Getter
|
||||
private boolean shade;
|
||||
private int cachedFlags;
|
||||
@Getter
|
||||
private ForgeDirection face;
|
||||
private int colorIndex = -1;
|
||||
private TextureAtlasSprite sprite = null;
|
||||
|
||||
/** Returns the face, forced to take one of 6 directions to mirror the behavior of baked quads in 1.16.5. */
|
||||
@Override
|
||||
public ForgeDirection getLightFace() {
|
||||
return this.face != ForgeDirection.UNKNOWN ? this.face : ForgeDirection.UP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getCullFace() {
|
||||
return this.face;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getX(int idx) {
|
||||
return Float.intBitsToFloat(this.data[idx * VERTEX_STRIDE + X_INDEX]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getY(int idx) {
|
||||
return Float.intBitsToFloat(this.data[idx * VERTEX_STRIDE + Y_INDEX]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getZ(int idx) {
|
||||
return Float.intBitsToFloat(this.data[idx * VERTEX_STRIDE + Z_INDEX]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTexU(int idx) {
|
||||
return Float.intBitsToFloat(this.data[idx * VERTEX_STRIDE + U_INDEX]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTexV(int idx) {
|
||||
return Float.intBitsToFloat(this.data[idx * VERTEX_STRIDE + V_INDEX]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor(int idx) {
|
||||
return this.data[idx * VERTEX_STRIDE + COLOR_INDEX];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLight(int idx) {
|
||||
return this.data[idx * VERTEX_STRIDE + LIGHTMAP_INDEX];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNormal(int idx) {
|
||||
return this.data[idx * VERTEX_STRIDE + NORMAL_INDEX];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return this.cachedFlags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColorIndex() {
|
||||
return this.colorIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite rubidium$getSprite() {
|
||||
return this.sprite;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setCullFace(ForgeDirection face) {
|
||||
this.face = face;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setX(int idx, float x) {
|
||||
this.data[idx * VERTEX_STRIDE + X_INDEX] = Float.floatToRawIntBits(x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setY(int idx, float y) {
|
||||
this.data[idx * VERTEX_STRIDE + Y_INDEX] = Float.floatToRawIntBits(y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setZ(int idx, float z) {
|
||||
this.data[idx * VERTEX_STRIDE + Z_INDEX] = Float.floatToRawIntBits(z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTexU(int idx, float u) {
|
||||
this.data[idx * VERTEX_STRIDE + U_INDEX] = Float.floatToRawIntBits(u);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTexV(int idx, float v) {
|
||||
this.data[idx * VERTEX_STRIDE + V_INDEX] = Float.floatToRawIntBits(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(int idx, int c) {
|
||||
this.data[idx * VERTEX_STRIDE + COLOR_INDEX] = c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLight(int idx, int l) {
|
||||
this.data[idx * VERTEX_STRIDE + LIGHTMAP_INDEX] = l;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNormal(int idx, int n) {
|
||||
this.data[idx * VERTEX_STRIDE + NORMAL_INDEX] = n;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlags(int flags) {
|
||||
this.cachedFlags = flags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorIndex(int i) {
|
||||
this.colorIndex = i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSprite(TextureAtlasSprite sprite) {
|
||||
this.sprite = sprite;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getRawData() {
|
||||
return this.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience: access x, y, z by index 0-2.
|
||||
*/
|
||||
private float posByIndex(int vertexIndex, int coordinateIndex) {
|
||||
return Float.intBitsToFloat(this.data[vertexIndex * VERTEX_STRIDE + coordinateIndex]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience: access x, y, z by index 0-2.
|
||||
*/
|
||||
private void setPosByIndex(int vertexIndex, int coordinateIndex, float val) {
|
||||
this.data[vertexIndex * VERTEX_STRIDE + coordinateIndex] = Float.floatToRawIntBits(val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Offset all xs, ys, or zs by index 0-2.
|
||||
*/
|
||||
private void offsetPos(int idx, float offset) {
|
||||
this.setPosByIndex(0, idx, this.posByIndex(0, idx) + offset);
|
||||
this.setPosByIndex(1, idx, this.posByIndex(1, idx) + offset);
|
||||
this.setPosByIndex(2, idx, this.posByIndex(2, idx) + offset);
|
||||
this.setPosByIndex(3, idx, this.posByIndex(3, idx) + offset);
|
||||
}
|
||||
|
||||
private void clearNormals() {
|
||||
this.setNormal(0, 0);
|
||||
this.setNormal(1, 0);
|
||||
this.setNormal(2, 0);
|
||||
this.setNormal(3, 0);
|
||||
}
|
||||
|
||||
private void clearLight() {
|
||||
this.setLight(0, DEFAULT_LIGHTMAP);
|
||||
this.setLight(1, DEFAULT_LIGHTMAP);
|
||||
this.setLight(2, DEFAULT_LIGHTMAP);
|
||||
this.setLight(3, DEFAULT_LIGHTMAP);
|
||||
}
|
||||
|
||||
private boolean isEmpty() {
|
||||
return this.getX(0) == this.getX(1)
|
||||
&& this.getX(1) == this.getX(2)
|
||||
&& this.getX(2) == this.getX(3)
|
||||
&& this.getY(0) == this.getY(1)
|
||||
&& this.getY(1) == this.getY(2)
|
||||
&& this.getY(2) == this.getY(3);
|
||||
}
|
||||
|
||||
private void calcNormal() {
|
||||
this.vectorA.set(
|
||||
this.getX(1) - this.getX(0),
|
||||
this.getY(1) - this.getY(0),
|
||||
this.getZ(1) - this.getZ(0)
|
||||
);
|
||||
this.vectorB.set(
|
||||
this.getX(2) - this.getX(1),
|
||||
this.getY(2) - this.getY(1),
|
||||
this.getZ(2) - this.getZ(1)
|
||||
);
|
||||
this.vectorA.cross(this.vectorB, this.vectorC);
|
||||
}
|
||||
|
||||
protected void quadrangulate() {
|
||||
this.setX(3, this.getX(2));
|
||||
this.setY(3, this.getY(2));
|
||||
this.setZ(3, this.getZ(2));
|
||||
|
||||
this.setTexU(3, this.getTexU(2));
|
||||
this.setTexV(3, this.getTexV(2));
|
||||
|
||||
this.setLight(3, this.getLight(2));
|
||||
this.setColor(3, this.getColor(2));
|
||||
this.setNormal(3, this.getNormal(2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public QuadView copyFrom(QuadView quad) {
|
||||
|
||||
System.arraycopy(quad.getRawData(), 0, this.data, 0, QUAD_STRIDE);
|
||||
|
||||
this.deleted = quad.isDeleted();
|
||||
this.shade = quad.isShade();
|
||||
this.face = quad.getFace();
|
||||
this.colorIndex = quad.getColorIndex();
|
||||
this.cachedFlags = quad.getFlags();
|
||||
this.sprite = quad.rubidium$getSprite();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private void read(int[] rawBuffer, int offset, float offsetX, float offsetY, float offsetZ, int drawMode, BlockRenderer.Flags flags) {
|
||||
System.arraycopy(rawBuffer, offset, this.data, 0, QUAD_STRIDE);
|
||||
|
||||
if (offsetX != 0) this.offsetPos(0, offsetX);
|
||||
if (offsetY != 0) this.offsetPos(1, offsetY);
|
||||
if (offsetZ != 0) this.offsetPos(2, offsetZ);
|
||||
|
||||
if (!flags.hasColor) this.setColors(DEFAULT_COLOR);
|
||||
if (!flags.hasNormals) this.clearNormals();
|
||||
if (!flags.hasBrightness) this.clearLight();
|
||||
|
||||
// sus
|
||||
this.shade = flags.hasBrightness;
|
||||
|
||||
if (drawMode == GL11.GL_TRIANGLES) this.quadrangulate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setState(int[] rawBuffer, int offset, BlockRenderer.Flags flags, int drawMode, float offsetX, float offsetY, float offsetZ) {
|
||||
this.deleted = false;
|
||||
|
||||
read(rawBuffer, offset, offsetX, offsetY, offsetZ, drawMode, flags);
|
||||
|
||||
if (this.isEmpty()) {
|
||||
// ignore empty quads (e.g. alpha pass of EnderIO item conduits)
|
||||
this.deleted = true;
|
||||
return;
|
||||
}
|
||||
|
||||
this.calcNormal();
|
||||
this.face = ModelQuadFacing.toDirection(ModelQuadFacing.fromVector(this.vectorC));
|
||||
this.cachedFlags = ModelQuadFlags.getQuadFlags(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
Locale.ENGLISH,
|
||||
"%s[(%.1f, %.1f, %.1f), (%.1f, %.1f, %.1f), (%.1f, %.1f, %.1f), (%.1f, %.1f, %.1f)]",
|
||||
this.deleted ? "XXX " : "",
|
||||
this.getX(0),
|
||||
this.getY(0),
|
||||
this.getZ(0),
|
||||
this.getX(1),
|
||||
this.getY(1),
|
||||
this.getZ(1),
|
||||
this.getX(2),
|
||||
this.getY(2),
|
||||
this.getZ(2),
|
||||
this.getX(3),
|
||||
this.getY(3),
|
||||
this.getZ(3)
|
||||
);
|
||||
}
|
||||
}
|
||||
-78
@@ -1,78 +0,0 @@
|
||||
package me.jellysquid.mods.sodium.client.model.quad.properties;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
public enum ModelQuadFacing {
|
||||
UP,
|
||||
DOWN,
|
||||
EAST,
|
||||
WEST,
|
||||
SOUTH,
|
||||
NORTH,
|
||||
UNASSIGNED;
|
||||
|
||||
public static final ModelQuadFacing[] VALUES = ModelQuadFacing.values();
|
||||
public static final int COUNT = VALUES.length;
|
||||
|
||||
public static ModelQuadFacing fromDirection(ForgeDirection dir) {
|
||||
return switch (dir) {
|
||||
case DOWN -> DOWN;
|
||||
case UP -> UP;
|
||||
case NORTH -> NORTH;
|
||||
case SOUTH -> SOUTH;
|
||||
case WEST -> WEST;
|
||||
case EAST -> EAST;
|
||||
default -> UNASSIGNED;
|
||||
};
|
||||
}
|
||||
|
||||
public static ForgeDirection toDirection(ModelQuadFacing dir) {
|
||||
return switch (dir) {
|
||||
case DOWN -> ForgeDirection.DOWN;
|
||||
case UP -> ForgeDirection.UP;
|
||||
case NORTH -> ForgeDirection.NORTH;
|
||||
case SOUTH -> ForgeDirection.SOUTH;
|
||||
case WEST -> ForgeDirection.WEST;
|
||||
case EAST -> ForgeDirection.EAST;
|
||||
default -> ForgeDirection.UNKNOWN;
|
||||
};
|
||||
}
|
||||
|
||||
public static ModelQuadFacing fromVector(Vector3f normal) {
|
||||
if(normal.x == 0f) {
|
||||
if(normal.y == 0f) {
|
||||
if(normal.z > 0) {
|
||||
return SOUTH;
|
||||
} else if(normal.z < 0) {
|
||||
return NORTH;
|
||||
}
|
||||
} else if(normal.z == 0f) {
|
||||
if(normal.y > 0) {
|
||||
return UP;
|
||||
} else if(normal.y < 0) {
|
||||
return DOWN;
|
||||
}
|
||||
}
|
||||
} else if(normal.y == 0f && (normal.z == 0f)) {
|
||||
if(normal.x > 0) {
|
||||
return EAST;
|
||||
} else if(normal.x < 0) {
|
||||
return WEST;
|
||||
}
|
||||
}
|
||||
return UNASSIGNED;
|
||||
}
|
||||
|
||||
public ModelQuadFacing getOpposite() {
|
||||
return switch (this) {
|
||||
case UP -> DOWN;
|
||||
case DOWN -> UP;
|
||||
case EAST -> WEST;
|
||||
case WEST -> EAST;
|
||||
case SOUTH -> NORTH;
|
||||
case NORTH -> SOUTH;
|
||||
default -> UNASSIGNED;
|
||||
};
|
||||
}
|
||||
}
|
||||
-100
@@ -1,100 +0,0 @@
|
||||
package me.jellysquid.mods.sodium.client.model.quad.properties;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.Axis;
|
||||
import me.jellysquid.mods.sodium.client.model.quad.ModelQuadView;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class ModelQuadFlags {
|
||||
/**
|
||||
* Indicates that the quad does not fully cover the given face for the model.
|
||||
*/
|
||||
public static final int IS_PARTIAL = 0b001;
|
||||
|
||||
/**
|
||||
* Indicates that the quad is parallel to its light face.
|
||||
*/
|
||||
public static final int IS_PARALLEL = 0b010;
|
||||
|
||||
/**
|
||||
* Indicates that the quad is aligned to the block grid.
|
||||
* This flag is only set if {@link #IS_PARALLEL} is set.
|
||||
*/
|
||||
public static final int IS_ALIGNED = 0b100;
|
||||
|
||||
/**
|
||||
* @return True if the bit-flag of {@link ModelQuadFlags} contains the given flag
|
||||
*/
|
||||
public static boolean contains(int flags, int mask) {
|
||||
return (flags & mask) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the properties of the given quad. This data is used later by the light pipeline in order to make
|
||||
* certain optimizations.
|
||||
*/
|
||||
public static int getQuadFlags(ModelQuadView quad) {
|
||||
final ForgeDirection face = quad.getLightFace();
|
||||
final Axis axis = Axis.fromDirection(ModelQuadFacing.fromDirection(face));
|
||||
|
||||
float minX = 32.0F;
|
||||
float minY = 32.0F;
|
||||
float minZ = 32.0F;
|
||||
|
||||
float maxX = -32.0F;
|
||||
float maxY = -32.0F;
|
||||
float maxZ = -32.0F;
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
float x = quad.getX(i);
|
||||
float y = quad.getY(i);
|
||||
float z = quad.getZ(i);
|
||||
|
||||
minX = Math.min(minX, x);
|
||||
minY = Math.min(minY, y);
|
||||
minZ = Math.min(minZ, z);
|
||||
maxX = Math.max(maxX, x);
|
||||
maxY = Math.max(maxY, y);
|
||||
maxZ = Math.max(maxZ, z);
|
||||
}
|
||||
|
||||
boolean partial = switch (axis) {
|
||||
case X -> minY >= 0.0001f || minZ >= 0.0001f || maxY <= 0.9999F || maxZ <= 0.9999F;
|
||||
case Y -> minX >= 0.0001f || minZ >= 0.0001f || maxX <= 0.9999F || maxZ <= 0.9999F;
|
||||
case Z -> minX >= 0.0001f || minY >= 0.0001f || maxX <= 0.9999F || maxY <= 0.9999F;
|
||||
};
|
||||
|
||||
boolean parallel = switch (axis) {
|
||||
case X -> minX == maxX;
|
||||
case Y -> minY == maxY;
|
||||
case Z -> minZ == maxZ;
|
||||
};
|
||||
|
||||
boolean flag = switch (face) {
|
||||
case DOWN -> minY < 0.0001f;
|
||||
case UP -> maxY > 0.9999F;
|
||||
case NORTH -> minZ < 0.0001f;
|
||||
case SOUTH -> maxZ > 0.9999F;
|
||||
case WEST -> minX < 0.0001f;
|
||||
case EAST -> maxX > 0.9999F;
|
||||
default -> false;
|
||||
};
|
||||
|
||||
boolean aligned = parallel && flag;
|
||||
|
||||
int flags = 0;
|
||||
|
||||
if (partial) {
|
||||
flags |= IS_PARTIAL;
|
||||
}
|
||||
|
||||
if (parallel) {
|
||||
flags |= IS_PARALLEL;
|
||||
}
|
||||
|
||||
if (aligned) {
|
||||
flags |= IS_ALIGNED;
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
-35
@@ -1,35 +0,0 @@
|
||||
package me.jellysquid.mods.sodium.client.model.quad.properties;
|
||||
|
||||
/**
|
||||
* Defines the orientation of vertices in a model quad. This information be used to re-orient the quad's vertices to a
|
||||
* consistent order, eliminating a number of shading issues caused by anisotropy problems.
|
||||
*/
|
||||
public enum ModelQuadOrientation {
|
||||
NORMAL(new int[] { 0, 1, 2, 3 }),
|
||||
FLIP(new int[] { 1, 2, 3, 0 });
|
||||
|
||||
private final int[] indices;
|
||||
|
||||
ModelQuadOrientation(int[] indices) {
|
||||
this.indices = indices;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The re-oriented index of the vertex {@param idx}
|
||||
*/
|
||||
public int getVertexIndex(int idx) {
|
||||
return this.indices[idx];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the orientation of the vertices in the quad.
|
||||
*/
|
||||
public static ModelQuadOrientation orient(float[] brightnesses) {
|
||||
// If one side of the quad is brighter, flip the sides
|
||||
if (brightnesses[0] + brightnesses[2] > brightnesses[1] + brightnesses[3]) {
|
||||
return NORMAL;
|
||||
} else {
|
||||
return FLIP;
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -1,7 +1,9 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.glyph;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.DefaultVertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.DefaultVertexFormat;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.VertexFormat;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.VertexSink;
|
||||
import me.jellysquid.mods.sodium.client.util.math.Matrix4fExtended;
|
||||
import me.jellysquid.mods.sodium.client.util.math.MatrixUtil;
|
||||
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.glyph;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexConsumer;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.writer.GlyphVertexBufferWriterNio;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.writer.GlyphVertexBufferWriterUnsafe;
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.line;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.DefaultVertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.DefaultVertexFormat;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.VertexFormat;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.VertexSink;
|
||||
import me.jellysquid.mods.sodium.client.util.color.ColorABGR;
|
||||
|
||||
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.line;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexConsumer;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.line.writer.LineVertexBufferWriterNio;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.line.writer.LineVertexBufferWriterUnsafe;
|
||||
|
||||
+4
-2
@@ -1,7 +1,9 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.particle;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.DefaultVertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.DefaultVertexFormat;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.VertexFormat;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.VertexSink;
|
||||
|
||||
|
||||
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.particle;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexConsumer;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.particle.writer.ParticleVertexBufferWriterNio;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.particle.writer.ParticleVertexBufferWriterUnsafe;
|
||||
|
||||
+4
-2
@@ -1,8 +1,10 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.quad;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.DefaultVertexFormat;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.DefaultVertexFormat;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.MatrixStack;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.VertexSink;
|
||||
import me.jellysquid.mods.sodium.client.util.math.Matrix4fExtended;
|
||||
import me.jellysquid.mods.sodium.client.util.math.MatrixUtil;
|
||||
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.quad;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexConsumer;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.quad.writer.QuadVertexBufferWriterNio;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.quad.writer.QuadVertexBufferWriterUnsafe;
|
||||
|
||||
+4
-2
@@ -1,7 +1,9 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.screen_quad;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.DefaultVertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.DefaultVertexFormat;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.VertexFormat;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.VertexSink;
|
||||
import me.jellysquid.mods.sodium.client.util.math.Matrix4fExtended;
|
||||
import me.jellysquid.mods.sodium.client.util.math.MatrixUtil;
|
||||
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.screen_quad;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexConsumer;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.screen_quad.writer.BasicScreenQuadVertexBufferWriterNio;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.screen_quad.writer.BasicScreenQuadVertexBufferWriterUnsafe;
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.type;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.VertexFormat;
|
||||
import me.jellysquid.mods.sodium.client.gl.attribute.BufferVertexFormat;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.VertexSink;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk;
|
||||
|
||||
import me.jellysquid.mods.sodium.common.util.DirectionUtil;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.util.DirectionUtil;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class ChunkRenderColumn<T extends ChunkGraphicsState> {
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.BlockPosImpl;
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.ChunkSectionPos;
|
||||
import com.gtnewhorizons.angelica.utils.AnimationsRenderUtils;
|
||||
import lombok.Getter;
|
||||
@@ -265,8 +265,8 @@ public class ChunkRenderContainer<T extends ChunkGraphicsState> {
|
||||
return this.getOriginZ() + 8.0D;
|
||||
}
|
||||
|
||||
public BlockPosImpl getRenderOrigin() {
|
||||
return new BlockPosImpl(this.getRenderX(), this.getRenderY(), this.getRenderZ());
|
||||
public BlockPos getRenderOrigin() {
|
||||
return new BlockPos(this.getRenderX(), this.getRenderY(), this.getRenderZ());
|
||||
}
|
||||
|
||||
public void setGraphicsState(BlockRenderPass pass, T state) {
|
||||
|
||||
+1
-1
@@ -1,5 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.backends.multidraw;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayFIFOQueue;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
@@ -22,7 +23,6 @@ import me.jellysquid.mods.sodium.client.gl.tessellation.GlPrimitiveType;
|
||||
import me.jellysquid.mods.sodium.client.gl.tessellation.GlTessellation;
|
||||
import me.jellysquid.mods.sodium.client.gl.tessellation.TessellationBinding;
|
||||
import me.jellysquid.mods.sodium.client.gl.util.BufferSlice;
|
||||
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.type.ChunkVertexType;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.ChunkCameraContext;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.ChunkRenderContainer;
|
||||
|
||||
+1
-1
@@ -1,10 +1,10 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.backends.multidraw;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.gl.arena.GlBufferSegment;
|
||||
import me.jellysquid.mods.sodium.client.gl.attribute.GlVertexFormat;
|
||||
import me.jellysquid.mods.sodium.client.gl.device.CommandList;
|
||||
import me.jellysquid.mods.sodium.client.gl.util.BufferSlice;
|
||||
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.ChunkGraphicsState;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.ChunkRenderContainer;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.data.ChunkMeshData;
|
||||
|
||||
+1
-1
@@ -1,5 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.backends.oneshot;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import me.jellysquid.mods.sodium.client.gl.attribute.GlVertexAttributeBinding;
|
||||
import me.jellysquid.mods.sodium.client.gl.attribute.GlVertexFormat;
|
||||
@@ -12,7 +13,6 @@ import me.jellysquid.mods.sodium.client.gl.tessellation.GlPrimitiveType;
|
||||
import me.jellysquid.mods.sodium.client.gl.tessellation.GlTessellation;
|
||||
import me.jellysquid.mods.sodium.client.gl.tessellation.TessellationBinding;
|
||||
import me.jellysquid.mods.sodium.client.gl.util.BufferSlice;
|
||||
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.ChunkGraphicsState;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.ChunkRenderContainer;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.data.ChunkMeshData;
|
||||
|
||||
+1
-1
@@ -1,11 +1,11 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.backends.oneshot;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.gl.device.CommandList;
|
||||
import me.jellysquid.mods.sodium.client.gl.device.DrawCommandList;
|
||||
import me.jellysquid.mods.sodium.client.gl.device.RenderDevice;
|
||||
import me.jellysquid.mods.sodium.client.gl.util.BufferSlice;
|
||||
import me.jellysquid.mods.sodium.client.gl.util.GlMultiDrawBatch;
|
||||
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.type.ChunkVertexType;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.ChunkCameraContext;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.ChunkRenderContainer;
|
||||
|
||||
+1
-1
@@ -1,12 +1,12 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.compile;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import lombok.Getter;
|
||||
import me.jellysquid.mods.sodium.client.SodiumClientMod;
|
||||
import me.jellysquid.mods.sodium.client.gl.buffer.VertexData;
|
||||
import me.jellysquid.mods.sodium.client.gl.util.BufferSlice;
|
||||
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferBuilder;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.type.ChunkVertexType;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.compile.buffers.BakedChunkModelBuffers;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.compile.buffers;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.data.ChunkRenderData;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.format.ModelVertexSink;
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.compile.buffers;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.data.ChunkRenderData;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.format.ModelVertexSink;
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.compile.buffers;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.data.ChunkRenderData;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.format.ModelVertexSink;
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.cull;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
|
||||
public class ChunkFaceFlags {
|
||||
public static final int UP = of(ModelQuadFacing.UP);
|
||||
|
||||
+14
-14
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.cull.graph;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.BlockPosImpl;
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.Camera;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.ChunkOcclusionData;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.ChunkSectionPos;
|
||||
@@ -76,24 +76,24 @@ public class ChunkGraphCuller implements ChunkCuller {
|
||||
|
||||
this.visible.clear();
|
||||
|
||||
BlockPosImpl origin = camera.getBlockPos();
|
||||
final BlockPos origin = camera.getBlockPos();
|
||||
|
||||
int chunkX = origin.getX() >> 4;
|
||||
final int chunkX = origin.getX() >> 4;
|
||||
int chunkY = origin.getY() >> 4;
|
||||
int chunkZ = origin.getZ() >> 4;
|
||||
final int chunkZ = origin.getZ() >> 4;
|
||||
|
||||
this.centerChunkX = chunkX;
|
||||
this.centerChunkY = chunkY;
|
||||
this.centerChunkZ = chunkZ;
|
||||
|
||||
ChunkGraphNode rootNode = this.getNode(chunkX, chunkY, chunkZ);
|
||||
final ChunkGraphNode rootNode = this.getNode(chunkX, chunkY, chunkZ);
|
||||
|
||||
if (rootNode != null) {
|
||||
rootNode.resetCullingState();
|
||||
rootNode.setLastVisibleFrame(frame);
|
||||
|
||||
if (spectator) {
|
||||
Block block = this.world.getBlock(origin.getX(), origin.getY(), origin.getZ());
|
||||
final Block block = this.world.getBlock(origin.getX(), origin.getY(), origin.getZ());
|
||||
if(block.isOpaqueCube()) {
|
||||
this.useOcclusionCulling = false;
|
||||
}
|
||||
@@ -103,11 +103,11 @@ public class ChunkGraphCuller implements ChunkCuller {
|
||||
} else {
|
||||
chunkY = MathHelper.clamp_int(origin.getY() >> 4, 0, 15);
|
||||
|
||||
List<ChunkGraphNode> bestNodes = new ArrayList<>();
|
||||
final List<ChunkGraphNode> bestNodes = new ArrayList<>();
|
||||
|
||||
for (int x2 = -this.renderDistance; x2 <= this.renderDistance; ++x2) {
|
||||
for (int z2 = -this.renderDistance; z2 <= this.renderDistance; ++z2) {
|
||||
ChunkGraphNode node = this.getNode(chunkX + x2, chunkY, chunkZ + z2);
|
||||
final ChunkGraphNode node = this.getNode(chunkX + x2, chunkY, chunkZ + z2);
|
||||
|
||||
if (node == null || node.isCulledByFrustum(frustum)) {
|
||||
continue;
|
||||
@@ -148,7 +148,7 @@ public class ChunkGraphCuller implements ChunkCuller {
|
||||
|
||||
private void connectNeighborNodes(ChunkGraphNode node) {
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
ChunkGraphNode adj = this.findAdjacentNode(node, dir);
|
||||
final ChunkGraphNode adj = this.findAdjacentNode(node, dir);
|
||||
|
||||
if (adj != null) {
|
||||
adj.setAdjacentNode(dir.getOpposite(), node);
|
||||
@@ -160,7 +160,7 @@ public class ChunkGraphCuller implements ChunkCuller {
|
||||
|
||||
private void disconnectNeighborNodes(ChunkGraphNode node) {
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
ChunkGraphNode adj = node.getConnectedNode(dir);
|
||||
final ChunkGraphNode adj = node.getConnectedNode(dir);
|
||||
|
||||
if (adj != null) {
|
||||
adj.setAdjacentNode(dir.getOpposite(), null);
|
||||
@@ -189,8 +189,8 @@ public class ChunkGraphCuller implements ChunkCuller {
|
||||
|
||||
@Override
|
||||
public void onSectionLoaded(int x, int y, int z, int id) {
|
||||
ChunkGraphNode node = new ChunkGraphNode(x, y, z, id);
|
||||
ChunkGraphNode prev;
|
||||
final ChunkGraphNode node = new ChunkGraphNode(x, y, z, id);
|
||||
final ChunkGraphNode prev;
|
||||
|
||||
if ((prev = this.nodes.put(ChunkSectionPos.asLong(x, y, z), node)) != null) {
|
||||
this.disconnectNeighborNodes(prev);
|
||||
@@ -201,7 +201,7 @@ public class ChunkGraphCuller implements ChunkCuller {
|
||||
|
||||
@Override
|
||||
public void onSectionUnloaded(int x, int y, int z) {
|
||||
ChunkGraphNode node = this.nodes.remove(ChunkSectionPos.asLong(x, y, z));
|
||||
final ChunkGraphNode node = this.nodes.remove(ChunkSectionPos.asLong(x, y, z));
|
||||
|
||||
if (node != null) {
|
||||
this.disconnectNeighborNodes(node);
|
||||
@@ -210,7 +210,7 @@ public class ChunkGraphCuller implements ChunkCuller {
|
||||
|
||||
@Override
|
||||
public boolean isSectionVisible(int x, int y, int z) {
|
||||
ChunkGraphNode render = this.getNode(x, y, z);
|
||||
final ChunkGraphNode render = this.getNode(x, y, z);
|
||||
|
||||
if (render == null) {
|
||||
return false;
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.cull.graph;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.BlockPosImpl;
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.ChunkOcclusionData;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.data.ChunkRenderData;
|
||||
import me.jellysquid.mods.sodium.client.util.math.FrustumExtended;
|
||||
@@ -145,7 +145,7 @@ public class ChunkGraphNode {
|
||||
* @return The squared distance from the center of this chunk in the world to the center of the block position
|
||||
* given by {@param pos}
|
||||
*/
|
||||
public double getSquaredDistance(BlockPosImpl pos) {
|
||||
public double getSquaredDistance(BlockPos pos) {
|
||||
return this.getSquaredDistance(pos.x + 0.5D, pos.y + 0.5D, pos.z + 0.5D);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.data;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.gl.buffer.VertexData;
|
||||
import me.jellysquid.mods.sodium.client.gl.util.BufferSlice;
|
||||
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadFacing;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
||||
+1
-1
@@ -1,12 +1,12 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.data;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.ChunkOcclusionData;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ISpriteExt;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import lombok.Getter;
|
||||
import me.jellysquid.mods.sodium.client.gl.util.BufferSlice;
|
||||
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.passes.BlockRenderPass;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.region;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import me.jellysquid.mods.sodium.client.gl.arena.GlBufferArena;
|
||||
import me.jellysquid.mods.sodium.client.gl.device.CommandList;
|
||||
import me.jellysquid.mods.sodium.client.gl.device.RenderDevice;
|
||||
import me.jellysquid.mods.sodium.client.gl.tessellation.GlTessellation;
|
||||
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.ChunkGraphicsState;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.backends.multidraw.ChunkDrawCallBatcher;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.compile.ChunkBuildResult;
|
||||
|
||||
+7
-7
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.tasks;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.BlockPosImpl;
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.ChunkOcclusionDataBuilder;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ITexturesCache;
|
||||
@@ -48,7 +48,7 @@ import java.util.concurrent.ExecutionException;
|
||||
public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkRenderBuildTask<T> {
|
||||
private final ChunkRenderContainer<T> render;
|
||||
|
||||
private final BlockPosImpl offset;
|
||||
private final BlockPos offset;
|
||||
|
||||
private final ChunkRenderContext context;
|
||||
|
||||
@@ -56,7 +56,7 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
|
||||
private final boolean translucencySorting;
|
||||
|
||||
public ChunkRenderRebuildTask(ChunkRenderContainer<T> render, ChunkRenderContext context, BlockPosImpl offset) {
|
||||
public ChunkRenderRebuildTask(ChunkRenderContainer<T> render, ChunkRenderContext context, BlockPos offset) {
|
||||
this.render = render;
|
||||
this.offset = offset;
|
||||
this.context = context;
|
||||
@@ -122,8 +122,8 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
final int baseY = this.render.getOriginY();
|
||||
final int baseZ = this.render.getOriginZ();
|
||||
|
||||
final BlockPosImpl pos = new BlockPosImpl();
|
||||
final BlockPosImpl renderOffset = this.offset;
|
||||
final BlockPos pos = new BlockPos();
|
||||
final BlockPos renderOffset = this.offset;
|
||||
|
||||
final LongArrayFIFOQueue mainThreadBlocks = new LongArrayFIFOQueue();
|
||||
boolean hasMainThreadBlocks = false;
|
||||
@@ -241,11 +241,11 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
*/
|
||||
private void performMainBuild(ChunkRenderCacheLocal cache, ChunkBuildBuffers buffers, CancellationSource cancellationSource, ChunkRenderBounds.Builder bounds, ChunkRenderData.Builder renderData, LongArrayFIFOQueue mainThreadBlocks) {
|
||||
final WorldSlice slice = cache.getWorldSlice();
|
||||
final BlockPosImpl pos = new BlockPosImpl();
|
||||
final BlockPos pos = new BlockPos();
|
||||
final int baseX = this.render.getOriginX();
|
||||
final int baseY = this.render.getOriginY();
|
||||
final int baseZ = this.render.getOriginZ();
|
||||
final BlockPosImpl renderOffset = this.offset;
|
||||
final BlockPos renderOffset = this.offset;
|
||||
final RenderBlocks rb = new RenderBlocks(slice.getWorld());
|
||||
if(rb instanceof ITexturesCache) ((ITexturesCache)rb).enableTextureTracking();
|
||||
while(!mainThreadBlocks.isEmpty()) {
|
||||
|
||||
+4
-4
@@ -1,9 +1,9 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.tasks;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.BlockPosImpl;
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.gl.buffer.VertexData;
|
||||
import me.jellysquid.mods.sodium.client.gl.util.BufferSlice;
|
||||
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.ChunkGraphicsState;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.ChunkRenderContainer;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.compile.ChunkBufferSorter;
|
||||
@@ -32,10 +32,10 @@ public class ChunkRenderTranslucencySortTask<T extends ChunkGraphicsState> exten
|
||||
private static final BlockRenderPass[] NO_PASSES = new BlockRenderPass[0];
|
||||
|
||||
private final ChunkRenderContainer<T> render;
|
||||
private final BlockPosImpl offset;
|
||||
private final BlockPos offset;
|
||||
private final Vector3d camera;
|
||||
|
||||
public ChunkRenderTranslucencySortTask(ChunkRenderContainer<T> render, BlockPosImpl offset, Vector3d camera) {
|
||||
public ChunkRenderTranslucencySortTask(ChunkRenderContainer<T> render, BlockPos offset, Vector3d camera) {
|
||||
this.render = render;
|
||||
this.offset = offset;
|
||||
this.camera = camera;
|
||||
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
package me.jellysquid.mods.sodium.client.render.entity;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import net.minecraft.entity.Entity;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.BlockPosImpl;
|
||||
|
||||
public interface EntityLightSampler<T extends Entity> {
|
||||
int bridge$getBlockLight(T entity, BlockPosImpl pos);
|
||||
int bridge$getBlockLight(T entity, BlockPos pos);
|
||||
|
||||
int bridge$getSkyLight(T entity, BlockPosImpl pos);
|
||||
int bridge$getSkyLight(T entity, BlockPos pos);
|
||||
}
|
||||
+10
-13
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.occlusion;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.BlockPosImpl;
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ByteLinkedOpenHashMap;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
@@ -11,7 +11,7 @@ public class BlockOcclusionCache {
|
||||
|
||||
private final Object2ByteLinkedOpenHashMap<CachedOcclusionShapeTest> map;
|
||||
private final CachedOcclusionShapeTest cachedTest = new CachedOcclusionShapeTest();
|
||||
private final BlockPosImpl cpos = new BlockPosImpl();
|
||||
private final BlockPos cpos = new BlockPos();
|
||||
|
||||
public BlockOcclusionCache() {
|
||||
this.map = new Object2ByteLinkedOpenHashMap<>(2048, 0.5F);
|
||||
@@ -26,14 +26,14 @@ public class BlockOcclusionCache {
|
||||
* @param facing The facing direction of the side to check
|
||||
* @return True if the block side facing {@param dir} is not occluded, otherwise false
|
||||
*/
|
||||
public boolean shouldDrawSide(Block block, int meta, IBlockAccess view, BlockPosImpl pos, ForgeDirection facing) {
|
||||
public boolean shouldDrawSide(Block block, int meta, IBlockAccess view, BlockPos pos, ForgeDirection facing) {
|
||||
if (facing == ForgeDirection.UNKNOWN)
|
||||
return true;
|
||||
|
||||
BlockPosImpl adjPos = this.cpos;
|
||||
final BlockPos adjPos = this.cpos;
|
||||
adjPos.set(pos.getX() + facing.offsetX, pos.getY() + facing.offsetY, pos.getZ() + facing.offsetZ);
|
||||
|
||||
Block adjState = view.getBlock(adjPos.x, adjPos.y, adjPos.z);
|
||||
final Block adjState = view.getBlock(adjPos.x, adjPos.y, adjPos.z);
|
||||
|
||||
return !adjState.isOpaqueCube();
|
||||
|
||||
@@ -41,18 +41,18 @@ public class BlockOcclusionCache {
|
||||
}
|
||||
|
||||
private boolean calculate(Block selfShape, Block adjShape) {
|
||||
CachedOcclusionShapeTest cache = this.cachedTest;
|
||||
final CachedOcclusionShapeTest cache = this.cachedTest;
|
||||
cache.a = selfShape;
|
||||
cache.b = adjShape;
|
||||
cache.updateHash();
|
||||
|
||||
byte cached = this.map.getByte(cache);
|
||||
final byte cached = this.map.getByte(cache);
|
||||
|
||||
if (cached != UNCACHED_VALUE) {
|
||||
return cached == 1;
|
||||
}
|
||||
|
||||
boolean ret = adjShape.isOpaqueCube() && selfShape.isOpaqueCube();
|
||||
final boolean ret = adjShape.isOpaqueCube() && selfShape.isOpaqueCube();
|
||||
|
||||
this.map.put(cache.copy(), (byte) (ret ? 1 : 0));
|
||||
|
||||
@@ -90,11 +90,8 @@ public class BlockOcclusionCache {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof CachedOcclusionShapeTest) {
|
||||
CachedOcclusionShapeTest that = (CachedOcclusionShapeTest) o;
|
||||
|
||||
return this.a == that.a &&
|
||||
this.b == that.b;
|
||||
if (o instanceof CachedOcclusionShapeTest that) {
|
||||
return this.a == that.a && this.b == that.b;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package me.jellysquid.mods.sodium.client.render.pipeline;
|
||||
|
||||
import com.gtnewhorizons.angelica.api.QuadProvider;
|
||||
import com.gtnewhorizons.angelica.api.QuadView;
|
||||
import com.gtnewhorizons.angelica.client.renderer.CapturingTessellator;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.BlockPosImpl;
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.CapturingTessellator;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.TessellatorManager;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.QuadProvider;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.QuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadOrientation;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.util.DirectionUtil;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.glsm.TessellatorManager;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ModeledBlock;
|
||||
import com.gtnewhorizons.angelica.utils.ObjectPooler;
|
||||
import me.jellysquid.mods.sodium.client.SodiumClientMod;
|
||||
@@ -13,9 +16,8 @@ import me.jellysquid.mods.sodium.client.model.light.LightMode;
|
||||
import me.jellysquid.mods.sodium.client.model.light.LightPipeline;
|
||||
import me.jellysquid.mods.sodium.client.model.light.LightPipelineProvider;
|
||||
import me.jellysquid.mods.sodium.client.model.light.data.QuadLightData;
|
||||
import me.jellysquid.mods.sodium.client.model.quad.Quad;
|
||||
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadOrientation;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.Quad;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.compile.buffers.ChunkModelBuffers;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.data.ChunkRenderData;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.format.ModelVertexSink;
|
||||
@@ -23,7 +25,6 @@ import me.jellysquid.mods.sodium.client.render.occlusion.BlockOcclusionCache;
|
||||
import me.jellysquid.mods.sodium.client.util.ModelQuadUtil;
|
||||
import me.jellysquid.mods.sodium.client.util.color.ColorABGR;
|
||||
import me.jellysquid.mods.sodium.client.util.rand.XoRoShiRoRandom;
|
||||
import me.jellysquid.mods.sodium.common.util.DirectionUtil;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -48,6 +49,7 @@ public class BlockRenderer {
|
||||
private final LightPipelineProvider lighters;
|
||||
private final BlockOcclusionCache occlusionCache;
|
||||
|
||||
private Object Quad;
|
||||
private final ObjectPooler<QuadView> quadPool = new ObjectPooler<>(Quad::new);
|
||||
// TODO: Use modern model API, and store them here
|
||||
|
||||
@@ -60,7 +62,7 @@ public class BlockRenderer {
|
||||
this.occlusionCache = new BlockOcclusionCache();
|
||||
}
|
||||
|
||||
public boolean renderModel(IBlockAccess world, RenderBlocks renderBlocks, Block block, int meta, BlockPosImpl pos, ChunkModelBuffers buffers, boolean cull, long seed) {
|
||||
public boolean renderModel(IBlockAccess world, RenderBlocks renderBlocks, Block block, int meta, BlockPos pos, ChunkModelBuffers buffers, boolean cull, long seed) {
|
||||
final LightMode mode = LightMode.SMOOTH; // TODO: this.getLightingMode(block); is what was previously used. The flat pipeline is busted and was only an optimization for very few blocks.
|
||||
final LightPipeline lighter = this.lighters.getLighter(mode);
|
||||
|
||||
@@ -116,7 +118,7 @@ public class BlockRenderer {
|
||||
return rendered;
|
||||
}
|
||||
|
||||
private void renderQuadList(BlockPosImpl pos, LightPipeline lighter, ChunkModelBuffers buffers, List<QuadView> quads, ModelQuadFacing facing, boolean useSodiumLight) {
|
||||
private void renderQuadList(BlockPos pos, LightPipeline lighter, ChunkModelBuffers buffers, List<QuadView> quads, ModelQuadFacing facing, boolean useSodiumLight) {
|
||||
final ForgeDirection cullFace = ModelQuadFacing.toDirection(facing);
|
||||
|
||||
final ModelVertexSink sink = buffers.getSink(facing);
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
package me.jellysquid.mods.sodium.client.render.pipeline;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.BlockPosImpl;
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.ModelQuad;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.ModelQuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.ModelQuadViewMutable;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFlags;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.util.DirectionUtil;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.util.WorldUtil;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import me.jellysquid.mods.sodium.client.model.light.LightMode;
|
||||
import me.jellysquid.mods.sodium.client.model.light.LightPipeline;
|
||||
import me.jellysquid.mods.sodium.client.model.light.LightPipelineProvider;
|
||||
import me.jellysquid.mods.sodium.client.model.light.data.QuadLightData;
|
||||
import me.jellysquid.mods.sodium.client.model.quad.ModelQuad;
|
||||
import me.jellysquid.mods.sodium.client.model.quad.ModelQuadView;
|
||||
import me.jellysquid.mods.sodium.client.model.quad.ModelQuadViewMutable;
|
||||
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadFlags;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.compile.buffers.ChunkModelBuffers;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.format.ModelVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.util.Norm3b;
|
||||
import me.jellysquid.mods.sodium.client.util.color.ColorABGR;
|
||||
import me.jellysquid.mods.sodium.client.util.color.ColorARGB;
|
||||
import me.jellysquid.mods.sodium.client.world.WorldSlice;
|
||||
import me.jellysquid.mods.sodium.common.util.DirectionUtil;
|
||||
import me.jellysquid.mods.sodium.common.util.WorldUtil;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -38,7 +38,7 @@ public class FluidRenderer {
|
||||
private static final float EPSILON = 0.001f;
|
||||
private final LightPipelineProvider lpp;
|
||||
|
||||
private final BlockPosImpl scratchPos = new BlockPosImpl();
|
||||
private final BlockPos scratchPos = new BlockPos();
|
||||
|
||||
private final ModelQuadViewMutable quad = new ModelQuad();
|
||||
|
||||
@@ -71,7 +71,7 @@ public class FluidRenderer {
|
||||
}
|
||||
|
||||
private boolean isSideExposed(IBlockAccess world, int x, int y, int z, ForgeDirection dir, float height) {
|
||||
BlockPosImpl pos = this.scratchPos.set(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
|
||||
BlockPos pos = this.scratchPos.set(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
|
||||
Block block = world.getBlock(pos.x, pos.y, pos.z);
|
||||
|
||||
if (block.getMaterial().isOpaque()) {
|
||||
@@ -89,7 +89,7 @@ public class FluidRenderer {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean render(IBlockAccess world, WorldSlice slice, Block block, BlockPosImpl pos, ChunkModelBuffers buffers) {
|
||||
public boolean render(IBlockAccess world, WorldSlice slice, Block block, BlockPos pos, ChunkModelBuffers buffers) {
|
||||
this.useSeparateAo = AngelicaConfig.enableIris && BlockRenderingSettings.INSTANCE.shouldUseSeparateAo();
|
||||
|
||||
int posX = pos.x;
|
||||
@@ -356,7 +356,7 @@ public class FluidRenderer {
|
||||
return rendered;
|
||||
}
|
||||
|
||||
private void calculateQuadColors(ModelQuadView quad, BlockPosImpl pos, LightPipeline lighter, ForgeDirection dir, float brightness, boolean colorized, WorldSlice slice) {
|
||||
private void calculateQuadColors(ModelQuadView quad, BlockPos pos, LightPipeline lighter, ForgeDirection dir, float brightness, boolean colorized, WorldSlice slice) {
|
||||
QuadLightData light = this.quadLightData;
|
||||
lighter.calculate(quad, pos, light, null, dir, false);
|
||||
|
||||
@@ -441,7 +441,7 @@ public class FluidRenderer {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
BlockPosImpl pos = this.scratchPos.set(x2, y, z2);
|
||||
BlockPos pos = this.scratchPos.set(x2, y, z2);
|
||||
|
||||
block = world.getBlock(pos.x, pos.y, pos.z);
|
||||
int meta = world.getBlockMetadata(pos.x, pos.y, pos.z);
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
package me.jellysquid.mods.sodium.common.util;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadFacing;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.Vector3i;
|
||||
|
||||
/**
|
||||
* Contains a number of cached arrays to avoid allocations since calling Enum#values() requires the backing array to
|
||||
* be cloned every time.
|
||||
*/
|
||||
public class DirectionUtil {
|
||||
public static final ForgeDirection[] ALL_DIRECTIONS = ForgeDirection.values();
|
||||
|
||||
|
||||
// Provides the same order as enumerating ForgeDirection and checking the axis of each value
|
||||
public static final ForgeDirection[] HORIZONTAL_DIRECTIONS = new ForgeDirection[] { ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.WEST, ForgeDirection.EAST };
|
||||
|
||||
public static final Vector3i[] STEP = {
|
||||
|
||||
//DOWN
|
||||
new Vector3i(0, -1, 0),
|
||||
// UP
|
||||
new Vector3i(0, 1, 0),
|
||||
// NORTH
|
||||
new Vector3i(0, 0, -1),
|
||||
// SOUTH
|
||||
new Vector3i(0, 0, 1),
|
||||
// WEST
|
||||
new Vector3i(-1, 0, 0),
|
||||
// EAST
|
||||
new Vector3i(1, 0, 0),
|
||||
// UNKNOWN
|
||||
new Vector3i(0, 0, 0)
|
||||
};
|
||||
|
||||
public static ForgeDirection rotateDir(ForgeDirection in, Matrix4f rotMat) {
|
||||
|
||||
final Vector3f v = new Vector3f(in.offsetX, in.offsetY, in.offsetZ);
|
||||
v.mulPosition(rotMat);
|
||||
return ModelQuadFacing.toDirection(ModelQuadFacing.fromVector(v));
|
||||
}
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
package me.jellysquid.mods.sodium.common.util;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.BlockPosImpl;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLiquid;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import org.joml.Vector3d;
|
||||
|
||||
/**
|
||||
* Contains methods stripped from BlockState or FluidState that didn't actually need to be there. Technically these
|
||||
* could be a mixin to Block or Fluid, but that's annoying while not actually providing any benefit.
|
||||
*/
|
||||
public class WorldUtil {
|
||||
|
||||
public static Vector3d getVelocity(IBlockAccess world, int x, int y, int z, Block thizz) {
|
||||
|
||||
Vector3d velocity = new Vector3d();
|
||||
int decay = getEffectiveFlowDecay(world, x, y, z, thizz);
|
||||
|
||||
for (ForgeDirection dire : DirectionUtil.HORIZONTAL_DIRECTIONS) {
|
||||
|
||||
int adjX = x + dire.offsetX;
|
||||
int adjZ = z + dire.offsetZ;
|
||||
|
||||
int adjDecay = getEffectiveFlowDecay(world, adjX, y, adjZ, thizz);
|
||||
|
||||
if (adjDecay < 0) {
|
||||
|
||||
if (!world.getBlock(adjX, y, adjZ).getMaterial().blocksMovement()) {
|
||||
|
||||
adjDecay = getEffectiveFlowDecay(world, adjX, y - 1, adjZ, thizz);
|
||||
|
||||
if (adjDecay >= 0) {
|
||||
|
||||
adjDecay -= (decay - 8);
|
||||
velocity = velocity.add((adjX - x) * adjDecay, 0, (adjZ - z) * adjDecay);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
adjDecay -= decay;
|
||||
velocity = velocity.add((adjX - x) * adjDecay, 0, (adjZ - z) * adjDecay);
|
||||
}
|
||||
}
|
||||
|
||||
if (world.getBlockMetadata(x, y, z) >= 8) {
|
||||
|
||||
if (thizz.isBlockSolid(world, x, y, z - 1, 2)
|
||||
|| thizz.isBlockSolid(world, x, y, z + 1, 3)
|
||||
|| thizz.isBlockSolid(world, x - 1, y, z, 4)
|
||||
|| thizz.isBlockSolid(world, x + 1, y, z, 5)
|
||||
|| thizz.isBlockSolid(world, x, y + 1, z - 1, 2)
|
||||
|| thizz.isBlockSolid(world, x, y + 1, z + 1, 3)
|
||||
|| thizz.isBlockSolid(world, x - 1, y + 1, z, 4)
|
||||
|| thizz.isBlockSolid(world, x + 1, y + 1, z, 5)) {
|
||||
velocity = velocity.normalize().add(0.0D, -6.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
|
||||
if (velocity.x == 0 && velocity.y == 0 && velocity.z == 0)
|
||||
return velocity.zero();
|
||||
return velocity.normalize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if any block in a 3x3x3 cube is not the same fluid and not an opaque full cube.
|
||||
* Equivalent to FluidState::method_15756 in modern.
|
||||
*/
|
||||
public static boolean method_15756(IBlockAccess world, BlockPosImpl pos, Fluid fluid) {
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
for (int j = 0; j < 2; ++j) {
|
||||
Block block = world.getBlock(pos.x, pos.y, pos.z);
|
||||
if (!block.isOpaqueCube() && getFluid(block) != fluid) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns fluid height as a percentage of the block; 0 is none and 1 is full.
|
||||
*/
|
||||
public static float getFluidHeight(Fluid fluid, int meta) {
|
||||
return fluid == null ? 0 : 1 - BlockLiquid.getLiquidHeightPercent(meta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the flow decay but converts values indicating falling liquid (values >=8) to their effective source block
|
||||
* value of zero
|
||||
*/
|
||||
public static int getEffectiveFlowDecay(IBlockAccess world, int x, int y, int z, Block thiz) {
|
||||
|
||||
if (world.getBlock(x, y, z).getMaterial() != thiz.getMaterial()) {
|
||||
|
||||
return -1;
|
||||
} else {
|
||||
|
||||
int decay = world.getBlockMetadata(x, y, z);
|
||||
return decay >= 8 ? 0 : decay;
|
||||
}
|
||||
}
|
||||
|
||||
// I believe forge mappings in modern say BreakableBlock, while yarn says TransparentBlock.
|
||||
// I have a sneaking suspicion isOpaque is neither, but it works for now
|
||||
public static boolean shouldDisplayFluidOverlay(Block block) {
|
||||
return !block.getMaterial().isOpaque() || block.getMaterial() == Material.leaves;
|
||||
}
|
||||
|
||||
public static Fluid getFluid(Block b) {
|
||||
return b instanceof IFluidBlock ? ((IFluidBlock) b).getFluid() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent to method_15748 in 1.16.5
|
||||
*/
|
||||
public static boolean isEmptyOrSame(Fluid fluid, Fluid otherFluid) {
|
||||
return otherFluid == null || fluid == otherFluid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent to method_15749 in 1.16.5
|
||||
*/
|
||||
public static boolean method_15749(IBlockAccess world, Fluid thiz, BlockPosImpl pos, ForgeDirection dir) {
|
||||
Block b = world.getBlock(pos.x, pos.y, pos.z);
|
||||
Fluid f = getFluid(b);
|
||||
if (f == thiz) {
|
||||
return false;
|
||||
}
|
||||
if (dir == ForgeDirection.UP) {
|
||||
return true;
|
||||
}
|
||||
return b.getMaterial() != Material.ice && b.isSideSolid(world, pos.x, pos.y, pos.z, dir);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user