]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/blob - src/main/java/com/irtimaled/bbor/common/models/AbstractBoundingBox.java
Add "Fast Render" option to configure culling behaviors
[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.client.ClientRenderer;
4 import com.irtimaled.bbor.client.RenderCulling;
5 import com.irtimaled.bbor.client.renderers.AbstractRenderer;
6 import com.irtimaled.bbor.common.BoundingBoxType;
7
8 public abstract class AbstractBoundingBox {
9     private final BoundingBoxType type;
10
11     protected AbstractBoundingBox(BoundingBoxType type) {
12         this.type = type;
13     }
14
15     public abstract Boolean intersectsBounds(int minX, int minZ, int maxX, int maxZ);
16
17     public BoundingBoxType getType() {
18         return type;
19     }
20
21     public double getDistance(double x, double y, double z) {
22         double dX = getDistanceX(x);
23         double dY = getDistanceY(y);
24         double dZ = getDistanceZ(z);
25         return dX * dX + dY * dY + dZ * dZ;
26     }
27
28     protected abstract double getDistanceX(double x);
29
30     protected abstract double getDistanceY(double y);
31
32     protected abstract double getDistanceZ(double z);
33
34     public AbstractRenderer<?> getRenderer() {
35         return ClientRenderer.getRenderer(this.getClass());
36     }
37
38     public boolean isVisibleCulling() {
39         RenderCulling.incrementCulling();
40         return true;
41     }
42 }