Monogame physics integration - entity modeling

I am trying to integrate Bepu physics into my monogame project and am trying to figure out the best way to map / integrate the Bepu entities to the Monogame entities.

From what I can gather, Bepu will manage / control the position and rotation of the model, and scale / size can be defined externally (but set on the Bepu entity).

It’s a little confusing as to how I should tie these together…

If you integrated physics, how did you manage this relationship between the physics entities and the monogame entities / models?

Thanks.

I just did it super quickly and I don’t think it’s optimal, but it works, maybe you can use this for reference.

I think it is disabled by default in the current version since I wanted a static image for testing.

In EngineTest/Main/MainLogic.cs

in line 92 set hasStaticPhysics: to true.

Activate Physics either in Resources/GameSettings p_Physics = true
or
ingame

press ^ or ~ (the button above tab) and type in p_Physics true

@kosmonautgames Thanks, I’ll check it out.

From Ross Nordby’s blog: http://www.bepuphysics.com/, he has updated the code to github and monogame instead of codeplex.
But I don’t know if the optimized version is included (https://github.com/RossNordby/scratchpad)

Good stuff! I’m very excited for v2 :slight_smile:

Yes, it will be a very good physics framework when all these optimizations are included. (Not it is not currently a good one, it is already a good one, but it will be better/faster)
I’m very excited to try it in my game which is highly demanding on physics to see the improvements.

A problem with Bepu right now is that it generates garbage, I wish that was a focus as well

Edit: I might be wrong

Maybe this will be considered (more) in version 2? From the graphs shown in the blog, the performance will be significantly better at least :slight_smile:

I am using the code from the github repo, and I don’t believe it has any of the v2 optimizations.

One thing to note… in it’s current state, Bepu does not work with UWP projects. This is due to the code not being .net core compatible i.e. some references / classes are not available in the current version of .net core like Thread.

I created this thread in the Bepu forums on the issue:

https://forum.bepuentertainment.com/viewtopic.php?f=4&t=2457

According to the author, these issues will be resolved with v2.

In order to get it to integrate with UWP project, the code requires some changes to be compatible with .net standard / core.

I hope Thread can make it into .NET Core though https://github.com/dotnet/corefx/issues/2576

Doesn’t Tasks uses Threads in its underlying code?

I hope microsoft will let developers choose how they want their app run instead of commanding how an should be done because it could… It should… Whatever reason.

Hello, bepuguy here!

A few things:

  1. Over on github, jwollen has compensated for my laziness and created a portable fork targeting .NET Standard v1.4: https://github.com/jwollen/bepuphysics1/commits/portable
    I haven’t tried it, but it looks like it covers all the expected areas. v2 is indeed targeting out of the box portability. Probably .NET Standard 2.0, unless platform support is still lagging by the time BEPUphysics v2 is near completion.

  2. You’re correct that the bepuphysics1 repo (library version v1.5.0) does not include any of the v2 optimizations. v2 is a ground-up rewrite with some pretty huge changes in data flow; each new system in isolation wouldn’t fit well or help as much in v1.

  3. @kosmonautgames If you’re seeing garbage, there might be a bug. While there are a few known situations where garbage is generated (one-time array resizes when the simulation expands beyond preallocated complexity, or situations where the API makes it hard to reuse memory like reconstructing a StaticMesh’s internal hierarchy in response to topological changes), regular steady-state execution shouldn’t be creating any garbage. If you can reproduce it in the demos or otherwise in isolation, I could take a look and see if I can fix it.

(That said, v2 should have even fewer opportunities for garbage. Heap complexity is also massively reduced, so unrelated application GCs should go faster too.)

4 Likes

@Norbo Thanks for the update! I have managed to convert the original github code to work with UWP (at least… it appears to be working with the simple test I have)… now just trying to integrate it cleanly into my existing Monogame project.

We’re looking forward to v2 which I am sure is going to be awesome! :slight_smile:

  1. You’re correct that the bepuphysics1 repo (library version v1.5.0) does not include any of the v2 optimizations. v2 is a ground-up rewrite with some pretty huge changes in data flow; each new system in isolation wouldn’t fit well or help as much in v1.

Hum… I don’t have time to play with the scratchpad repo :disappointed: