Hi Clay!
I'm wondering, is there any place in particular in the code that's causing problems for your port? You mentioned an assert, where is that happening? skatehead, quixote_arg and I have all fought through a lot of issues, perhaps some of them are similar. One piece of advice: watch anywhere that there is either a memmove or memcpy call and make sure that everything is happening right.
Also, I see that the Java port was giving you some problems, were there bugs that you discovered in the Java code or was it a problem in getting the Java->D translation working right?
Anyways, good luck, I know it's a tricky task.
Hey,
With trying to convert the java version, I'm not quite sure what is wrong with it, it is probably the farthest I've got trying to port box2d to D, as helloworld actually executes without asserts. However, the helloworld program simply prints out
0.0, 4.0; 0.0
Over and over again.
Tracing the execution of the program, for some reason at this point in world.d [line 253 in world.java, oh and I'm using the source from 1.0.0\src\, is this right?]
if (seed.m_invMass == 0.0f || seed.m_islandFlag == true || seed.m_isSleeping == true)
{
continue;
}
Here, for whatever reason, continue is called for all three bodies. I've tried to figure out why and I've failed, also it is the end of the semester for me so I really don't have too much time to work on it now, I'm hoping to get it done during Christmas break however. 🙂
Thanks for offering to help.
~ Clay
With the cpp --> D version, I'm getting an assert in b2BroadPhase in AddPair
assert(m_proxyPool[id1].IsValid() && m_proxyPool[id2].IsValid());
is being triggered. I'll probably try tracing the execution more of both the c++ and java ports to d over the break, and perhaps work on both of them until one of them decides to start working.
~ Clay
Well, our 1.0.0 was the earliest and roughest one, I think we still had quite a few of our own bugs in there on top of the ones that Erin has since fixed on his end. If I recall we never quite had that working completely without hitting an occasional assert. The most recent is in the trunk, and that is somewhere around 1.4.0 right now (working on bringing it up to date as we speak).
I'll warn you now - a lot of stuff changes in the early versions. If we had to go back, I think we would have started the port with the latest available version just to avoid having to look through and change everything after the fact. It's not a huge deal, though, it took probably a few hours to move from 1.0.0 to 1.3.0 directly.
I'd look through your Java->D and see which of those flags is being set. The island one is only touched within World, but I doubt this is the problem; the others might be a little trickier to track down. The likely cause really depends on which one is going wrong. The inv_mass one would suggest that somewhere a member copy didn't happen and it's left set as 0f by default. If it's a sleeping issue, check to make sure that the Settings.timeToSleep variable is nonzero and peek around the island, world, and body files.
For the Java version, a lot of problems arose from deep copy vs. shallow copy issues, especially in the broad phase (watch out for memcpy and memmove) - make absolutely sure whether you're supposed to be copying the objects that an array points to when you're copying or moving, or just the pointer to each object. It looks like you might be hitting something like that while dealing with the buffered pairs, and it copied a pointer (or reference) rather than an object and then something else has changed the object, making your "copy" buffered as well even though it was supposed to be unbuffered.
Our of curiosity, is there a benefit to porting the code rather than simply writing glue to allow D to work directly with the original version? I was under the impression that D could work with c/c++..