1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-08-30 17:17:55 +00:00

fix: ModelTransformer return old code, it was wrong get offset length

This commit is contained in:
Nikita Savyolov
2021-10-10 08:41:23 +03:00
parent 1395c877af
commit 9dcb9f9537

View File

@@ -64,36 +64,23 @@ public final class ModelTransformer
{ {
for( VertexFormatElement element : format.getElements() ) // For each vertex element for( VertexFormatElement element : format.getElements() ) // For each vertex element
{ {
if( element.isPosition() && int start = offsetBytes / Integer.BYTES;
element.getDataType() == VertexFormatElement.DataType.FLOAT && if( element.getType() == VertexFormatElement.Type.POSITION && element.getDataType() == VertexFormatElement.DataType.FLOAT ) // When we find a position element
element.getLength() == 3 ) // When we find a position element
{ {
for ( int j = 0; j < 4; ++j ) // For each corner of the quad Vector4f pos = new Vector4f( Float.intBitsToFloat( vertexData[start] ),
{ Float.intBitsToFloat( vertexData[start + 1] ),
int start = offsetBytes + j * format.getVertexSize(); Float.intBitsToFloat( vertexData[start + 2] ),
if ( (start % 4) == 0 ) 1 );
{
start = start / 4;
// Extract the position // Transform the position
Vector4f pos = new Vector4f( pos.transform( transform );
Float.intBitsToFloat( vertexData[start] ),
Float.intBitsToFloat( vertexData[start + 1] ),
Float.intBitsToFloat( vertexData[start + 2] ),
1
);
// Transform the position // Insert the position
pos.transform( transform ); vertexData[start] = Float.floatToRawIntBits( pos.getX() );
vertexData[start + 1] = Float.floatToRawIntBits( pos.getY() );
// Insert the position vertexData[start + 2] = Float.floatToRawIntBits( pos.getZ() );
vertexData[start] = Float.floatToRawIntBits( pos.getX() );
vertexData[start + 1] = Float.floatToRawIntBits( pos.getY() );
vertexData[start + 2] = Float.floatToRawIntBits( pos.getZ() );
}
}
} }
offsetBytes += element.getLength(); offsetBytes += element.getByteLength();
} }
} }
return copy; return copy;