godotengine / godot

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

GridMap mouse movement and selection is not aligned with non-centered cells #77196

Closed rcorre closed 1 year ago

rcorre commented 1 year ago

Godot version

v4.0.2.stable.arch_linux

System information

Linux

Issue description

Mouse movement and selection is not well aligned with the grid when the cells are not centered.

1684407311 https://github.com/godotengine/godot/assets/2496231/c070d9b8-0b0f-4bae-b69e-83bc374dffc8

Steps to reproduce

  1. Add a GridMap
  2. Set CellSize to 1,1,1
  3. Set CenterX,CenterY,CenterZ to false
  4. Move the mouse around the grid, notice that it doesn't snap to a coord until the mouse has just about passed it (as if it is snapping to the ceil of the mouse coordinate rather than round, if that makes sense)
  5. Hold shift to create a selection
  6. Notice the selection box is not aligned with the grid.

Minimal reproduction project

N/A

smix8 commented 1 year ago

I have trouble to understand what the issue is here. If I slow down the video it updates the preview the very second the mouse hovers over a new grid cell to a position that I would expect.

The only thing that I do not see aligned with the grid is the item visuals from the MeshLibrary.

rcorre commented 1 year ago

Sorry, I was misunderstanding how this should work. I was trying to have the grid itself centered so that e.g. there is a tile centered at the global position (0, 0). I think what I actually wanted to do was change the Grid transform, not the centering of the cells. Thanks!