public void PaintBrush(VoxelChunk chunk, Vector3 Pos, float fSize, float fStr) { if (chunk == null || chunk.DensityVolume == null) { Debug.LogWarning("invaild chunk"); return; } //Debug.Log("PaintBrush"); //Chunk.FillEmpty(CShader_Generator,Chunk.PersistentVol); //Debug.DrawLine(chunk.transform.position, Pos,Color.red); /*CHUNK_OPERATION d; * d = delegate() * { */ CHUNK_OPERATION d; chunk.cColor = Color.red; if (!chunk.QPlanned) { //CHUNK_OPERATION d; chunk.QPlanned = true; d = delegate() { if (chunk == null) { Debug.LogWarning("chunk was already destroyed"); return; } Mesh ChunkMesh = chunk.transform.GetComponent <MeshFilter>().sharedMesh; if (_WithNeighbours != 0) { RenderTexture[,,] Neighbours = GetNeighbours(chunk); BuildChunkMesh(chunk.DensityVolume, ChunkMesh, Neighbours); } else { BuildChunkMesh(chunk.DensityVolume, ChunkMesh, null); } chunk._Col = Color.green; chunk.bNeedCollisionUpdate = true; chunk.QPlanned = false; //CHUNK_OPERATION d2; //d2 = delegate() //{ if (chunk.IsInvoking()) { chunk.CancelInvoke(); } chunk.Invoke("CheckNeedToDestroy", 3.0f); //}; //QBuilder.Enqueue(d2); //CreateEmptyVolume(chunk.DensityVolume, GetNeighbours(chunk), chunk._SizeZ); }; QBuilder.Enqueue(d); } if (!chunk.QDPlanned) { chunk.QDPlanned = true; d = delegate() { Vector3 LocalPos = chunk.transform.InverseTransformPoint(Pos) * chunk.transform.localScale.x; //Debug.DrawLine(chunk.transform.position, chunk.transform.position+LocalPos,Color.yellow); //Vector3 cPos = new Vector4(chunk.transform.localPosition.x,chunk.transform.localPosition.y,chunk.transform.localPosition.z,0.0f); Vector3 pPos = new Vector4(LocalPos.x, LocalPos.y, LocalPos.z, 0.0f); int mgen_id = _CShaderGenerator.FindKernel("SphereAdd"); _CShaderGenerator.SetTexture(mgen_id, "Result", chunk.DensityVolume); //RenderTexture[] vol = new RenderTexture[27]; //vol[0] = chunk.DensityVolume; //_CShaderGenerator.SetVector("_StartPos",new Vector4(cPos.x,cPos.y,cPos.z,0.0f)); _CShaderGenerator.SetVector("_BrushPos", pPos); _CShaderGenerator.SetFloat("_Brush_Size", fSize); _CShaderGenerator.SetFloat("_Brush_Strength", fStr); _CShaderGenerator.Dispatch(mgen_id, ChunkSizeZ + Overlay, ChunkSizeZ + Overlay, ChunkSizeZ + Overlay); //chunk.cColor = Color.yellow; chunk._Col = Color.green; chunk.QDPlanned = false; }; QGenerator.Enqueue(d); } }