Posts: 3
Threads: 1
Joined: Mar 2023
Reputation:
0
03-03-2023, 07:39 PM
(This post was last modified: 04-03-2023, 02:23 AM by LuckyPretzel.)
I have a cloth that is sitting on a frame with a hole in it. The cloth is attached to the object on both sides preventing it from falling through the hole.
On top of the cloth (where the hole is located), a rounded object is resting. Unfortunately, the object will continue to rotate nonstop. With a cube, the object continues to move but it is difficult to notice and cannot overcome the hard edges to rotate. When the objects spin, they don't move positions for the most part but notice the attachments and you'll notice they're rotating in place despite being at "rest".
What can I do to prevent this from spinning? I've added friction materials as well as dampening on the cloth and solver.
Any ideas? Thanks!
Posts: 6,346
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
05-03-2023, 07:34 PM
(This post was last modified: 05-03-2023, 08:51 PM by josemendez.)
(03-03-2023, 07:39 PM)LuckyPretzel Wrote: I have a cloth that is sitting on a frame with a hole in it. The cloth is attached to the object on both sides preventing it from falling through the hole.
On top of the cloth (where the hole is located), a rounded object is resting. Unfortunately, the object will continue to rotate nonstop. With a cube, the object continues to move but it is difficult to notice and cannot overcome the hard edges to rotate. When the objects spin, they don't move positions for the most part but notice the attachments and you'll notice they're rotating in place despite being at "rest".
What can I do to prevent this from spinning? I've added friction materials as well as dampening on the cloth and solver.
Any ideas? Thanks!
Hi!
All iterative physics engines exhibit this problem: when there's multiple contacts affecting the same object, the order in which they're applied affects the outcome. If contacts are applied in approximately the same order every frame (and they are in most engines, to eliminate jittering that would otherwise happen if contacts were applied in a random order) there will always be a slight bias, since contacts applied last are more "important" as they can modify the result of all previously applied contacts.
Here's a video of the same effect taking place in a pile of regular rigidbodies in Unity. As you can see, some of the spheres will keep slowly rotating indefinitely when affected by multiple contacts:
In the case of cloth, it generates a lot of contacts around rigidbodies so this can get quite noticeable.
Unfortunately there's no proper solution for this, other than switching both Obi and Unity to an entirely different kind of physics solver - a direct solver. A typical hack is to freeze rigidbody rotation in place if their angular speed is below a threshold, this is often referred to as "sleeping".
kind regards,
Posts: 3
Threads: 1
Joined: Mar 2023
Reputation:
0
(05-03-2023, 07:34 PM)josemendez Wrote: Hi!
All iterative physics engines exhibit this problem: when there's multiple contacts affecting the same object, the order in which they're applied affects the outcome. If contacts are applied in approximately the same order every frame (and they are in most engines, to eliminate jittering that would otherwise happen if contacts were applied in a random order) there will always be a slight bias, since contacts applied last are more "important" as they can modify the result of all previously applied contacts.
Here's a video of the same effect taking place in a pile of regular rigidbodies in Unity. As you can see, some of the spheres will keep slowly rotating indefinitely when affected by multiple contacts:
In the case of cloth, it generates a lot of contacts around rigidbodies so this can get quite noticeable.
Unfortunately there's no proper solution for this, other than switching both Obi and Unity to an entirely different kind of physics solver - a direct solver. A typical hack is to freeze rigidbody rotation in place if their angular speed is below a threshold, this is often referred to as "sleeping".
kind regards,
Thanks for the response. That seems doable. The object does slightly move its position but it is not enough for me to care.
While I've got your attention, I have some further questions regarding Obi Cloth. I've noticed I can add weight/mass to the cloth via the blueprint but I don't know if I get the desired effect. I've created a video to show the real-life movement of what the cloth should achieve: https://youtube.com/shorts/XPpiNU5zTVY
Notice in the video that the net has some weight to it and that after an object sits on the net, the net doesn't completely rebound back. It remains in a bit of a sunken state. Additionally, when an object is sitting on top, the net slopes downwards towards the object. It's not just one tiny area of the net affected.
Currently, I have particle attachments for the sides, the top crossbar in the front, and the entire bottom of the net on the ground. My net object is made of 1 plane extruded in a method to retain it as a 2-manifold object. Most of the object is comprised of squares and not triangles and they are fairly big, in my opinion.
I'm curious if you have any suggestions. Should I be using "seams" instead of just one object? Do I need to limit stretchiness completely and add create more slack in the net object model? Should I increase the number of squares or perhaps use triangles?
Any advice you have is appreciated. I'm mostly focused on making the net have more weight and strength without seeming like it's rigid like a box but keeping in mind performance.
Posts: 6,346
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
07-03-2023, 08:22 AM
(This post was last modified: 07-03-2023, 08:33 AM by josemendez.)
(07-03-2023, 05:37 AM)LuckyPretzel Wrote: While I've got your attention, I have some further questions regarding Obi Cloth. I've noticed I can add weight/mass to the cloth via the blueprint but I don't know if I get the desired effect. I've created a video to show the real-life movement of what the cloth should achieve: https://youtube.com/shorts/XPpiNU5zTVY
Notice in the video that the net has some weight to it and that after an object sits on the net, the net doesn't completely rebound back.
Hi!
Depending on the mass ratio between the cloth and the objects resting on top of it, it will sag more (heavier objects) or less (lighter objects). Note that the only important thing is the mass ratio, that means behavior will be identical for a 1 kg cloth and 2 kg objects and for 10 kg cloth and 20 kg objects, since 1/2 == 10/20 == 0.5.
However, in the absence of any objects on top, the cloth it will behave the same regardless of its mass. Mass doesn't have any impact on the internal dynamics of the cloth, neither in a simulation or the real world. This is because mass has zero effect on accelerations: since gravity is an acceleration objects fall at the exact same speed regardless of their mass. Mass only has an effect on forces.
(07-03-2023, 05:37 AM)LuckyPretzel Wrote: It remains in a bit of a sunken state. Additionally, when an object is sitting on top, the net slopes downwards towards the object. It's not just one tiny area of the net affected.
This should be the default behavior of cloth, what are you getting in Obi instead?
(07-03-2023, 05:37 AM)LuckyPretzel Wrote: I'm curious if you have any suggestions. Should I be using "seams" instead of just one object?
This would make no difference, since using seams basically joins two different cloth actors into one.
(07-03-2023, 05:37 AM)LuckyPretzel Wrote: Do I need to limit stretchiness completely and add create more slack in the net object model?
Stretchiness is limited as much as possible - depends on how many substeps you're using- by default, creating slack in the model itself doesn't have any advantage.
(07-03-2023, 05:37 AM)LuckyPretzel Wrote: Should I increase the number of squares or perhaps use triangles?
Internally all 3D engines use triangles for both rendering and physics. A square (quad) is just 2 triangles, so it makes no difference at all. The only advantage of using triangles is that you can control the direction of the diagonal in quads when modeling, which is sometimes useful when doing low-poly models.
(07-03-2023, 05:37 AM)LuckyPretzel Wrote: Any advice you have is appreciated. I'm mostly focused on making the net have more weight and strength without seeming like it's rigid like a box but keeping in mind performance.
My advice would be to always use real-world units for distances, forces, mass ratios and accelerations. This is specially important for distances, since larger objects appear to move slower (since the distance they travel per second at the same speed is smaller compared to their size). There's a huge difference in simulating the exact same scene at a 10 cm scale and a 10 m scale.
Also use as many substeps as you can get away with given your performance budget (will find them in your ObiFixedUpdater component), and adjust distance and bending constraints depending on the results you're after. For instance, you may want to allow distance constraints to compress a bit by setting max compression > 0, and allow for more bending.
kind regards,
Posts: 3
Threads: 1
Joined: Mar 2023
Reputation:
0
(07-03-2023, 08:22 AM)josemendez Wrote: Hi!
Depending on the mass ratio between the cloth and the objects resting on top of it, it will sag more (heavier objects) or less (lighter objects). Note that the only important thing is the mass ratio, that means behavior will be identical for a 1 kg cloth and 2 kg objects and for 10 kg cloth and 20 kg objects, since 1/2 == 10/20 == 0.5.
However, in the absence of any objects on top, the cloth it will behave the same regardless of its mass. Mass doesn't have any impact on the internal dynamics of the cloth, neither in a simulation or the real world. This is because mass has zero effect on accelerations: since gravity is an acceleration objects fall at the exact same speed regardless of their mass. Mass only has an effect on forces.
This should be the default behavior of cloth, what are you getting in Obi instead?
This would make no difference, since using seams basically joins two different cloth actors into one.
Stretchiness is limited as much as possible - depends on how many substeps you're using- by default, creating slack in the model itself doesn't have any advantage.
Internally all 3D engines use triangles for both rendering and physics. A square (quad) is just 2 triangles, so it makes no difference at all. The only advantage of using triangles is that you can control the direction of the diagonal in quads when modeling, which is sometimes useful when doing low-poly models.
My advice would be to always use real-world units for distances, forces, mass ratios and accelerations. This is specially important for distances, since larger objects appear to move slower (since the distance they travel per second at the same speed is smaller compared to their size). There's a huge difference in simulating the exact same scene at a 10 cm scale and a 10 m scale.
Also use as many substeps as you can get away with given your performance budget (will find them in your ObiFixedUpdater component), and adjust distance and bending constraints depending on the results you're after. For instance, you may want to allow distance constraints to compress a bit by setting max compression > 0, and allow for more bending.
kind regards,
Thanks for the quick response. I'll spend some time making the adjustments you suggested and update my results here (good or bad). I figured sizing might be an issue and would impact the overall physics. This is why I tried tackling this small subset before building out the entirety of the game and had to scale up on everything, which could be a bit troublesome. Thanks again!
|