예제 #1
0
 void Apply(MeshManager manager, DeltaDoneDelegate onDone, bool undo)
 {
     if (m_co != null)
     {
         m_co.done = true;
     }
     m_co = Scheduler.StartCoroutine(DoApply(manager, onDone, undo));
 }
예제 #2
0
 public void RedoAction(MeshManager manager, DeltaDoneDelegate onDone)
 {
     Apply(manager);
     if (onDone != null)
     {
         onDone();
     }
 }
예제 #3
0
    public void UndoAction(MeshManager manager, DeltaDoneDelegate onDone)
    {
        blobDelta.UndoAction(manager, onDone);

        if (m_converter != null)
        {
            m_converter.shouldAbort = true;
            m_converter             = null;
        }
    }
예제 #4
0
    IEnumerator DoApply(MeshManager manager, DeltaDoneDelegate onDone, bool undo)
    {
        VoxelBlob targetData = manager.m_blob;

        foreach (BlobHolder holder in blobs.Values)
        {
            if (Scheduler.ShouldYield())
            {
                yield return(null);
            }
            VoxelBlob blob = holder.blob;
            if (holder.unDone == undo)
            {
                continue;
            }
            for (int x = 0; x < blob.width; ++x)
            {
                for (int y = 0; y < blob.height; ++y)
                {
                    for (int z = 0; z < blob.depth; ++z)
                    {
                        byte newMat = blob[x, y, z];
                        if (newMat != System.Convert.ToByte(0))
                        {
                            int  dataX  = x + (int)blob.position.x;
                            int  dataY  = y + (int)blob.position.y;
                            int  dataZ  = z + (int)blob.position.z;
                            byte oldMat = targetData[dataX, dataY, dataZ];
                            if (oldMat == 0)
                            {
                                oldMat = MeshManager.kVoxelSubtract;
                            }
                            if (newMat == MeshManager.kVoxelSubtract)
                            {
                                newMat = 0;
                            }

                            blob[x, y, z] = oldMat;
                            targetData[dataX, dataY, dataZ] = newMat;
                            manager.MarkChunksForRegenForPoint(dataX, dataY, dataZ);
                        }
                    }
                }
            }
            holder.unDone = undo;
        }

        if (onDone != null)
        {
            onDone();
        }
    }
예제 #5
0
    public void RedoAction(MeshManager manager, DeltaDoneDelegate onDone)
    {
        if (m_data == null)
        {
            blobDelta.RedoAction(manager, onDone);
            return;
        }

        GameObject go = new GameObject("MeshPatternConverter");

        m_converter = go.AddComponent <MeshPatternConverter>();

        m_converter.Init(manager, m_data, this);

        Scheduler.StartCoroutine(MeshPattern.CreateMeshObject(go, m_data.faces, m_data.meshMat, LayerMask.NameToLayer("Voxel"),
                                                              (m_data.material != MeshManager.kVoxelSubtract)));

        m_currentCallback = onDone;
        blobDelta.RedoAction(manager, RestartConverter);
    }
예제 #6
0
 public void Apply(MeshManager manager, DeltaDoneDelegate onDone)
 {
     Apply(manager, onDone, true);
 }
예제 #7
0
 public void RedoAction(MeshManager manager, DeltaDoneDelegate onDone)
 {
     Apply(manager, onDone, false);
 }