Kites not colliding

Discuss any Chipmunk bugs here.
Post Reply
User avatar
juanpi
Posts: 24
Joined: Wed Jan 30, 2008 3:52 pm
Contact:

Kites not colliding

Post by juanpi »

(This is a post that has been in the main index for long while...Maybe I should have put it here form the beginning.)
Hi,
Once again I am having problems.
The phenomenology is showed here:

http://www.youtube.com/watch?v=IpPsg91U47I

Basically the collision detection fails. I have tried different values for the hashes (static and active, dim and count) but nothing changes. In the video, the kite shape is defined by the following vertices (in the order given):
cpVect vertex[]={
cpv(0,-30),
cpv(-20,0),
cpv(0,16),
cpv(20,0)
};
Then each kite is displaced to (0,-21) and (0,21). A Pivot joint is placed at (0,0).
If vertex[0] is scaled to (0,-22) then it works...
I have also tried modifying the iterations, but again, no success....
Anybody knows what I am doing wrong?

Thanks!
Ezequiel
Posts: 8
Joined: Thu Jan 10, 2008 1:50 pm
Contact:

Re: Kites not colliding

Post by Ezequiel »

I have the same problem. To sum it up:

1. Create two monokites using the polygon class (a kite with sides 1/2 and sqrt(3)/2 (and angles of 120, 90, 60 and 90 degrees)
2. Put them in contact through one of the vertices.
3. Pin them in the contact vertex with a PinJoint
4. Apply an impulse on them to make the move.

The polygons should bounce when their sides get in contact.

The bug happens using the latest version of chipmunk, but also using it through pymunk. The bug happens on Windows and Linux.
ker
Posts: 56
Joined: Tue Jul 15, 2008 4:13 am
Contact:

Re: Kites not colliding

Post by ker »

I'm having a similar problem, never had it before because I was only using spaceship to circle, spaceship to near-circle polygon and circle to circle collision:

Code: Select all

cpVect points[] = {cpv(-2.0, -4.0), cpv(-3.0, 5.0), cpv(3.0, 5.0), cpv(2.0, -4.0), cpv(0.0, -5.0) }; // spaceship collision shape

cpVect bsA[] = {cpv(-10.0, -10.0), cpv(-10.0, 10.0), cpv(10.0, 10.0), cpv(10.0, -10.0)}; // box

I can also deliver exact collision angles and stuff if that is necessary

also a video of what's happening: http://uk.youtube.com/watch?v=lKrY8xhV3iQ
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Kites not colliding

Post by slembcke »

I suppose I should make some sort of appearance. I did somehow miss the original post in the main forum, and haven't gotten time to look at it since this new post. I'll see if I can get to it by the end of the week. I'm guessing the two constraints are fighting somehow.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Kites not colliding

Post by slembcke »

Ah. In the docs I mention that there is a problem with thin or pointy polygons. This is that issue.

The problem is that I generate collision points from the vertexes. In general this works very well, but breaks down when you have overlapping shapes were neither contains vertexes of the other. Think of something like the star of david (http://en.wikipedia.org/wiki/Star_of_David). Two overlapping triangles, but no collision points!

The one thought I had to fix this was to do something like I do for poly to line segment collisions. What that does is to create a box from the segment by adding two perpendicular edges on the ends of the segment and letting the fourth edge be off at infinity. For poly to poly collisions, it would ignore backfacing normals. I think this would still allow it to pick sensible collision points along the minimum separating axis.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Kites not colliding

Post by slembcke »

That was actually a bit easier than I thought and seems to work in a couple simple cases that I tried. I've attached a patch if you want to try it out before I officially make it part of trunk.

In case you are unfamiliar:

Code: Select all

patch -p0 -i pointy_collisions.diff
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
ker
Posts: 56
Joined: Tue Jul 15, 2008 4:13 am
Contact:

Re: Kites not colliding

Post by ker »

I applied the patch (+ tested if anything new was in the repos, which wasn't)
A full (make clean && make && sudo make install) recompile and install does not fix my bug here. I also recompiled my whole game just to make sure.

This is the c-representation of my setup, and the ship goes smoothly through the box while a single vertex (at least) is inside. I can present another movie if necessary, or I can create a fully working c-prototype (or ruby if you prefer) showing that bug.

Code: Select all

cpVect shipPolygon[] = {cpv(-2.0, -4.0), cpv(-3.0, 5.0), cpv(3.0, 5.0), cpv(2.0, -4.0), cpv(0.0, -5.0) }; // spaceship collision shape
cpVect boxPolygon[] = {cpv(-10.0, -10.0), cpv(-10.0, 10.0), cpv(10.0, 10.0), cpv(10.0, -10.0)}; // box
cpVect shipPos = cpv(70.0, 100.0);
cpVect boxPos = cpvzero;
cpFloat shipAngle = -30.0 * 3.14159 / 180.0;
// create bodies and space here
cpVect bodyspeed = cpBodyLocal2World(body, cpv(0.0, -1.0)*10) - (body -> p));
cpBodyApplyImpulse(body, bodyspeed, cpvzero);
// do enough cpSpaceStep-calls
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Kites not colliding

Post by slembcke »

ker wrote:I applied the patch (+ tested if anything new was in the repos, which wasn't)
A full (make clean && make && sudo make install) recompile and install does not fix my bug here. I also recompiled my whole game just to make sure.

This is the c-representation of my setup, and the ship goes smoothly through the box while a single vertex (at least) is inside. I can present another movie if necessary, or I can create a fully working c-prototype (or ruby if you prefer) showing that bug.
I was unable to reproduce the bug given the information provided. If you could modify one of the demos to set up the simplest possible replication that would be very helpful.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
juanpi
Posts: 24
Joined: Wed Jan 30, 2008 3:52 pm
Contact:

Re: Kites not colliding

Post by juanpi »

Thanks for your quick answer and patch, though I am more unfamiliar to this procedures (I am learning, I am learning...) that what you thought.
Where shall I copy the patch file?
BTW, which is the correct repository: Aerosol or Chipmunk (both in googlecode)?

Thanks again.
JPi
ker
Posts: 56
Joined: Tue Jul 15, 2008 4:13 am
Contact:

Re: Kites not colliding

Post by ker »

slembcke wrote:
ker wrote:I applied the patch (+ tested if anything new was in the repos, which wasn't)
A full (make clean && make && sudo make install) recompile and install does not fix my bug here. I also recompiled my whole game just to make sure.

This is the c-representation of my setup, and the ship goes smoothly through the box while a single vertex (at least) is inside. I can present another movie if necessary, or I can create a fully working c-prototype (or ruby if you prefer) showing that bug.
I was unable to reproduce the bug given the information provided. If you could modify one of the demos to set up the simplest possible replication that would be very helpful.
I created a smallest possible version, and i found out the problem happened in a cpVect-array to vector<cpVect> conversion, sorry about that
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests