Ray casting or general segment2segment

Discuss new features and future development.

Ray casting or general segment2segment

Postby afaucher » Wed Apr 30, 2008 3:53 am

I have been trying to write a physics based shooter using chipmunk. So far the biggest problem I've run into is that there is no general support for raycasting or line/line intersection.

What I am trying to do, from a fixed point, get the closest intersection in the direction of a vector, with some max distance I care about. Right now I am adding a static line to the scene with a collision type handler. And for every collision I get during the update, I keep track of the one closest to the start. This has a few disadvantages, one, it takes alot of external management to keep track of multiple instances of this. I have to do the query during an update for example, when I only really care what happens at one particular time. Two, line segments don't intersect other line segments. That one is really a problem, right now my 'laser' goes right though my walls. The help docs list "Line segments: Meant mainly as a static shape. They can be attached to moving bodies, but they don’t generate collisions with other line segments." but it doesn't say why this is the case. Has nobody bothered to write it? Or is there some fundamental problem with line collisions? I can see how they would be hard to physically simulate, but I don't want them to move, just register collisions. I've written line/line collision more times then I can count but the thought of writing it again saddens me.

Has anyone written an extension to handle this? Either segment2segment or a more general mechanism for this? Would adding segment2segment to the list of collision types cause the simulation to freak out, even if they are all static?

Posts: 1
Joined: Wed Apr 30, 2008 3:35 am

Re: Ray casting or general segment2segment

Postby dc443 » Sun May 04, 2008 7:57 pm

Interested in this as well, since I would like to have cheap line segment objects that would hopefully be less expensive to simulate than polygons.

And ray casting would be very very useful.
Posts: 20
Joined: Sun Dec 02, 2007 3:54 am

Re: Ray casting or general segment2segment

Postby slembcke » Mon May 12, 2008 1:19 am

Sorry for the long wait. A friend and I have been hard at work for the last couple of weeks completing our first shareware game.

You're right that segment to segment collision detection is pretty easy. The reason why I doesn't support it yet is that until I added beveled line segments, it wouldn't have been useful as a collision shape at all. The other part of this that you really want is the ability to do collision queries against a segment. To do this efficiently, I'll also have to make a nice API similar to the point queries and make code that traverses the spatial hash. I want and plan to do this eventually, but it will take time, and I can't promise when I'll have time to work on it.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
Site Admin
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Return to Features/Development

Who is online

Users browsing this forum: No registered users and 1 guest