Skip to content

Chaotic bounce results with LockRotation off, implying issue with collision resolver #387

@Hexicube

Description

@Hexicube

Describe the bug

Bounces at slightly different speeds produce wildly different results in a simple scene, implying an issue with collision resolution.

Before bounce:

Image

After bounce:

Image

To Reproduce

Add this to the root Node3D:

[Export]
public PhysicsMaterial BallMat;

RigidBody3D[] ballClones = new RigidBody3D[10];
override public void _PhysicsProcess(double delta) {
    if (ballClones[0] == null) {
        for (int a = 0; a < 10; a++) {
            ballClones[a] = new RigidBody3D();
            //ballClones[a].LockRotation = true;
            ballClones[a].ContinuousCd = true;
            ballClones[a].LinearDampMode = RigidBody3D.DampMode.Replace;
            ballClones[a].PhysicsMaterialOverride = BallMat;
            ballClones[a].CollisionMask = 0;
            ballClones[a].Position = new Vector3(0, 10f, 0);
            ballClones[a].LinearVelocity = new Vector3(0, a-15f, 0);

            CollisionShape3D shape = new CollisionShape3D();
            SphereShape3D sphere = new SphereShape3D();
            sphere.Radius = 0.1f;
            shape.Shape = sphere;
            ballClones[a].AddChild(shape);

            MeshInstance3D mesh = new MeshInstance3D();
            SphereMesh sphereMesh = new SphereMesh();
            sphereMesh.Radius = 0.1f;
            sphereMesh.Height = 0.2f;
            mesh.Mesh = sphereMesh;
            ballClones[a].AddChild(mesh);

            AddChild(ballClones[a]);
        }
    }
}

Passed in BallMat is 0.0 friction and 1.0 bounce, floor is 0.2 rough friction and 0.5 absorbent bounce.

Place a slightly sloped flat panel (approx 15deg) so that the bounce is towards -X (doubt direction/angle matters) at Y=0. Observe that the resulting bounces are chaotic.

Uncomment the LockRotation line. Observe that the resulting bounces are far less chaotic.

This may be due to not implementing ContinuousCd, results are identical with or without it enabled.
Results are also far less chaotic when changing physics ticks per second from 60 to 1000.

Issue vanishes with a frictionless bounce, which may be because zero friction bounces do not impart any spin on the ball.
I suspect the added spin is causing one tick of friction calculation with varied levels of penetration and spin.

Expected behavior

Bounce should be far more consistent, like how it is with LockRotation enabled:

Image

Note: This is a consistent but wrong bounce, should be far more to the right.
Fully expected bounce looks like this (set friction to 0):

Image

Environment:

  • OS: Manjaro
  • Version: 0.8.10
  • Godot Version: 4.5
  • Type: 3D single

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions