M
M
Macgluk2015-06-11 16:35:03
Game development
Macgluk, 2015-06-11 16:35:03

What are the algorithms for determining the object under the mouse cursor?

You need to determine which object is under the mouse cursor.
So far, the only option that came to mind is to collect all the objects and check each for coordinates, but there are a lot of objects, so I divided the entire area into sectors and, selecting a sector with the mouse, check its collection of objects. How can this algorithm be simplified? Better yet, are there other ways? (Preferably with a more or less balance between simplicity and performance, because the area can be large, and objects exceed a million)
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
GreatRash, 2015-06-11
@GreatRash

For example, in Unity 3D, you can cast a ray from the cursor coordinates into the depth and check whether it intersects with any object.

M
Macgluk, 2015-06-11
@Macgluk

Preferably something for 2d.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question