Best way to convert XNA project to use BEPU math?

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
snoozbuster
Posts: 172
Joined: Sat Sep 24, 2011 7:31 am

Best way to convert XNA project to use BEPU math?

Post by snoozbuster »

I think the title basically says it all. I have an XNA project, downloaded the XNA fork (I think), and now all my math is broken. What's the best way to go about fixing it? Should I switch entirely to BEPU math and only do XNA conversions when I need to make framework calls? Should I add implicit casting operators to the more common BEPU math classes (Quaternion and Vector3, I'm looking at you)? Should I keep a couple extension methods ToBepuVector() and ToXnaVector()?

It'd be nice if the XNA fork could somehow provide a wrapper over at least the more commonly use types to facilitate upgrading, although I suppose XNA *is* deprecated now anyway.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Best way to convert XNA project to use BEPU math?

Post by Norbo »

Should I switch entirely to BEPU math and only do XNA conversions when I need to make framework calls?
In my projects, I generally use BEPUutilities whereever possible. In the BEPUphysicsDemos you can see BEPUutilities has pretty much taken over. For the SharpDX project, I'm actually using BEPUutilities math exclusively.

The benefits of this approach are simplicity and a negligible performance advantage, both arising from the lack of conversions.

Other people might not be as comfortable relying on it totally, which is understandable. I'm very familiar with it, so I have no concerns about having to extend its functionality if I run into an unsupported corner case.
Should I add implicit casting operators to the more common BEPU math classes (Quaternion and Vector3, I'm looking at you)?
Of the ways which involve interoperation between different math libraries, this one tends to be the most transparent. It's generally easiest for users who don't want to use BEPUutilities everywhere and don't want to make a bunch of code changes.
It'd be nice if the XNA fork could somehow provide a wrapper over at least the more commonly use types to facilitate upgrading, although I suppose XNA *is* deprecated now anyway.
It has a MathConverter. It's not as convenient as, say, implicit casts, but it avoids BEPUutilities modifications.
snoozbuster
Posts: 172
Joined: Sat Sep 24, 2011 7:31 am

Re: Best way to convert XNA project to use BEPU math?

Post by snoozbuster »

Norbo wrote:
Should I add implicit casting operators to the more common BEPU math classes (Quaternion and Vector3, I'm looking at you)?
Of the ways which involve interoperation between different math libraries, this one tends to be the most transparent. It's generally easiest for users who don't want to use BEPUutilities everywhere and don't want to make a bunch of code changes.
Alright. I think I'm going to take this route, as if I don't I will probably have to go through about 500 usages of Vector3 and Quaternion and manually edit them, not to mention this (for the most part) avoids name conflicts between Microsoft.Xna.Framework and BEPUutilities. I didn't know about that MathConverter, though; I'll probably use that for less-common conversions.
Post Reply