From 877eaa469db207ca3ef39ed273ea92ca9fa0e5d8 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 16 May 2020 16:11:50 -0700 Subject: [PATCH] feat(JOML): migrate ChunkViewCore --- .../world/chunks/ChunkConstants.java | 4 +- .../world/internal/BlockUpdate.java | 54 ------------------ .../world/internal/ChunkViewCore.java | 57 +++++++++++++------ .../world/internal/ChunkViewCoreImpl.java | 11 ++++ 4 files changed, 54 insertions(+), 72 deletions(-) delete mode 100644 engine/src/main/java/org/terasology/world/internal/BlockUpdate.java diff --git a/engine/src/main/java/org/terasology/world/chunks/ChunkConstants.java b/engine/src/main/java/org/terasology/world/chunks/ChunkConstants.java index 97864828b20..e72fe756af6 100644 --- a/engine/src/main/java/org/terasology/world/chunks/ChunkConstants.java +++ b/engine/src/main/java/org/terasology/world/chunks/ChunkConstants.java @@ -37,8 +37,8 @@ public final class ChunkConstants { public static final int POWER_Y = TeraMath.sizeOfPower(SIZE_Y); public static final int POWER_Z = TeraMath.sizeOfPower(SIZE_Z); - public static final byte MAX_LIGHT = 0x0f; - public static final byte MAX_SUNLIGHT = 0x0f; + public static final byte MAX_LIGHT = 0x0f; // max light for a light source 0-15 + public static final byte MAX_SUNLIGHT = 0x0f; // max sunlight for sunlight bounded 0-15 public static final byte MAX_SUNLIGHT_REGEN = 63; public static final byte SUNLIGHT_REGEN_THRESHOLD = 48; diff --git a/engine/src/main/java/org/terasology/world/internal/BlockUpdate.java b/engine/src/main/java/org/terasology/world/internal/BlockUpdate.java deleted file mode 100644 index 4d3097d09a1..00000000000 --- a/engine/src/main/java/org/terasology/world/internal/BlockUpdate.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2013 MovingBlocks - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.terasology.world.internal; - -import org.terasology.math.geom.Vector3i; -import org.terasology.world.block.Block; - -/** - * A single requested block change. - * - */ -public class BlockUpdate { - - private Vector3i position; - private Block oldType; - private Block newType; - - /** - * @param pos The block position to change - * @param newType The block type to change it to - * @param oldType The block type to change it from - */ - public BlockUpdate(Vector3i pos, Block newType, Block oldType) { - this.position = pos; - this.oldType = oldType; - this.newType = newType; - } - - public Vector3i getPosition() { - return position; - } - - public Block getOldType() { - return oldType; - } - - public Block getNewType() { - return newType; - } -} diff --git a/engine/src/main/java/org/terasology/world/internal/ChunkViewCore.java b/engine/src/main/java/org/terasology/world/internal/ChunkViewCore.java index f399750c0e3..6c2ad427dbf 100644 --- a/engine/src/main/java/org/terasology/world/internal/ChunkViewCore.java +++ b/engine/src/main/java/org/terasology/world/internal/ChunkViewCore.java @@ -16,44 +16,69 @@ package org.terasology.world.internal; +import org.joml.Vector3ic; import org.terasology.math.geom.Vector3i; import org.terasology.world.ChunkView; public interface ChunkViewCore extends ChunkView { /** - * Sets the light level at the given position + * Sets the light level at the given position. the value is usually bounded by {@link org.terasology.world.chunks.ChunkConstants#MAX_LIGHT} * - * @param pos - * @param light + * @param pos The position relative to the corner of the chunk + * @param light set the light value of a block. + * @deprecated This is scheduled for removal in an upcoming version + * method will be replaced with JOML implementation {@link #setLight(Vector3ic, byte)}. */ + @Deprecated void setLight(Vector3i pos, byte light); /** - * Sets the light level at the given coordinates + * Sets the light level at the given position. the value is usually bounded by {@link org.terasology.world.chunks.ChunkConstants#MAX_LIGHT} * - * @param blockX - * @param blockY - * @param blockZ - * @param light + * @param pos The position relative to the corner of the chunk + * @param light set the light value of a block. + */ + void setLight(Vector3ic pos, byte light); + + /** + * Sets the light level at the given coordinates. the value is usually bounded by {@link org.terasology.world.chunks.ChunkConstants#MAX_LIGHT} + * + * @param blockX X offset from the corner of the chunk + * @param blockY Y offset from the corner of the chunk + * @param blockZ Z offset from the corner of the chunk + * @param light set the light value of a block. */ void setLight(int blockX, int blockY, int blockZ, byte light); /** - * Sets the sunlight level at the given position + * Sets the sunlight level at the given position. the value is usually bounded by {@link org.terasology.world.chunks.ChunkConstants#MAX_SUNLIGHT} * - * @param pos - * @param light + * @param pos The position relative to the corner of the chunk + * @param light set the sunlight light value of a block. + * @deprecated This is scheduled for removal in an upcoming version + * method will be replaced with JOML implementation {@link #setSunlight(Vector3ic, byte)}. */ + @Deprecated void setSunlight(Vector3i pos, byte light); + + /** + * Sets the sunlight level at the given position. the value is usually bounded by {@link org.terasology.world.chunks.ChunkConstants#MAX_SUNLIGHT} + * + * @param pos The position relative to the corner of the chunk + * @param light set the sunlight light value of a block. + */ + void setSunlight(Vector3ic pos, byte light); + + /** - * Sets the sunlight level at the given coordinates + * Sets the sunlight level at the given coordinates. the value is usually bounded by {@link org.terasology.world.chunks.ChunkConstants#MAX_SUNLIGHT} * - * @param blockX - * @param blockY - * @param blockZ - * @param light + * @param blockX X offset from the corner of the chunk + * @param blockY Y offset from the corner of the chunk + * @param blockZ Z offset from the corner of the chunk + * @param light set the sunlight light value of a block. */ void setSunlight(int blockX, int blockY, int blockZ, byte light); diff --git a/engine/src/main/java/org/terasology/world/internal/ChunkViewCoreImpl.java b/engine/src/main/java/org/terasology/world/internal/ChunkViewCoreImpl.java index b6aaca9bdf6..a02d3b1fe23 100644 --- a/engine/src/main/java/org/terasology/world/internal/ChunkViewCoreImpl.java +++ b/engine/src/main/java/org/terasology/world/internal/ChunkViewCoreImpl.java @@ -16,6 +16,7 @@ package org.terasology.world.internal; +import org.joml.Vector3ic; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.terasology.math.ChunkMath; @@ -144,6 +145,11 @@ public void setLight(Vector3i pos, byte light) { setLight(pos.x, pos.y, pos.z, light); } + @Override + public void setLight(Vector3ic pos, byte light) { + setLight(pos.x(), pos.y(), pos.z(), light); + } + @Override public void setLight(int blockX, int blockY, int blockZ, byte light) { if (blockRegion.encompasses(blockX, blockY, blockZ)) { @@ -159,6 +165,11 @@ public void setSunlight(Vector3i pos, byte light) { setSunlight(pos.x, pos.y, pos.z, light); } + @Override + public void setSunlight(Vector3ic pos, byte light) { + setSunlight(pos.x(), pos.y(), pos.z(), light); + } + @Override public void setSunlight(int blockX, int blockY, int blockZ, byte light) { if (blockRegion.encompasses(blockX, blockY, blockZ)) {