godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.34k stars 21.06k forks source link

move_and_slide performance extremely bad on gridmap #26054

Closed wbulot closed 3 years ago

wbulot commented 5 years ago

Godot version: 3.1 beta 5

OS/device including version: Windows 10

Issue description: move_and_slide performance is extremely bad when kinematicBody is on a gridmap. The more cells the gridmap have, the more the performance decrease.

I made my test with a simple kinematicBody (cube) and and script with move_and_slide. When moving on a very basic meshInstance, the move_and_slide take around 0.00002 to process. When moving on a gridmap with just one cell, the move_and_slide take around 0.00010 to process. When moving on a more complex gridmap (24x7), the move_and_slide take between 0.00050 and 0.00120 to process.

It seems that the larger the gridmap is, the worse the performance of move_and_slide gets.

This is a big problem because by using just a few dozen kinematicBodies on a gridmap, the game freezes completely because of this performance problem.

Steps to reproduce: Create a kinematicBody Attach a simple script to move it with move_and_slide Compare the performance between a simple meshInstance and a gridmap

Minimal reproduction project: debugProject.zip

Calinou commented 4 years ago

@wbulot Does the performance improve if you lower the GridMap's Octant Size to 1? See #28801.

akien-mga commented 4 years ago

I tested the attached project, but I get performance ratings in the similar order of magnitude for both the MeshInstance and the GridMap (both around 0.0004-0.0010).

KoBeWi commented 3 years ago

Can anyone still reproduce this bug in Godot 3.2.3 or any later release? I also don't see any difference.

wbulot commented 3 years ago

I confirm that I am not able to reproduce the bug in version 3.2