{"record":{"id":"bf1a5b1b0fdcb559","repo":"stride3d/stride","slug":"invalid-geometricprimitive-0-expecting-non-zero-vertices","errorCode":null,"errorMessage":"Invalid GeometricPrimitive [{0}]. Expecting non-zero Vertices array","messagePattern":"Invalid GeometricPrimitive \\[(.+?)\\]\\. Expecting non-zero Vertices array","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Rendering/Rendering/ProceduralModels/PrimitiveProceduralModelBase.cs","lineNumber":103,"sourceCode":"        }\n\n        public void Generate(IServiceRegistry services, Model model)\n        {\n            ArgumentNullException.ThrowIfNull(model);\n\n            var needsTempDevice = false;\n            var graphicsDevice = services?.GetSafeServiceAs<IGraphicsDeviceService>().GraphicsDevice;\n            if (graphicsDevice == null)\n            {\n                graphicsDevice = GraphicsDevice.New();\n                needsTempDevice = true;\n            }\n\n            var data = CreatePrimitiveMeshData();\n\n            if (data.Vertices.Length == 0)\n            {\n                throw new InvalidOperationException(\"Invalid GeometricPrimitive [{0}]. Expecting non-zero Vertices array\");\n            }\n\n            if (LocalOffset != Vector3.Zero)\n            {\n                for (var index = 0; index < data.Vertices.Length; index++)\n                {\n                    data.Vertices[index].Position += LocalOffset;\n                }\n            }\n\n            //Scale if necessary\n            if (Scale != Vector3.One)\n            {\n                var inverseMatrix = Matrix.Scaling(Scale);\n                inverseMatrix.Invert();\n                for (var index = 0; index < data.Vertices.Length; index++)\n                {\n                    data.Vertices[index].Position *= Scale;","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Rendering/Rendering/ProceduralModels/PrimitiveProceduralModelBase.cs#L85-L121","documentation":"PrimitiveProceduralModelBase.Generate builds the mesh via CreatePrimitiveMeshData and requires at least one vertex. If the produced GeometricMeshData has an empty Vertices array the primitive type failed to produce geometry, so InvalidOperationException is thrown.","triggerScenarios":"A derived procedural model (Type property) whose CreatePrimitiveMeshData returns an empty vertex array — e.g. a primitive type not yet initialized, a custom primitive with zero parameters, or a type whose mesh generation silently produced nothing.","commonSituations":"ProceduralModelDescriptor with a custom IProceduralModel implementation returning empty data; uninitialized primitive Type field; degenerate parameters (e.g. zero tessellation) causing no vertices.","solutions":["Fix or initialize the primitive Type so CreatePrimitiveMeshData returns real geometry","Check custom CreatePrimitiveMeshData overrides to ensure they populate Vertices","Validate primitive parameters (slices, tessellation, scale) are non-degenerate before generating"],"exampleFix":"// before\npublic override GeometricMeshData<VertexPositionNormalTexture> CreatePrimitiveMeshData()\n    => _cachedData; // may be empty\n// after\npublic override GeometricMeshData<VertexPositionNormalTexture> CreatePrimitiveMeshData()\n{\n    var data = _cachedData ?? BuildSphere(tessellation);\n    if (data.Vertices.Length == 0)\n        data = BuildSphere(DefaultTessellation); // fall back to valid geometry\n    return data;\n}","handlingStrategy":"validation","validationCode":"var data = primitive.CreatePrimitiveMeshData();\nif (data == null || data.Vertices == null || data.Vertices.Length == 0)\n    throw new InvalidOperationException(\"Primitive produced no vertices; check Type and parameters\");","typeGuard":null,"tryCatchPattern":"try { descriptor.Type.Generate(services, model); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"non-zero Vertices\")) {\n    logger.Error($\"Primitive {descriptor.Type} generated an empty mesh\");\n}","preventionTips":["Validate primitive parameters (tessellation, radius, scale) before generating","Test custom IProceduralModel implementations with unit checks on vertex counts","Never return cached-but-uninitialized mesh data"],"tags":["rendering","procedural-models","mesh-generation"],"backgroundTag":"empty-required-field","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}