示例#1
0
    public void MoveTo(
        int faceId,
        int[] faceIds,
        Vector3 destinationLocalSpace, bool snap, bool tick)
    {
        var   translation = destinationLocalSpace - _manifold.GetCenter(faceId);
        var   normal      = _manifold.GetFaceNormal(faceId);
        float d           = Vector3.Dot(normal, translation);

        if (snap)
        {
            if (tick)
            {
                Vector3 normalExtrusionVector = d * normal;
                float   originalMagnitude     = normalExtrusionVector.magnitude;
                float   roundedMagnitude      = Mathf.Round(originalMagnitude * 50) / 50;
                float   scale       = roundedMagnitude / originalMagnitude;
                Vector3 scaleVector = new Vector3(scale, scale, scale);

                _manifold.MoveFacesAlongVector(faceIds, Vector3.Scale(normalExtrusionVector, scaleVector));
            }
            else
            {
                _manifold.MoveFacesAlongVector(faceIds, d * normal);
            }
        }
        else
        {
            _manifold.MoveFacesAlongVector(faceIds, translation);
        }
    }