protected virtual IOperation CreateOperationFromEditor(Vector3 start, Vector3 end, TerrainToolEditor editor)
    {
        var     voxelType = EditorUtils.GetVoxelTypeFromIndex(VoxelTypeIndex, editor.Terrain.VoxelTypeSet);
        Vector3 vL, vH, vW;

        UMath.ComputeEdgeVectors(start, end, Width, Height, out vL, out vH, out vW);
        return(Parallelepiped.CreateFromUnityWorld(editor.Terrain, Dig, start, vL, vH, vW, voxelType));
    }
Example #2
0
    private void UpdateForParallelepiped(Vector3 wpos)
    {
        reticleLinesForEditor.EnableRenderer(true);

        if (Input.GetKey(KeyCode.LeftControl) || Input.GetMouseButtonDown(1))
        {
            firstClickPosition = null;
        }

        var     p = wpos - new Vector3(0, BrushSize * 0.5f, BrushSize * 0.5f);
        Vector3 vL, vH, vW;

        if (firstClickPosition.HasValue)
        {
            UMath.ComputeEdgeVectors(firstClickPosition.Value, p, BrushSize, BrushSize, out vL, out vH, out vW);
            reticleLinesForEditor.SetCornerAndEdges(firstClickPosition.Value, vL, vH, vW);
        }
        else
        {
            UMath.ComputeEdgeVectors(p, p + Vector3.forward, BrushSize, BrushSize, out vL, out vH, out vW);
            reticleLinesForEditor.SetCornerAndEdges(p, vL, vH, vW);
        }

        if (clicking && Terrain.OperationsManager.IsReadyToComputeAsync)
        {
            if (!firstClickPosition.HasValue)
            {
                firstClickPosition = p;
            }
            else
            {
                Vector3 vLd, vHd, vWd;
                UMath.ComputeEdgeVectors(
                    firstClickPosition.Value, p, BrushSize, BrushSize, out vLd, out vHd, out vWd);
                Terrain.OperationsManager
                .Add(Parallelepiped.CreateFromUnityWorld(Terrain, dig, firstClickPosition.Value, vLd, vHd, vWd, voxelType), true)
                .PerformAll(asyncOperations);
                firstClickPosition = null;
            }
        }
    }