Hi there,
I've spent the day looking over BEPU as a solution to physics in our current project and I must say it looks great!
I've started to implement a few basic objects into the current project but am at a crossroads with how to neatly handle the conversion between BEPU and XNA Vector3 types (and others once I get to them).
It's worth mentioning that the project is already quite substantial, for example we have a very solid Transform system in place already..
So yeh, I'd love to hear how others have resolved this sort of neatness issue in the past!
Cheers
Transitioning between XNA Vector3 and BEPU Vector3
-
- Posts: 49
- Joined: Mon Oct 08, 2012 4:57 pm
Re: Transitioning between XNA Vector3 and BEPU Vector3
You're familiar with MathConverter class? It handles conversion between BEPU and XNA types.
I'd recommend search-n-replace throughout your solution and replace types for most scenarios. Another option is to use aforementioned MathConverter but I'd recommend using it outside update, draw or other methods executed multiple times per frame to avoid GC and method call overhead.
I'd recommend search-n-replace throughout your solution and replace types for most scenarios. Another option is to use aforementioned MathConverter but I'd recommend using it outside update, draw or other methods executed multiple times per frame to avoid GC and method call overhead.
Re: Transitioning between XNA Vector3 and BEPU Vector3
Other than the MathConverter and generally explicit approaches, there's also the option of tossing some implicit conversions into the BEPUutilities math types. That will make most interaction transparent.
Unsurprisingly, I usually just use BEPUutilities for everything in my projects, and it's possible (but a bit tedious) to replace all the BEPUutilities math in BEPUphysics with XNA references if you really wanted to.
While all of the conversion operations will indeed involve a little overhead from method calls and data copies, you don't have to worry about GC. The involved objects are all value types.Another option is to use aforementioned MathConverter but I'd recommend using it outside update, draw or other methods executed multiple times per frame to avoid GC and method call overhead.
Unsurprisingly, I usually just use BEPUutilities for everything in my projects, and it's possible (but a bit tedious) to replace all the BEPUutilities math in BEPUphysics with XNA references if you really wanted to.