public void ReadTriangleStripSubBatch(BinaryReader dStream, BinaryReader gStream, int tsDOffset, int vBatchID, int sNameOffset) { //The amount of recusion in these files is bullshit... dStream.BaseStream.Seek(DataOffset + tsDOffset + 0x14, SeekOrigin.Begin); int tso = IO.ReadBig32(dStream); int nextOffset = IO.ReadBig32(dStream); if (nextOffset != 0) { ReadTriangleStripSubBatch(dStream, gStream, nextOffset, vBatchID, sNameOffset); } if (tso != 0) { dStream.BaseStream.Seek(DataOffset + tso + 0x3c, SeekOrigin.Begin); } else { dStream.BaseStream.Seek(DataOffset + tsDOffset + 0x3c, SeekOrigin.Begin); } int tsOffsetPtr = IO.ReadBig32(dStream); int tsTypePtr = IO.ReadBig32(dStream); int tsCountPtr = IO.ReadBig32(dStream); bool tsFullIndex = (IO.ReadBig16(dStream) == 1); dStream.BaseStream.Seek(DataOffset + tsOffsetPtr, SeekOrigin.Begin); int tsGPUOffset = IO.ReadBig32(dStream); dStream.BaseStream.Seek(DataOffset + tsTypePtr, SeekOrigin.Begin); int tsGPUType = IO.ReadBig32(dStream); dStream.BaseStream.Seek(DataOffset + tsCountPtr, SeekOrigin.Begin); int tsGPUCount = IO.ReadBig32(dStream); //var tmpTBatch = new TriStripBatch(); var tmpTBatch = new TriangleBatch(); gStream.BaseStream.Seek(GPUOffset + tsGPUOffset, SeekOrigin.Begin); tmpTBatch.Read(tsGPUCount, vBatchID, gStream, tsFullIndex); dStream.BaseStream.Seek(DataOffset + sNameOffset, SeekOrigin.Begin); string tmpMaterialName = IO.ReadString(dStream); //TriStripBatches.Add(tmpTBatch); TriangleBatches.Add(tmpTBatch); if (!MaterialMap.ContainsKey(tmpMaterialName)) { var tmpMaterial = new Material(tmpMaterialName); MaterialList.Add(tmpMaterial); MaterialMap[tmpMaterialName] = MaterialList.Count - 1; tmpTBatch.MaterialID = MaterialList.Count - 1; } else { tmpTBatch.MaterialID = MaterialMap[tmpMaterialName]; } }
static TextureGLSingle() { QuadBatch <TexturedVertex2D> quadBatch = new QuadBatch <TexturedVertex2D>(512, 128); default_quad_action = quadBatch.AddAction; // We multiply the size param by 3 such that the amount of vertices is a multiple of the amount of vertices // per primitive (triangles in this case). Otherwise overflowing the batch will result in wrong // grouping of vertices into primitives. TriangleBatch <TexturedVertex2D> triangleBatch = new TriangleBatch <TexturedVertex2D>(512, 128); default_triangle_action = triangleBatch.AddAction; }
private void updateTriangleBatch() { if (Children == null) { return; } // This logic got roughly copied from the old osu! code base. These constants seem to have worked well so far. int clampedAmountChildren = MathHelper.Clamp(Children.Count, 1, 1000); if (mayHaveOwnVertexBatch(clampedAmountChildren) && (triangleBatch == null || triangleBatch.Size < clampedAmountChildren)) { // The same general idea as updateQuadBatch(), except that each child draws up to 3 vertices * 6 triangles after quad-quad intersection triangleBatch = new TriangleBatch <TexturedVertex2D>(clampedAmountChildren * 2, 500); } }