ClippingHelperImpl .java

net.minecraft.client.renderer.culling.ClippingHelperImpl (class): members: projectionMatrixBuffer, modelviewMatrixBuffer, field_78564_h, getInstance, init.

net.minecraft.client.renderer.cullingclass100 linesclientextends ClippingHelper5.9 KB

API Surface (2)

ClippingHelper getInstance()
void init()

Fields & Constants (4)

instance
projectionMatrixBuffer
modelviewMatrixBuffer
field_78564_h

Code Graph: Dependencies (4)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

ClippingHelperImpl.java100 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.renderer.culling;
2
3
import java.nio.FloatBuffer;
4
import net.minecraft.client.renderer.GLAllocation;
5
import net.minecraft.client.renderer.GlStateManager;
6
import net.minecraft.util.MathHelper;
7
8
public class ClippingHelperImpl extends ClippingHelper
9
{
10
    private static ClippingHelperImpl instance = new ClippingHelperImpl();
11
    private FloatBuffer projectionMatrixBuffer = GLAllocation.createDirectFloatBuffer(16);
12
    private FloatBuffer modelviewMatrixBuffer = GLAllocation.createDirectFloatBuffer(16);
13
    private FloatBuffer field_78564_h = GLAllocation.createDirectFloatBuffer(16);
14
15
    /**
16
     * Initialises the ClippingHelper object then returns an instance of it.
17
     */
18
    public static ClippingHelper getInstance()
19
    {
20
        instance.init();
21
        return instance;
22
    }
23
24
    private void normalize(float[] p_180547_1_)
25
    {
26
        float f = MathHelper.sqrt_float(p_180547_1_[0] * p_180547_1_[0] + p_180547_1_[1] * p_180547_1_[1] + p_180547_1_[2] * p_180547_1_[2]);
27
        p_180547_1_[0] /= f;
28
        p_180547_1_[1] /= f;
29
        p_180547_1_[2] /= f;
30
        p_180547_1_[3] /= f;
31
    }
32
33
    public void init()
34
    {
35
        this.projectionMatrixBuffer.clear();
36
        this.modelviewMatrixBuffer.clear();
37
        this.field_78564_h.clear();
38
        GlStateManager.getFloat(2983, this.projectionMatrixBuffer);
39
        GlStateManager.getFloat(2982, this.modelviewMatrixBuffer);
40
        float[] afloat = this.projectionMatrix;
41
        float[] afloat1 = this.modelviewMatrix;
42
        this.projectionMatrixBuffer.flip().limit(16);
43
        this.projectionMatrixBuffer.get(afloat);
44
        this.modelviewMatrixBuffer.flip().limit(16);
45
        this.modelviewMatrixBuffer.get(afloat1);
46
        this.clippingMatrix[0] = afloat1[0] * afloat[0] + afloat1[1] * afloat[4] + afloat1[2] * afloat[8] + afloat1[3] * afloat[12];
47
        this.clippingMatrix[1] = afloat1[0] * afloat[1] + afloat1[1] * afloat[5] + afloat1[2] * afloat[9] + afloat1[3] * afloat[13];
48
        this.clippingMatrix[2] = afloat1[0] * afloat[2] + afloat1[1] * afloat[6] + afloat1[2] * afloat[10] + afloat1[3] * afloat[14];
49
        this.clippingMatrix[3] = afloat1[0] * afloat[3] + afloat1[1] * afloat[7] + afloat1[2] * afloat[11] + afloat1[3] * afloat[15];
50
        this.clippingMatrix[4] = afloat1[4] * afloat[0] + afloat1[5] * afloat[4] + afloat1[6] * afloat[8] + afloat1[7] * afloat[12];
51
        this.clippingMatrix[5] = afloat1[4] * afloat[1] + afloat1[5] * afloat[5] + afloat1[6] * afloat[9] + afloat1[7] * afloat[13];
52
        this.clippingMatrix[6] = afloat1[4] * afloat[2] + afloat1[5] * afloat[6] + afloat1[6] * afloat[10] + afloat1[7] * afloat[14];
53
        this.clippingMatrix[7] = afloat1[4] * afloat[3] + afloat1[5] * afloat[7] + afloat1[6] * afloat[11] + afloat1[7] * afloat[15];
54
        this.clippingMatrix[8] = afloat1[8] * afloat[0] + afloat1[9] * afloat[4] + afloat1[10] * afloat[8] + afloat1[11] * afloat[12];
55
        this.clippingMatrix[9] = afloat1[8] * afloat[1] + afloat1[9] * afloat[5] + afloat1[10] * afloat[9] + afloat1[11] * afloat[13];
56
        this.clippingMatrix[10] = afloat1[8] * afloat[2] + afloat1[9] * afloat[6] + afloat1[10] * afloat[10] + afloat1[11] * afloat[14];
57
        this.clippingMatrix[11] = afloat1[8] * afloat[3] + afloat1[9] * afloat[7] + afloat1[10] * afloat[11] + afloat1[11] * afloat[15];
58
        this.clippingMatrix[12] = afloat1[12] * afloat[0] + afloat1[13] * afloat[4] + afloat1[14] * afloat[8] + afloat1[15] * afloat[12];
59
        this.clippingMatrix[13] = afloat1[12] * afloat[1] + afloat1[13] * afloat[5] + afloat1[14] * afloat[9] + afloat1[15] * afloat[13];
60
        this.clippingMatrix[14] = afloat1[12] * afloat[2] + afloat1[13] * afloat[6] + afloat1[14] * afloat[10] + afloat1[15] * afloat[14];
61
        this.clippingMatrix[15] = afloat1[12] * afloat[3] + afloat1[13] * afloat[7] + afloat1[14] * afloat[11] + afloat1[15] * afloat[15];
62
        float[] afloat2 = this.frustum[0];
63
        afloat2[0] = this.clippingMatrix[3] - this.clippingMatrix[0];
64
        afloat2[1] = this.clippingMatrix[7] - this.clippingMatrix[4];
65
        afloat2[2] = this.clippingMatrix[11] - this.clippingMatrix[8];
66
        afloat2[3] = this.clippingMatrix[15] - this.clippingMatrix[12];
67
        this.normalize(afloat2);
68
        float[] afloat3 = this.frustum[1];
69
        afloat3[0] = this.clippingMatrix[3] + this.clippingMatrix[0];
70
        afloat3[1] = this.clippingMatrix[7] + this.clippingMatrix[4];
71
        afloat3[2] = this.clippingMatrix[11] + this.clippingMatrix[8];
72
        afloat3[3] = this.clippingMatrix[15] + this.clippingMatrix[12];
73
        this.normalize(afloat3);
74
        float[] afloat4 = this.frustum[2];
75
        afloat4[0] = this.clippingMatrix[3] + this.clippingMatrix[1];
76
        afloat4[1] = this.clippingMatrix[7] + this.clippingMatrix[5];
77
        afloat4[2] = this.clippingMatrix[11] + this.clippingMatrix[9];
78
        afloat4[3] = this.clippingMatrix[15] + this.clippingMatrix[13];
79
        this.normalize(afloat4);
80
        float[] afloat5 = this.frustum[3];
81
        afloat5[0] = this.clippingMatrix[3] - this.clippingMatrix[1];
82
        afloat5[1] = this.clippingMatrix[7] - this.clippingMatrix[5];
83
        afloat5[2] = this.clippingMatrix[11] - this.clippingMatrix[9];
84
        afloat5[3] = this.clippingMatrix[15] - this.clippingMatrix[13];
85
        this.normalize(afloat5);
86
        float[] afloat6 = this.frustum[4];
87
        afloat6[0] = this.clippingMatrix[3] - this.clippingMatrix[2];
88
        afloat6[1] = this.clippingMatrix[7] - this.clippingMatrix[6];
89
        afloat6[2] = this.clippingMatrix[11] - this.clippingMatrix[10];
90
        afloat6[3] = this.clippingMatrix[15] - this.clippingMatrix[14];
91
        this.normalize(afloat6);
92
        float[] afloat7 = this.frustum[5];
93
        afloat7[0] = this.clippingMatrix[3] + this.clippingMatrix[2];
94
        afloat7[1] = this.clippingMatrix[7] + this.clippingMatrix[6];
95
        afloat7[2] = this.clippingMatrix[11] + this.clippingMatrix[10];
96
        afloat7[3] = this.clippingMatrix[15] + this.clippingMatrix[14];
97
        this.normalize(afloat7);
98
    }
99
}
100

Deobfuscated MCP 1.8.9 source of ClippingHelperImpl from Marcelektro/MavenMCP-1.8.9 (net/minecraft/client/renderer/culling/ClippingHelperImpl.java), stored verbatim.