{"record":{"id":"25af4b715d6af73c","repo":"stride3d/stride","slug":"this-kind-of-shape-cannot-be-used-for-a-shapesweep","errorCode":null,"errorMessage":"This kind of shape cannot be used for a ShapeSweep.","messagePattern":"This kind of shape cannot be used for a ShapeSweep\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Physics/Simulation.cs","lineNumber":978,"sourceCode":"        }\n\n        /// <summary>\n        /// Performs a sweep test using a collider shape and returns the closest hit\n        /// </summary>\n        /// <param name=\"shape\">The shape used when testing collisions with colliders in the simulation</param>\n        /// <param name=\"from\">The starting point of this sweep</param>\n        /// <param name=\"to\">The end point of this sweep</param>\n        /// <param name=\"filterGroup\">The collision group of this shape sweep</param>\n        /// <param name=\"filterFlags\">The collision group that this shape sweep can collide with</param>\n        /// <param name=\"hitTriggers\">Whether this test should collide with <see cref=\"PhysicsTriggerComponentBase\"/></param>\n        /// <exception cref=\"System.ArgumentException\">This kind of shape cannot be used for a ShapeSweep.</exception>\n        /// <returns>The result of this test</returns>\n        public HitResult ShapeSweep(ColliderShape shape, Matrix from, Matrix to, CollisionFilterGroups filterGroup = DefaultGroup, CollisionFilterGroupFlags filterFlags = DefaultFlags, bool hitTriggers = false)\n        {\n            var sh = shape.InternalShape as BulletSharp.ConvexShape;\n            if (sh == null)\n            {\n                throw new ArgumentException(\"This kind of shape cannot be used for a ShapeSweep.\");\n            }\n\n            var callback = StrideClosestConvexResultCallback.Shared(hitTriggers, filterGroup, filterFlags);\n            collisionWorld.ConvexSweepTest(sh, from, to, callback);\n            return callback.Result;\n        }\n\n        /// <summary>\n        /// Performs a sweep test using a collider shape and never stops until \"to\"\n        /// </summary>\n        /// <param name=\"shape\">The shape against which colliders in the simulation will be tested</param>\n        /// <param name=\"from\">The starting point of this sweep</param>\n        /// <param name=\"to\">The end point of this sweep</param>\n        /// <param name=\"resultsOutput\">The collection to add hit results to</param>\n        /// <param name=\"filterGroup\">The collision group of this shape sweep</param>\n        /// <param name=\"filterFlags\">The collision group that this shape sweep can collide with</param>\n        /// <param name=\"hitTriggers\">Whether this test should collide with <see cref=\"PhysicsTriggerComponentBase\"/></param>\n        /// <exception cref=\"System.ArgumentException\">This kind of shape cannot be used for a ShapeSweep.</exception>","sourceCodeStart":960,"sourceCodeEnd":996,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Physics/Simulation.cs#L960-L996","documentation":"ShapeSweep performs a convex sweep test, which Bullet restricts to ConvexShape instances. If the ColliderShape's internal Bullet shape is not convex (e.g. a concave triangle mesh or heightfield), the cast to BulletSharp.ConvexShape yields null and an ArgumentException is thrown.","triggerScenarios":"Calling Simulation.ShapeSweep with a ColliderShape whose underlying shape is non-convex: mesh colliders marked concave, compound shapes containing non-convex children, or heightfields.","commonSituations":"Developers sweep with a static world/mesh collider shape expecting a ray-like trace; using the level geometry as the sweep shape; swapping a convex shape for a concave one after profiling.","solutions":["Use a convex shape (box, sphere, capsule, convex hull, convex mesh) for the sweep","Perform a raycast instead if a simple line test suffices","Bake a ConvexHull shape from the mesh for approximate sweeps"],"exampleFix":"// before\nvar result = simulation.ShapeSweep(meshColliderShape, from, to); // throws: mesh is concave\n// after\nvar convexShape = new ConvexHullShapeDesc { /* generated from mesh */ };\nvar result = simulation.ShapeSweep(convexColliderShape, from, to);","handlingStrategy":"type-guard","validationCode":"if ((shape.InternalShape is BulletSharp.ConvexShape) == false) throw new InvalidOperationException(\"ShapeSweep requires a convex shape\");","typeGuard":"bool IsConvex(ColliderShape s) => s?.InternalShape is BulletSharp.ConvexShape;","tryCatchPattern":"try { simulation.ShapeSweep(shape, from, to); } catch (ArgumentException e) { Log.Error(\"Non-convex shape: \" + e.Message); }","preventionTips":["Keep dedicated convex probe shapes for sweeps","Avoid reusing static mesh/heightfield collider shapes as sweep shapes"],"tags":["physics","shapesweep","shape-compatibility"],"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-23T08:17:48.524Z"}