28-02-2021, 07:16 PM
(This post was last modified: 28-02-2021, 07:17 PM by josemendez.)
Hi,
The link you posted does not seem to contain an image, and it's not visible
Deformable objects can't be non-uniformly scaled at runtime. In few words, the reason for this is that non-uniform scaling does not preserve euclidean distances. I'll copy-paste a more detailed explanation I gave in a different thread:
The easiest workaround for this is to generate several blueprints of your object at different scales, then at runtime pick between them at random.
The link you posted does not seem to contain an image, and it's not visible
Deformable objects can't be non-uniformly scaled at runtime. In few words, the reason for this is that non-uniform scaling does not preserve euclidean distances. I'll copy-paste a more detailed explanation I gave in a different thread:
Quote:There's several kinds of transforms: affine, rigid, perspective, etc. The transforms used in Unity (and most 3D packages) are affine transforms. This means they have translation, rotation, scale (and shear/skew). If they had only translation and rotation, they'd be rigid transforms.
Now, here's the caveat: rigid transforms preserve euclidean distance, affine transforms do not. This means that if you have a line and you rigidly transform it (rotate or translate it) its length remains the same. But if you scale it (applying an affine transform) its length changes. If scaling is uniform, you can get the new length by multiplying the unscaled length by the scale. But if scaling is not uniform, there's no quick way to recover the new length from the old one (you'd have to do the full math of subtracting both ends of the line, dot product the resulting vector with itself and take the square root to recalculate the post-scale length).
What does this have to do with cloth and deformable objects in general? well, part of the information stored by cloth to remember its rest shape is the length of all edges in the mesh. This is so that the cloth can stretch/compress/bend, but still keep its original shape and return to it. So if you scale cloth, its rest shape remains unscaled, otherwise the rest shape would need to be recalculated every frame which is very costly. Scale is applied to the object after deformation, which can result in weird spiky meshes and all sorts of visual glitches.
For this reason, when you scale a piece of cloth (or any deformable object) it won't grow/shrink like a rigid object would. Only rigid transforms can be applied to deformable objects, affine transforms cannot. So if your cloth transform in the scene has a value of 200,200,200, you need to use a scale of 1/200, 1/200, 1/200 when generating the cloth blueprint, so that they compensate each other once an affine transform is applied to it. It can also lead to floating point precision issues, since the simulation would be performed using very tiny numbers (depending on how large your scale is, 1/200 is smaller than 1/100). This is cumbersome and not immediately obvious for most people. It's also not exclusive to Obi, all deformable physics engines I've ever used or heard of precalculate and store the rest shape of objects.
The easiest workaround for this is to generate several blueprints of your object at different scales, then at runtime pick between them at random.