add Dh prefix to DH math objects

This commit is contained in:
James Seibel
2026-06-01 22:07:03 -05:00
parent e192abe666
commit 44aed79e78
21 changed files with 153 additions and 172 deletions
@@ -19,15 +19,12 @@
package com.seibel.distanthorizons.core.api.external.methods.data; package com.seibel.distanthorizons.core.api.external.methods.data;
import com.seibel.distanthorizons.api.interfaces.block.IDhApiBiomeWrapper;
import com.seibel.distanthorizons.api.interfaces.block.IDhApiBlockStateWrapper;
import com.seibel.distanthorizons.api.interfaces.data.IDhApiTerrainDataCache; import com.seibel.distanthorizons.api.interfaces.data.IDhApiTerrainDataCache;
import com.seibel.distanthorizons.api.interfaces.world.IDhApiLevelWrapper; import com.seibel.distanthorizons.api.interfaces.world.IDhApiLevelWrapper;
import com.seibel.distanthorizons.api.objects.DhApiResult; import com.seibel.distanthorizons.api.objects.DhApiResult;
import com.seibel.distanthorizons.api.objects.data.DhApiRaycastResult; import com.seibel.distanthorizons.api.objects.data.DhApiRaycastResult;
import com.seibel.distanthorizons.api.objects.data.DhApiTerrainDataPoint; import com.seibel.distanthorizons.api.objects.data.DhApiTerrainDataPoint;
import com.seibel.distanthorizons.api.interfaces.data.IDhApiTerrainDataRepo; import com.seibel.distanthorizons.api.interfaces.data.IDhApiTerrainDataRepo;
import com.seibel.distanthorizons.api.objects.data.IDhApiFullDataSource;
import com.seibel.distanthorizons.api.objects.math.DhApiVec3i; import com.seibel.distanthorizons.api.objects.math.DhApiVec3i;
import com.seibel.distanthorizons.core.api.internal.SharedApi; import com.seibel.distanthorizons.core.api.internal.SharedApi;
import com.seibel.distanthorizons.core.dataObjects.fullData.FullDataPointIdMap; import com.seibel.distanthorizons.core.dataObjects.fullData.FullDataPointIdMap;
@@ -37,26 +34,20 @@ import com.seibel.distanthorizons.core.level.IDhLevel;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.core.pos.DhChunkPos; import com.seibel.distanthorizons.core.pos.DhChunkPos;
import com.seibel.distanthorizons.core.pos.DhSectionPos; import com.seibel.distanthorizons.core.pos.DhSectionPos;
import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos;
import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPosMutable;
import com.seibel.distanthorizons.core.render.renderer.AbstractDebugWireframeRenderer; import com.seibel.distanthorizons.core.render.renderer.AbstractDebugWireframeRenderer;
import com.seibel.distanthorizons.core.util.DhApiTerrainDataPointUtil; import com.seibel.distanthorizons.core.util.DhApiTerrainDataPointUtil;
import com.seibel.distanthorizons.core.util.FullDataPointUtil; import com.seibel.distanthorizons.core.util.FullDataPointUtil;
import com.seibel.distanthorizons.core.util.LodUtil; import com.seibel.distanthorizons.core.util.LodUtil;
import com.seibel.distanthorizons.core.util.RayCastUtil; import com.seibel.distanthorizons.core.util.RayCastUtil;
import com.seibel.distanthorizons.core.util.math.Vec3f; import com.seibel.distanthorizons.core.util.math.DhVec3f;
import com.seibel.distanthorizons.core.world.AbstractDhWorld; import com.seibel.distanthorizons.core.world.AbstractDhWorld;
import com.seibel.distanthorizons.core.wrapperInterfaces.IWrapperFactory; import com.seibel.distanthorizons.core.wrapperInterfaces.IWrapperFactory;
import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
import com.seibel.distanthorizons.coreapi.util.BitShiftUtil; import com.seibel.distanthorizons.coreapi.util.BitShiftUtil;
import com.seibel.distanthorizons.core.util.math.Vec3d; import com.seibel.distanthorizons.core.util.math.DhVec3d;
import com.seibel.distanthorizons.core.util.math.Vec3i; import com.seibel.distanthorizons.core.util.math.DhVec3i;
import com.seibel.distanthorizons.coreapi.util.ColorUtil;
import it.unimi.dsi.fastutil.longs.LongArrayList; import it.unimi.dsi.fastutil.longs.LongArrayList;
import com.seibel.distanthorizons.core.logging.DhLogger; import com.seibel.distanthorizons.core.logging.DhLogger;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@@ -80,7 +71,7 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
// debugging values // debugging values
private static volatile boolean debugThreadRunning = false; private static volatile boolean debugThreadRunning = false;
private static DhApiTerrainDataCache debugDataCache = new DhApiTerrainDataCache(); private static DhApiTerrainDataCache debugDataCache = new DhApiTerrainDataCache();
private static DhApiVec3i currentDebugVec3i = new Vec3i(); private static DhApiVec3i currentDebugVec3i = new DhVec3i();
@@ -375,8 +366,8 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
IDhApiTerrainDataCache dataCache) IDhApiTerrainDataCache dataCache)
{ {
return this.raycastLodData(levelWrapper, return this.raycastLodData(levelWrapper,
new Vec3d(rayOriginX, rayOriginY, rayOriginZ), new DhVec3d(rayOriginX, rayOriginY, rayOriginZ),
new Vec3f(rayDirectionX, rayDirectionY, rayDirectionZ), new DhVec3f(rayDirectionX, rayDirectionY, rayDirectionZ),
maxRayBlockLength, dataCache); maxRayBlockLength, dataCache);
} }
@@ -388,7 +379,7 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
*/ */
private DhApiResult<DhApiRaycastResult> raycastLodData( private DhApiResult<DhApiRaycastResult> raycastLodData(
IDhApiLevelWrapper levelWrapper, IDhApiLevelWrapper levelWrapper,
Vec3d rayOrigin, Vec3f rayDirection, DhVec3d rayOrigin, DhVec3f rayDirection,
int maxRayBlockLength, int maxRayBlockLength,
@Nullable @Nullable
IDhApiTerrainDataCache dataCache) IDhApiTerrainDataCache dataCache)
@@ -405,9 +396,9 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
int currentLength = 0; int currentLength = 0;
// the exact position of this step // the exact position of this step
Vec3d exactPos = new Vec3d(rayOrigin.x, rayOrigin.y, rayOrigin.z); DhVec3d exactPos = new DhVec3d(rayOrigin.x, rayOrigin.y, rayOrigin.z);
// the block position for this step // the block position for this step
Vec3i blockPos = new Vec3i((int) Math.round(rayOrigin.x), (int) Math.round(rayOrigin.y), (int) Math.round(rayOrigin.z)); DhVec3i blockPos = new DhVec3i((int) Math.round(rayOrigin.x), (int) Math.round(rayOrigin.y), (int) Math.round(rayOrigin.z));
DhApiRaycastResult closetFoundDataPoint = null; DhApiRaycastResult closetFoundDataPoint = null;
@@ -417,8 +408,8 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
&& currentLength <= maxRayBlockLength) && currentLength <= maxRayBlockLength)
{ {
// get the LOD columns around this position // get the LOD columns around this position
ArrayList<Vec3i> columnPositions = getIntersectingColumnsAtPosition(blockPos, rayDirection); ArrayList<DhVec3i> columnPositions = getIntersectingColumnsAtPosition(blockPos, rayDirection);
for (Vec3i columnPos : columnPositions) for (DhVec3i columnPos : columnPositions)
{ {
// check each column // check each column
DhApiResult<DhApiTerrainDataPoint[]> result = this.getColumnDataAtBlockPos(levelWrapper, columnPos.x, columnPos.z, dataCache); DhApiResult<DhApiTerrainDataPoint[]> result = this.getColumnDataAtBlockPos(levelWrapper, columnPos.x, columnPos.z, dataCache);
@@ -435,7 +426,7 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
if (dataPoint.blockStateWrapper != null && !dataPoint.blockStateWrapper.isAir()) if (dataPoint.blockStateWrapper != null && !dataPoint.blockStateWrapper.isAir())
{ {
// does this LOD contain the given Y position? // does this LOD contain the given Y position?
Vec3i dataPointPos = new Vec3i(columnPos.x, dataPoint.bottomYBlockPos, columnPos.z); DhVec3i dataPointPos = new DhVec3i(columnPos.x, dataPoint.bottomYBlockPos, columnPos.z);
if (exactPos.y >= dataPoint.bottomYBlockPos if (exactPos.y >= dataPoint.bottomYBlockPos
&& exactPos.y <= dataPoint.topYBlockPos) && exactPos.y <= dataPoint.topYBlockPos)
{ {
@@ -488,15 +479,15 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
* *
* Used to make sure the raycast step doesn't accidentally walk over any adjacent data. * Used to make sure the raycast step doesn't accidentally walk over any adjacent data.
*/ */
private static ArrayList<Vec3i> getIntersectingColumnsAtPosition(Vec3i rayEndingPos, Vec3f rayDirection) private static ArrayList<DhVec3i> getIntersectingColumnsAtPosition(DhVec3i rayEndingPos, DhVec3f rayDirection)
{ {
ArrayList<Vec3i> returnList = new ArrayList<>(9); ArrayList<DhVec3i> returnList = new ArrayList<>(9);
for (int x = -1; x <= 1; x++) for (int x = -1; x <= 1; x++)
{ {
for (int z = -1; z <= 1; z++) for (int z = -1; z <= 1; z++)
{ {
Vec3i pos = new Vec3i(rayEndingPos.x + x, rayEndingPos.y, rayEndingPos.z + z); DhVec3i pos = new DhVec3i(rayEndingPos.x + x, rayEndingPos.y, rayEndingPos.z + z);
// check if this column is intersected by the ray // check if this column is intersected by the ray
if (RayCastUtil.rayIntersectsSquare(rayEndingPos.x, rayEndingPos.z, rayDirection.x, rayDirection.z, pos.x, pos.z, 1)) if (RayCastUtil.rayIntersectsSquare(rayEndingPos.x, rayEndingPos.z, rayDirection.x, rayDirection.z, pos.x, pos.z, 1))
@@ -36,7 +36,7 @@ import com.seibel.distanthorizons.core.render.RenderParams;
import com.seibel.distanthorizons.core.render.RenderThreadTaskHandler; import com.seibel.distanthorizons.core.render.RenderThreadTaskHandler;
import com.seibel.distanthorizons.core.render.renderer.*; import com.seibel.distanthorizons.core.render.renderer.*;
import com.seibel.distanthorizons.core.util.TimerUtil; import com.seibel.distanthorizons.core.util.TimerUtil;
import com.seibel.distanthorizons.core.util.math.Vec3d; import com.seibel.distanthorizons.core.util.math.DhVec3d;
import com.seibel.distanthorizons.core.util.objects.Pair; import com.seibel.distanthorizons.core.util.objects.Pair;
import com.seibel.distanthorizons.core.util.objects.RollingAverage; import com.seibel.distanthorizons.core.util.objects.RollingAverage;
import com.seibel.distanthorizons.core.util.threading.ThreadPoolUtil; import com.seibel.distanthorizons.core.util.threading.ThreadPoolUtil;
@@ -156,7 +156,7 @@ public class ClientApi
* @see ClientApi#MIN_MS_BETWEEN_SPEED_CHECKS * @see ClientApi#MIN_MS_BETWEEN_SPEED_CHECKS
*/ */
private final RollingAverage cameraSpeedRollingAverage = new RollingAverage(40); private final RollingAverage cameraSpeedRollingAverage = new RollingAverage(40);
private Vec3d lastCameraPosForSpeedCheck = new Vec3d(); private DhVec3d lastCameraPosForSpeedCheck = new DhVec3d();
private long msSinceLastSpeedCheck = 0L; private long msSinceLastSpeedCheck = 0L;
public double getAvgCameraSpeed() { return cameraSpeedRollingAverage.getAverage(); } public double getAvgCameraSpeed() { return cameraSpeedRollingAverage.getAverage(); }
@@ -470,7 +470,7 @@ public class ClientApi
this.msSinceLastSpeedCheck = nowMs; this.msSinceLastSpeedCheck = nowMs;
// get the distance traveled since last frame // get the distance traveled since last frame
Vec3d camPos = MC_RENDER.getCameraExactPosition(); DhVec3d camPos = MC_RENDER.getCameraExactPosition();
double distanceInBlocks = camPos.getDistance(this.lastCameraPosForSpeedCheck); double distanceInBlocks = camPos.getDistance(this.lastCameraPosForSpeedCheck);
double speed = distanceInBlocks / secSinceLastCheck; double speed = distanceInBlocks / secSinceLastCheck;
@@ -1,7 +1,7 @@
package com.seibel.distanthorizons.core.api.internal.rendering; package com.seibel.distanthorizons.core.api.internal.rendering;
import com.seibel.distanthorizons.core.api.internal.ClientApi; import com.seibel.distanthorizons.core.api.internal.ClientApi;
import com.seibel.distanthorizons.core.util.math.Mat4f; import com.seibel.distanthorizons.core.util.math.DhMat4f;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
@@ -12,8 +12,8 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapp
*/ */
public class DhRenderState public class DhRenderState
{ {
public Mat4f mcModelViewMatrix = null; public DhMat4f mcModelViewMatrix = null;
public Mat4f mcProjectionMatrix = null; public DhMat4f mcProjectionMatrix = null;
/** /**
* percentage of time into the current client tick. <br><br> * percentage of time into the current client tick. <br><br>
* *
@@ -19,7 +19,7 @@
package com.seibel.distanthorizons.core.enums; package com.seibel.distanthorizons.core.enums;
import com.seibel.distanthorizons.core.util.math.Vec3i; import com.seibel.distanthorizons.core.util.math.DhVec3i;
/** /**
* Up <Br> * Up <Br>
@@ -32,17 +32,17 @@ import com.seibel.distanthorizons.core.util.math.Vec3i;
public enum EDhDirection public enum EDhDirection
{ {
/** negative Y */ /** negative Y */
DOWN("down", EDhDirection.AxisDirection.NEGATIVE, EDhDirection.Axis.Y, new Vec3i(0, -1, 0), -1), DOWN("down", EDhDirection.AxisDirection.NEGATIVE, EDhDirection.Axis.Y, new DhVec3i(0, -1, 0), -1),
/** positive Y */ /** positive Y */
UP("up", EDhDirection.AxisDirection.POSITIVE, EDhDirection.Axis.Y, new Vec3i(0, 1, 0), -1), UP("up", EDhDirection.AxisDirection.POSITIVE, EDhDirection.Axis.Y, new DhVec3i(0, 1, 0), -1),
/** negative Z */ /** negative Z */
NORTH("north", EDhDirection.AxisDirection.NEGATIVE, EDhDirection.Axis.Z, new Vec3i(0, 0, -1), 0), NORTH("north", EDhDirection.AxisDirection.NEGATIVE, EDhDirection.Axis.Z, new DhVec3i(0, 0, -1), 0),
/** positive Z */ /** positive Z */
SOUTH("south", EDhDirection.AxisDirection.POSITIVE, EDhDirection.Axis.Z, new Vec3i(0, 0, 1), 1), SOUTH("south", EDhDirection.AxisDirection.POSITIVE, EDhDirection.Axis.Z, new DhVec3i(0, 0, 1), 1),
/** negative X */ /** negative X */
WEST("west", EDhDirection.AxisDirection.NEGATIVE, EDhDirection.Axis.X, new Vec3i(-1, 0, 0), 2), WEST("west", EDhDirection.AxisDirection.NEGATIVE, EDhDirection.Axis.X, new DhVec3i(-1, 0, 0), 2),
/** positive X */ /** positive X */
EAST("east", EDhDirection.AxisDirection.POSITIVE, EDhDirection.Axis.X, new Vec3i(1, 0, 0), 3); EAST("east", EDhDirection.AxisDirection.POSITIVE, EDhDirection.Axis.X, new DhVec3i(1, 0, 0), 3);
/** Up, Down, West, East, North, South */ /** Up, Down, West, East, North, South */
@@ -68,7 +68,7 @@ public enum EDhDirection
public final String name; public final String name;
public final EDhDirection.Axis axis; public final EDhDirection.Axis axis;
public final EDhDirection.AxisDirection axisDirection; public final EDhDirection.AxisDirection axisDirection;
public final Vec3i normal; public final DhVec3i normal;
/** -1 if not a {@link EDhDirection#CARDINAL_COMPASS} direction */ /** -1 if not a {@link EDhDirection#CARDINAL_COMPASS} direction */
public final int compassIndex; public final int compassIndex;
@@ -78,7 +78,7 @@ public enum EDhDirection
// constructor // // constructor //
//=============// //=============//
EDhDirection(String name, EDhDirection.AxisDirection axisDirection, EDhDirection.Axis axis, Vec3i normal, int compassIndex) EDhDirection(String name, EDhDirection.AxisDirection axisDirection, EDhDirection.Axis axis, DhVec3i normal, int compassIndex)
{ {
this.name = name; this.name = name;
this.axis = axis; this.axis = axis;
@@ -21,14 +21,13 @@ import com.seibel.distanthorizons.core.pos.DhSectionPos;
import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos2D; import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos2D;
import com.seibel.distanthorizons.core.util.LodUtil; import com.seibel.distanthorizons.core.util.LodUtil;
import com.seibel.distanthorizons.core.util.WorldGenUtil; import com.seibel.distanthorizons.core.util.WorldGenUtil;
import com.seibel.distanthorizons.core.util.math.Vec3d; import com.seibel.distanthorizons.core.util.math.DhVec3d;
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IServerPlayerWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IServerPlayerWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper;
import com.seibel.distanthorizons.core.logging.DhLogger; import com.seibel.distanthorizons.core.logging.DhLogger;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
import java.io.IOException; import java.io.IOException;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.List; import java.util.List;
@@ -113,7 +112,7 @@ public abstract class AbstractDhServerLevel extends AbstractDhLevel implements I
this.worldGenPlayerCenteringQueue.add(firstPlayer); this.worldGenPlayerCenteringQueue.add(firstPlayer);
this.worldGenPlayerCenteringQueue.remove(firstPlayer); this.worldGenPlayerCenteringQueue.remove(firstPlayer);
Vec3d position = firstPlayer.getPosition(); DhVec3d position = firstPlayer.getPosition();
return new DhBlockPos2D((int) position.x, (int) position.z); return new DhBlockPos2D((int) position.x, (int) position.z);
} }
@@ -132,7 +131,7 @@ public abstract class AbstractDhServerLevel extends AbstractDhLevel implements I
return; return;
} }
Vec3d playerPosition = serverPlayerState.getServerPlayer().getPosition(); DhVec3d playerPosition = serverPlayerState.getServerPlayer().getPosition();
int distanceFromPlayer = DhSectionPos.getChebyshevSignedBlockDistance(message.sectionPos, new DhBlockPos2D((int) playerPosition.x, (int) playerPosition.z)) / 16; int distanceFromPlayer = DhSectionPos.getChebyshevSignedBlockDistance(message.sectionPos, new DhBlockPos2D((int) playerPosition.x, (int) playerPosition.z)) / 16;
ServerPlayerState.RateLimiterSet rateLimiterSet = serverPlayerState.getRateLimiterSet(this); ServerPlayerState.RateLimiterSet rateLimiterSet = serverPlayerState.getRateLimiterSet(this);
@@ -249,7 +248,7 @@ public abstract class AbstractDhServerLevel extends AbstractDhLevel implements I
continue; continue;
} }
Vec3d playerPosition = serverPlayerState.getServerPlayer().getPosition(); DhVec3d playerPosition = serverPlayerState.getServerPlayer().getPosition();
int distanceFromPlayer = DhSectionPos.getChebyshevSignedBlockDistance(data.getPos(), new DhBlockPos2D((int) playerPosition.x, (int) playerPosition.z)) / 16; int distanceFromPlayer = DhSectionPos.getChebyshevSignedBlockDistance(data.getPos(), new DhBlockPos2D((int) playerPosition.x, (int) playerPosition.z)) / 16;
if (distanceFromPlayer <= serverPlayerState.sessionConfig.getMaxUpdateDistanceRadius()) if (distanceFromPlayer <= serverPlayerState.sessionConfig.getMaxUpdateDistanceRadius())
{ {
@@ -29,7 +29,7 @@ import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos2D;
import com.seibel.distanthorizons.core.render.QuadTree.LodQuadTree; import com.seibel.distanthorizons.core.render.QuadTree.LodQuadTree;
import com.seibel.distanthorizons.core.render.RenderBufferHandler; import com.seibel.distanthorizons.core.render.RenderBufferHandler;
import com.seibel.distanthorizons.core.util.LodUtil; import com.seibel.distanthorizons.core.util.LodUtil;
import com.seibel.distanthorizons.core.util.math.Vec3d; import com.seibel.distanthorizons.core.util.math.DhVec3d;
import com.seibel.distanthorizons.core.wrapperInterfaces.IWrapperFactory; import com.seibel.distanthorizons.core.wrapperInterfaces.IWrapperFactory;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
@@ -110,7 +110,7 @@ public class ClientLevelModule implements Closeable, IDataSourceUpdateListenerFu
} }
// use camera position instead of player pos so free cam mods work better // use camera position instead of player pos so free cam mods work better
Vec3d cameraDoublePos = MC_RENDER.getCameraExactPosition(); DhVec3d cameraDoublePos = MC_RENDER.getCameraExactPosition();
DhBlockPos2D cameraBlockPos = new DhBlockPos2D((int)cameraDoublePos.x, (int)cameraDoublePos.z); DhBlockPos2D cameraBlockPos = new DhBlockPos2D((int)cameraDoublePos.x, (int)cameraDoublePos.z);
clientRenderState.quadtree.tryTick(cameraBlockPos); clientRenderState.quadtree.tryTick(cameraBlockPos);
} }
@@ -22,7 +22,7 @@ package com.seibel.distanthorizons.core.pos;
import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos; import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos;
import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos2D; import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos2D;
import com.seibel.distanthorizons.core.util.LodUtil; import com.seibel.distanthorizons.core.util.LodUtil;
import com.seibel.distanthorizons.core.util.math.Vec3d; import com.seibel.distanthorizons.core.util.math.DhVec3d;
/** /**
* immutable <br><br> * immutable <br><br>
@@ -65,7 +65,7 @@ public class DhChunkPos
// >> 4 is the Same as div 16 // >> 4 is the Same as div 16
this(blockPos.x >> 4, blockPos.z >> 4); this(blockPos.x >> 4, blockPos.z >> 4);
} }
public DhChunkPos(Vec3d pos) public DhChunkPos(DhVec3d pos)
{ {
// >> 4 is the Same as div 16 // >> 4 is the Same as div 16
this(((int)pos.x) >> 4, ((int)pos.z) >> 4); this(((int)pos.x) >> 4, ((int)pos.z) >> 4);
@@ -22,7 +22,6 @@ package com.seibel.distanthorizons.core.render;
import com.seibel.distanthorizons.api.DhApi; import com.seibel.distanthorizons.api.DhApi;
import com.seibel.distanthorizons.api.interfaces.override.rendering.IDhApiCullingFrustum; import com.seibel.distanthorizons.api.interfaces.override.rendering.IDhApiCullingFrustum;
import com.seibel.distanthorizons.api.interfaces.override.rendering.IDhApiShadowCullingFrustum; import com.seibel.distanthorizons.api.interfaces.override.rendering.IDhApiShadowCullingFrustum;
import com.seibel.distanthorizons.api.objects.math.DhApiMat4f;
import com.seibel.distanthorizons.core.config.Config; import com.seibel.distanthorizons.core.config.Config;
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.LodBufferContainer; import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.LodBufferContainer;
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector; import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
@@ -43,10 +42,9 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRen
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IIrisAccessor; import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IIrisAccessor;
import com.seibel.distanthorizons.coreapi.ModInfo; import com.seibel.distanthorizons.coreapi.ModInfo;
import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IOverrideInjector; import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IOverrideInjector;
import com.seibel.distanthorizons.core.util.math.Mat4f; import com.seibel.distanthorizons.core.util.math.DhMat4f;
import com.seibel.distanthorizons.core.util.math.Vec3d; import com.seibel.distanthorizons.core.util.math.DhVec3d;
import org.joml.Matrix4f; import org.joml.Matrix4f;
import org.joml.Matrix4fc;
import java.util.ArrayList; import java.util.ArrayList;
@@ -65,7 +63,7 @@ public class RenderBufferHandler implements AutoCloseable
private static final float[] JOML_TRANSPOSE_ARRAY = new float[16]; private static final float[] JOML_TRANSPOSE_ARRAY = new float[16];
private static final Matrix4f WORLD_VIEW_JOML_MATRIX = new Matrix4f(); private static final Matrix4f WORLD_VIEW_JOML_MATRIX = new Matrix4f();
private static final Matrix4f WORLD_VIEW_PROJ_JOML_MATRIX = new Matrix4f(); private static final Matrix4f WORLD_VIEW_PROJ_JOML_MATRIX = new Matrix4f();
private static final Mat4f FRUSTOM_DH_MATRIX = new Mat4f(); private static final DhMat4f FRUSTOM_DH_MATRIX = new DhMat4f();
/** contains all relevant data */ /** contains all relevant data */
@@ -172,7 +170,7 @@ public class RenderBufferHandler implements AutoCloseable
int worldMinY = renderParams.clientLevelWrapper.getMinHeight(); int worldMinY = renderParams.clientLevelWrapper.getMinHeight();
int worldHeight = renderParams.clientLevelWrapper.getMaxHeight(); int worldHeight = renderParams.clientLevelWrapper.getMaxHeight();
Vec3d cameraPos = MC_RENDER.getCameraExactPosition(); DhVec3d cameraPos = MC_RENDER.getCameraExactPosition();
renderParams.mcModelViewMatrix.putValuesInArray(JOML_TRANSPOSE_ARRAY); renderParams.mcModelViewMatrix.putValuesInArray(JOML_TRANSPOSE_ARRAY);
WORLD_VIEW_JOML_MATRIX WORLD_VIEW_JOML_MATRIX
@@ -2,15 +2,14 @@ package com.seibel.distanthorizons.core.render;
import com.seibel.distanthorizons.api.enums.rendering.EDhApiRenderPass; import com.seibel.distanthorizons.api.enums.rendering.EDhApiRenderPass;
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam; import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam;
import com.seibel.distanthorizons.api.objects.math.DhApiMat4f;
import com.seibel.distanthorizons.core.api.internal.SharedApi; import com.seibel.distanthorizons.core.api.internal.SharedApi;
import com.seibel.distanthorizons.core.api.internal.rendering.DhRenderState; import com.seibel.distanthorizons.core.api.internal.rendering.DhRenderState;
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector; import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.level.IDhClientLevel; import com.seibel.distanthorizons.core.level.IDhClientLevel;
import com.seibel.distanthorizons.core.util.RenderUtil; import com.seibel.distanthorizons.core.util.RenderUtil;
import com.seibel.distanthorizons.core.util.math.Mat4f; import com.seibel.distanthorizons.core.util.math.DhMat4f;
import com.seibel.distanthorizons.core.util.math.Vec3d; import com.seibel.distanthorizons.core.util.math.DhVec3d;
import com.seibel.distanthorizons.core.world.IDhClientWorld; import com.seibel.distanthorizons.core.world.IDhClientWorld;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
@@ -46,7 +45,7 @@ public class RenderParams extends DhApiRenderParam
public ILightMapWrapper lightmap; public ILightMapWrapper lightmap;
public RenderBufferHandler renderBufferHandler; public RenderBufferHandler renderBufferHandler;
public IDhGenericRenderer genericRenderer; public IDhGenericRenderer genericRenderer;
public Vec3d exactCameraPosition; public DhVec3d exactCameraPosition;
/** @see DhRenderState#vanillaFogEnabled */ /** @see DhRenderState#vanillaFogEnabled */
public boolean vanillaFogEnabled; public boolean vanillaFogEnabled;
@@ -154,14 +153,14 @@ public class RenderParams extends DhApiRenderParam
return "No Generic Renderer Present"; return "No Generic Renderer Present";
} }
if (this.dhModelViewMatrix.equals(Mat4f.IDENTITY) if (this.dhModelViewMatrix.equals(DhMat4f.IDENTITY)
|| this.dhModelViewMatrix.equals(Mat4f.EMPTY)) || this.dhModelViewMatrix.equals(DhMat4f.EMPTY))
{ {
return "No DH MVM Matrix Given"; return "No DH MVM Matrix Given";
} }
if (this.mcModelViewMatrix.equals(Mat4f.IDENTITY) if (this.mcModelViewMatrix.equals(DhMat4f.IDENTITY)
|| this.mcModelViewMatrix.equals(Mat4f.EMPTY)) || this.mcModelViewMatrix.equals(DhMat4f.EMPTY))
{ {
return "No MC MVM Matrix Given"; return "No MC MVM Matrix Given";
} }
@@ -7,9 +7,9 @@ import com.seibel.distanthorizons.core.logging.DhLogger;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.core.pos.DhSectionPos; import com.seibel.distanthorizons.core.pos.DhSectionPos;
import com.seibel.distanthorizons.core.render.RenderParams; import com.seibel.distanthorizons.core.render.RenderParams;
import com.seibel.distanthorizons.core.util.math.Mat4f; import com.seibel.distanthorizons.core.util.math.DhMat4f;
import com.seibel.distanthorizons.core.util.math.Vec3d; import com.seibel.distanthorizons.core.util.math.DhVec3d;
import com.seibel.distanthorizons.core.util.math.Vec3f; import com.seibel.distanthorizons.core.util.math.DhVec3f;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IBindable; import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IBindable;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -35,8 +35,8 @@ public abstract class AbstractDebugWireframeRenderer implements IBindable
protected final PriorityBlockingQueue<BoxParticle> particles = new PriorityBlockingQueue<>(); protected final PriorityBlockingQueue<BoxParticle> particles = new PriorityBlockingQueue<>();
// used when rendering // used when rendering
protected Mat4f dhMvmProjMatrixThisFrame; protected DhMat4f dhMvmProjMatrixThisFrame;
protected Vec3f camPosFloatThisFrame; protected DhVec3f camPosFloatThisFrame;
@@ -47,9 +47,9 @@ public abstract class AbstractDebugWireframeRenderer implements IBindable
public void render(RenderParams renderParams) public void render(RenderParams renderParams)
{ {
this.dhMvmProjMatrixThisFrame = new Mat4f(renderParams.dhMvmProjMatrix); this.dhMvmProjMatrixThisFrame = new DhMat4f(renderParams.dhMvmProjMatrix);
Vec3d camPos = MC_RENDER.getCameraExactPosition(); DhVec3d camPos = MC_RENDER.getCameraExactPosition();
this.camPosFloatThisFrame = new Vec3f((float) camPos.x, (float) camPos.y, (float) camPos.z); this.camPosFloatThisFrame = new DhVec3f((float) camPos.x, (float) camPos.y, (float) camPos.z);
this.rendererLists.render(this); this.rendererLists.render(this);
@@ -113,8 +113,8 @@ public abstract class AbstractDebugWireframeRenderer implements IBindable
public static final class Box public static final class Box
{ {
public Vec3f minPos; public DhVec3f minPos;
public Vec3f maxPos; public DhVec3f maxPos;
public Color color; public Color color;
@@ -128,13 +128,13 @@ public abstract class AbstractDebugWireframeRenderer implements IBindable
int maxBlockPosX = minBlockPosX + DhSectionPos.getBlockWidth(pos); int maxBlockPosX = minBlockPosX + DhSectionPos.getBlockWidth(pos);
int maxBlockPosZ = minBlockPosZ + DhSectionPos.getBlockWidth(pos); int maxBlockPosZ = minBlockPosZ + DhSectionPos.getBlockWidth(pos);
this.minPos = new Vec3f(minBlockPosX + edgeOffset, minY, minBlockPosZ + edgeOffset); this.minPos = new DhVec3f(minBlockPosX + edgeOffset, minY, minBlockPosZ + edgeOffset);
this.maxPos = new Vec3f(maxBlockPosX - edgeOffset, maxY, maxBlockPosZ - edgeOffset); this.maxPos = new DhVec3f(maxBlockPosX - edgeOffset, maxY, maxBlockPosZ - edgeOffset);
this.color = color; this.color = color;
} }
/** only used for */ /** only used for */
public Box(Vec3f minPos, Vec3f maxPos, Color color) public Box(DhVec3f minPos, DhVec3f maxPos, Color color)
{ {
this.minPos = minPos; this.minPos = minPos;
this.maxPos = maxPos; this.maxPos = maxPos;
@@ -177,8 +177,8 @@ public abstract class AbstractDebugWireframeRenderer implements IBindable
float yDiff = this.yChange * percent; float yDiff = this.yChange * percent;
return new Box( return new Box(
new Vec3f(this.box.minPos.x, this.box.minPos.y + yDiff, this.box.minPos.z), new DhVec3f(this.box.minPos.x, this.box.minPos.y + yDiff, this.box.minPos.z),
new Vec3f(this.box.maxPos.x, this.box.maxPos.y + yDiff, this.box.maxPos.z), new DhVec3f(this.box.maxPos.x, this.box.maxPos.y + yDiff, this.box.maxPos.z),
this.box.color); this.box.color);
} }
@@ -34,7 +34,7 @@ import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos;
import com.seibel.distanthorizons.core.sql.dto.BeaconBeamDTO; import com.seibel.distanthorizons.core.sql.dto.BeaconBeamDTO;
import com.seibel.distanthorizons.core.util.LodUtil; import com.seibel.distanthorizons.core.util.LodUtil;
import com.seibel.distanthorizons.core.util.RenderUtil; import com.seibel.distanthorizons.core.util.RenderUtil;
import com.seibel.distanthorizons.core.util.math.Vec3d; import com.seibel.distanthorizons.core.util.math.DhVec3d;
import com.seibel.distanthorizons.core.util.threading.ThreadPoolUtil; import com.seibel.distanthorizons.core.util.threading.ThreadPoolUtil;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhGenericRenderer; import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhGenericRenderer;
@@ -138,7 +138,7 @@ public class BeaconRenderHandler
// lock to make sure we don't try adding beacons to the arrays while processing them // lock to make sure we don't try adding beacons to the arrays while processing them
this.updateLock.lock(); this.updateLock.lock();
Vec3d cameraPos = MC_RENDER.getCameraExactPosition(); DhVec3d cameraPos = MC_RENDER.getCameraExactPosition();
// fading by the overdraw prevention amount helps reduce beacons from rendering strangely // fading by the overdraw prevention amount helps reduce beacons from rendering strangely
// on the border of DH's render distance // on the border of DH's render distance
@@ -156,7 +156,7 @@ public class BeaconRenderHandler
for (DhApiRenderableBox box : this.fullBeaconBoxList) for (DhApiRenderableBox box : this.fullBeaconBoxList)
{ {
// if a beacon is outside the vanilla render distance render it // if a beacon is outside the vanilla render distance render it
double distance = Vec3d.getHorizontalDistance(cameraPos, box.minPos); double distance = DhVec3d.getHorizontalDistance(cameraPos, box.minPos);
if (distance > dhFadeDistance) if (distance > dhFadeDistance)
{ {
this.activeBeaconBoxRenderGroup.add(box); this.activeBeaconBoxRenderGroup.add(box);
@@ -31,8 +31,8 @@ import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.level.IDhClientLevel; import com.seibel.distanthorizons.core.level.IDhClientLevel;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.core.util.LodUtil; import com.seibel.distanthorizons.core.util.LodUtil;
import com.seibel.distanthorizons.core.util.math.Vec3d; import com.seibel.distanthorizons.core.util.math.DhVec3d;
import com.seibel.distanthorizons.core.util.math.Vec3f; import com.seibel.distanthorizons.core.util.math.DhVec3f;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhGenericRenderer; import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhGenericRenderer;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
@@ -89,13 +89,13 @@ public class CloudRenderHandler
private final IDhGenericRenderer renderer; private final IDhGenericRenderer renderer;
/** cached array so we don't need to re-create it each frame for each cloud group */ /** cached array so we don't need to re-create it each frame for each cloud group */
private final Vec3d[] cullingCorners = new Vec3d[] private final DhVec3d[] cullingCorners = new DhVec3d[]
{ {
// the values of each will be overwritten during the culling pass // the values of each will be overwritten during the culling pass
new Vec3d(), new DhVec3d(),
new Vec3d(), new DhVec3d(),
new Vec3d(), new DhVec3d(),
new Vec3d(), new DhVec3d(),
}; };
@@ -511,8 +511,8 @@ public class CloudRenderHandler
this.cullingCorners[3].y = minPosY; this.cullingCorners[3].y = minPosY;
this.cullingCorners[3].z = minPosZ + cloudParams.widthInBlocks; this.cullingCorners[3].z = minPosZ + cloudParams.widthInBlocks;
Vec3d cameraPos = MC_RENDER.getCameraExactPosition(); DhVec3d cameraPos = MC_RENDER.getCameraExactPosition();
Vec3f cameraLookAtVector = MC_RENDER.getLookAtVector(); DhVec3f cameraLookAtVector = MC_RENDER.getLookAtVector();
cameraLookAtVector.normalize(); cameraLookAtVector.normalize();
double renderDistance = Config.Client.Advanced.Graphics.Quality.lodChunkRenderDistanceRadius.get() double renderDistance = Config.Client.Advanced.Graphics.Quality.lodChunkRenderDistanceRadius.get()
@@ -529,14 +529,14 @@ public class CloudRenderHandler
boolean allOutsideRenderDistance = true; boolean allOutsideRenderDistance = true;
boolean allBehindCamera = true; boolean allBehindCamera = true;
for (Vec3d corner : this.cullingCorners) for (DhVec3d corner : this.cullingCorners)
{ {
// Check if the corner is within the render distance // Check if the corner is within the render distance
// (ignoring height, since LODs also ignore height) // (ignoring height, since LODs also ignore height)
Vec3d cornerNoHeight = new Vec3d(corner); DhVec3d cornerNoHeight = new DhVec3d(corner);
cornerNoHeight.y = 0; cornerNoHeight.y = 0;
Vec3d cameraPosNoHeight = new Vec3d(cameraPos); DhVec3d cameraPosNoHeight = new DhVec3d(cameraPos);
cameraPosNoHeight.y = 0; cameraPosNoHeight.y = 0;
double cornerDistance = cornerNoHeight.getDistance(cameraPosNoHeight); double cornerDistance = cornerNoHeight.getDistance(cameraPosNoHeight);
@@ -547,7 +547,7 @@ public class CloudRenderHandler
// Check if the corner is in front of the camera (dot product > 0 means in front) // Check if the corner is in front of the camera (dot product > 0 means in front)
Vec3f toCorner = new Vec3f( DhVec3f toCorner = new DhVec3f(
(float) (corner.x - cameraPos.x), (float) (corner.x - cameraPos.x),
(float) (corner.y - cameraPos.y), (float) (corner.y - cameraPos.y),
(float) (corner.z - cameraPos.z)); (float) (corner.z - cameraPos.z));
@@ -3,7 +3,7 @@ package com.seibel.distanthorizons.core.render.renderer.cullingFrustum;
import com.seibel.distanthorizons.api.interfaces.override.rendering.IDhApiCullingFrustum; import com.seibel.distanthorizons.api.interfaces.override.rendering.IDhApiCullingFrustum;
import com.seibel.distanthorizons.api.objects.math.DhApiMat4f; import com.seibel.distanthorizons.api.objects.math.DhApiMat4f;
import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IOverrideInjector; import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IOverrideInjector;
import com.seibel.distanthorizons.core.util.math.Mat4f; import com.seibel.distanthorizons.core.util.math.DhMat4f;
import org.joml.FrustumIntersection; import org.joml.FrustumIntersection;
import org.joml.Matrix4f; import org.joml.Matrix4f;
import org.joml.Matrix4fc; import org.joml.Matrix4fc;
@@ -41,7 +41,7 @@ public class DhFrustumBounds implements IDhApiCullingFrustum
this.worldMinY = worldMinBlockY; this.worldMinY = worldMinBlockY;
this.worldMaxY = worldMaxBlockY; this.worldMaxY = worldMaxBlockY;
Matrix4f worldViewProjection = new Matrix4f(Mat4f.createJomlMatrix(dhWorldViewProjection)); Matrix4f worldViewProjection = new Matrix4f(DhMat4f.createJomlMatrix(dhWorldViewProjection));
this.frustum.set(worldViewProjection); this.frustum.set(worldViewProjection);
Matrix4fc matWorldViewProjectionInv = new Matrix4f(worldViewProjection).invert(); Matrix4fc matWorldViewProjectionInv = new Matrix4f(worldViewProjection).invert();
@@ -32,7 +32,7 @@ import java.nio.FloatBuffer;
* @author James Seibel * @author James Seibel
* @version 11-11-2021 * @version 11-11-2021
*/ */
public class Mat4f extends DhApiMat4f public class DhMat4f extends DhApiMat4f
{ {
/** /**
* A matrix containing all 0's. <br><br> * A matrix containing all 0's. <br><br>
@@ -60,16 +60,16 @@ public class Mat4f extends DhApiMat4f
//==============// //==============//
/** all values are 0 */ /** all values are 0 */
public Mat4f() { } public DhMat4f() { }
public Mat4f(DhApiMat4f sourceMatrix) { super(sourceMatrix); } public DhMat4f(DhApiMat4f sourceMatrix) { super(sourceMatrix); }
/** Expects the values of the input buffer to be in row major order (AKA rows then columns) */ /** Expects the values of the input buffer to be in row major order (AKA rows then columns) */
public Mat4f(FloatBuffer buffer) { this(buffer.array()); } public DhMat4f(FloatBuffer buffer) { this(buffer.array()); }
/** Expects the values of the input array to be in row major order (AKA rows then columns) */ /** Expects the values of the input array to be in row major order (AKA rows then columns) */
public Mat4f(float[] values) { super(values); } public DhMat4f(float[] values) { super(values); }
public Mat4f(Matrix4fc sourceMatrix) { this.set(sourceMatrix); } public DhMat4f(Matrix4fc sourceMatrix) { this.set(sourceMatrix); }
public void set(Matrix4fc sourceMatrix) public void set(Matrix4fc sourceMatrix)
{ {
@@ -120,10 +120,10 @@ public class Mat4f extends DhApiMat4f
// methods // // methods //
//=========// //=========//
public static Mat4f perspective(double fov, float widthHeightRatio, float nearClipPlane, float farClipPlane) public static DhMat4f perspective(double fov, float widthHeightRatio, float nearClipPlane, float farClipPlane)
{ {
float f = (float) (1.0D / Math.tan(fov * ((float) Math.PI / 180F) / 2.0D)); float f = (float) (1.0D / Math.tan(fov * ((float) Math.PI / 180F) / 2.0D));
Mat4f matrix = new Mat4f(); DhMat4f matrix = new DhMat4f();
matrix.m00 = f / widthHeightRatio; matrix.m00 = f / widthHeightRatio;
matrix.m11 = f; matrix.m11 = f;
matrix.m22 = (farClipPlane + nearClipPlane) / (nearClipPlane - farClipPlane); matrix.m22 = (farClipPlane + nearClipPlane) / (nearClipPlane - farClipPlane);
@@ -136,9 +136,9 @@ public class Mat4f extends DhApiMat4f
public void multiplyTranslationMatrix(double x, double y, double z) public void multiplyTranslationMatrix(double x, double y, double z)
{ multiply(createTranslateMatrix((float) x, (float) y, (float) z)); } { multiply(createTranslateMatrix((float) x, (float) y, (float) z)); }
public static Mat4f createScaleMatrix(float x, float y, float z) public static DhMat4f createScaleMatrix(float x, float y, float z)
{ {
Mat4f matrix = new Mat4f(); DhMat4f matrix = new DhMat4f();
matrix.m00 = x; matrix.m00 = x;
matrix.m11 = y; matrix.m11 = y;
matrix.m22 = z; matrix.m22 = z;
@@ -146,9 +146,9 @@ public class Mat4f extends DhApiMat4f
return matrix; return matrix;
} }
public static Mat4f createTranslateMatrix(float x, float y, float z) public static DhMat4f createTranslateMatrix(float x, float y, float z)
{ {
Mat4f matrix = new Mat4f(); DhMat4f matrix = new DhMat4f();
matrix.m00 = 1.0F; matrix.m00 = 1.0F;
matrix.m11 = 1.0F; matrix.m11 = 1.0F;
matrix.m22 = 1.0F; matrix.m22 = 1.0F;
@@ -203,7 +203,7 @@ public class Mat4f extends DhApiMat4f
this.m23 = z; this.m23 = z;
} }
public Mat4f copy() { return new Mat4f(this); } public DhMat4f copy() { return new DhMat4f(this); }
@@ -20,7 +20,6 @@
package com.seibel.distanthorizons.core.util.math; package com.seibel.distanthorizons.core.util.math;
import com.seibel.distanthorizons.api.objects.math.DhApiVec3d; import com.seibel.distanthorizons.api.objects.math.DhApiVec3d;
import com.seibel.distanthorizons.api.objects.math.DhApiVec3f;
import com.seibel.distanthorizons.coreapi.util.MathUtil; import com.seibel.distanthorizons.coreapi.util.MathUtil;
/** /**
@@ -31,16 +30,16 @@ import com.seibel.distanthorizons.coreapi.util.MathUtil;
* @author James Seibel * @author James Seibel
* @version 11-18-2021 * @version 11-18-2021
*/ */
public class Vec3d extends DhApiVec3d public class DhVec3d extends DhApiVec3d
{ {
public static Vec3d XNeg = new Vec3d(-1.0F, 0.0F, 0.0F); public static DhVec3d XNeg = new DhVec3d(-1.0F, 0.0F, 0.0F);
public static Vec3d XPos = new Vec3d(1.0F, 0.0F, 0.0F); public static DhVec3d XPos = new DhVec3d(1.0F, 0.0F, 0.0F);
public static Vec3d YNeg = new Vec3d(0.0F, -1.0F, 0.0F); public static DhVec3d YNeg = new DhVec3d(0.0F, -1.0F, 0.0F);
public static Vec3d YPos = new Vec3d(0.0F, 1.0F, 0.0F); public static DhVec3d YPos = new DhVec3d(0.0F, 1.0F, 0.0F);
public static Vec3d ZNeg = new Vec3d(0.0F, 0.0F, -1.0F); public static DhVec3d ZNeg = new DhVec3d(0.0F, 0.0F, -1.0F);
public static Vec3d ZPos = new Vec3d(0.0F, 0.0F, 1.0F); public static DhVec3d ZPos = new DhVec3d(0.0F, 0.0F, 1.0F);
public static final Vec3d ZERO_VECTOR = new Vec3d(0.0D, 0.0D, 0.0D); public static final DhVec3d ZERO_VECTOR = new DhVec3d(0.0D, 0.0D, 0.0D);
@@ -48,26 +47,26 @@ public class Vec3d extends DhApiVec3d
// constructors // // constructors //
//==============// //==============//
public Vec3d() { } public DhVec3d() { }
public Vec3d(double x, double y, double z) public DhVec3d(double x, double y, double z)
{ {
this.x = x; this.x = x;
this.y = y; this.y = y;
this.z = z; this.z = z;
} }
public Vec3d(DhApiVec3d that) public DhVec3d(DhApiVec3d that)
{ {
this.x = that.x; this.x = that.x;
this.y = that.y; this.y = that.y;
this.z = that.z; this.z = that.z;
} }
public Vec3d(double[] values) { this.set(values); } public DhVec3d(double[] values) { this.set(values); }
public Vec3d copy() { return new Vec3d(this); } public DhVec3d copy() { return new DhVec3d(this); }
@@ -110,29 +109,29 @@ public class Vec3d extends DhApiVec3d
this.z += z; this.z += z;
} }
public void add(Vec3d vector) public void add(DhVec3d vector)
{ {
this.x += vector.x; this.x += vector.x;
this.y += vector.y; this.y += vector.y;
this.z += vector.z; this.z += vector.z;
} }
public void subtract(Vec3d vector) public void subtract(DhVec3d vector)
{ {
this.x -= vector.x; this.x -= vector.x;
this.y -= vector.y; this.y -= vector.y;
this.z -= vector.z; this.z -= vector.z;
} }
public double dotProduct(Vec3d vector) { return this.x * vector.x + this.y * vector.y + this.z * vector.z; } public double dotProduct(DhVec3d vector) { return this.x * vector.x + this.y * vector.y + this.z * vector.z; }
public Vec3d normalize() public DhVec3d normalize()
{ {
double value = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); double value = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
return value < 1.0E-4D ? ZERO_VECTOR : new Vec3d(this.x / value, this.y / value, this.z / value); return value < 1.0E-4D ? ZERO_VECTOR : new DhVec3d(this.x / value, this.y / value, this.z / value);
} }
public void crossProduct(Vec3d vector) public void crossProduct(DhVec3d vector)
{ {
double f = this.x; double f = this.x;
double f1 = this.y; double f1 = this.y;
@@ -168,9 +167,9 @@ public class Vec3d extends DhApiVec3d
+ Math.pow(a.z - b.z, 2)); + Math.pow(a.z - b.z, 2));
} }
/** @see Vec3d#getSquaredDistance(DhApiVec3d, DhApiVec3d) */ /** @see DhVec3d#getSquaredDistance(DhApiVec3d, DhApiVec3d) */
public double getSquaredDistance(DhApiVec3d other) { return getSquaredDistance(this, other); } public double getSquaredDistance(DhApiVec3d other) { return getSquaredDistance(this, other); }
/** slightly faster version of {@link Vec3d#getDistance} */ /** slightly faster version of {@link DhVec3d#getDistance} */
public static double getSquaredDistance(DhApiVec3d a, DhApiVec3d b) public static double getSquaredDistance(DhApiVec3d a, DhApiVec3d b)
{ {
return Math.pow(a.x - b.x, 2) return Math.pow(a.x - b.x, 2)
@@ -178,7 +177,7 @@ public class Vec3d extends DhApiVec3d
+ Math.pow(a.z - b.z, 2); + Math.pow(a.z - b.z, 2);
} }
/** @see Vec3d#getHorizontalDistance(DhApiVec3d, DhApiVec3d) */ /** @see DhVec3d#getHorizontalDistance(DhApiVec3d, DhApiVec3d) */
public double getHorizontalDistance(DhApiVec3d other) { return getHorizontalDistance(this, other); } public double getHorizontalDistance(DhApiVec3d other) { return getHorizontalDistance(this, other); }
/** Gets the distance between points A and B, ignoring Y height. */ /** Gets the distance between points A and B, ignoring Y height. */
public static double getHorizontalDistance(DhApiVec3d a, DhApiVec3d b) public static double getHorizontalDistance(DhApiVec3d a, DhApiVec3d b)
@@ -29,29 +29,29 @@ import com.seibel.distanthorizons.coreapi.util.MathUtil;
* @author James Seibel * @author James Seibel
* @version 11-11-2021 * @version 11-11-2021
*/ */
public class Vec3f extends DhApiVec3f public class DhVec3f extends DhApiVec3f
{ {
//==============// //==============//
// constructors // // constructors //
//==============// //==============//
public Vec3f() { this(0,0,0); } public DhVec3f() { this(0,0,0); }
public Vec3f(float x, float y, float z) public DhVec3f(float x, float y, float z)
{ {
this.x = x; this.x = x;
this.y = y; this.y = y;
this.z = z; this.z = z;
} }
public Vec3f(DhApiVec3f pos) public DhVec3f(DhApiVec3f pos)
{ {
this.x = pos.x; this.x = pos.x;
this.y = pos.y; this.y = pos.y;
this.z = pos.z; this.z = pos.z;
} }
public Vec3f(Vec3d pos) public DhVec3f(DhVec3d pos)
{ {
this.x = (float) pos.x; this.x = (float) pos.x;
this.y = (float) pos.y; this.y = (float) pos.y;
@@ -93,21 +93,21 @@ public class Vec3f extends DhApiVec3f
this.z += z; this.z += z;
} }
public void add(Vec3f vector) public void add(DhVec3f vector)
{ {
this.x += vector.x; this.x += vector.x;
this.y += vector.y; this.y += vector.y;
this.z += vector.z; this.z += vector.z;
} }
public void subtract(Vec3f vector) public void subtract(DhVec3f vector)
{ {
this.x -= vector.x; this.x -= vector.x;
this.y -= vector.y; this.y -= vector.y;
this.z -= vector.z; this.z -= vector.z;
} }
public float dotProduct(Vec3f vector) { return this.x * vector.x + this.y * vector.y + this.z * vector.z; } public float dotProduct(DhVec3f vector) { return this.x * vector.x + this.y * vector.y + this.z * vector.z; }
/** @return true if normalization had to be done */ /** @return true if normalization had to be done */
public boolean normalize() public boolean normalize()
@@ -127,7 +127,7 @@ public class Vec3f extends DhApiVec3f
} }
} }
public void crossProduct(Vec3f vector) public void crossProduct(DhVec3f vector)
{ {
float f = this.x; float f = this.x;
float f1 = this.y; float f1 = this.y;
@@ -167,6 +167,6 @@ public class Vec3f extends DhApiVec3f
this.z = z; this.z = z;
} }
public Vec3f copy() { return new Vec3f(this.x, this.y, this.z); } public DhVec3f copy() { return new DhVec3f(this.x, this.y, this.z); }
} }
@@ -29,27 +29,27 @@ import com.seibel.distanthorizons.api.objects.math.DhApiVec3i;
* @author James Seibel * @author James Seibel
* @version 2022-11-19 * @version 2022-11-19
*/ */
public class Vec3i extends DhApiVec3i // extends the API object so it can be returned through the API public class DhVec3i extends DhApiVec3i // extends the API object so it can be returned through the API
{ {
public static Vec3i XNeg = new Vec3i(-1, 0, 0); public static DhVec3i XNeg = new DhVec3i(-1, 0, 0);
public static Vec3i XPos = new Vec3i(1, 0, 0); public static DhVec3i XPos = new DhVec3i(1, 0, 0);
public static Vec3i YNeg = new Vec3i(0, -1, 0); public static DhVec3i YNeg = new DhVec3i(0, -1, 0);
public static Vec3i YPos = new Vec3i(0, 1, 0); public static DhVec3i YPos = new DhVec3i(0, 1, 0);
public static Vec3i ZNeg = new Vec3i(0, 0, -1); public static DhVec3i ZNeg = new DhVec3i(0, 0, -1);
public static Vec3i ZPos = new Vec3i(0, 0, 1); public static DhVec3i ZPos = new DhVec3i(0, 0, 1);
// x,y,z variables are handled in the parent object // x,y,z variables are handled in the parent object
public Vec3i() public DhVec3i()
{ {
this.x = 0; this.x = 0;
this.y = 0; this.y = 0;
this.z = 0; this.z = 0;
} }
public Vec3i(int x, int y, int z) public DhVec3i(int x, int y, int z)
{ {
this.x = x; this.x = x;
this.y = y; this.y = y;
@@ -93,14 +93,14 @@ public class Vec3i extends DhApiVec3i // extends the API object so it can be ret
this.z += z; this.z += z;
} }
public void add(Vec3i vector) public void add(DhVec3i vector)
{ {
this.x += vector.x; this.x += vector.x;
this.y += vector.y; this.y += vector.y;
this.z += vector.z; this.z += vector.z;
} }
public void subtract(Vec3i vector) public void subtract(DhVec3i vector)
{ {
this.x -= vector.x; this.x -= vector.x;
this.y -= vector.y; this.y -= vector.y;
@@ -116,7 +116,7 @@ public class Vec3i extends DhApiVec3i // extends the API object so it can be ret
return (xAdd * xAdd) + (yAdd * yAdd) + (zAdd * zAdd); return (xAdd * xAdd) + (yAdd * yAdd) + (zAdd * zAdd);
} }
public int distManhattan(Vec3i otherVec) public int distManhattan(DhVec3i otherVec)
{ {
float xSub = Math.abs(otherVec.x - this.x); float xSub = Math.abs(otherVec.x - this.x);
float ySub = Math.abs(otherVec.y - this.y); float ySub = Math.abs(otherVec.y - this.y);
@@ -125,30 +125,30 @@ public class Vec3i extends DhApiVec3i // extends the API object so it can be ret
} }
/** inner product */ /** inner product */
public float dotProduct(Vec3i vector) public float dotProduct(DhVec3i vector)
{ {
return (this.x * vector.x) + (this.y * vector.y) + (this.z * vector.z); return (this.x * vector.x) + (this.y * vector.y) + (this.z * vector.z);
} }
/** Cross product */ /** Cross product */
public Vec3i cross(Vec3i otherVec) public DhVec3i cross(DhVec3i otherVec)
{ {
return new Vec3i( return new DhVec3i(
(this.y * otherVec.z) - (this.z * otherVec.y), (this.y * otherVec.z) - (this.z * otherVec.y),
(this.z * otherVec.x) - (this.x * otherVec.z), (this.z * otherVec.x) - (this.x * otherVec.z),
(this.x * otherVec.y) - (this.y * otherVec.x)); (this.x * otherVec.y) - (this.y * otherVec.x));
} }
public Vec3i copy() public DhVec3i copy()
{ {
return new Vec3i(this.x, this.y, this.z); return new DhVec3i(this.x, this.y, this.z);
} }
// Forge start // Forge start
public Vec3i(int[] values) { this.set(values); } public DhVec3i(int[] values) { this.set(values); }
public void set(int[] values) public void set(int[] values)
{ {
@@ -22,12 +22,11 @@ package com.seibel.distanthorizons.core.wrapperInterfaces.minecraft;
import java.awt.Color; import java.awt.Color;
import com.seibel.distanthorizons.core.api.internal.rendering.DhRenderState; import com.seibel.distanthorizons.core.api.internal.rendering.DhRenderState;
import com.seibel.distanthorizons.core.enums.EDhDirection;
import com.seibel.distanthorizons.api.enums.config.EDhApiRenderingApi; import com.seibel.distanthorizons.api.enums.config.EDhApiRenderingApi;
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.ILightMapWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.misc.ILightMapWrapper;
import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IBindable; import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IBindable;
import com.seibel.distanthorizons.core.util.math.Vec3d; import com.seibel.distanthorizons.core.util.math.DhVec3d;
import com.seibel.distanthorizons.core.util.math.Vec3f; import com.seibel.distanthorizons.core.util.math.DhVec3f;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@@ -41,7 +40,7 @@ import org.jetbrains.annotations.Nullable;
*/ */
public interface IMinecraftRenderWrapper extends IBindable public interface IMinecraftRenderWrapper extends IBindable
{ {
Vec3f getLookAtVector(); DhVec3f getLookAtVector();
boolean playerHasBlindingEffect(); boolean playerHasBlindingEffect();
@@ -60,7 +59,7 @@ public interface IMinecraftRenderWrapper extends IBindable
*/ */
float getPartialTickTime(); float getPartialTickTime();
Vec3d getCameraExactPosition(); DhVec3d getCameraExactPosition();
Color getFogColor(float partialTicks); Color getFogColor(float partialTicks);
@@ -21,9 +21,7 @@ package com.seibel.distanthorizons.core.wrapperInterfaces.misc;
import com.seibel.distanthorizons.api.interfaces.IDhApiUnsafeWrapper; import com.seibel.distanthorizons.api.interfaces.IDhApiUnsafeWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper;
import com.seibel.distanthorizons.core.util.math.Vec3d; import com.seibel.distanthorizons.core.util.math.DhVec3d;
import java.net.SocketAddress;
public interface IServerPlayerWrapper extends IDhApiUnsafeWrapper public interface IServerPlayerWrapper extends IDhApiUnsafeWrapper
{ {
@@ -31,6 +29,6 @@ public interface IServerPlayerWrapper extends IDhApiUnsafeWrapper
IServerLevelWrapper getLevel(); IServerLevelWrapper getLevel();
Vec3d getPosition(); DhVec3d getPosition();
} }
@@ -21,7 +21,7 @@ package com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor;
import com.seibel.distanthorizons.core.pos.DhChunkPos; import com.seibel.distanthorizons.core.pos.DhChunkPos;
import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos; import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos;
import com.seibel.distanthorizons.core.util.math.Vec3d; import com.seibel.distanthorizons.core.util.math.DhVec3d;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@@ -70,7 +70,7 @@ public interface IImmersivePortalsAccessor extends IModAccessor
* variables in order to render the camera in multiple dimensions. * variables in order to render the camera in multiple dimensions.
*/ */
@Nullable @Nullable
Vec3d getActualCameraPos(); DhVec3d getActualCameraPos();
@@ -20,8 +20,6 @@
package com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass; package com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass;
import com.seibel.distanthorizons.core.render.RenderParams; import com.seibel.distanthorizons.core.render.RenderParams;
import com.seibel.distanthorizons.core.util.math.Mat4f;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IBindable; import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IBindable;
public interface IDhVanillaFadeRenderer extends IBindable public interface IDhVanillaFadeRenderer extends IBindable