Skip to content

Stride Bepu Physics: When BodyComponent Teleport used with Quaternion.Zero it breaks this body physics #3163

@corthax

Description

@corthax

Release Type: Official Release/GitHub (please choose appropriate option)
Official Release
Version: Version number and/or git branch
4.3.0.2507
Platform(s): Does the problem occur on Windows, Android...?
Windows
Describe the bug
A clear and concise description of what the bug is.
When BodyComponent (body) Teleport used with orientation set to Quaternion.Zero (or default) it breaks this body physics. If after Teleport body is collided with another, it's being teleported to another dimention where position cannot be described with numbers (memory corruption?), if velocity is fast enough 😃 After a few collisions it may stop to collide with anything at all, also then cannot disable gravity or set it kinematic. Rarely throws an IndexOutOfRangeException (see below).
To Reproduce
Steps to reproduce the behavior:

  1. Setup a simple scene (body sphere above the static cube for example).
  2. In sphere startup script: Entity.Get<BodyComponent>().Teleport(Vector3.UnitY * 10, default);
  3. Then see sphere falling and wanishing into oblivion when collided with cube (attach camera to it to be sure!!). If not then apply a bit stronger gravity.
    Expected behavior
    A clear and concise description of what you expected to happen.
    It should throw an error as Quaternion.Zero orientation makes no sense. Or maybe fallback to Quaternion.Identity
    Screenshots
    If applicable, add screenshots to help explain your problem (use GitHub drag & drop)

Log and callstacks
If any, please attach here any log or callstack (preferably in a .txt file using GitHub drag and drop)
[Game]: Error: Unexpected exception. System.IndexOutOfRangeException: Index was outside the bounds of the array.
at BepuPhysics.CollisionDetection.PairCache.Prepare(IThreadDispatcher threadDispatcher)
at BepuPhysics.CollisionDetection.CollidableOverlapFinder`1.DispatchOverlaps(Single dt, IThreadDispatcher threadDispatcher)
at BepuPhysics.Simulation.CollisionDetection(Single dt, IThreadDispatcher threadDispatcher)
at Stride.BepuPhysics.BepuSimulation.Update(TimeSpan elapsed) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.BepuPhysics\Stride.BepuPhysics\BepuSimulation.cs:line 722
at Stride.BepuPhysics.Systems.PhysicsGameSystem.Update(GameTime time) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.BepuPhysics\Stride.BepuPhysics\Systems\PhysicsGameSystem.cs:line 33
Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions