public void DeleteSelection() { m_Action = new VCEAction(); VCEditor.s_Mirror.CalcPrepare(VCEditor.s_Scene.m_Setting.m_VoxelSize); foreach (KeyValuePair <int, byte> kvp in m_SelectionMgr.m_Selection) { // Mirror if (VCEditor.s_Mirror.Enabled_Masked) { IntVector3 pos = VCIsoData.KeyToIPos(kvp.Key); VCEditor.s_Mirror.MirrorVoxel(pos); float strength = (float)(kvp.Value) / 255.0f; for (int i = 0; i < VCEditor.s_Mirror.OutputCnt; ++i) { if (VCEditor.s_Scene.m_IsoData.IsPointIn(VCEditor.s_Mirror.Output[i])) { int voxel_pos = VCIsoData.IPosToKey(VCEditor.s_Mirror.Output[i]); VCVoxel old_voxel = VCEditor.s_Scene.m_IsoData.GetVoxel(voxel_pos); VCVoxel new_voxel = old_voxel; new_voxel.VolumeF = new_voxel.VolumeF * (1 - strength); if (old_voxel != new_voxel) { VCEAlterVoxel modify = new VCEAlterVoxel(voxel_pos, old_voxel, new_voxel); modify.Redo(); m_Action.Modifies.Add(modify); } } } } // No mirror else { float strength = (float)(kvp.Value) / 255.0f; int voxel_pos = kvp.Key; VCVoxel old_voxel = VCEditor.s_Scene.m_IsoData.GetVoxel(voxel_pos); VCVoxel new_voxel = old_voxel; new_voxel.VolumeF = new_voxel.VolumeF * (1 - strength); if (old_voxel != new_voxel) { VCEAlterVoxel modify = new VCEAlterVoxel(voxel_pos, old_voxel, new_voxel); m_Action.Modifies.Add(modify); } } } ColorSelection(VCIsoData.BLANK_COLOR, false, true); if (m_Action.Modifies.Count > 0) { m_Action.DoButNotRegister(); VCUtils.ISOCut(VCEditor.s_Scene.m_IsoData, m_Action); m_Action.Register(); VCEStatusBar.ShowText("Selected voxels have been removed".ToLocalizationString(), 2); } ClearSelection(); }
public void TextureSelection() { if (!VCEditor.Instance.m_UI.m_MaterialTab.isChecked) { return; } if (VCEditor.SelectedVoxelType < 0) { return; } m_Action = new VCEAction(); ulong oldmat_guid = VCEditor.s_Scene.m_IsoData.MaterialGUID(VCEditor.SelectedVoxelType); ulong newmat_guid = VCEditor.SelectedMaterial.m_Guid; if (oldmat_guid != newmat_guid) { VCEAlterMaterialMap modify = new VCEAlterMaterialMap(VCEditor.SelectedVoxelType, oldmat_guid, newmat_guid); m_Action.Modifies.Add(modify); } VCEditor.s_Mirror.CalcPrepare(VCEditor.s_Scene.m_Setting.m_VoxelSize); foreach (KeyValuePair <int, byte> kvp in m_SelectionMgr.m_Selection) { // Mirror if (VCEditor.s_Mirror.Enabled_Masked) { IntVector3 pos = VCIsoData.KeyToIPos(kvp.Key); VCEditor.s_Mirror.MirrorVoxel(pos); float strength = (float)(kvp.Value) / 255.0f; if (strength < 0.5f) { continue; } for (int i = 0; i < VCEditor.s_Mirror.OutputCnt; ++i) { if (VCEditor.s_Scene.m_IsoData.IsPointIn(VCEditor.s_Mirror.Output[i])) { int voxel_pos = VCIsoData.IPosToKey(VCEditor.s_Mirror.Output[i]); VCVoxel old_voxel = VCEditor.s_Scene.m_IsoData.GetVoxel(voxel_pos); VCVoxel new_voxel = new VCVoxel(old_voxel.Volume, (byte)(VCEditor.SelectedVoxelType)); if (old_voxel != new_voxel) { VCEAlterVoxel modify = new VCEAlterVoxel(voxel_pos, old_voxel, new_voxel); modify.Redo(); m_Action.Modifies.Add(modify); } } } } // No mirror else { float strength = (float)(kvp.Value) / 255.0f; if (strength < 0.5f) { continue; } int voxel_pos = kvp.Key; VCVoxel old_voxel = VCEditor.s_Scene.m_IsoData.GetVoxel(voxel_pos); VCVoxel new_voxel = new VCVoxel(old_voxel.Volume, (byte)(VCEditor.SelectedVoxelType)); if (old_voxel != new_voxel) { VCEAlterVoxel modify = new VCEAlterVoxel(voxel_pos, old_voxel, new_voxel); m_Action.Modifies.Add(modify); } } } if (m_Action.Modifies.Count > 0) { m_Action.Do(); VCEStatusBar.ShowText("Selected voxels have been textured".ToLocalizationString(), 2); } }