Add BoundingBox interface to Camera
This commit is contained in:
@@ -4,10 +4,11 @@ import com.bartlomiejpluta.base.api.context.Context;
|
||||
import com.bartlomiejpluta.base.api.move.Movable;
|
||||
import com.bartlomiejpluta.base.api.screen.Screen;
|
||||
import com.bartlomiejpluta.base.internal.object.Placeable;
|
||||
import com.bartlomiejpluta.base.internal.render.BoundingBox;
|
||||
import com.bartlomiejpluta.base.internal.render.ShaderManager;
|
||||
import org.joml.Matrix4fc;
|
||||
|
||||
public interface Camera extends Placeable {
|
||||
public interface Camera extends Placeable, BoundingBox {
|
||||
Matrix4fc computeViewModelMatrix(Matrix4fc modelMatrix);
|
||||
|
||||
boolean insideFrustum(float x, float y, float radius);
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.bartlomiejpluta.base.internal.render;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public interface BoundingBox {
|
||||
float getMinX();
|
||||
|
||||
float getMaxX();
|
||||
|
||||
float getMinY();
|
||||
|
||||
float getMaxY();
|
||||
|
||||
default boolean containsBox(float minX, float maxX, float minY, float maxY) {
|
||||
return !(this.getMaxX() < minX ||
|
||||
this.getMinX() > maxX ||
|
||||
this.getMaxY() < minY ||
|
||||
this.getMinY() > maxY);
|
||||
}
|
||||
|
||||
default boolean containsBox(BoundingBox box) {
|
||||
return !(this.getMaxX() < box.getMinX() ||
|
||||
this.getMinX() > box.getMaxX() ||
|
||||
this.getMaxY() < box.getMinY() ||
|
||||
this.getMinY() > box.getMaxY());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user