1010package org .enginehub .worldeditcui .render ;
1111
1212import com .mojang .blaze3d .opengl .GlStateManager ;
13- import com .mojang .blaze3d .systems .RenderSystem ;
1413import com .mojang .blaze3d .vertex .BufferBuilder ;
1514import com .mojang .blaze3d .vertex .Tesselator ;
1615import com .mojang .blaze3d .vertex .VertexFormat ;
@@ -28,7 +27,7 @@ public class BufferBuilderRenderSink implements RenderSink {
2827 private final RenderType quads ;
2928 private final Runnable preFlush ;
3029 private final Runnable postFlush ;
31- private static BufferBuilder builder ;
30+ private BufferBuilder builder ;
3231 private @ Nullable BufferBuilderRenderSink .RenderType activeRenderType ;
3332 private boolean active ;
3433 private boolean canFlush ;
@@ -58,14 +57,11 @@ public static class LineWidth {
5857 private static float lineWidth = GL11 .glGetInteger (GL11 .GL_LINE_WIDTH );
5958
6059 public static void set (final float width ) {
61- if (HAS_COMPATIBILITY ) {
62- if (lineWidth != width ) {
63- GL11 .glLineWidth (width );
64- lineWidth = width ;
65- }
60+ if (HAS_COMPATIBILITY && lineWidth != width ) {
61+ GL11 .glLineWidth (width );
6662 }
6763
68- builder . setLineWidth ( width ) ;
64+ lineWidth = width ;
6965 }
7066
7167 }
@@ -112,12 +108,12 @@ public RenderSink vertex(final double x, final double y, final double z) {
112108 // duplicate last
113109 if (this .canLoop ) {
114110 final Vector3f normal = this .activeRenderType .hasNormals ? this .computeNormal (this .loopX , this .loopY , this .loopZ , x , y , z ) : null ;
115- builder .addVertex (this .loopX , this .loopY , this .loopZ ).setColor (this .r , this .g , this .b , this .a );
111+ builder .addVertex (this .loopX , this .loopY , this .loopZ ).setColor (this .r , this .g , this .b , this .a ). setLineWidth ( LineWidth . lineWidth ) ;
116112 if (normal != null ) {
117113 // we need to compute normals pointing directly towards the screen
118114 builder .setNormal (normal .x (), normal .y (), normal .z ());
119115 }
120- builder .addVertex ((float ) x , (float ) y , (float ) z ).setColor (this .r , this .g , this .b , this .a );
116+ builder .addVertex ((float ) x , (float ) y , (float ) z ).setColor (this .r , this .g , this .b , this .a ). setLineWidth ( LineWidth . lineWidth ) ;
121117 if (normal != null ) {
122118 builder .setNormal (normal .x (), normal .y (), normal .z ());
123119 }
@@ -134,11 +130,11 @@ public RenderSink vertex(final double x, final double y, final double z) {
134130 // we buffer vertices so we can compute normals here
135131 if (this .canLoop ) {
136132 final Vector3f normal = this .activeRenderType .hasNormals ? this .computeNormal (this .loopX , this .loopY , this .loopZ , x , y , z ) : null ;
137- builder .addVertex (this .loopX , this .loopY , this .loopZ ).setColor (this .r , this .g , this .b , this .a );
133+ builder .addVertex (this .loopX , this .loopY , this .loopZ ).setColor (this .r , this .g , this .b , this .a ). setLineWidth ( LineWidth . lineWidth ) ;
138134 if (normal != null ) {
139135 builder .setNormal (normal .x (), normal .y (), normal .z ());
140136 }
141- builder .addVertex ((float ) x , (float ) y , (float ) z ).setColor (this .r , this .g , this .b , this .a );
137+ builder .addVertex ((float ) x , (float ) y , (float ) z ).setColor (this .r , this .g , this .b , this .a ). setLineWidth ( LineWidth . lineWidth ) ;
142138 if (normal != null ) {
143139 builder .setNormal (normal .x (), normal .y (), normal .z ());
144140 }
@@ -150,7 +146,7 @@ public RenderSink vertex(final double x, final double y, final double z) {
150146 this .canLoop = true ;
151147 }
152148 } else {
153- builder .addVertex ((float ) x , (float ) y , (float ) z ).setColor (this .r , this .g , this .b , this .a );
149+ builder .addVertex ((float ) x , (float ) y , (float ) z ).setColor (this .r , this .g , this .b , this .a ). setLineWidth ( LineWidth . lineWidth ) ;
154150 }
155151 return this ;
156152 }
@@ -178,12 +174,12 @@ public RenderSink endLineLoop() {
178174 if (this .canLoop ) {
179175 this .canLoop = false ;
180176 final Vector3f normal = this .activeRenderType .hasNormals ? this .computeNormal (this .loopX , this .loopY , this .loopZ , this .loopFirstX , this .loopFirstY , this .loopFirstZ ) : null ;
181- this .builder .addVertex (this .loopX , this .loopY , this .loopZ ).setColor (this .r , this .g , this .b , this .a );
177+ this .builder .addVertex (this .loopX , this .loopY , this .loopZ ).setColor (this .r , this .g , this .b , this .a ). setLineWidth ( LineWidth . lineWidth ) ;
182178 if (normal != null ) {
183179 this .builder .setNormal (normal .x (), normal .y (), normal .z ());
184180 }
185181
186- this .builder .addVertex (this .loopFirstX , this .loopFirstY , this .loopFirstZ ).setColor (this .r , this .g , this .b , this .a );
182+ this .builder .addVertex (this .loopFirstX , this .loopFirstY , this .loopFirstZ ).setColor (this .r , this .g , this .b , this .a ). setLineWidth ( LineWidth . lineWidth ) ;
187183 if (normal != null ) {
188184 this .builder .setNormal (normal .x (), normal .y (), normal .z ());
189185 }
0 commit comments