OctreeDebugRenderer.java

net.minecraft.client.renderer.debug.OctreeDebugRenderer

信息

  • 全限定名:net.minecraft.client.renderer.debug.OctreeDebugRenderer
  • 类型:public class
  • 包:net.minecraft.client.renderer.debug
  • 源码路径:src/main/java/net/minecraft/client/renderer/debug/OctreeDebugRenderer.java
  • 起始行号:L18
  • 实现:DebugRenderer.SimpleDebugRenderer
  • 职责:

    TODO

字段/常量

  • minecraft
    • 类型: Minecraft
    • 修饰符: private final
    • 源码定位: L19
    • 说明:

      TODO

内部类/嵌套类型

构造器

public OctreeDebugRenderer(Minecraft minecraft) @ L21

  • 构造器名:OctreeDebugRenderer
  • 源码定位:L21
  • 修饰符:public

参数:

  • minecraft: Minecraft

说明:

TODO

方法

下面的方法块按源码顺序生成。

public void emitGizmos(double camX, double camY, double camZ, DebugValueAccess debugValues, Frustum frustum, float partialTicks) @ L25

  • 方法名:emitGizmos
  • 源码定位:L25
  • 返回类型:void
  • 修饰符:public

参数:

  • camX: double
  • camY: double
  • camZ: double
  • debugValues: DebugValueAccess
  • frustum: Frustum
  • partialTicks: float

说明:

TODO

private void renderNode(Octree.Node node, int depth, boolean fullyVisible, MutableInt count, boolean isClose) @ L32

  • 方法名:renderNode
  • 源码定位:L32
  • 返回类型:void
  • 修饰符:private

参数:

  • node: Octree.Node
  • depth: int
  • fullyVisible: boolean
  • count: MutableInt
  • isClose: boolean

说明:

TODO

private static float getColorComponent(long size, float multiplier) @ L53

  • 方法名:getColorComponent
  • 源码定位:L53
  • 返回类型:float
  • 修饰符:private static

参数:

  • size: long
  • multiplier: float

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class OctreeDebugRenderer implements DebugRenderer.SimpleDebugRenderer {
    private final Minecraft minecraft;
 
    public OctreeDebugRenderer(Minecraft minecraft) {
        this.minecraft = minecraft;
    }
 
    @Override
    public void emitGizmos(double camX, double camY, double camZ, DebugValueAccess debugValues, Frustum frustum, float partialTicks) {
        Octree octree = this.minecraft.levelRenderer.getSectionOcclusionGraph().getOctree();
        MutableInt count = new MutableInt(0);
        octree.visitNodes((node, fullyVisible, depth, isClose) -> this.renderNode(node, depth, fullyVisible, count, isClose), frustum, 32);
    }
 
    private void renderNode(Octree.Node node, int depth, boolean fullyVisible, MutableInt count, boolean isClose) {
        AABB aabb = node.getAABB();
        double xSize = aabb.getXsize();
        long size = Math.round(xSize / 16.0);
        if (size == 1L) {
            count.add(1);
            int color = isClose ? -16711936 : -1;
            Gizmos.billboardText(String.valueOf(count.intValue()), aabb.getCenter(), TextGizmo.Style.forColorAndCentered(color).withScale(4.8F));
        }
 
        long colorNum = size + 5L;
        Gizmos.cuboid(
            aabb.deflate(0.1 * depth),
            GizmoStyle.stroke(
                ARGB.colorFromFloat(
                    fullyVisible ? 0.4F : 1.0F, getColorComponent(colorNum, 0.3F), getColorComponent(colorNum, 0.8F), getColorComponent(colorNum, 0.5F)
                )
            )
        );
    }
 
    private static float getColorComponent(long size, float multiplier) {
        float minColor = 0.1F;
        return Mth.frac(multiplier * (float)size) * 0.9F + 0.1F;
    }
}

引用的其他类

  • Minecraft

    • 引用位置: 参数/字段
  • Octree

    • 引用位置: 参数
  • Frustum

    • 引用位置: 参数
  • DebugRenderer

    • 引用位置: 实现
  • GizmoStyle

    • 引用位置: 方法调用
    • 关联成员: GizmoStyle.stroke()
  • Gizmos

    • 引用位置: 方法调用
    • 关联成员: Gizmos.billboardText(), Gizmos.cuboid()
  • TextGizmo

    • 引用位置: 方法调用
    • 关联成员: TextGizmo.Style.forColorAndCentered()
  • ARGB

    • 引用位置: 方法调用
    • 关联成员: ARGB.colorFromFloat()
  • Mth

    • 引用位置: 方法调用
    • 关联成员: Mth.frac()
  • DebugValueAccess

    • 引用位置: 参数