mirror of
https://github.com/raysan5/raygui.git
synced 2026-02-01 03:39:18 -05:00
Use floor for mouse to cell mapping, it is more readable and would work for theoretical negative cell positions. (#241)
This commit is contained in:
@ -3283,9 +3283,9 @@ Vector2 GuiGrid(Rectangle bounds, const char *text, float spacing, int subdivs)
|
|||||||
{
|
{
|
||||||
if (CheckCollisionPointRec(mousePoint, bounds))
|
if (CheckCollisionPointRec(mousePoint, bounds))
|
||||||
{
|
{
|
||||||
// NOTE: Cell values must be rounded to int
|
// NOTE: Cell values must be the upper left of the cell the mouse is in
|
||||||
currentCell.x = (float)((int)((mousePoint.x - bounds.x)/spacing));
|
currentCell.x = floorf((mousePoint.x - bounds.x)/spacing));
|
||||||
currentCell.y = (float)((int)((mousePoint.y - bounds.y)/spacing));
|
currentCell.y = floorf((mousePoint.y - bounds.y)/spacing));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user