Skip to content

LatticeDeformer behaves differently in edit mode compared to play mode #69

@msklywenn

Description

@msklywenn

Describe the bug
In edit mode, if a mesh is instantiated and a latticedeformer added to it, it's scale will be changed to match the size of the bounds of the mesh. Doing the same thing in play mode will keep its original scale.

To Reproduce
Make some editor script that instantiates a mesh with bounds different from (1,1,1) and adds a latticedeformer to it, and run it both in edit and play mode. Something like:

            var road = Instantiate(RoadPrefab, transform);
            var deformable = road.gameObject.AddComponent<Deform.Deformable>();
            var lattice = road.gameObject.AddComponent<Deform.LatticeDeformer>();
            deformable.AddDeformer(lattice);
            lattice.GenerateControlPoints(new Vector3Int(2, 2, 2));
            lattice.SetControlPoint(0, 0, 0, ...

Expected behavior
Scale doesn't change when script is run in edit mode.

  • OS: Windows 10
  • Unity: 2021.2.10
  • Deform version: 1.2.1

Additional context
The scale change is done when LatticeDeformer.Reset() is called by the editor. I think the problem is that this function should not be named Reset as it is one of Unity's "special functions". Renaming Reset to Reconstruct fixes the issue. I'm also not sure why Reset/Reconstruct changes the scale of the mesh, it doesn't seem needed for LatticeDeformer to work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions