{"record":{"id":"68c782a68a4756e1","repo":"stride3d/stride","slug":"can-only-merge-trianglelist","errorCode":null,"errorMessage":"Can only merge TriangleList.","messagePattern":"Can only merge TriangleList\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Rendering/Extensions/MergeExtensions.cs","lineNumber":59,"sourceCode":"            for (int i = 0; i < meshDrawDatas.Count; i++)\n            {\n                var meshDrawData = meshDrawDatas[i];\n\n                // This should not happen anymore\n                if (i != 0)\n                {\n                    if (!meshDrawData.IsSimple())\n                        throw new InvalidOperationException(\"Can only merge simple MeshDrawData.\");\n\n                    if (meshDrawData.VertexBuffers.Length != firstMeshDrawData.VertexBuffers.Length)\n                        throw new InvalidOperationException(\"Non-matching vertex buffer declarations.\");\n\n                    if (!meshDrawData.VertexBuffers[0].Declaration.Equals(firstMeshDrawData.VertexBuffers[0].Declaration))\n                        throw new InvalidOperationException(\"Non-matching vertex buffer declarations.\");\n                }\n\n                if (meshDrawData.PrimitiveType != PrimitiveType.TriangleList)\n                    throw new InvalidOperationException(\"Can only merge TriangleList.\");\n\n                // Update vertex/index counts\n                totalVertexCount += meshDrawData.VertexBuffers[0].Count;\n                if (hasIndexBuffer)\n                {\n                    if (meshDrawData.IndexBuffer != null)\n                        totalIndexCount += meshDrawData.IndexBuffer.Count;\n                    else\n                        totalIndexCount += meshDrawData.VertexBuffers[0].Count;\n                }\n            }\n\n            // Allocate vertex buffer\n            var result = new MeshDraw { PrimitiveType = PrimitiveType.TriangleList };\n            var destBufferData = new byte[firstVertexBuffer.Declaration.VertexStride * totalVertexCount];\n            result.VertexBuffers = new VertexBufferBinding[]\n            {\n                new VertexBufferBinding(","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Rendering/Extensions/MergeExtensions.cs#L41-L77","documentation":"MergeDrawData only supports merging meshes whose PrimitiveType is TriangleList. This error is thrown when a mesh in the merge group uses any other primitive type (lines, strips, fan, triangle lists with adjacency, etc.), because index/vertex concatenation logic assumes triangle-list topology.","triggerScenarios":"Calling MergeDrawData (via GroupDrawData) with a MeshDrawData whose PrimitiveType is TriangleStrip, LineList, LineStrip, PointList, or TriangleListWithAdjacency instead of TriangleList.","commonSituations":"Merging debug line meshes or strip-based geometry with regular triangle meshes; procedurally generated geometry using strips; meshes imported with preserved primitive topology.","solutions":["Convert the mesh to TriangleList (expand strips via degenerate-triangle insertion or index rewriting) before merging","Exclude non-TriangleList meshes from the merge group","Set meshDrawData.PrimitiveType = PrimitiveType.TriangleList when the underlying data is actually triangle-list"],"exampleFix":"// before\nmeshDrawData.PrimitiveType = PrimitiveType.TriangleStrip;\nMergeDrawData(list);\n// after\nmeshDrawData.PrimitiveType = PrimitiveType.TriangleList;\nConvertStripIndicesToList(meshDrawData); // expand strip indices\nMergeDrawData(list);","handlingStrategy":"validation","validationCode":"bool allTriangleLists = meshes.All(m => m.PrimitiveType == PrimitiveType.TriangleList);\nif (!allTriangleLists) throw new InvalidOperationException(\"Convert strips first.\");","typeGuard":"static bool IsTriangleList(MeshDrawData m) => m.PrimitiveType == PrimitiveType.TriangleList;","tryCatchPattern":"try { MergeDrawData(meshes); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Can only merge TriangleList\")) {\n    // convert offending meshes or exclude them, then retry\n}","preventionTips":["Normalize all geometry to TriangleList at import time","Never assign strip/line topologies to meshes destined for batch merging","Log primitive type when building merge candidate lists"],"tags":["csharp","rendering","primitive-topology"],"backgroundTag":"unsupported-operation","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}