Repository: godot
Issue: [GodotPhysics] CharacterBody3D interaction with large StaticBody3D producing too many collisions
Labels: bug,confirmed,topic:physics,topic:3d

### Godot version

4.0.beta7

### System information

Windows 11, RTX 3070TI, Vulcan

### Issue description
[UPDATE 3
After more specifically recreating the minimal reproduction projects to utilize a vertex shader displaced plane mesh, with run-time height-map sampled and generated HeightMapShape3D collision mesh data, it seems that the issue is much more specific to Godot4.0 than Godot Physics itself... I've reuploaded both 3.5 minimal reproduction (which seems to work fine in Bullet and Godot Physics) and the direct translation of that project to 4.0 (where the error occurs); Unfortunately this is a pretty major problem for ANY 3D game that intends to use Godot beyond basic planar/cube collision shapes in small indoor environments.
[https://youtu.be/pU8mz7SlkzE](https://youtu.be/pU8mz7SlkzE)
/UPDATE]

[UPDATE 2
I've uploaded a video demonstrating the issue a bit more clearly, although not fully demonstrating just how destructive the effect is, it at least demonstrates some of the incorrect calculations being performed.
[https://youtu.be/Kw0ThRnUPDs](https://youtu.be/Kw0ThRnUPDs)
/UPDATE]

[UPDATE 1
Update after more research and testing on the issue:

It appears that on top of generating too many collisions between only two objects (player and terrain) almost always hitting the hard-coded maximum collision count of 6, the Normals calculated from collisions also stand to be wildly inaccurate occasionally at collision mesh edges, they are capable of returning perpendicular normal angles (parallel to the terrain surface) which all affect the resultant velocity causing some really... bad motion

/UPDATE]

In Godot 4.0.beta5, beta6, and beta7 (and likely all 4.0) CharecterBody3D collisions utilizing any collision shape (most extensively tested with capsule mesh/collider) is producing undesirable and incorrect physics interactions by triggering too numerous collision events per tic with the same object. This is most exaggerated in the example of large terrain colliders, it would appear that even soft/subtle terrain gradient changes can trigger extremely large numbers of collisions (though gdscript only seems to report a maximum of 6 collisions per move_and_slide()?) that are causing incorrect and undesirable outcomes.

The perceived effect is that the player object is "snagged" and appears to almost snap to vertex and mesh edges along the collider when moving, and can completely negate all velocity while moving across a relatively flat collision mesh, sometimes also causing a sling-shot effect when the player object escapes a snag.

In attempts to trouble-shoot this matter, I discovered that printing/producing the entire list of collisions while the player is moving indicates that any trouble-interactions are indicated by far more collisions with the StaticBody than normal. 

In Godot 3.5, the KinematicBody and StaticBody interaction produces typically 1 collision per physics tic, which is the expected result, and occasionally produces 2 collisions when moving up steeper collisions, which is also to be expected and behaves correctly.
![image](https://user-images.githubusercontent.com/8258356/206007804-7c3a8359-9fd4-4fc8-a23d-abfbf94f8252.png)
(Output of all instances where more than one collision occurs simultaneously per tic; notice the infrequency and collision count never exceeding two (index of 1))


In Godot 4.0.b7, the CharecterBody3D and StaticBody3D interaction produces between 2-6 collisions per physics tic, which is NOT the expected result between only two colliders, and does not appear to report on collision counts past 6 (index 5). This directly seems to affect the move_and_slide() behavior very negatively and incorrectly. 
![image](https://user-images.githubusercontent.com/8258356/206008251-0fede7f7-8638-4e1d-880f-01274533ec34.png)
(Output of all instances where more than one collision occurs simultaneously per tic; notice the massive increase in frequency of occurrence, and the number/volume of collisions per tic is 6 (possibly more but not reported?) 

I have produced two minimal projects to demonstrate this contrasting issue in 3.5 and 4.0.b7, however due to size of the terrain mesh object, the file-size exceeds GitHub upload limitations, so I'm trying to figure out how to upload/share them... They were produced using the exact same high resolution terrain mesh in GLB format automatically generating a collision mesh through Godot's import process, and the only thing added to the scene other than the terrain is a very basic player controller, utilizing a KinematicBody/CharecterBody3D with a Capsule CollisionShape and Capsule MeshInstance, with a child camera, and very basic identical (other than translation) input controls for movement and utilizing "move_and_slide"...

![image](https://user-images.githubusercontent.com/8258356/206009359-0fa2aba8-c5cf-44cc-8cec-fcb6ebbe9322.png)
(Godot 4 snapshot of Terrainmesh+Collider)
![image](https://user-images.githubusercontent.com/8258356/206009462-34fabdbd-6467-46ce-a927-091944cf6476.png)
(Godot 3.5 snapshot of Terrainmesh+Collider)


### Steps to reproduce

Create large size terrain mesh in GLB format, automatically generating a collision mesh through Godot's import process, and add basic player controller, utilizing a KinematicBody/CharecterBody3D with a Capsule CollisionShape and Capsule MeshInstance, with a child camera, and very basic identical (other than translation) input controls for movement and utilizing "move_and_slide"

### Minimal reproductio
[HeightTest_3_5.zip](https://github.com/godotengine/godot/files/10178287/HeightTest_3_5.zip)
n project
[HeightTest_3_5_to_4_0.zip](https://github.com/godotengine/godot/files/10178496/HeightTest_3_5_to_4_0.zip)