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

feat(JOML): migrate ChunkViewCore #3961

Merged
merged 2 commits into from
Aug 8, 2020
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 @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)) {
Expand All @@ -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)) {
Expand Down