using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UndoVertexPositions : IUndoAction
{

    private Vector3[] _originalVertices;
    private Vector3[] OriginalVertices
    {
        get
        {
            return _originalVertices;
        }
        set
        {
            _originalVertices = new Vector3[value.Length];
            Array.Copy(value, _originalVertices, value.Length);
            //_originalVertices = value;
        }
    }

    public void RevertAction(DeformationManager deformationManager)
    {
        Debug.Log("reverting action");

        deformationManager.CurrentVertices = _originalVertices;
        deformationManager.DeformingMesh.vertices = _originalVertices;
        deformationManager.DeformingMesh.RecalculateBounds();
        deformationManager.DeformingMesh.RecalculateNormals();
    }

    public void SetupUndoAction(DeformationManager manager)
    {
        OriginalVertices = manager.CurrentVertices;
    }
}
