C# port of Box2D.

Discuss issues specific to the C#/XNA ports of Box2D
taumuon
Posts: 4
Joined: Sat Jun 28, 2008 1:32 pm
Location: Cambridge, UK
Contact:

Re: C# port of Box2D.

Postby taumuon » Mon Aug 04, 2008 12:07 pm

Nikster wrote:
ivailo91 wrote:I don't know if this is the right place to ask, but...
As I look at the Box2DX source code, I'm just wondering, there are so many functions that accept for example Vector2 parameters. These functions don't actually modify the Vector2's or anything, but yet they don't use the ref keyword. A simple observation can point you that there is significant speedup with ref's even with so simple types...


1) if they don't modify the values why the need for ref ?
2) In my bench tests, using by value is slightly faster over a million iterations, this is OK for Vector2 as the size of it fits in well how the IL works, anything lower than 16-24 bytes (can't remember which) should have no performance difference than by passing by value or ref, I'd like to see proof otherwise to which you came to your conclusions or a citation to your observation, C++ != c# so don't assume they work the same way when passing by ref.

*snip*

EDIT: you can also change from structs to classes if you think it will make a difference.


If you're passing structs around by value, then the values need to be copied (a new struct is created and the values copied across), but if you pass by ref, then a reference to the original struct is passed, meaning that you don't incur the overhead of the copying. I wouldn't make these sorts of changes without actually measuring the performance difference.
Also, prior to the .NET 3.5 SP1 (coming around the corner), methods that took structs as parameters weren't as optimised as they could be (see http://blogs.msdn.com/vancem/archive/20 ... 5-sp1.aspx).

Jonas
Posts: 7
Joined: Sat Sep 20, 2008 5:00 pm

Re: C# port of Box2D.

Postby Jonas » Sat Sep 20, 2008 5:02 pm

First of all, thank you for this port! I just recently found Box2D, and directly thought "it would be great if there were a C# version". And it was! Really glad to find it =)

How complete is this port considered to be?

Thanks!

ihar3d
Posts: 24
Joined: Thu Feb 28, 2008 5:20 am

Re: C# port of Box2D.

Postby ihar3d » Tue Oct 07, 2008 2:51 am

Hi All! Sorry for the long absence.
I'm very glad to inform that I start updating Box2DX to the latest Box2D version, after I'm planning to perform refactoring and make performance better. Also a few reported issues were fixed (see http://code.google.com/p/box2dx/issues/list?can=1&q=&colspec=ID+Type+Status+Priority+Milestone+Owner+Summary&cells=tiles), and Broadpahse test was enabled in Testbed.

P.S.

Erin, thanks a lot for the Box2D!!! It's amazing physics engine!!! :)
Thanks ALL for interest to my port.

JeffWeber
Posts: 40
Joined: Mon Sep 17, 2007 4:30 am
Location: appleton, wi
Contact:

Re: C# port of Box2D.

Postby JeffWeber » Tue Oct 07, 2008 10:40 am

Great!

Welcome back... I had about given up on you.

I'm running some tests with your engine right now in Silverlight. Good to hear you are going to be updating it again.

-Jeff

endquote
Posts: 12
Joined: Mon Sep 22, 2008 1:49 pm
Location: Seattle, WA
Contact:

Re: C# port of Box2D.

Postby endquote » Tue Oct 07, 2008 10:47 am

Ah, he lives!

I'm working on renderers for WPF and Silverlight. The WPF version is pretty complete (but I still need to port the test bed), and the Silverlight version is coming along. The WPF version is shown here: http://stimulant.io/wp/index.php/2008/1 ... e-surface/

I plan to open-source these, but I'll probably need 2-3 weeks to get things into a releasable state.

endquote
Posts: 12
Joined: Mon Sep 22, 2008 1:49 pm
Location: Seattle, WA
Contact:

Re: C# port of Box2D.

Postby endquote » Sun Oct 12, 2008 8:22 pm

I finished a first version of a Box2d wrapper for Silverlight, and am now moving onto making the testbed for both WPF and Silverlight. I thought I'd update to the latest box2dx rev first, though. I'm noticing a few cases of the "unsafe" keyword being used for pointers in the Broadphase class. This is fine in WPF, but VS will now allow the compilation of unsafe code in a Silverlight project. Is there a way for box2x to provide safe versions of any unsafe methods, and is there a compiler flag or something that would allow the code to compile correctly for Silverlight?

ihar3d
Posts: 24
Joined: Thu Feb 28, 2008 5:20 am

Re: C# port of Box2D.

Postby ihar3d » Mon Oct 13, 2008 1:56 am

Is there a way for box2x to provide safe versions of any unsafe methods, and is there a compiler flag or something that would allow the code to compile correctly for Silverlight?


Hi! Please use ALLOWUNSAFE (in Broadphase.cs) directive for this. Safe and unsafe equivalents of QuerySegment and AddProxyResult methods were tested on new Raycast Test in TestBed.

ihar3d
Posts: 24
Joined: Thu Feb 28, 2008 5:20 am

Re: C# port of Box2D.

Postby ihar3d » Wed Oct 15, 2008 7:30 am

Updating to Box2D r175 has been finished - r51. Updated demo suite is available here http://box2dx.googlecode.com/files/Box2DX-2.0.1.3-r175-RC-DemoSuite.zip.

JeffWeber
Posts: 40
Joined: Mon Sep 17, 2007 4:30 am
Location: appleton, wi
Contact:

Re: C# port of Box2D.

Postby JeffWeber » Wed Oct 15, 2008 2:59 pm

Hi Ihar,

I just tried to run the new demos behind the link you provided. They would not run for me.

I'm using Vista.

Just thought I'd let you know.

ihar3d
Posts: 24
Joined: Thu Feb 28, 2008 5:20 am

Re: C# port of Box2D.

Postby ihar3d » Wed Oct 15, 2008 11:51 pm

Thanks a lot! There is problem with drawing text using freetype6. I'm going to fix this ASAP.


Return to “C Sharp”



Who is online

Users browsing this forum: No registered users and 1 guest