redoshyte
unknown
csharp
2 months ago
1.7 kB
2
Indexable
void CertainUnclearedMethod(int indexOffset, int y, int x, int textureIndex, out IEnumerable<float> vertices, out IEnumerable<int> indices) { var textureDims = _textureDimensions[textureIndex]; float texWidth = textureDims.width; float texHeight = textureDims.height; GetVertices(y, x, texWidth, texHeight, out vertices); indices = new[] { indexOffset, indexOffset + 1, indexOffset + 2, indexOffset + 2, indexOffset + 1, indexOffset + 3 }; } void GetVertices(int y, int x, float texWidth, float texHeight, out IEnumerable<float> vertices) { const int someSize = 128; //magic numbers GTFO float cellWidth = .1f, //why is this here? cellHeight = .1f, startX = -1f + x * cellWidth, startY = .5f - y * cellHeight; float u0, v0; u0 = v0 = 0; float u1 = someSize / texWidth; float v1 = someSize / texHeight; vertices = Enumerable.Empty<float>(); //might be overkill vertices = AddVerticesBlock(vertices, startX, startY, u0, v0); vertices = AddVerticesBlock(vertices, startX + cellWidth, startY, u1, v0); vertices = AddVerticesBlock(vertices, startX, startY + cellHeight, u0, v1); vertices = AddVerticesBlock(vertices, startX + cellWidth, startY + cellHeight, u1, v1); } IEnumerable<float> AddVerticesBlock(IEnumerable<float> floats, float x, float y, float u, float v) => floats.Append(x) .Append(y) .Append(0) .Append(u) .Append(v);
Editor is loading...
Leave a Comment