/** * Bakes this Quad to a BakedQuad. * * @return The BakedQuad. */ public BakedQuad bake() { int[] packedData = new int[this.format.format.getNextOffset()]; for( int v = 0; v < 4; v++ ) { for( int e = 0; e < this.format.elementCount; e++ ) { LightUtil.pack( this.vertices[v].raw[e], packedData, this.format.format, v, e ); } } return new BakedQuad( packedData, this.tintIndex, this.orientation, this.sprite, this.diffuseLighting, this.format.format ); }
int stride = format.getNextOffset() / 4; int normalIdx = format.getNormalOffset(); VertexFormatElement.EnumType normalType = null;
@Override public void putBulkData(ByteBuffer buffer) { growBuffer(buffer.limit() + this.vertexFormat.getNextOffset()); this.byteBuffer.position(this.vertexCount * this.vertexFormat.getNextOffset()); this.byteBuffer.put(buffer); this.vertexCount += buffer.limit() / this.vertexFormat.getNextOffset(); } }
@Override public void endVertex() { ++this.vertexCount; this.growBuffer(this.vertexFormat.getNextOffset()); }
/** * Gets the position into the vertex data buffer at which the given vertex's color data can be found, in {@code * int}s. */ @Override public int getColorIndex(int vertexIndex) { return ((this.vertexCount - vertexIndex) * this.vertexFormat.getNextOffset() + this.vertexFormat.getColorOffset()) / 4; }
@Override public void putNormal(float x, float y, float z) { int i = (byte) ((int) (x * 127.0F)) & 255; int j = (byte) ((int) (y * 127.0F)) & 255; int k = (byte) ((int) (z * 127.0F)) & 255; int l = i | j << 8 | k << 16; int i1 = this.vertexFormat.getNextOffset() >> 2; int j1 = (this.vertexCount - 4) * i1 + this.vertexFormat.getNormalOffset() / 4; this.rawIntBuffer.put(j1, l); this.rawIntBuffer.put(j1 + i1, l); this.rawIntBuffer.put(j1 + i1 * 2, l); this.rawIntBuffer.put(j1 + i1 * 3, l); }
@Override public void putBrightness4(int p_178962_1_, int p_178962_2_, int p_178962_3_, int p_178962_4_) { int i = (this.vertexCount - 4) * this.vertexFormat.getIntegerSize() + this.vertexFormat.getUvOffsetById(1) / 4; int j = this.vertexFormat.getNextOffset() >> 2; this.rawIntBuffer.put(i, p_178962_1_); this.rawIntBuffer.put(i + j, p_178962_2_); this.rawIntBuffer.put(i + j * 2, p_178962_3_); this.rawIntBuffer.put(i + j * 3, p_178962_4_); }
@Override public void addVertexData(int[] vertexData) { this.growBuffer(vertexData.length * 4 + this.vertexFormat.getNextOffset());//Forge, fix MC-122110 this.rawIntBuffer.position(this.getBufferSize()); this.rawIntBuffer.put(vertexData); this.vertexCount += vertexData.length / this.vertexFormat.getIntegerSize(); }
private void growBuffer(int p_181670_1_) { if (MathHelper.roundUp(p_181670_1_, 4) / 4 > this.rawIntBuffer.remaining() || this.vertexCount * this.vertexFormat.getNextOffset() + p_181670_1_ > this.byteBuffer.capacity()) { int i = this.byteBuffer.capacity(); int j = i + MathHelper.roundUp(p_181670_1_, 2097152); LOGGER.debug("Needed to grow BufferBuilder buffer: Old size {} bytes, new size {} bytes.", Integer.valueOf(i), Integer.valueOf(j)); int k = this.rawIntBuffer.position(); ByteBuffer bytebuffer = GLAllocation.createDirectByteBuffer(j); this.byteBuffer.position(0); bytebuffer.put(this.byteBuffer); bytebuffer.rewind(); this.byteBuffer = bytebuffer; this.rawFloatBuffer = this.byteBuffer.asFloatBuffer().asReadOnlyBuffer(); this.rawIntBuffer = this.byteBuffer.asIntBuffer(); this.rawIntBuffer.position(k); this.rawShortBuffer = this.byteBuffer.asShortBuffer(); this.rawShortBuffer.position(k << 1); } }
@Override public BufferBuilder pos(double x, double y, double z) { int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex); switch (this.vertexFormatElement.getType()) { case FLOAT: this.byteBuffer.putFloat(i, (float) (x + this.xOffset)); this.byteBuffer.putFloat(i + 4, (float) (y + this.yOffset)); this.byteBuffer.putFloat(i + 8, (float) (z + this.zOffset)); break; case UINT: case INT: this.byteBuffer.putInt(i, Float.floatToRawIntBits((float) (x + this.xOffset))); this.byteBuffer.putInt(i + 4, Float.floatToRawIntBits((float) (y + this.yOffset))); this.byteBuffer.putInt(i + 8, Float.floatToRawIntBits((float) (z + this.zOffset))); break; case USHORT: case SHORT: this.byteBuffer.putShort(i, (short) ((int) (x + this.xOffset))); this.byteBuffer.putShort(i + 2, (short) ((int) (y + this.yOffset))); this.byteBuffer.putShort(i + 4, (short) ((int) (z + this.zOffset))); break; case UBYTE: case BYTE: this.byteBuffer.put(i, (byte) ((int) (x + this.xOffset))); this.byteBuffer.put(i + 1, (byte) ((int) (y + this.yOffset))); this.byteBuffer.put(i + 2, (byte) ((int) (z + this.zOffset))); } this.nextVertexFormatIndex(); return this; }
@Override public BufferBuilder normal(float x, float y, float z) { int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex); switch (this.vertexFormatElement.getType()) { case FLOAT: this.byteBuffer.putFloat(i, x); this.byteBuffer.putFloat(i + 4, y); this.byteBuffer.putFloat(i + 8, z); break; case UINT: case INT: this.byteBuffer.putInt(i, (int) x); this.byteBuffer.putInt(i + 4, (int) y); this.byteBuffer.putInt(i + 8, (int) z); break; case USHORT: case SHORT: this.byteBuffer.putShort(i, (short) ((int) (x * 32767) & 65535)); this.byteBuffer.putShort(i + 2, (short) ((int) (y * 32767) & 65535)); this.byteBuffer.putShort(i + 4, (short) ((int) (z * 32767) & 65535)); break; case UBYTE: case BYTE: this.byteBuffer.put(i, (byte) ((int) (x * 127) & 255)); this.byteBuffer.put(i + 1, (byte) ((int) (y * 127) & 255)); this.byteBuffer.put(i + 2, (byte) ((int) (z * 127) & 255)); } this.nextVertexFormatIndex(); return this; }
@Override public BufferBuilder tex(double u, double v) { int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex); switch (this.vertexFormatElement.getType()) { case FLOAT: this.byteBuffer.putFloat(i, (float) u); this.byteBuffer.putFloat(i + 4, (float) v); break; case UINT: case INT: this.byteBuffer.putInt(i, (int) u); this.byteBuffer.putInt(i + 4, (int) v); break; case USHORT: case SHORT: this.byteBuffer.putShort(i, (short) ((int) v)); this.byteBuffer.putShort(i + 2, (short) ((int) u)); break; case UBYTE: case BYTE: this.byteBuffer.put(i, (byte) ((int) v)); this.byteBuffer.put(i + 1, (byte) ((int) u)); } this.nextVertexFormatIndex(); return this; }
@Override public BufferBuilder lightmap(int p_187314_1_, int p_187314_2_) { int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex); switch (this.vertexFormatElement.getType()) { case FLOAT: this.byteBuffer.putFloat(i, p_187314_1_); this.byteBuffer.putFloat(i + 4, p_187314_2_); break; case UINT: case INT: this.byteBuffer.putInt(i, p_187314_1_); this.byteBuffer.putInt(i + 4, p_187314_2_); break; case USHORT: case SHORT: this.byteBuffer.putShort(i, (short) p_187314_2_); this.byteBuffer.putShort(i + 2, (short) p_187314_1_); break; case UBYTE: case BYTE: this.byteBuffer.put(i, (byte) p_187314_2_); this.byteBuffer.put(i + 1, (byte) p_187314_1_); } this.nextVertexFormatIndex(); return this; }
return this; int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex);
@Override public int[] getVertexData() { final int[] tmpData = new int[format.getNextOffset() /* / 4 * 4 */]; for ( int v = 0; v < 4; v++ ) { for ( int e = 0; e < format.getElementCount(); e++ ) { LightUtil.pack( getRawPart( v, e ), tmpData, format, v, e ); } } return tmpData; }
afloat[j] = getDistanceSq(this.rawFloatBuffer, (float) (p_181674_1_ + this.xOffset), (float) (p_181674_2_ + this.yOffset), (float) (p_181674_3_ + this.zOffset), this.vertexFormat.getIntegerSize(), j * this.vertexFormat.getNextOffset()); int l = this.vertexFormat.getNextOffset(); int[] aint = new int[l];
@Override public void draw(VertexBuffer vertexBufferIn) { if (vertexBufferIn.getVertexCount() > 0) { GlStateManager.enableTexture2D(); OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); VertexFormat vertexformat = vertexBufferIn.getVertexFormat(); int i = vertexformat.getNextOffset(); ByteBuffer bytebuffer = vertexBufferIn.getByteBuffer(); List<VertexFormatElement> list = vertexformat.getElements(); for (int j = 0; j < list.size(); ++j) { bytebuffer.position(vertexformat.getOffset(j)); list.get(j).getUsage().preDraw(vertexformat, j, i, bytebuffer); } GlStateManager.glDrawArrays(vertexBufferIn.getDrawMode(), 0, vertexBufferIn.getVertexCount()); int i1 = 0; for (int j1 = list.size(); i1 < j1; ++i1) { list.get(i1).getUsage().postDraw(vertexformat, i1, i, bytebuffer); } } } }
int i = vertexformat.getNextOffset(); ByteBuffer bytebuffer = bufferBuilder.getByteBuffer(); List<VertexFormatElement> list = vertexformat.getElements();
Runnable cleanup = () -> {}; final int stride = vf.getNextOffset();
int i = vertexformat.getNextOffset(); ByteBuffer bytebuffer = bufferBuilder.getByteBuffer(); List<VertexFormatElement> list = vertexformat.getElements();