// Submit this selecting action protected override void Submit() { m_Iso.ClampPointI(m_Begin); m_Iso.ClampPointI(m_End); IntVector3 iMin = new IntVector3(0, 0, 0); IntVector3 iMax = new IntVector3(0, 0, 0); iMin.x = Mathf.Min(m_Begin.x, m_End.x); iMin.y = Mathf.Min(m_Begin.y, m_End.y); iMin.z = Mathf.Min(m_Begin.z, m_End.z); iMax.x = Mathf.Max(m_Begin.x, m_End.x); iMax.y = Mathf.Max(m_Begin.y, m_End.y); iMax.z = Mathf.Max(m_Begin.z, m_End.z); // Calculate feather effect bound IntVector3 fMin = new IntVector3(0, 0, 0); IntVector3 fMax = new IntVector3(0, 0, 0); fMin.x = iMin.x - m_FeatherLength; fMin.y = iMin.y - m_FeatherLength; fMin.z = iMin.z - m_FeatherLength; fMax.x = iMax.x + m_FeatherLength; fMax.y = iMax.y + m_FeatherLength; fMax.z = iMax.z + m_FeatherLength; if (m_PlaneFeather) { switch (m_Coord) { case ECoordPlane.XY: fMin.z = iMin.z; fMax.z = iMax.z; break; case ECoordPlane.XZ: fMin.y = iMin.y; fMax.y = iMax.y; break; case ECoordPlane.ZY: fMin.x = iMin.x; fMax.x = iMax.x; break; } } m_Iso.ClampPointI(fMin); m_Iso.ClampPointI(fMax); // Select if (!VCEInput.s_Shift && !VCEInput.s_Alt && !VCEInput.s_Control) { m_Selection.Clear(); } for (int x = fMin.x; x <= fMax.x; ++x) { for (int y = fMin.y; y <= fMax.y; ++y) { for (int z = fMin.z; z <= fMax.z; ++z) { int poskey = VCIsoData.IPosToKey(x, y, z); if (m_Iso.GetVoxel(poskey).Volume < 1) { continue; } int old_sv = 0; int alter_sv = (m_FeatherLength == 0) ? (255) : ((int)(VCEMath.BoxFeather(new IntVector3(x, y, z), iMin, iMax, m_FeatherLength) * 255.0f)); int new_sv = 0; if (alter_sv < 1) { continue; } if (m_Selection.ContainsKey(poskey)) { old_sv = m_Selection[poskey]; } if (VCEInput.s_Shift) { new_sv = old_sv + alter_sv; } else if (VCEInput.s_Alt) { new_sv = old_sv - alter_sv; } else if (VCEInput.s_Control) { new_sv = Mathf.Abs(old_sv - alter_sv); } else { new_sv = alter_sv; } new_sv = Mathf.Clamp(new_sv, 0, 255); if (new_sv < 1) { m_Selection.Remove(poskey); } else if (old_sv < 1) { m_Selection.Add(poskey, (byte)new_sv); } else { m_Selection[poskey] = (byte)new_sv; } if (m_MaterialSelect) { VCVoxel vcv = m_Iso.GetVoxel(poskey); if (m_Iso.m_Materials[vcv.Type] != VCEditor.SelectedMaterial) { m_Selection.Remove(poskey); } } } } } }