{"record":{"id":"10c4863f7483dc5c","repo":"stride3d/stride","slug":"can-only-merge-simple-meshdrawdata","errorCode":null,"errorMessage":"Can only merge simple MeshDrawData.","messagePattern":"Can only merge simple MeshDrawData\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Rendering/Extensions/MergeExtensions.cs","lineNumber":32,"sourceCode":"    public static class MergeExtensions\n    {\n        /// <summary>\n        /// Transform a vertex buffer positions, normals, tangents and bitangents using the given matrix.\n        /// </summary>\n        /// <param name=\"meshDrawDatas\">The mesh draw datas.</param>\n        /// <param name=\"can32BitIndex\">A flag stating if 32 bit index buffers.</param>\n        public static unsafe MeshDraw MergeDrawData(IList<MeshDraw> meshDrawDatas, bool can32BitIndex)\n        {\n            if (meshDrawDatas.Count == 0)\n                throw new ArgumentException(\"Need at least 1 MeshDrawData.\", \"meshDrawDatas\");\n\n            if (meshDrawDatas.Count == 1)\n                return meshDrawDatas[0];\n\n            // Check that vertex buffer declarations are matching\n            var firstMeshDrawData = meshDrawDatas[0];\n            if (!firstMeshDrawData.IsSimple())\n                throw new InvalidOperationException(\"Can only merge simple MeshDrawData.\");\n\n            var firstVertexBuffer = firstMeshDrawData.VertexBuffers[0];\n            var hasIndexBuffer = IsIndexed(meshDrawDatas);\n            int totalVertexCount = 0;\n            int totalIndexCount = 0;\n\n            //TODO: extend to non-simple vertex declarations, fill with default values it missing declarations etc. ?\n\n            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","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Rendering/Extensions/MergeExtensions.cs#L14-L50","documentation":"MergeDrawData can only merge 'simple' MeshDraw instances (single vertex buffer, no complex draw data, as determined by IsSimple()). If the first element is not simple, an InvalidOperationException is thrown since multi-buffer or non-simple draws cannot be concatenated.","triggerScenarios":"Passing a MeshDraw with multiple vertex buffers or non-simple structure as the first element of the list to MergeDrawData (e.g. skinned meshes or draws with extra streaming buffers).","commonSituations":"Merging meshes with different layouts — morph targets, skinning, multiple VBs — into a batched draw.","solutions":["Only pass MeshDraw instances where IsSimple() returns true","Split non-simple meshes into separate draw calls instead of merging","Verify mesh import settings produce simple draws for the batching path"],"exampleFix":"// before\nvar merged = MeshDraw.MergeDrawData(meshDraws, true);\n// after\nvar merged = meshDraws.All(m => m.IsSimple()) ? MeshDraw.MergeDrawData(meshDraws, true) : meshDraws[0];","handlingStrategy":"validation","validationCode":"if (meshDrawDatas.Count > 1 && !meshDrawDatas[0].IsSimple())\n    return meshDrawDatas[0]; // cannot merge; use as-is\nvar merged = MeshDraw.MergeDrawData(meshDrawDatas, can32BitIndex);","typeGuard":"static bool AllSimple(IList<MeshDraw> list) => list.All(m => m.IsSimple());","tryCatchPattern":"try { var merged = MeshDraw.MergeDrawData(meshDrawDatas, can32BitIndex); } catch (InvalidOperationException) { /* non-simple MeshDrawData */ }","preventionTips":["Check IsSimple() on every element before batching","Keep non-simple meshes (multi-VB, skinned) out of merge groups"],"tags":["rendering","mesh-merge","invalid-operation"],"backgroundTag":"incompatible-source-type","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"}