stride3d/stride · error · ArgumentException
This kind of shape cannot be used for a ShapeSweep.
Error message
This kind of shape cannot be used for a ShapeSweep.
What it means
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.
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
Example fix
// before
var result = simulation.ShapeSweep(meshColliderShape, from, to); // throws: mesh is concave
// after
var convexShape = new ConvexHullShapeDesc { /* generated from mesh */ };
var result = simulation.ShapeSweep(convexColliderShape, from, to); Defensive patterns
Strategy: type-guard
Validate before calling
if ((shape.InternalShape is BulletSharp.ConvexShape) == false) throw new InvalidOperationException("ShapeSweep requires a convex shape"); Type guard
bool IsConvex(ColliderShape s) => s?.InternalShape is BulletSharp.ConvexShape;
Try / catch
try { simulation.ShapeSweep(shape, from, to); } catch (ArgumentException e) { Log.Error("Non-convex shape: " + e.Message); } Prevention
- Keep dedicated convex probe shapes for sweeps
- Avoid reusing static mesh/heightfield collider shapes as sweep shapes
When it happens
Trigger: Calling Simulation.ShapeSweep with a ColliderShape whose underlying shape is non-convex: mesh colliders marked concave, compound shapes containing non-convex children, or heightfields.
Common situations: 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.
Understand the failure class
Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.
Related errors
- A Gear constraint always needs two rigidbodies to be…
- A Gear constraint requires two rigidbodies.
- AfterUpdate cannot be called out of the micro-thread…
- All should have hashsets associated to them
- ArgumentNullException: data
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/25af4b715d6af73c.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Physics/Simulation.cs:978
}
/// <summary>
/// Performs a sweep test using a collider shape and returns the closest hit
/// </summary>
/// <param name="shape">The shape used when testing collisions with colliders in the simulation</param>
/// <param name="from">The starting point of this sweep</param>
/// <param name="to">The end point of this sweep</param>
/// <param name="filterGroup">The collision group of this shape sweep</param>
/// <param name="filterFlags">The collision group that this shape sweep can collide with</param>
/// <param name="hitTriggers">Whether this test should collide with <see cref="PhysicsTriggerComponentBase"/></param>
/// <exception cref="System.ArgumentException">This kind of shape cannot be used for a ShapeSweep.</exception>
/// <returns>The result of this test</returns>
public HitResult ShapeSweep(ColliderShape shape, Matrix from, Matrix to, CollisionFilterGroups filterGroup = DefaultGroup, CollisionFilterGroupFlags filterFlags = DefaultFlags, bool hitTriggers = false)
{
var sh = shape.InternalShape as BulletSharp.ConvexShape;
if (sh == null)
{
throw new ArgumentException("This kind of shape cannot be used for a ShapeSweep.");
}
var callback = StrideClosestConvexResultCallback.Shared(hitTriggers, filterGroup, filterFlags);
collisionWorld.ConvexSweepTest(sh, from, to, callback);
return callback.Result;
}
/// <summary>
/// Performs a sweep test using a collider shape and never stops until "to"
/// </summary>
/// <param name="shape">The shape against which colliders in the simulation will be tested</param>
/// <param name="from">The starting point of this sweep</param>
/// <param name="to">The end point of this sweep</param>
/// <param name="resultsOutput">The collection to add hit results to</param>
/// <param name="filterGroup">The collision group of this shape sweep</param>
/// <param name="filterFlags">The collision group that this shape sweep can collide with</param>
/// <param name="hitTriggers">Whether this test should collide with <see cref="PhysicsTriggerComponentBase"/></param>
/// <exception cref="System.ArgumentException">This kind of shape cannot be used for a ShapeSweep.</exception>View on GitHub (pinned to 96fad776d2)