Neos-Metaverse / NeosPublic

A public issue/wiki only repository for the NeosVR project
193 stars 9 forks source link

Cloth physics simulation #2853

Open 3x1t-5tyl3 opened 3 years ago

3x1t-5tyl3 commented 3 years ago

Is your feature request related to a problem? Please describe.

Not really. It's just a different approach than "DynamicBones" to make stuff wiggle about. In this case specifically towards cloth instead of stuff like ears, tails, hair ect.

Relevant issues

22 #232

Describe the solution you'd like

A cloth-physics related system: BepuV2 integrates this. I also found a Demo Scene on their GH https://github.com/bepu/bepuphysics2/tree/master/Demos/Demos -> ClothDemo

Describe alternatives you've considered

None

Additional context

Not sure. I think I can be confident that this is well known. I do wanna say that I'm not entirely sure how it is performance wise either. So definitely something to look out for.

Frooxius commented 3 years ago

We wouldn't use the BEPUv2 for cloth physics simulation, using a full blown physics engine isn't really the right way of doing this. The BEPUv2 demo is more of a showcase of the physics engine, rather than a thing you'd do practically, because it's pretty much hundreds of rigidbodies connected with constraints.

That's fine for a demo like that, where the only thing you have is that piece of cloth, but you don't want to blow majority of your performance budget on a single piece of cloth - you want other stuff in the scene too! And probably more than 1 piece of cloth too!

The way this would be implemented is actually analogous to the dynamic bones - a specialized simulation that's heavily optimized just for the cloth simulation and orders of magnitude faster as a result. Pretty much think of as dynamic bone, but a 2D grid instead. That's something I'd definitely like to add at some point.

This is how it's typically handled in games and game engines nowadays. E.g. Unity's Cloth simulation uses this approach: https://docs.unity3d.com/Manual/class-Cloth.html They used to do it in the physics engine, but that gets really costly really fast.

3x1t-5tyl3 commented 3 years ago

Interesting. Thanks for the answer. I was not wanting to force BV2, I jsut happen to see it while browsing the BepuV2 repository earlier today and decided to open this and #2854

Frooxius commented 3 years ago

Please keep in mind a lot of those demos are focused on what you can do purely with the engine and how to code various things, they're not necessarily "features" that could be integrated - they're for the most part built with the same building blocks that will be exposed with #22 - a bunch of rigidbodies and constraints.

3x1t-5tyl3 commented 3 years ago

That's actually really good to know. I was a bit unaware there. Though I wonder what the plan (if any exists right now) would be to expose this in neos. Ergo constraints -> rigid body sim

I'm also coming at this with little experience so I do thank you for explaining how this works. I somehow had it differently in mind. This makes a lot more sense to me now!

Frooxius commented 3 years ago

No problem!

I recommend checking the #22 issue, I've recently updated it with a bunch of new information! Constraints are part of what the proper Rigidbody support entails, which will allow you to build all kinds of cool stuff!

And yeah, the demos can be a bit misleading. They can be a bit of a showcase of "Look how far you can push this tech alone!" and also showcases for other developers how to code with it, as the demos showcase different approaches and aspects of it.

When it gets into other systems, e.g. Neos, it's important to consider how it'll interact with everything else - you need to spend performance on lots of other things, like fancy graphics, behaviors, avatars, interactions, UI and so on - plus you have potentially dozens of each and they also need to be networked in a lot of cases and that takes performance away from purely doing the physics stuff.

3x1t-5tyl3 commented 3 years ago

Definitely will check that out agian. I've unfortunately been out of the loop a bit recently. Thanks taking your time to explain this :)