Gravity Works, Collision Doesn't [Solved]

Official forum for the Chipmunk2D Physics Library.
Post Reply
DarkPrince
Posts: 3
Joined: Mon May 19, 2008 7:30 am
Contact:

Gravity Works, Collision Doesn't [Solved]

Post by DarkPrince »

I am really sorry if I missed something important in the 'docs' and examples, but I am pretty sure I looked through the majority of example code and I am not spotting what would be causing such an issue. I have one dynamic object which is suppose to fall and rest on a static object (floor). The problem is at the moment it seems there is no collision at all. I tried Demo1's callback idea and outputs that to a file and ends up there was no collision trigger. I read into the layers bit mask and the collision_type and I am pretty sure I have those either set correctly or leaving them default. I am terribly sorry if I am missing something stupid, but I am new to this 2D physics engine and hope to solve this as it looks quite promising.

The total accumulated lines of source is close to 400-500 lines so I decided to make pastes of it on a paste site (rafb.net). Thank you in advance for your help and I hope keep going with this engine, as I feel it is more to my taste.

Physics.h http://rafb.net/p/KmDuia90.html
Physics.cpp http://rafb.net/p/1f5qS128.html
Main.cpp h[url]ttp://rafb.net/p/Z2Djqr46.html[/url]
Last edited by DarkPrince on Wed May 21, 2008 3:48 pm, edited 1 time in total.
the pizza boy
Posts: 5
Joined: Thu Apr 24, 2008 9:03 pm
Contact:

Re: Gravity Works, Collision Doesn't

Post by the pizza boy »

I had the same symptoms, solved here: http://www.slembcke.net/forums/viewtopic.php?f=1&t=167
I don't know if your problem is as simple as mine was though.
DarkPrince
Posts: 3
Joined: Mon May 19, 2008 7:30 am
Contact:

Re: Gravity Works, Collision Doesn't

Post by DarkPrince »

So far it doesn't seem that this is the same case. I added some debugging code and with the two entities being created I got the output:
Physics Engine Module
Powered By: Chipmunk (2D Physics)
----------------------------------------
Entity Created:
Mass: 5
Inertia: 83.3333

Entity Created:
Mass: 1
Inertia: 1.#INF

Shutdown!
The 2nd would be the static object and the first is the falling box that should land onto the static object but refuses to even interact with it at all. Thanks for the help so far, and I will also keep looking into it but if you got any more good ideas or just wild guesses please say. Thanks.
maximile
Posts: 157
Joined: Mon Aug 20, 2007 12:53 pm
Location: London, UK
Contact:

Re: Gravity Works, Collision Doesn't

Post by maximile »

You could check for incorrect polygon winding, or make sure you added the collision shapes to the bodies. I get lost in C++, but I couldn't see either of these mistakes in yours from a quick glance. I'd try commenting out all of your layer code to make sure it's nothing to do with that (by default, everything should collide). Someone else might spot something more obvious.
DarkPrince
Posts: 3
Joined: Mon May 19, 2008 7:30 am
Contact:

Re: Gravity Works, Collision Doesn't

Post by DarkPrince »

Yes you are correct about having an incorrect winding on the poly. I guess I really just didn't understand how to determine which way winding goes. Sorry about that, I didn't do enough research.
Post Reply

Who is online

Users browsing this forum: No registered users and 26 guests