keenanwoodall / Deform

A fully-featured deformer system for Unity that lets you stack effects to animate models in real-time
MIT License
3.27k stars 225 forks source link

Lattice further UX improvements #49

Closed sabresaurus closed 3 years ago

sabresaurus commented 3 years ago
keenanwoodall commented 3 years ago

Awesome!

Only thing I noticed is auto-fit not working with scaled or rotated deformables in an LOD Group ph9bADpqp7

Looks like changing this

if (deformable != null)
{
    var bounds = deformable.GetCurrentMesh().bounds;
    transform.localPosition = bounds.center;
    transform.localScale = bounds.size;
    // Make sure the rotation is zeroed so that we're not applying the size is the wrong axis
    transform.localRotation = Quaternion.identity;
}

to this works. Perhaps there's a better way to do it without lossy scale tho

if (deformable != null)
{
    var bounds = deformable.GetCurrentMesh().bounds;
    var rendererTransform = deformable.GetRenderer().transform;
    transform.localPosition = bounds.center;
    transform.localScale = Vector3.Scale(bounds.size, rendererTransform.lossyScale);
    transform.localRotation = rendererTransform.rotation;
}
sabresaurus commented 3 years ago

Thanks, fix applied