Bug in cpSpaceSegmentQueryFirst

Official forum for the Chipmunk2D Physics Library.
Beta Carotene
Posts: 123
Joined: Sat Aug 04, 2012 6:34 pm
Contact:

Re: Bug in cpSpaceSegmentQueryFirst

Post by Beta Carotene »

Tried calling it after all positions of the platforms (all static platforms) and calling directly before the query. No difference.
Beta Carotene
Posts: 123
Joined: Sat Aug 04, 2012 6:34 pm
Contact:

Re: Bug in cpSpaceSegmentQueryFirst

Post by Beta Carotene »

Im going to try and make a video
Beta Carotene
Posts: 123
Joined: Sat Aug 04, 2012 6:34 pm
Contact:

Re: Bug in cpSpaceSegmentQueryFirst

Post by Beta Carotene »

http://www.youtube.com/watch?v=A_PEWmQ0 ... e=youtu.be

the one not under the cyan circle is the mouse. I had to run this 6 times before it would reproduce the bug
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Bug in cpSpaceSegmentQueryFirst

Post by slembcke »

It shouldn't, no.

What happens if you disable the moving platforms? Maybe I'm grasping at a straw here, but that's the only thing that makes sense which might be interfering.

Another thing to try would be disabling where it writes to t_exit in SubtreeSegmentQuery() (github).

Instead of the lines like this:

Code: Select all

if(t_a < t_exit) t_exit = cpfmin(t_exit, SubtreeSegmentQuery(subtree->A, obj, a, b, t_exit, func, data));
Make them be like this:

Code: Select all

if(t_a < t_exit) cpfmin(t_exit, SubtreeSegmentQuery(subtree->A, obj, a, b, t_exit, func, data));
That way t_exit will always stay at 1.0 and all subtrees will always be tried. That might (double?) the cost of raycasts though.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Beta Carotene
Posts: 123
Joined: Sat Aug 04, 2012 6:34 pm
Contact:

Re: Bug in cpSpaceSegmentQueryFirst

Post by Beta Carotene »

Well.... I.... think we can conclude that that is not the cause seeing as how the tree modification made it a hell of a lot *worse*
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Bug in cpSpaceSegmentQueryFirst

Post by slembcke »

Say what??? Argh. I'm starting to feel some fraction of your pain here. This is bizarre. :(

Code: Select all

static cpFloat
SubtreeSegmentQuery(Node *subtree, void *obj, cpVect a, cpVect b, cpFloat t_exit, cpSpatialIndexSegmentQueryFunc func, void *data)
{
	if(NodeIsLeaf(subtree)){
		func(obj, subtree->obj, data);
		return 1.0f;
	} else {
		SubtreeSegmentQuery(subtree->A, obj, a, b, 1.0f, func, data));
		SubtreeSegmentQuery(subtree->B, obj, a, b, 1.0f, func, data));
		return 1.0f;
	}
}
Ok... What happens if you do this? Just traverse the entire tree and query against all leaves. Couldn't be more brute force than that, but I don't know where any bugs can hide in that.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Beta Carotene
Posts: 123
Joined: Sat Aug 04, 2012 6:34 pm
Contact:

Re: Bug in cpSpaceSegmentQueryFirst

Post by Beta Carotene »

Well either to joy or dismay, I made that modification and I cant get it to happen anymore.... so.... what now....
Beta Carotene
Posts: 123
Joined: Sat Aug 04, 2012 6:34 pm
Contact:

Re: Bug in cpSpaceSegmentQueryFirst

Post by Beta Carotene »

further confirmation: I enabled it again and it started happening immediately
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Bug in cpSpaceSegmentQueryFirst

Post by slembcke »

Hrm. I dunno. I think it means that either the bounding box data is incorrect (which seems very very unlikely since you are reindexing right before querying, etc), or that MSVC doesn't compile cpBBSegmentQuery(). Those are the only two possibilities I can think of. The latter seems plausible since it uses a bunch of IEEE infinite (but not NaN) math bits to deal with lines that don't cross and such.

Do you know how to enable strict FP on MSVC? I guess I'd try that before trying to rewrite the function just to be sure. I haven't had issues with it on other platforms, and it's not doing anything particularly fancy. Maybe a compiler bug then? Either way, if strict FP doesn't fix it or ruins performance, then it will have to be rewritten differently I guess.

Another easy check would be to do a simple BB check of the ray segment against the child BBs. Wouldn't be great performance wise though, but would help narrow down the issue to cpBBSegmentQuery().
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Beta Carotene
Posts: 123
Joined: Sat Aug 04, 2012 6:34 pm
Contact:

Re: Bug in cpSpaceSegmentQueryFirst

Post by Beta Carotene »

I had it set to FP:precise before, set it to FP strict and am now recompiling.
Post Reply

Who is online

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