Hi, I'm trying to make Box2D work on a handheld. It should be easy, it seems to work fine except for the fact that, when I run any simulation, it looks like it was in pause mode.
For example, in the hello world, I get the ground box and the small box one over the other (as it should be) but nothing happens next. Seems to be sleeping but is not the case, and I don't know where to start looking for. Some of you have been porting Box2D to other languajes, so may be you know how I should proceed from now on to make it work.
Thanks in advance 😉
Are you calling b2World::Step? Is the time step positive? Is gravity non-zero?
Yes, exactly the same example works fine on PC. I know is some kind of bug or implementation missed somewhere, but I don't know what to do to found what's happening... May be some experienced programmer could give me some tips 🙄
First off, what kind of handheld are you using, and in what programming language? Have you ported all the code, and if so, are you able to let us see it? We ran into a lot of different issues with the Java port, but I can't say if any would be relevant to your code without knowing more about your setup.
Can you set a break point on line 100 of b2Island.cpp?
b->m_position += dt * b->m_linearVelocity;
Look at dt and m_linearVelocity. They should be non-zeo.
I can't debug programs as we usually do, but I'm going to see what you suggested, thanks 😉
Well, for the Java port we didn't do anything very special, mainly just got it to compile then started trying to run it with assertions enabled. We fought our way through every one of the assertions and runtime null pointer errors that popped up, and once we were done with that, things looked like they were working right. Most of the problems were really just issues with the C++ -> Java translation process, not anything particularly tricky with the program logic.
Not an expert on mobile devices, but if the GP32 is anything like any of the ones I've used or programmed for, it has no floating point unit - that could be one issue, though I'm not sure if it would make nothing happen at all, it would probably just slow it down a lot. Apart from that, some pieces of Box2D pre-allocate memory in large chunks rather than taking it from the OS as needed. Maybe the engine is running past the memory limit of the device before anything actually happens? Calls to the allocator should usually check to make sure that the memory is there before they use it, so it may just not be doing anything because the pointers are coming back null; if that's the case, it's worth figuring out the easiest solution in case people want to use this engine in other memory-constrained situations. I don't know how much memory Box2D tends to use, but it shouldn't be too tough to track that down on your PC.
Otherwise, maybe the data types are of unusual sizes? There's some bitwise stuff in the code, so if your int32s are for some reason only 16 bits or something odd like that, you might have trouble. I'd check the memory stuff first, though, it seems most plausible to me.
Thanks a lot for your help 😀 I'll try all of this tonight...keep my fingers crossed 😆
I wonder if the fixed point math is causing some terms to be zero that should not be. I recommend running the HelloWorld test simultaneously on the PC and on your console and looking at the differences in the math.