Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(joml): migrate ChunkView #24

Merged
merged 2 commits into from
Jan 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ public BlockMeshGeneratorDebugLiquid(Block block, WorldAtlas worldAtlas, int flo

@Override
public void generateChunkMesh(ChunkView view, ChunkMesh chunkMesh, int x, int y, int z) {
Vector3i pos = new Vector3i(x,y,z);
int fluidHeight = LiquidData.getHeight((byte)view.getExtraData(flowIx, pos));
org.joml.Vector3i pos = new org.joml.Vector3i(x, y, z);
int fluidHeight = LiquidData.getHeight((byte) view.getExtraData(flowIx, pos));
BlockAppearance appearance = block.getAppearance(null); //I know it's DebugLiquid, which doesn't vary its appearance.
for(Side side : Side.values()) {
if(isSideVisibleForBlockTypes(view.getBlock(side.getAdjacentPos(pos)), block, side)) {
for (Side side : Side.values()) {
if (isSideVisibleForBlockTypes(view.getBlock(side.getAdjacentPos(pos, new org.joml.Vector3i())), block, side)) {
BlockMeshPart basePart = appearance.getPart(BlockPart.fromSide(side));
BlockMeshPart labelledPart = basePart.mapTexCoords(JomlUtil.from(textureOffsets[fluidHeight]), texCoordScale,1);
BlockMeshPart labelledPart = basePart.mapTexCoords(JomlUtil.from(textureOffsets[fluidHeight]), texCoordScale, 1);
labelledPart.appendTo(chunkMesh, x, y, z, ChunkMesh.RenderType.OPAQUE, ChunkVertexFlag.NORMAL);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ public void generateChunkMesh(ChunkView view, ChunkMesh chunkMesh, int x, int y,
renderType = ChunkMesh.RenderType.WATER_AND_ICE;
}

Vector3i pos = new Vector3i(x,y,z);
org.joml.Vector3i pos = new org.joml.Vector3i(x,y,z);
float[] renderHeight = getRenderHeight(view, pos);
boolean suppressed = view.getBlock(pos.x, pos.y+1, pos.z) == block; // Render it as full even though it actually isn't.
boolean full = suppressed || isFull(renderHeight);

BlockAppearance appearance = block.getAppearance(null); //TODO: collect information the block wants, or avoid this entirely.
for(Side side : Side.values()) {
Vector3i adjacentPos = side.getAdjacentPos(pos);
org.joml.Vector3i adjacentPos = side.getAdjacentPos(pos, new org.joml.Vector3i());
Block adjacentBlock = view.getBlock(adjacentPos);
boolean adjacentSuppressed = view.getBlock(adjacentPos.x, adjacentPos.y+1, adjacentPos.z) == block;
if(isSideVisibleForBlockTypes(adjacentBlock, adjacentSuppressed, block, full, suppressed, side)) {
Expand All @@ -96,13 +96,13 @@ public void generateChunkMesh(ChunkView view, ChunkMesh chunkMesh, int x, int y,
}

// The height of the liquid block, as it is displayed.
private float[] getRenderHeight(ChunkView view, Vector3i pos) {
private float[] getRenderHeight(ChunkView view, org.joml.Vector3ic pos) {
float[] heights = new float[4];
int[] liquidCount = new int[4];
for (int x = -1; x <= 1; x++) {
for (int z = -1; z <= 1; z++) {
if (view.getBlock(pos.x+x, pos.y, pos.z+z) == block && view.getBlock(pos.x+x, pos.y+1, pos.z+z) != block) {
int height = LiquidData.getHeight((byte)view.getExtraData(flowIx, pos.x+x, pos.y, pos.z+z));
if (view.getBlock(pos.x() + x, pos.y(), pos.z() + z) == block && view.getBlock(pos.x() + x, pos.y() + 1, pos.z() + z) != block) {
int height = LiquidData.getHeight((byte) view.getExtraData(flowIx, pos.x() + x, pos.y(), pos.z() + z));
for (int i = 0; i < 4; i++) {
if (((i < 2) ? (x <= 0) : (x >= 0)) && ((i % 2 == 0) ? (z <= 0) : (z >= 0))) {
liquidCount[i]++;
Expand Down