HardonCollider and ray collisions

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
pudding
Prole
Posts: 6
Joined: Tue Jul 05, 2011 5:09 am
Location: Paris, France

HardonCollider and ray collisions

Post by pudding »

Hello!

I want to "fire" a ray from one set of co-ordinates to another set of co-ordinates and detect whether there is a collision along the length of the ray and if so, where that collision has occurred. The number of objects that could potentially collide with the ray number in the low hundreds.

I know HardonCollider fortunately has the handy "function shape:intersectsRay(x, y, dx, dy)" to test for a collision with a particular shape; my question is: is iterating through all of the potential objects which might collide with the ray the best way of doing this or am I just being an idiot and there's a much better way?
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: HardonCollider and ray collisions

Post by bartbes »

It depends on how you structure your data, if it's just a plain array, then it's probably the only way. Using a tree could speed up the process, but also make the implementation harder, and I'm sure somebody else here will be able to give you another way to store your data that's more efficient, in the end it's just a matter of how much work you do beforehand.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 4 guests