Add IDhApiCullingFrustum
This commit is contained in:
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2023 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.distanthorizons.api.interfaces.override.rendering;
|
||||
|
||||
import com.seibel.distanthorizons.api.enums.EDhApiDetailLevel;
|
||||
import com.seibel.distanthorizons.api.interfaces.override.IDhApiOverrideable;
|
||||
import com.seibel.distanthorizons.coreapi.util.math.Mat4f;
|
||||
|
||||
/**
|
||||
* Used to determine if a LOD should be rendered or is outside the
|
||||
* user's field of view.
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2024-2-6
|
||||
* @since API 1.1.0
|
||||
*/
|
||||
public interface IDhApiCullingFrustum extends IDhApiOverrideable
|
||||
{
|
||||
|
||||
/**
|
||||
* Called before a render pass is done.
|
||||
*
|
||||
* @param worldMinBlockY the lowest block position this level allows.
|
||||
* @param worldMaxBlockY the highest block position this level allows.
|
||||
* @param worldViewProjection the projection matrix used in this render pass.
|
||||
*/
|
||||
void update(int worldMinBlockY, int worldMaxBlockY, Mat4f worldViewProjection);
|
||||
|
||||
/**
|
||||
* returns true if the LOD bounds intersect this frustum
|
||||
*
|
||||
* @param lodBlockPosMinX this LOD's starting block X position closest to negative infinity
|
||||
* @param lodBlockPosMinZ this LOD's starting block Z position closest to negative infinity
|
||||
* @param lodBlockWidth this LOD's width in blocks
|
||||
* @param lodDetailLevel this LOD's detail level
|
||||
*
|
||||
* @see EDhApiDetailLevel
|
||||
*/
|
||||
boolean intersects(int lodBlockPosMinX, int lodBlockPosMinZ, int lodBlockWidth, int lodDetailLevel);
|
||||
|
||||
}
|
||||
@@ -20,6 +20,7 @@
|
||||
package com.seibel.distanthorizons.coreapi.util.math;
|
||||
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Matrix4fc;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
@@ -75,8 +76,8 @@ public class Mat4f
|
||||
this.m33 = sourceMatrix.m33;
|
||||
}
|
||||
|
||||
public Mat4f(Matrix4f sourceMatrix) { this(convertJomlMatrixToArray(sourceMatrix)); }
|
||||
private static float[] convertJomlMatrixToArray(Matrix4f sourceMatrix)
|
||||
public Mat4f(Matrix4fc sourceMatrix) { this(convertJomlMatrixToArray(sourceMatrix)); }
|
||||
private static float[] convertJomlMatrixToArray(Matrix4fc sourceMatrix)
|
||||
{
|
||||
FloatBuffer buffer = FloatBuffer.allocate(16);
|
||||
|
||||
@@ -216,6 +217,17 @@ public class Mat4f
|
||||
floatBuffer.put(bufferIndex(3, 3), this.m33);
|
||||
}
|
||||
|
||||
public Matrix4f createJomlMatrix()
|
||||
{
|
||||
return new Matrix4f(
|
||||
this.m00, this.m10, this.m20, this.m30,
|
||||
this.m01, this.m11, this.m21, this.m31,
|
||||
this.m02, this.m12, this.m22, this.m32,
|
||||
this.m03, this.m13, this.m23, this.m33
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private static int bufferIndex(int xIndex, int zIndex)
|
||||
{
|
||||
return (zIndex * 4) + xIndex;
|
||||
|
||||
Reference in New Issue
Block a user