Box2D Forums

It is currently Wed May 22, 2013 9:09 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 14 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Tue Sep 25, 2007 9:14 am 
Offline

Joined: Wed Sep 12, 2007 2:23 pm
Posts: 14
This thread will be dedicated to the box2d port for the D programming language. The port is still under construction.

http://www.digitalmars.com/d
http://www.dsource.org/projects/box2d4d

~ Clay


Top
 Profile  
 
PostPosted: Sat Nov 24, 2007 6:51 pm 
Offline

Joined: Wed Sep 12, 2007 2:23 pm
Posts: 14
This porting effort is not dead, just more difficult then I imagined. See http://arclib.blogspot.com/ for more details.


Top
 Profile  
 
PostPosted: Mon Nov 26, 2007 3:48 pm 
Offline

Joined: Sun Sep 23, 2007 2:35 pm
Posts: 803
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.


Top
 Profile  
 
PostPosted: Tue Nov 27, 2007 10:38 am 
Offline

Joined: Wed Sep 12, 2007 2:23 pm
Posts: 14
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


Top
 Profile  
 
PostPosted: Tue Nov 27, 2007 10:42 am 
Offline

Joined: Wed Sep 12, 2007 2:23 pm
Posts: 14
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


Top
 Profile  
 
PostPosted: Tue Nov 27, 2007 4:19 pm 
Offline

Joined: Sun Sep 23, 2007 2:35 pm
Posts: 803
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.


Top
 Profile  
 
PostPosted: Thu Jan 24, 2008 1:39 pm 
Offline

Joined: Wed Sep 12, 2007 2:23 pm
Posts: 14
Hey,

I decided to start over again with 1.4.3.

Anyway, it's not done but it compiles.

Here's a link to documentation I've auto generated for box2d as well.

http://svn.dsource.org/projects/box2d4d ... Phase.html


Top
 Profile  
 
PostPosted: Fri Jan 25, 2008 10:28 am 
Offline

Joined: Wed Sep 12, 2007 2:23 pm
Posts: 14
Ok, here are the results of the first hello world test run.

Quote:
tango.core.Exception.AssertException@box2d4d\collision\b2PairManager.d(412): m_broadPhase.TestOverlap(proxy1, proxy2) == true
0.00 4.00 0.00
0.00 3.99 0.00
0.00 3.98 0.00
0.00 3.97 0.00
0.00 3.96 0.00
0.00 3.94 0.00
0.00 3.92 0.00
0.00 3.90 0.00
0.00 3.87 0.00
0.00 3.85 0.00
0.00 3.82 0.00
0.00 3.78 0.00
0.00 3.75 0.00
0.00 3.71 0.00
0.00 3.67 0.00
0.00 3.62 0.00
0.00 3.57 0.00
0.00 3.52 0.00
0.00 3.47 0.00
0.00 3.42 0.00
0.00 3.36 0.00
0.00 3.30 0.00
0.00 3.23 0.00
0.00 3.17 0.00
0.00 3.10 0.00
0.00 3.02 0.00
0.00 2.95 0.00
0.00 2.87 0.00
0.00 2.79 0.00
0.00 2.71 0.00
0.00 2.62 0.00
0.00 2.53 0.00
0.00 2.44 0.00
0.00 2.35 0.00
0.00 2.25 0.00
0.00 2.15 0.00
0.00 2.05 0.00
0.00 1.94 0.00
0.00 1.83 0.00
0.00 1.72 0.00
0.00 1.61 0.00
0.00 1.49 0.00
0.00 1.37 0.00
0.00 1.25 0.00
0.00 1.13 0.00
tango.core.Exception.FinalizeException: An exception was thrown while finalizing an instance of class box2d4d.collision.b2Shape.b2PolyShape
tango.core.Exception.AssertException@box2d4d\collision\b2PairManager.d(384): pair.IsBuffered()


It looks like the results are good compared to the C++ program, however two asserts are triggered.
Any suggestions would be appreciated, otherwise I'll be manually tracing the execution path of both programs and comparing them.

~ Clay


Top
 Profile  
 
PostPosted: Fri Jan 25, 2008 1:53 pm 
Offline

Joined: Sun Sep 23, 2007 2:35 pm
Posts: 803
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.


Top
 Profile  
 
PostPosted: Sat Jan 26, 2008 8:27 am 
Offline

Joined: Fri Sep 28, 2007 7:49 am
Posts: 61
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++..


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ]  Go to page 1, 2  Next

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group