]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/blob - src/main/java/com/irtimaled/bbor/common/models/AbstractBoundingBox.java
Fix Z-ordering of boxes
[BoundingBoxOutlineReloaded.git] / src / main / java / com / irtimaled / bbor / common / models / AbstractBoundingBox.java
1 package com.irtimaled.bbor.common.models;
2
3 import com.irtimaled.bbor.common.BoundingBoxType;
4
5 public abstract class AbstractBoundingBox {
6     private final BoundingBoxType type;
7
8     protected AbstractBoundingBox(BoundingBoxType type) {
9         this.type = type;
10     }
11
12     public abstract Boolean intersectsBounds(int minX, int minZ, int maxX, int maxZ);
13
14     public BoundingBoxType getType() {
15         return type;
16     }
17
18     public double getDistance(double x, double y, double z) {
19         double dX = getDistanceX(x);
20         double dY = getDistanceY(y);
21         double dZ = getDistanceZ(z);
22         return Math.cbrt(dX * dX + dY * dY + dZ * dZ);
23     }
24
25     protected abstract double getDistanceX(double x);
26
27     protected abstract double getDistanceY(double y);
28
29     protected abstract double getDistanceZ(double z);
30 }