BEPUutilities questions

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
needshelprendering
Posts: 25
Joined: Mon Sep 17, 2012 1:17 am

BEPUutilities questions

Post by needshelprendering »

Hi Norbo,

I decided to update my engine's copy of BepuPhysics today and I saw on your blog that you are no longer using XNA's math class, I have a few questions.

Why did you choose BEPUutilities over XNA's math? Is there a performance difference?
My graphics/the rest of my engine uses XNA's math class, is there a reasonable way to mesh BEPUutilities in with this? For example I simply swapped out the previous version of Bepu with your new one, I got error such as

Code: Select all

Cannot convert XNA.Vector3 to BEPUutilities.Vector3
Does BEPUutilities have undefined/quirky behavior, would it be reasonable to just use BEPUutilities for my graphics/outside Bepu?

Thanks for keeping Bepu on XNA, by the way.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: BEPUutilities questions

Post by Norbo »

Why did you choose BEPUutilities over XNA's math? Is there a performance difference?
They should be basically identical, even down to the assembly level in many cases (there are not many ways to code Vector3.Add). The one exception is on WP7 Mango. XNA math has an advantage there due to XNA-only SIMD/ARM-NEON optimizations.

BEPUutilities was chosen because it will run anywhere. For example, it's possible to dump the BEPUphysics assemblies on linux and things just work (provided a compatible version of Mono is installed).

[BEPUutilities is used instead of other open source managed math libraries like OpenTK's since I had been incrementally building the math library over time for other purposes. By the time I decided to move to a fully dependency free version, my own library was already ready.]
My graphics/the rest of my engine uses XNA's math class, is there a reasonable way to mesh BEPUutilities in with this? For example I simply swapped out the previous version of Bepu with your new one, I got error
One way is to use something like the MathConverter class. This is what the BEPUphysicsDemos do.

Another common option is to put implicit casts in the BEPUutilities math types which transparently convert between the XNA and BEPUutilities types. Those casts aren't in there by default since they would make the BEPUutilities library depend on XNA. If you're only targeting XNA, though, there's no problem with tossing them in.

There is always the option of replacing all the BEPUutilities references with XNA references, too. It's not hard, but it is tedious enough to discourage me from doing it anymore :)
Does BEPUutilities have undefined/quirky behavior, would it be reasonable to just use BEPUutilities for my graphics/outside Bepu?
It behaves pretty much exactly like XNA. If I remember correctly, the largest difference would be the absence of the BoundingFrustum struct.

I personally use BEPUutilities math for everything in my projects. The core of SharpDX has no dependencies on SharpDX math that I'm aware of, so it is pretty easy. Vertex buffers and everything else are just built from BEPUutilities types.

XNA (and perhaps the higher-level SharpDX toolkit, I haven't used it) can get in the way a bit more. For example, whenever you interact with SpriteBatch or BasicEffects, it will expect XNA types and a conversion will be necessary.
needshelprendering
Posts: 25
Joined: Mon Sep 17, 2012 1:17 am

Re: BEPUutilities questions

Post by needshelprendering »

Hi Norbo, thanks for the quick reply.

Since I am still learning C#, I don't exactly know how to replace the BEPUutilities with XNA math, do you have any tips? I imagine it is easier than just going error by error and converting it to use XNA's math class. I will only be targeting Windows and the Xbox 360 (if it is even around when I finish this).

Also did you remove/move GetVerticesAndIndicesFromModel? It is in BEPUphysics.DataStructures.TriangleMesh in older versions but I cannot find it now.

Thanks.

Edit: Also how can I tell which version of Bepu I have, AssemblyVersion in AssemblyInfo.cs always says 1.3.0.0.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: BEPUutilities questions

Post by Norbo »

Since I am still learning C#, I don't exactly know how to replace the BEPUutilities with XNA math, do you have any tips? I imagine it is easier than just going error by error and converting it to use XNA's math class.
Like I said, it's tedious enough to discourage me from doing it :)

It just comes down to swapping references to XNA and propagating the change as far as it needs to go. The manual approach is indeed just to follow the errors. There will be many of them.

Some more automatic approaches could exist. Something like using an existing C# parser to find symbols would be really nice. I'm not aware of any easy pre-existing options. I did the porting process so rarely that I just bit the bullet and did it manually rather than trying to set anything up.
Also did you remove/move GetVerticesAndIndicesFromModel? It is in BEPUphysics.DataStructures.TriangleMesh in older versions but I cannot find it now.
That depends on XNA, so it's in the BEPUphysicsDemos now in the ModelDataExtractor class.
Edit: Also how can I tell which version of Bepu I have, AssemblyVersion in AssemblyInfo.cs always says 1.3.0.0.
v1.3.0 is the version you're using. If you want to know which specific changeset you're using:
1) If you downloaded the source directly off codeplex, the downloaded file name had the changeset appended. For example: bepuphysics_0354fd402025.zip, where 0354fd402025 is the latest main changeset.
2) If you cloned the repository locally, you can look at it in the repository browser.
needshelprendering
Posts: 25
Joined: Mon Sep 17, 2012 1:17 am

Re: BEPUutilities questions

Post by needshelprendering »

Thanks Norbo,

This is fairly beyond my scope and the engine is already simply too vast for me to manually replace everything. I am out of my element with this. I will just keep using an older version of BepuPhysics.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: BEPUutilities questions

Post by Norbo »

v1.3.0 is a pretty huge upgrade over v1.2.0, I would strongly recommend using it. The 'manually convert to XNA' is not the only option, remember- if you tossed in the implicit casts, you wouldn't have to change much of anything.
needshelprendering
Posts: 25
Joined: Mon Sep 17, 2012 1:17 am

Re: BEPUutilities questions

Post by needshelprendering »

Norbo wrote:v1.3.0 is a pretty huge upgrade over v1.2.0, I would strongly recommend using it. The 'manually convert to XNA' is not the only option, remember- if you tossed in the implicit casts, you wouldn't have to change much of anything.
I will look into using those, if you have anymore information I could use it. Thanks.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: BEPUutilities questions

Post by Norbo »

The msdn documentation pretty much covers everything you need. Just put two implicit conversion operators in each BEPUutilities XNA-equivalent math class, one to convert each way.
Post Reply