import com.irtimaled.bbor.client.config.ConfigManager;
import com.irtimaled.bbor.client.models.Point;
+import com.irtimaled.bbor.common.MathHelper;
import com.irtimaled.bbor.common.models.AbstractBoundingBox;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
public abstract class AbstractRenderer<T extends AbstractBoundingBox> {
private static final double TAU = 6.283185307179586D;
+ public static final double PHI_SEGMENT = TAU / 90D;
private static final double PI = TAU / 2D;
+ public static final double THETA_SEGMENT = PHI_SEGMENT / 2D;
public abstract void render(T boundingBox);
RenderHelper.lineWidth2();
double offset = ((radius - (int) radius) == 0) ? center.getY() - (int) center.getY() : 0;
- for (double dy = offset - radius; dy <= radius + 1; dy++) {
+ int dyStep = radius < 64 ? 1 : MathHelper.floor(radius / 32);
+ for (double dy = offset - radius; dy <= radius + 1; dy += dyStep) {
double circleRadius = Math.sqrt((radius * radius) - (dy * dy));
if (circleRadius == 0) circleRadius = Math.sqrt(2) / 2;
renderCircle(center, circleRadius, color, dy + 0.001F);
Renderer renderer = Renderer.startLineLoop()
.setColor(color);
- for (int a = 0; a < 360; a += 5) {
- double heading = a * PI / 180;
- renderer.addPoint(new OffsetPoint(center.offset(Math.cos(heading) * radius, dy, Math.sin(heading) * radius)));
+ for (double phi = 0.0D; phi < TAU; phi += PHI_SEGMENT) {
+ renderer.addPoint(new OffsetPoint(center.offset(Math.cos(phi) * radius, dy, Math.sin(phi) * radius)));
}
renderer.render();
Renderer renderer = Renderer.startPoints()
.setColor(color);
- int segments = 64;
- double thetaSegment = PI / (double) segments;
- double phiSegment = TAU / (double) segments;
-
- for (double phi = 0.0D; phi < TAU; phi += phiSegment) {
- for (double theta = 0.0D; theta < PI; theta += thetaSegment) {
- double dx = radius * Math.sin(phi) * Math.cos(theta);
- double dz = radius * Math.sin(phi) * Math.sin(theta);
- double dy = radius * Math.cos(phi);
+ for (double phi = 0.0D; phi < TAU; phi += PHI_SEGMENT) {
+ double dy = radius * Math.cos(phi);
+ double radiusBySinPhi = radius * Math.sin(phi);
+ for (double theta = 0.0D; theta < PI; theta += THETA_SEGMENT) {
+ double dx = radiusBySinPhi * Math.cos(theta);
+ double dz = radiusBySinPhi * Math.sin(theta);
renderer.addPoint(new OffsetPoint(center.offset(dx, dy, dz)));
}