Well, while that specific example might work, what I was running up against was that I was reading shape coordinates, stored as ints, from a file, and then passing them as parameters to different chipmunk functions. I don't specifically remember what I was doing though, but when my character would collide with the ground (the only two things I had on the field at the time) the character's x and y variables would get set to NaN.slembcke wrote:Could you explain what you mean by using ints? Do you mean simply changing a 0 to a 0.0f or something? What compiler?
Body disappearing upon collision
-
- Posts: 46
- Joined: Tue Aug 21, 2007 10:30 am
- Contact:
Re: Body disappearing upon collision
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Body disappearing upon collision
That is... very strange. No idea why an implicit cast would be any different.
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: 46
- Joined: Tue Aug 21, 2007 10:30 am
- Contact:
Re: Body disappearing upon collision
From what I gathered, no implicit casting was happening. (I built a version of chipmunk that printed out the hex values of the different variables when the shape was created.) I was not explicitly casting, and the ints I passed on were being treated as floats. That is, no changes were made to their bits. With 0, this doesn't make a difference, since the bits are all the same, but generally, I found that the bits I were passing in were invalid as floats.
This may be due to the fact that I was using Uint32, Sint32, etc. instead of unsigned int, int, etc. but I'm pretty sure I had some hard-coded values (e.g. cpv(10, 100);) which failed too.
This may be due to the fact that I was using Uint32, Sint32, etc. instead of unsigned int, int, etc. but I'm pretty sure I had some hard-coded values (e.g. cpv(10, 100);) which failed too.
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Body disappearing upon collision
Very odd. I had never heard of such a problem before. I've been trying to be a stickler for making actual float constants. Maybe that's why I've not run into it.
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/
Who is online
Users browsing this forum: No registered users and 21 guests