Segment Query (raycasting) API requests
-
- Posts: 176
- Joined: Fri Feb 27, 2009 7:12 am
- Location: Germany
- Contact:
Re: Segment Query (raycasting) API requests
Hi,
it turned out that raycasting would be the best thing for my current problem. Is this implemented in the trunk and usable?
Thomas
it turned out that raycasting would be the best thing for my current problem. Is this implemented in the trunk and usable?
Thomas
Visit our game Blog: [url]http://zombiesmash.gamedrs.com[/url] or follow us on twitter: [url]http://twitter.com/zombiesmash[/url]
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Segment Query (raycasting) API requests
Yes, and no. I've implemented the segment/primitive collision functions, but it's missing a way to work efficiently with the spatial hash. I started out with a simple AABB version that generated a AABB for the segment, then checked against all objects returned by the hash. This works, but it's very non-optimal for long diagonal segments.
I started working on stepping through the spatial hash to check only cells that the line hits, but there was a bug causing it to miss some collisions. I haven't had time to work on it for a couple of weeks. Eventually I also want to be able to short circuit the search when you know you've hit the closest object.
If you want to look at the work in progress code, it's in demo/query.c. I've been marshaling the new code there before adding it to the final API.
I started working on stepping through the spatial hash to check only cells that the line hits, but there was a bug causing it to miss some collisions. I haven't had time to work on it for a couple of weeks. Eventually I also want to be able to short circuit the search when you know you've hit the closest object.
If you want to look at the work in progress code, it's in demo/query.c. I've been marshaling the new code there before adding it to the final API.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
-
- Posts: 176
- Joined: Fri Feb 27, 2009 7:12 am
- Location: Germany
- Contact:
Re: Segment Query (raycasting) API requests
Hi,
I now use your code form Query.c for raycasting. It nearly works perfect. The problem I have is the following:
When I call cpSpaceShapeSegmentQueryFirst(space, start, end, -1, 0, &info)) it finds the nearest shape. However when I call it again (directly after the first call) It says there is no shape between start and end (which is wrong).
I do not need to call the function two times after each other, but the same happens, when I call it too fast, maybe before the next spaceStep.
What is the difference between those calls? Any ideas?
Edit: It really seems to happen then and only then when there is no spaceStep called between two cpSpaceShapeSegmentQueryFirst calls.
Thomas
They are coming... - Follow me on Twitter: http://twitter.com/ZombieSmash
I now use your code form Query.c for raycasting. It nearly works perfect. The problem I have is the following:
When I call cpSpaceShapeSegmentQueryFirst(space, start, end, -1, 0, &info)) it finds the nearest shape. However when I call it again (directly after the first call) It says there is no shape between start and end (which is wrong).
I do not need to call the function two times after each other, but the same happens, when I call it too fast, maybe before the next spaceStep.
What is the difference between those calls? Any ideas?
Edit: It really seems to happen then and only then when there is no spaceStep called between two cpSpaceShapeSegmentQueryFirst calls.
Thomas
They are coming... - Follow me on Twitter: http://twitter.com/ZombieSmash
Visit our game Blog: [url]http://zombiesmash.gamedrs.com[/url] or follow us on twitter: [url]http://twitter.com/zombiesmash[/url]
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Segment Query (raycasting) API requests
Weird. I'm not sure. Like I said, it's not finished quite yet, and there seems to be some bugs.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
-
- Posts: 176
- Joined: Fri Feb 27, 2009 7:12 am
- Location: Germany
- Contact:
Re: Segment Query (raycasting) API requests
Is such a query chnaging some states? I couldnt find anything that would be different between two calls after each other.
Visit our game Blog: [url]http://zombiesmash.gamedrs.com[/url] or follow us on twitter: [url]http://twitter.com/zombiesmash[/url]
-
- Posts: 176
- Joined: Fri Feb 27, 2009 7:12 am
- Location: Germany
- Contact:
Re: Segment Query (raycasting) API requests
The problem is in
static inline void query(cpSpaceHash *hash, cpSpaceHashBin *bin, void *obj, cpSpaceHashQueryFunc func, void *data)
hand->stamp = hash->stamp;
There you set a stamp to not check a object twice. When I remove this it works. But I think performance will suffer as you had a reason to do this. How can I reset(?) the stamp?
Edit: I added the line
hash->stamp++ to the end of the raycasting method. Seems to work fine.
Thomas
static inline void query(cpSpaceHash *hash, cpSpaceHashBin *bin, void *obj, cpSpaceHashQueryFunc func, void *data)
hand->stamp = hash->stamp;
There you set a stamp to not check a object twice. When I remove this it works. But I think performance will suffer as you had a reason to do this. How can I reset(?) the stamp?
Edit: I added the line
hash->stamp++ to the end of the raycasting method. Seems to work fine.
Thomas
Visit our game Blog: [url]http://zombiesmash.gamedrs.com[/url] or follow us on twitter: [url]http://twitter.com/zombiesmash[/url]
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Segment Query (raycasting) API requests
Aha! I wouldn't have thought of that right away. Thanks for catching that.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
-
- Posts: 114
- Joined: Sat Mar 07, 2009 7:23 am
- Contact:
Re: Segment Query (raycasting) API requests
Hi, im experiencing problmems with raytracing. It's just not working for me.
ive found if modify demo sample Query.c as following
113: cpVect start = cpvzero; ->>> cpVect start = cpv(0.0f, -1.0f);
157: cpSpaceResizeStaticHash(space, 40.0, 999); ->> cpSpaceResizeStaticHash(space, 40.0, 2053);
158: cpSpaceResizeActiveHash(space, 30.0, 2999); ->> cpSpaceResizeActiveHash(space, 40.0, 2053);
175: body->p = cpv(0.0f, 100.0f); ->> body->p = cpv(0.0f, -31.0);
segment shape become invisible for raytracing. This bug dissapear sometimes, and it hard to say what it depends on.
ive tried bullet implementation with ray tracing and found that bullets hits rarely, no matter what type of shapes it is.
ive found if modify demo sample Query.c as following
113: cpVect start = cpvzero; ->>> cpVect start = cpv(0.0f, -1.0f);
157: cpSpaceResizeStaticHash(space, 40.0, 999); ->> cpSpaceResizeStaticHash(space, 40.0, 2053);
158: cpSpaceResizeActiveHash(space, 30.0, 2999); ->> cpSpaceResizeActiveHash(space, 40.0, 2053);
175: body->p = cpv(0.0f, 100.0f); ->> body->p = cpv(0.0f, -31.0);
segment shape become invisible for raytracing. This bug dissapear sometimes, and it hard to say what it depends on.
ive tried bullet implementation with ray tracing and found that bullets hits rarely, no matter what type of shapes it is.
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Segment Query (raycasting) API requests
There are still bugs in that code, that's why there is no real API for it yet.
I've been trying to focus my attention on contract work and our Twilight Golf game. So I haven't made any progress on this lately.
I've been trying to focus my attention on contract work and our Twilight Golf game. So I haven't made any progress on this lately.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
-
- Posts: 176
- Joined: Fri Feb 27, 2009 7:12 am
- Location: Germany
- Contact:
Re: Segment Query (raycasting) API requests
Hi,
I use raycasting without problems. One change I made some time ago was:
I added the line
hash->stamp++;
to the end of the raycasting method in cpSpaceHash.c
I updated chipmunk to the recent trunk and lost this change. That made some of my raycasting not working anymore. Putting this back in and everything is working fine. It so long ago I made this (did I made it?) that I have no idea why I have done it.
EDIT: Just saw that I wrote that in this same thread a few month ago
Thomas
I use raycasting without problems. One change I made some time ago was:
I added the line
hash->stamp++;
to the end of the raycasting method in cpSpaceHash.c
I updated chipmunk to the recent trunk and lost this change. That made some of my raycasting not working anymore. Putting this back in and everything is working fine. It so long ago I made this (did I made it?) that I have no idea why I have done it.
EDIT: Just saw that I wrote that in this same thread a few month ago
Thomas
Last edited by dieterweb on Sat Oct 24, 2009 4:45 pm, edited 1 time in total.
Visit our game Blog: [url]http://zombiesmash.gamedrs.com[/url] or follow us on twitter: [url]http://twitter.com/zombiesmash[/url]
Who is online
Users browsing this forum: No registered users and 0 guests