diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.psdimporter@4.0.2/Editor/PSDImportPostProcessor.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.psdimporter@4.0.2/Editor/PSDImportPostProcessor.cs new file mode 100644 index 0000000000000000000000000000000000000000..d0c69259539082163a7888eb699191479c53c033 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.psdimporter@4.0.2/Editor/PSDImportPostProcessor.cs @@ -0,0 +1,85 @@ +using System.Collections.Generic; +using System.Linq; +using UnityEditor.U2D; +using UnityEditor.U2D.Sprites; +using UnityEngine; + +namespace UnityEditor.U2D.PSD +{ + internal class PSDImportPostProcessor : AssetPostprocessor + { + private static string s_CurrentApplyAssetPath = null; + + void OnPostprocessSprites(Texture2D texture, Sprite[] sprites) + { + var dataProviderFactories = new SpriteDataProviderFactories(); + dataProviderFactories.Init(); + PSDImporter psd = AssetImporter.GetAtPath(assetPath) as PSDImporter; + if (psd == null) + return; + ISpriteEditorDataProvider importer = dataProviderFactories.GetSpriteEditorDataProviderFromObject(psd); + if (importer != null) + { + importer.InitSpriteEditorDataProvider(); + var physicsOutlineDataProvider = importer.GetDataProvider(); + var textureDataProvider = importer.GetDataProvider(); + int actualWidth = 0, actualHeight = 0; + textureDataProvider.GetTextureActualWidthAndHeight(out actualWidth, out actualHeight); + float definitionScaleW = (float)texture.width / actualWidth; + float definitionScaleH = (float)texture.height / actualHeight; + float definitionScale = Mathf.Min(definitionScaleW, definitionScaleH); + foreach (var sprite in sprites) + { + var guid = sprite.GetSpriteID(); + var outline = physicsOutlineDataProvider.GetOutlines(guid); + var outlineOffset = sprite.rect.size / 2; + if (outline != null && outline.Count > 0) + { + // Ensure that outlines are all valid. + int validOutlineCount = 0; + for (int i = 0; i < outline.Count; ++i) + validOutlineCount = validOutlineCount + ( (outline[i].Length > 2) ? 1 : 0 ); + + int index = 0; + var convertedOutline = new Vector2[validOutlineCount][]; + for (int i = 0; i < outline.Count; ++i) + { + if (outline[i].Length > 2) + { + convertedOutline[index] = new Vector2[outline[i].Length]; + for (int j = 0; j < outline[i].Length; ++j) + { + convertedOutline[index][j] = outline[i][j] * definitionScale + outlineOffset; + } + index++; + } + } + sprite.OverridePhysicsShape(convertedOutline); + } + } + } + } + + public static string currentApplyAssetPath + { + set { s_CurrentApplyAssetPath = value; } + } + static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromPath) + { + if (!string.IsNullOrEmpty(s_CurrentApplyAssetPath)) + { + foreach (var asset in importedAssets) + { + if (asset == s_CurrentApplyAssetPath) + { + var obj = AssetDatabase.LoadMainAssetAtPath(asset); + Selection.activeObject = obj; + Unsupported.SceneTrackerFlushDirty(); + s_CurrentApplyAssetPath = null; + break; + } + } + } + } + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.psdimporter@4.0.2/Editor/PSDImporterEditor.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.psdimporter@4.0.2/Editor/PSDImporterEditor.cs new file mode 100644 index 0000000000000000000000000000000000000000..bec7512c759b98ccbf1912486eb28abc699240c9 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.psdimporter@4.0.2/Editor/PSDImporterEditor.cs @@ -0,0 +1,1126 @@ +using System; +using System.Collections.Generic; +using System.IO; +using PhotoshopFile; +using UnityEditor.AssetImporters; +using UnityEditor.U2D.Animation; +using UnityEditor.U2D.Common; +using UnityEditor.U2D.Sprites; +using UnityEngine; +using UnityEngine.Scripting.APIUpdating; + +namespace UnityEditor.U2D.PSD +{ + /// + /// Inspector for PSDImporter + /// + [CustomEditor(typeof(PSDImporter))] + [MovedFrom("UnityEditor.Experimental.AssetImporters")] + public class PSDImporterEditor : ScriptedImporterEditor, ITexturePlatformSettingsDataProvider + { + SerializedProperty m_TextureType; + SerializedProperty m_TextureShape; + SerializedProperty m_SpriteMode; + SerializedProperty m_SpritePixelsToUnits; + SerializedProperty m_SpriteMeshType; + SerializedProperty m_SpriteExtrude; + SerializedProperty m_Alignment; + SerializedProperty m_SpritePivot; + SerializedProperty m_NPOTScale; + SerializedProperty m_IsReadable; + SerializedProperty m_sRGBTexture; + SerializedProperty m_AlphaSource; + SerializedProperty m_MipMapMode; + SerializedProperty m_EnableMipMap; + SerializedProperty m_FadeOut; + SerializedProperty m_BorderMipMap; + SerializedProperty m_MipMapsPreserveCoverage; + SerializedProperty m_AlphaTestReferenceValue; + SerializedProperty m_MipMapFadeDistanceStart; + SerializedProperty m_MipMapFadeDistanceEnd; + SerializedProperty m_AlphaIsTransparency; + SerializedProperty m_FilterMode; + SerializedProperty m_Aniso; + + SerializedProperty m_WrapU; + SerializedProperty m_WrapV; + SerializedProperty m_WrapW; + SerializedProperty m_ConvertToNormalMap; + SerializedProperty m_MosaicLayers; + SerializedProperty m_ImportHiddenLayers; + SerializedProperty m_ResliceFromLayer; + SerializedProperty m_CharacterMode; + SerializedProperty m_DocumentPivot; + SerializedProperty m_DocumentAlignment; + SerializedProperty m_GenerateGOHierarchy; + SerializedProperty m_PaperDollMode; + SerializedProperty m_KeepDupilcateSpriteName; + + readonly int[] m_FilterModeOptions = (int[])(Enum.GetValues(typeof(FilterMode))); + + bool m_IsPOT = false; + bool m_ShowAdvanced = false; + bool m_ShowExperimental = false; + Dictionary m_AdvanceInspectorGUI = new Dictionary(); + int m_PlatformSettingsIndex; + bool m_ShowPerAxisWrapModes = false; + + TexturePlatformSettingsHelper m_TexturePlatformSettingsHelper; + + TexturePlatformSettingsView m_TexturePlatformSettingsView = new TexturePlatformSettingsView(); + TexturePlatformSettingsController m_TexturePlatformSettingsController = new TexturePlatformSettingsController(); + + /// + /// Implementation of AssetImporterEditor.OnEnable + /// + public override void OnEnable() + { + base.OnEnable(); + m_MosaicLayers = serializedObject.FindProperty("m_MosaicLayers"); + m_ImportHiddenLayers = serializedObject.FindProperty("m_ImportHiddenLayers"); + m_ResliceFromLayer = serializedObject.FindProperty("m_ResliceFromLayer"); + m_CharacterMode = serializedObject.FindProperty("m_CharacterMode"); + m_DocumentPivot = serializedObject.FindProperty("m_DocumentPivot"); + m_DocumentAlignment = serializedObject.FindProperty("m_DocumentAlignment"); + m_GenerateGOHierarchy = serializedObject.FindProperty("m_GenerateGOHierarchy"); + m_PaperDollMode = serializedObject.FindProperty("m_PaperDollMode"); + m_KeepDupilcateSpriteName = serializedObject.FindProperty("m_KeepDupilcateSpriteName"); + + var textureImporterSettingsSP = serializedObject.FindProperty("m_TextureImporterSettings"); + m_TextureType = textureImporterSettingsSP.FindPropertyRelative("m_TextureType"); + m_TextureShape = textureImporterSettingsSP.FindPropertyRelative("m_TextureShape"); + m_ConvertToNormalMap = textureImporterSettingsSP.FindPropertyRelative("m_ConvertToNormalMap"); + m_SpriteMode = textureImporterSettingsSP.FindPropertyRelative("m_SpriteMode"); + m_SpritePixelsToUnits = textureImporterSettingsSP.FindPropertyRelative("m_SpritePixelsToUnits"); + m_SpriteMeshType = textureImporterSettingsSP.FindPropertyRelative("m_SpriteMeshType"); + m_SpriteExtrude = textureImporterSettingsSP.FindPropertyRelative("m_SpriteExtrude"); + m_Alignment = textureImporterSettingsSP.FindPropertyRelative("m_Alignment"); + m_SpritePivot = textureImporterSettingsSP.FindPropertyRelative("m_SpritePivot"); + m_NPOTScale = textureImporterSettingsSP.FindPropertyRelative("m_NPOTScale"); + m_IsReadable = textureImporterSettingsSP.FindPropertyRelative("m_IsReadable"); + m_sRGBTexture = textureImporterSettingsSP.FindPropertyRelative("m_sRGBTexture"); + m_AlphaSource = textureImporterSettingsSP.FindPropertyRelative("m_AlphaSource"); + m_MipMapMode = textureImporterSettingsSP.FindPropertyRelative("m_MipMapMode"); + m_EnableMipMap = textureImporterSettingsSP.FindPropertyRelative("m_EnableMipMap"); + m_FadeOut = textureImporterSettingsSP.FindPropertyRelative("m_FadeOut"); + m_BorderMipMap = textureImporterSettingsSP.FindPropertyRelative("m_BorderMipMap"); + m_MipMapsPreserveCoverage = textureImporterSettingsSP.FindPropertyRelative("m_MipMapsPreserveCoverage"); + m_AlphaTestReferenceValue = textureImporterSettingsSP.FindPropertyRelative("m_AlphaTestReferenceValue"); + m_MipMapFadeDistanceStart = textureImporterSettingsSP.FindPropertyRelative("m_MipMapFadeDistanceStart"); + m_MipMapFadeDistanceEnd = textureImporterSettingsSP.FindPropertyRelative("m_MipMapFadeDistanceEnd"); + m_AlphaIsTransparency = textureImporterSettingsSP.FindPropertyRelative("m_AlphaIsTransparency"); + m_FilterMode = textureImporterSettingsSP.FindPropertyRelative("m_FilterMode"); + m_Aniso = textureImporterSettingsSP.FindPropertyRelative("m_Aniso"); + m_WrapU = textureImporterSettingsSP.FindPropertyRelative("m_WrapU"); + m_WrapV = textureImporterSettingsSP.FindPropertyRelative("m_WrapV"); + m_WrapW = textureImporterSettingsSP.FindPropertyRelative("m_WrapW"); + + var textureWidth = serializedObject.FindProperty("m_TextureActualWidth"); + var textureHeight = serializedObject.FindProperty("m_TextureActualHeight"); + m_IsPOT = Mathf.IsPowerOfTwo(textureWidth.intValue) && Mathf.IsPowerOfTwo(textureHeight.intValue); + + + var advanceGUIAction = new Action[] + { + ColorSpaceGUI, + AlphaHandlingGUI, + POTScaleGUI, + ReadableGUI, + MipMapGUI + }; + m_AdvanceInspectorGUI.Add(TextureImporterType.Sprite, advanceGUIAction); + + advanceGUIAction = new Action[] + { + POTScaleGUI, + ReadableGUI, + MipMapGUI + }; + m_AdvanceInspectorGUI.Add(TextureImporterType.Default, advanceGUIAction); + LoadPlatformSettings(); + m_TexturePlatformSettingsHelper = new TexturePlatformSettingsHelper(this); + } + + /// + /// Implementation of AssetImporterEditor.OnInspectorGUI + /// + public override void OnInspectorGUI() + { + serializedObject.Update(); + if (s_Styles == null) + s_Styles = new Styles(); + + EditorGUI.showMixedValue = m_TextureType.hasMultipleDifferentValues; + m_TextureType.intValue = EditorGUILayout.IntPopup(s_Styles.textureTypeTitle, m_TextureType.intValue, s_Styles.textureTypeOptions, s_Styles.textureTypeValues); + EditorGUI.showMixedValue = false; + + switch ((TextureImporterType)m_TextureType.intValue) + { + case TextureImporterType.Sprite: + DoSpriteInspector(); + break; + case TextureImporterType.Default: + DoTextureDefaultInspector(); + break; + default: + Debug.LogWarning("We only support Default or Sprite texture type for now. Texture type is set to default."); + m_TextureType.intValue = (int)TextureImporterType.Default; + break; + } + + DoAdvanceInspector(); + CommonTextureSettingsGUI(); + GUILayout.Space(10); + DoPlatformSettings(); + serializedObject.ApplyModifiedProperties(); + ApplyRevertGUI(); + } + + /// + /// Implementation of AssetImporterEditor.Apply + /// + protected override void Apply() + { + FileStream fileStream = new FileStream(((AssetImporter)target).assetPath, FileMode.Open, FileAccess.Read); + var doc = PaintDotNet.Data.PhotoshopFileType.PsdLoad.Load(fileStream, ELoadFlag.Header | ELoadFlag.ColorMode); + + PSDApplyEvent evt = new PSDApplyEvent() + { + instance_id = target.GetInstanceID(), + texture_type = m_TextureType.intValue, + sprite_mode = m_SpriteMode.intValue, + mosaic_layer = m_MosaicLayers.boolValue, + import_hidden_layer = m_ImportHiddenLayers.boolValue, + character_mode = m_CharacterMode.boolValue, + generate_go_hierarchy = m_GenerateGOHierarchy.boolValue, + reslice_from_layer = m_ResliceFromLayer.boolValue, + is_character_rigged = IsCharacterRigged(), + is_psd = IsPSD(doc), + color_mode = FileColorMode(doc) + }; + doc.Cleanup(); + AnalyticFactory.analytics.SendApplyEvent(evt); + m_TexturePlatformSettingsHelper.Apply(); + base.Apply(); + Selection.activeObject = null; + Unsupported.SceneTrackerFlushDirty(); + PSDImportPostProcessor.currentApplyAssetPath = ((PSDImporter) target).assetPath; + } + + static bool IsPSD(PsdFile doc) + { + return !doc.IsLargeDocument; + } + + static PsdColorMode FileColorMode(PsdFile doc) + { + return doc.ColorMode; + } + + bool IsCharacterRigged() + { + var importer = target as PSDImporter; + if (importer != null) + { + var characterProvider = importer.GetDataProvider(); + var meshDataProvider = importer.GetDataProvider(); + if (characterProvider != null && meshDataProvider != null) + { + var character = characterProvider.GetCharacterData(); + foreach (var parts in character.parts) + { + var vert = meshDataProvider.GetVertices(new GUID(parts.spriteId)); + var indices = meshDataProvider.GetIndices(new GUID(parts.spriteId)); + if (parts.bones != null && parts.bones.Length > 0 && + vert != null && vert.Length > 0 && + indices != null && indices.Length > 0) + return true; + } + } + } + return false; + } + + Dictionary> m_PlatfromSettings = new Dictionary>(); + void LoadPlatformSettings() + { + foreach (var t in targets) + { + var importer = ((PSDImporter)t); + var importerPlatformSettings = importer.GetAllPlatformSettings(); + for (int i = 0; i < importerPlatformSettings.Length; ++i) + { + var tip = importerPlatformSettings[i]; + List platformSettings = null; + m_PlatfromSettings.TryGetValue(tip.name, out platformSettings); + if (platformSettings == null) + { + platformSettings = new List(); + m_PlatfromSettings.Add(tip.name, platformSettings); + } + platformSettings.Add(tip); + } + } + } + + void StorePlatformSettings() + { + var platformSettingsSP = serializedObject.FindProperty("m_PlatformSettings"); + platformSettingsSP.ClearArray(); + foreach (var keyValue in m_PlatfromSettings) + { + if (!keyValue.Value[0].overridden) + continue; + + SerializedProperty platformSettingSP = null; + for (int i = 0; i < platformSettingsSP.arraySize; ++i) + { + var sp = platformSettingsSP.GetArrayElementAtIndex(i); + if (sp.FindPropertyRelative("m_Name").stringValue == keyValue.Key) + platformSettingSP = sp; + } + if (platformSettingSP == null) + { + platformSettingsSP.InsertArrayElementAtIndex(platformSettingsSP.arraySize); + platformSettingSP = platformSettingsSP.GetArrayElementAtIndex(platformSettingsSP.arraySize - 1); + } + + var tip = keyValue.Value[0]; + platformSettingSP.FindPropertyRelative("m_Name").stringValue = tip.name; + platformSettingSP.FindPropertyRelative("m_Overridden").intValue = tip.overridden ? 1 : 0; + platformSettingSP.FindPropertyRelative("m_MaxTextureSize").intValue = tip.maxTextureSize; + platformSettingSP.FindPropertyRelative("m_ResizeAlgorithm").intValue = (int)tip.resizeAlgorithm; + platformSettingSP.FindPropertyRelative("m_TextureFormat").intValue = (int)tip.format; + platformSettingSP.FindPropertyRelative("m_TextureCompression").intValue = (int)tip.textureCompression; + platformSettingSP.FindPropertyRelative("m_CompressionQuality").intValue = tip.compressionQuality; + platformSettingSP.FindPropertyRelative("m_CrunchedCompression").intValue = tip.crunchedCompression ? 1 : 0; + platformSettingSP.FindPropertyRelative("m_AllowsAlphaSplitting").intValue = tip.allowsAlphaSplitting ? 1 : 0; + } + } + + void DoPlatformSettings() + { + m_TexturePlatformSettingsHelper.ShowPlatformSpecificSettings(); + } + + void DoAdvanceInspector() + { + if (!m_TextureType.hasMultipleDifferentValues) + { + if (m_AdvanceInspectorGUI.ContainsKey((TextureImporterType)m_TextureType.intValue)) + { + EditorGUILayout.Space(); + + m_ShowAdvanced = EditorGUILayout.Foldout(m_ShowAdvanced, s_Styles.showAdvanced, true); + if (m_ShowAdvanced) + { + foreach (var action in m_AdvanceInspectorGUI[(TextureImporterType)m_TextureType.intValue]) + { + action(); + } + } + } + } + EditorGUILayout.Space(); + } + + void CommonTextureSettingsGUI() + { + EditorGUI.BeginChangeCheck(); + + // Wrap mode + bool isVolume = false; + WrapModePopup(m_WrapU, m_WrapV, m_WrapW, isVolume, ref m_ShowPerAxisWrapModes); + + + // Display warning about repeat wrap mode on restricted npot emulation + if (m_NPOTScale.intValue == (int)TextureImporterNPOTScale.None && + (m_WrapU.intValue == (int)TextureWrapMode.Repeat || m_WrapV.intValue == (int)TextureWrapMode.Repeat) && + !InternalEditorBridge.DoesHardwareSupportsFullNPOT()) + { + bool displayWarning = false; + foreach (var target in targets) + { + var imp = (PSDImporter)target; + int w = imp.textureActualWidth; + int h = imp.textureActualHeight; + if (!Mathf.IsPowerOfTwo(w) || !Mathf.IsPowerOfTwo(h)) + { + displayWarning = true; + break; + } + } + + if (displayWarning) + { + EditorGUILayout.HelpBox(s_Styles.warpNotSupportWarning.text, MessageType.Warning, true); + } + } + + // Filter mode + EditorGUI.showMixedValue = m_FilterMode.hasMultipleDifferentValues; + FilterMode filter = (FilterMode)m_FilterMode.intValue; + if ((int)filter == -1) + { + if (m_FadeOut.intValue > 0 || m_ConvertToNormalMap.intValue > 0) + filter = FilterMode.Trilinear; + else + filter = FilterMode.Bilinear; + } + filter = (FilterMode)EditorGUILayout.IntPopup(s_Styles.filterMode, (int)filter, s_Styles.filterModeOptions, m_FilterModeOptions); + EditorGUI.showMixedValue = false; + if (EditorGUI.EndChangeCheck()) + m_FilterMode.intValue = (int)filter; + + // Aniso + bool showAniso = (FilterMode)m_FilterMode.intValue != FilterMode.Point + && m_EnableMipMap.intValue > 0 + && (TextureImporterShape)m_TextureShape.intValue != TextureImporterShape.TextureCube; + using (new EditorGUI.DisabledScope(!showAniso)) + { + EditorGUI.BeginChangeCheck(); + EditorGUI.showMixedValue = m_Aniso.hasMultipleDifferentValues; + int aniso = m_Aniso.intValue; + if (aniso == -1) + aniso = 1; + aniso = EditorGUILayout.IntSlider(s_Styles.anisoLevelLabel, aniso, 0, 16); + EditorGUI.showMixedValue = false; + if (EditorGUI.EndChangeCheck()) + m_Aniso.intValue = aniso; + + if (aniso > 1) + { + if (QualitySettings.anisotropicFiltering == AnisotropicFiltering.Disable) + EditorGUILayout.HelpBox(s_Styles.anisotropicDisableInfo.text, MessageType.Info); + else if (QualitySettings.anisotropicFiltering == AnisotropicFiltering.ForceEnable) + EditorGUILayout.HelpBox(s_Styles.anisotropicForceEnableInfo.text, MessageType.Info); + } + } + } + + private static bool IsAnyTextureObjectUsingPerAxisWrapMode(UnityEngine.Object[] objects, bool isVolumeTexture) + { + foreach (var o in objects) + { + int u = 0, v = 0, w = 0; + // the objects can be Textures themselves, or texture-related importers + if (o is Texture) + { + var ti = (Texture)o; + u = (int)ti.wrapModeU; + v = (int)ti.wrapModeV; + w = (int)ti.wrapModeW; + } + if (o is TextureImporter) + { + var ti = (TextureImporter)o; + u = (int)ti.wrapModeU; + v = (int)ti.wrapModeV; + w = (int)ti.wrapModeW; + } + if (o is IHVImageFormatImporter) + { + var ti = (IHVImageFormatImporter)o; + u = (int)ti.wrapModeU; + v = (int)ti.wrapModeV; + w = (int)ti.wrapModeW; + } + u = Mathf.Max(0, u); + v = Mathf.Max(0, v); + w = Mathf.Max(0, w); + if (u != v) + { + return true; + } + if (isVolumeTexture) + { + if (u != w || v != w) + { + return true; + } + } + } + return false; + } + + // showPerAxisWrapModes is state of whether "Per-Axis" mode should be active in the main dropdown. + // It is set automatically if wrap modes in UVW are different, or if user explicitly picks "Per-Axis" option -- when that one is picked, + // then it should stay true even if UVW wrap modes will initially be the same. + // + // Note: W wrapping mode is only shown when isVolumeTexture is true. + internal static void WrapModePopup(SerializedProperty wrapU, SerializedProperty wrapV, SerializedProperty wrapW, bool isVolumeTexture, ref bool showPerAxisWrapModes) + { + if (s_Styles == null) + s_Styles = new Styles(); + + // In texture importer settings, serialized properties for things like wrap modes can contain -1; + // that seems to indicate "use defaults, user has not changed them to anything" but not totally sure. + // Show them as Repeat wrap modes in the popups. + var wu = (TextureWrapMode)Mathf.Max(wrapU.intValue, 0); + var wv = (TextureWrapMode)Mathf.Max(wrapV.intValue, 0); + var ww = (TextureWrapMode)Mathf.Max(wrapW.intValue, 0); + + // automatically go into per-axis mode if values are already different + if (wu != wv) + showPerAxisWrapModes = true; + if (isVolumeTexture) + { + if (wu != ww || wv != ww) + showPerAxisWrapModes = true; + } + + // It's not possible to determine whether any single texture in the whole selection is using per-axis wrap modes + // just from SerializedProperty values. They can only tell if "some values in whole selection are different" (e.g. + // wrap value on U axis is not the same among all textures), and can return value of "some" object in the selection + // (typically based on object loading order). So in order for more intuitive behavior with multi-selection, + // we go over the actual objects when there's >1 object selected and some wrap modes are different. + if (!showPerAxisWrapModes) + { + if (wrapU.hasMultipleDifferentValues || wrapV.hasMultipleDifferentValues || (isVolumeTexture && wrapW.hasMultipleDifferentValues)) + { + if (IsAnyTextureObjectUsingPerAxisWrapMode(wrapU.serializedObject.targetObjects, isVolumeTexture)) + { + showPerAxisWrapModes = true; + } + } + } + + int value = showPerAxisWrapModes ? -1 : (int)wu; + + // main wrap mode popup + EditorGUI.BeginChangeCheck(); + EditorGUI.showMixedValue = !showPerAxisWrapModes && (wrapU.hasMultipleDifferentValues || wrapV.hasMultipleDifferentValues || (isVolumeTexture && wrapW.hasMultipleDifferentValues)); + value = EditorGUILayout.IntPopup(s_Styles.wrapModeLabel, value, s_Styles.wrapModeContents, s_Styles.wrapModeValues); + if (EditorGUI.EndChangeCheck() && value != -1) + { + // assign the same wrap mode to all axes, and hide per-axis popups + wrapU.intValue = value; + wrapV.intValue = value; + wrapW.intValue = value; + showPerAxisWrapModes = false; + } + + // show per-axis popups if needed + if (value == -1) + { + showPerAxisWrapModes = true; + EditorGUI.indentLevel++; + WrapModeAxisPopup(s_Styles.wrapU, wrapU); + WrapModeAxisPopup(s_Styles.wrapV, wrapV); + if (isVolumeTexture) + { + WrapModeAxisPopup(s_Styles.wrapW, wrapW); + } + EditorGUI.indentLevel--; + } + EditorGUI.showMixedValue = false; + } + + static void WrapModeAxisPopup(GUIContent label, SerializedProperty wrapProperty) + { + // In texture importer settings, serialized properties for wrap modes can contain -1, which means "use default". + var wrap = (TextureWrapMode)Mathf.Max(wrapProperty.intValue, 0); + Rect rect = EditorGUILayout.GetControlRect(); + EditorGUI.BeginChangeCheck(); + EditorGUI.BeginProperty(rect, label, wrapProperty); + wrap = (TextureWrapMode)EditorGUI.EnumPopup(rect, label, wrap); + EditorGUI.EndProperty(); + if (EditorGUI.EndChangeCheck()) + { + wrapProperty.intValue = (int)wrap; + } + } + + void DoWrapModePopup() + { + WrapModePopup(m_WrapU, m_WrapV, m_WrapW, IsVolume(), ref m_ShowPerAxisWrapModes); + } + + bool IsVolume() + { + var t = target as Texture; + return t != null && t.dimension == UnityEngine.Rendering.TextureDimension.Tex3D; + } + + void DoSpriteInspector() + { + EditorGUI.BeginChangeCheck(); + EditorGUILayout.IntPopup(m_SpriteMode, s_Styles.spriteModeOptions, new[] { 1, 2, 3 }, s_Styles.spriteMode); + + // Ensure that PropertyField focus will be cleared when we change spriteMode. + if (EditorGUI.EndChangeCheck()) + { + GUIUtility.keyboardControl = 0; + } + + EditorGUI.indentLevel++; + + // Show generic attributes + if (m_SpriteMode.intValue != 0) + { + EditorGUILayout.PropertyField(m_SpritePixelsToUnits, s_Styles.spritePixelsPerUnit); + + if (m_SpriteMode.intValue != (int)SpriteImportMode.Polygon && !m_SpriteMode.hasMultipleDifferentValues) + { + EditorGUILayout.IntPopup(m_SpriteMeshType, s_Styles.spriteMeshTypeOptions, new[] { 0, 1 }, s_Styles.spriteMeshType); + } + + EditorGUILayout.IntSlider(m_SpriteExtrude, 0, 32, s_Styles.spriteExtrude); + + if (m_SpriteMode.intValue == 1) + { + EditorGUILayout.IntPopup(m_Alignment, s_Styles.spriteAlignmentOptions, new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s_Styles.spriteAlignment); + + if (m_Alignment.intValue == (int)SpriteAlignment.Custom) + { + GUILayout.BeginHorizontal(); + EditorGUILayout.PropertyField(m_SpritePivot, new GUIContent()); + GUILayout.EndHorizontal(); + } + } + } + + EditorGUILayout.PropertyField(m_ImportHiddenLayers, s_Styles.importHiddenLayer); + if (m_SpriteMode.intValue == (int)SpriteImportMode.Multiple && !m_SpriteMode.hasMultipleDifferentValues) + { + EditorGUILayout.PropertyField(m_MosaicLayers, s_Styles.mosaicLayers); + using (new EditorGUI.DisabledScope(!m_MosaicLayers.boolValue)) + { + EditorGUILayout.PropertyField(m_CharacterMode, s_Styles.characterMode); + using (new EditorGUI.DisabledScope(!m_CharacterMode.boolValue)) + { + EditorGUILayout.PropertyField(m_GenerateGOHierarchy, s_Styles.generateGOHierarchy); + EditorGUILayout.IntPopup(m_DocumentAlignment, s_Styles.spriteAlignmentOptions, new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s_Styles.characterAlignment); + if (m_DocumentAlignment.intValue == (int)SpriteAlignment.Custom) + { + GUILayout.BeginHorizontal(); + GUILayout.Space(EditorGUIUtility.labelWidth); + EditorGUILayout.PropertyField(m_DocumentPivot, new GUIContent()); + GUILayout.EndHorizontal(); + } + //EditorGUILayout.PropertyField(m_PaperDollMode, s_Styles.paperDollMode); + } + + + EditorGUILayout.PropertyField(m_ResliceFromLayer, s_Styles.resliceFromLayer); + if (m_ResliceFromLayer.boolValue) + { + EditorGUILayout.HelpBox(s_Styles.resliceFromLayerWarning.text, MessageType.Info, true); + } + } + m_ShowExperimental = EditorGUILayout.Foldout(m_ShowExperimental, s_Styles.experimental, true); + if (m_ShowExperimental) + { + EditorGUI.indentLevel++; + EditorGUILayout.PropertyField(m_KeepDupilcateSpriteName, s_Styles.keepDuplicateSpriteName); + EditorGUI.indentLevel--; + } + } + + using (new EditorGUI.DisabledScope(targets.Length != 1)) + { + GUILayout.BeginHorizontal(); + + GUILayout.FlexibleSpace(); + if (GUILayout.Button(s_Styles.spriteEditorButtonLabel)) + { + if (HasModified()) + { + // To ensure Sprite Editor Window to have the latest texture import setting, + // We must applied those modified values first. + string dialogText = string.Format(s_Styles.unappliedSettingsDialogContent.text, ((AssetImporter)target).assetPath); + if (EditorUtility.DisplayDialog(s_Styles.unappliedSettingsDialogTitle.text, + dialogText, s_Styles.applyButtonLabel.text, s_Styles.revertButtonLabel.text)) + { + ApplyAndImport(); + InternalEditorBridge.ShowSpriteEditorWindow(this.assetTarget); + + // We reimported the asset which destroyed the editor, so we can't keep running the UI here. + GUIUtility.ExitGUI(); + } + } + else + { + InternalEditorBridge.ShowSpriteEditorWindow(this.assetTarget); + } + } + GUILayout.EndHorizontal(); + } + EditorGUI.indentLevel--; + } + + void DoTextureDefaultInspector() + { + ColorSpaceGUI(); + AlphaHandlingGUI(); + } + + void ColorSpaceGUI() + { + ToggleFromInt(m_sRGBTexture, s_Styles.sRGBTexture); + } + + void POTScaleGUI() + { + using (new EditorGUI.DisabledScope(m_IsPOT || m_TextureType.intValue == (int)TextureImporterType.Sprite)) + { + EnumPopup(m_NPOTScale, typeof(TextureImporterNPOTScale), s_Styles.npot); + } + } + + void ReadableGUI() + { + ToggleFromInt(m_IsReadable, s_Styles.readWrite); + } + + void AlphaHandlingGUI() + { + EditorGUI.showMixedValue = m_AlphaSource.hasMultipleDifferentValues; + EditorGUI.BeginChangeCheck(); + int newAlphaUsage = EditorGUILayout.IntPopup(s_Styles.alphaSource, m_AlphaSource.intValue, s_Styles.alphaSourceOptions, s_Styles.alphaSourceValues); + + EditorGUI.showMixedValue = false; + if (EditorGUI.EndChangeCheck()) + { + m_AlphaSource.intValue = newAlphaUsage; + } + + bool showAlphaIsTransparency = (TextureImporterAlphaSource)m_AlphaSource.intValue != TextureImporterAlphaSource.None; + using (new EditorGUI.DisabledScope(!showAlphaIsTransparency)) + { + ToggleFromInt(m_AlphaIsTransparency, s_Styles.alphaIsTransparency); + } + } + + void MipMapGUI() + { + ToggleFromInt(m_EnableMipMap, s_Styles.generateMipMaps); + + if (m_EnableMipMap.boolValue && !m_EnableMipMap.hasMultipleDifferentValues) + { + EditorGUI.indentLevel++; + ToggleFromInt(m_BorderMipMap, s_Styles.borderMipMaps); + EditorGUILayout.Popup(s_Styles.mipMapFilter, m_MipMapMode.intValue, s_Styles.mipMapFilterOptions); + + ToggleFromInt(m_MipMapsPreserveCoverage, s_Styles.mipMapsPreserveCoverage); + if (m_MipMapsPreserveCoverage.intValue != 0 && !m_MipMapsPreserveCoverage.hasMultipleDifferentValues) + { + EditorGUI.indentLevel++; + EditorGUILayout.PropertyField(m_AlphaTestReferenceValue, s_Styles.alphaTestReferenceValue); + EditorGUI.indentLevel--; + } + + // Mipmap fadeout + ToggleFromInt(m_FadeOut, s_Styles.mipmapFadeOutToggle); + if (m_FadeOut.intValue > 0) + { + EditorGUI.indentLevel++; + EditorGUI.BeginChangeCheck(); + float min = m_MipMapFadeDistanceStart.intValue; + float max = m_MipMapFadeDistanceEnd.intValue; + EditorGUILayout.MinMaxSlider(s_Styles.mipmapFadeOut, ref min, ref max, 0, 10); + if (EditorGUI.EndChangeCheck()) + { + m_MipMapFadeDistanceStart.intValue = Mathf.RoundToInt(min); + m_MipMapFadeDistanceEnd.intValue = Mathf.RoundToInt(max); + } + EditorGUI.indentLevel--; + } + EditorGUI.indentLevel--; + } + } + + void ToggleFromInt(SerializedProperty property, GUIContent label) + { + EditorGUI.BeginChangeCheck(); + EditorGUI.showMixedValue = property.hasMultipleDifferentValues; + int value = EditorGUILayout.Toggle(label, property.intValue > 0) ? 1 : 0; + EditorGUI.showMixedValue = false; + if (EditorGUI.EndChangeCheck()) + property.intValue = value; + } + + void EnumPopup(SerializedProperty property, System.Type type, GUIContent label) + { + EditorGUILayout.IntPopup(label.text, property.intValue, + System.Enum.GetNames(type), + System.Enum.GetValues(type) as int[]); + } + + void ExportMosaicTexture() + { + var assetPath = ((AssetImporter)target).assetPath; + var texture2D = AssetDatabase.LoadAssetAtPath(assetPath); + if (texture2D == null) + return; + if (!texture2D.isReadable) + texture2D = InternalEditorBridge.CreateTemporaryDuplicate(texture2D, texture2D.width, texture2D.height); + var pixelData = texture2D.GetPixels(); + texture2D = new Texture2D(texture2D.width, texture2D.height); + texture2D.SetPixels(pixelData); + texture2D.Apply(); + byte[] bytes = texture2D.EncodeToPNG(); + var fileName = Path.GetFileNameWithoutExtension(assetPath); + var filePath = Path.GetDirectoryName(assetPath); + var savePath = Path.Combine(filePath, fileName + ".png"); + File.WriteAllBytes(savePath, bytes); + AssetDatabase.Refresh(); + } + + protected override void ResetValues() + { + base.ResetValues(); + LoadPlatformSettings(); + m_TexturePlatformSettingsHelper = new TexturePlatformSettingsHelper(this); + } + + public int GetTargetCount() + { + return targets.Length; + } + + public TextureImporterPlatformSettings GetPlatformTextureSettings(int i, string name) + { + if(m_PlatfromSettings.ContainsKey(name)) + if(m_PlatfromSettings[name].Count > i) + return m_PlatfromSettings[name][i]; + return new TextureImporterPlatformSettings() + { + name = name, + overridden = false + }; + } + + public bool ShowPresetSettings() + { + return assetTarget == null; + } + + public bool DoesSourceTextureHaveAlpha(int v) + { + return true; + } + + public bool IsSourceTextureHDR(int v) + { + return false; + } + + public void SetPlatformTextureSettings(int i, TextureImporterPlatformSettings platformSettings) + { + var psdImporter = ((PSDImporter)targets[i]); + psdImporter.SetPlatformTextureSettings(platformSettings); + psdImporter.Apply(); + } + + public void GetImporterSettings(int i, TextureImporterSettings settings) + { + ((PSDImporter)targets[i]).ReadTextureSettings(settings); + // Get settings that have been changed in the inspector + GetSerializedPropertySettings(settings); + } + + internal TextureImporterSettings GetSerializedPropertySettings(TextureImporterSettings settings) + { + if (!m_AlphaSource.hasMultipleDifferentValues) + settings.alphaSource = (TextureImporterAlphaSource)m_AlphaSource.intValue; + + if (!m_ConvertToNormalMap.hasMultipleDifferentValues) + settings.convertToNormalMap = m_ConvertToNormalMap.intValue > 0; + + if (!m_BorderMipMap.hasMultipleDifferentValues) + settings.borderMipmap = m_BorderMipMap.intValue > 0; + + if (!m_MipMapsPreserveCoverage.hasMultipleDifferentValues) + settings.mipMapsPreserveCoverage = m_MipMapsPreserveCoverage.intValue > 0; + + if (!m_AlphaTestReferenceValue.hasMultipleDifferentValues) + settings.alphaTestReferenceValue = m_AlphaTestReferenceValue.floatValue; + + if (!m_NPOTScale.hasMultipleDifferentValues) + settings.npotScale = (TextureImporterNPOTScale)m_NPOTScale.intValue; + + if (!m_IsReadable.hasMultipleDifferentValues) + settings.readable = m_IsReadable.intValue > 0; + + if (!m_sRGBTexture.hasMultipleDifferentValues) + settings.sRGBTexture = m_sRGBTexture.intValue > 0; + + if (!m_EnableMipMap.hasMultipleDifferentValues) + settings.mipmapEnabled = m_EnableMipMap.intValue > 0; + + if (!m_MipMapMode.hasMultipleDifferentValues) + settings.mipmapFilter = (TextureImporterMipFilter)m_MipMapMode.intValue; + + if (!m_FadeOut.hasMultipleDifferentValues) + settings.fadeOut = m_FadeOut.intValue > 0; + + if (!m_MipMapFadeDistanceStart.hasMultipleDifferentValues) + settings.mipmapFadeDistanceStart = m_MipMapFadeDistanceStart.intValue; + + if (!m_MipMapFadeDistanceEnd.hasMultipleDifferentValues) + settings.mipmapFadeDistanceEnd = m_MipMapFadeDistanceEnd.intValue; + + if (!m_SpriteMode.hasMultipleDifferentValues) + settings.spriteMode = m_SpriteMode.intValue; + + if (!m_SpritePixelsToUnits.hasMultipleDifferentValues) + settings.spritePixelsPerUnit = m_SpritePixelsToUnits.floatValue; + + if (!m_SpriteExtrude.hasMultipleDifferentValues) + settings.spriteExtrude = (uint)m_SpriteExtrude.intValue; + + if (!m_SpriteMeshType.hasMultipleDifferentValues) + settings.spriteMeshType = (SpriteMeshType)m_SpriteMeshType.intValue; + + if (!m_Alignment.hasMultipleDifferentValues) + settings.spriteAlignment = m_Alignment.intValue; + + if (!m_SpritePivot.hasMultipleDifferentValues) + settings.spritePivot = m_SpritePivot.vector2Value; + + if (!m_WrapU.hasMultipleDifferentValues) + settings.wrapModeU = (TextureWrapMode)m_WrapU.intValue; + if (!m_WrapV.hasMultipleDifferentValues) + settings.wrapModeU = (TextureWrapMode)m_WrapV.intValue; + if (!m_WrapW.hasMultipleDifferentValues) + settings.wrapModeU = (TextureWrapMode)m_WrapW.intValue; + + if (!m_FilterMode.hasMultipleDifferentValues) + settings.filterMode = (FilterMode)m_FilterMode.intValue; + + if (!m_Aniso.hasMultipleDifferentValues) + settings.aniso = m_Aniso.intValue; + + + if (!m_AlphaIsTransparency.hasMultipleDifferentValues) + settings.alphaIsTransparency = m_AlphaIsTransparency.intValue > 0; + + if (!m_TextureType.hasMultipleDifferentValues) + settings.textureType = (TextureImporterType)m_TextureType.intValue; + + if (!m_TextureShape.hasMultipleDifferentValues) + settings.textureShape = (TextureImporterShape)m_TextureShape.intValue; + + return settings; + } + /// + /// Override of AssetImporterEditor.showImportedObject + /// The property always returns false so that imported objects does not show up in the Inspector. + /// + /// false + public override bool showImportedObject + { + get { return false; } + } + + public bool textureTypeHasMultipleDifferentValues + { + get { return m_TextureType.hasMultipleDifferentValues; } + } + + public TextureImporterType textureType + { + get { return (TextureImporterType)m_TextureType.intValue; } + } + + public SpriteImportMode spriteImportMode + { + get { return (SpriteImportMode)m_SpriteMode.intValue; } + } + + public override bool HasModified() + { + if (base.HasModified()) + return true; + + return m_TexturePlatformSettingsHelper.HasModified(); + } + + internal class Styles + { + public readonly GUIContent textureTypeTitle = new GUIContent("Texture Type", "What will this texture be used for?"); + public readonly GUIContent[] textureTypeOptions = + { + new GUIContent("Default", "Texture is a normal image such as a diffuse texture or other."), + new GUIContent("Sprite (2D and UI)", "Texture is used for a sprite."), + }; + public readonly int[] textureTypeValues = + { + (int)TextureImporterType.Default, + (int)TextureImporterType.Sprite, + }; + + public readonly GUIContent textureShape = new GUIContent("Texture Shape", "What shape is this texture?"); + private readonly GUIContent textureShape2D = new GUIContent("2D, Texture is 2D."); + private readonly GUIContent textureShapeCube = new GUIContent("Cube", "Texture is a Cubemap."); + public readonly Dictionary textureShapeOptionsDictionnary = new Dictionary(); + public readonly Dictionary textureShapeValuesDictionnary = new Dictionary(); + + + public readonly GUIContent filterMode = new GUIContent("Filter Mode"); + public readonly GUIContent[] filterModeOptions = + { + new GUIContent("Point (no filter)"), + new GUIContent("Bilinear"), + new GUIContent("Trilinear") + }; + + public readonly GUIContent textureFormat = new GUIContent("Format"); + + public readonly GUIContent defaultPlatform = new GUIContent("Default"); + public readonly GUIContent mipmapFadeOutToggle = new GUIContent("Fadeout Mip Maps"); + public readonly GUIContent mipmapFadeOut = new GUIContent("Fade Range"); + public readonly GUIContent readWrite = new GUIContent("Read/Write Enabled", "Enable to be able to access the raw pixel data from code."); + + public readonly GUIContent alphaSource = new GUIContent("Alpha Source", "How is the alpha generated for the imported texture."); + public readonly GUIContent[] alphaSourceOptions = + { + new GUIContent("None", "No Alpha will be used."), + new GUIContent("Input Texture Alpha", "Use Alpha from the input texture if one is provided."), + new GUIContent("From Gray Scale", "Generate Alpha from image gray scale."), + }; + public readonly int[] alphaSourceValues = + { + (int)TextureImporterAlphaSource.None, + (int)TextureImporterAlphaSource.FromInput, + (int)TextureImporterAlphaSource.FromGrayScale, + }; + + public readonly GUIContent generateMipMaps = new GUIContent("Generate Mip Maps"); + public readonly GUIContent sRGBTexture = new GUIContent("sRGB (Color Texture)", "Texture content is stored in gamma space. Non-HDR color textures should enable this flag (except if used for IMGUI)."); + public readonly GUIContent borderMipMaps = new GUIContent("Border Mip Maps"); + public readonly GUIContent mipMapsPreserveCoverage = new GUIContent("Mip Maps Preserve Coverage", "The alpha channel of generated Mip Maps will preserve coverage during the alpha test."); + public readonly GUIContent alphaTestReferenceValue = new GUIContent("Alpha Cutoff Value", "The reference value used during the alpha test. Controls Mip Map coverage."); + public readonly GUIContent mipMapFilter = new GUIContent("Mip Map Filtering"); + public readonly GUIContent[] mipMapFilterOptions = + { + new GUIContent("Box"), + new GUIContent("Kaiser"), + }; + public readonly GUIContent npot = new GUIContent("Non Power of 2", "How non-power-of-two textures are scaled on import."); + + public readonly GUIContent compressionQuality = new GUIContent("Compressor Quality"); + public readonly GUIContent compressionQualitySlider = new GUIContent("Compressor Quality", "Use the slider to adjust compression quality from 0 (Fastest) to 100 (Best)"); + public readonly GUIContent[] mobileCompressionQualityOptions = + { + new GUIContent("Fast"), + new GUIContent("Normal"), + new GUIContent("Best") + }; + + public readonly GUIContent spriteMode = new GUIContent("Sprite Mode"); + public readonly GUIContent[] spriteModeOptions = + { + new GUIContent("Single"), + new GUIContent("Multiple"), + new GUIContent("Polygon"), + }; + public readonly GUIContent[] spriteMeshTypeOptions = + { + new GUIContent("Full Rect"), + new GUIContent("Tight"), + }; + + public readonly GUIContent spritePackingTag = new GUIContent("Packing Tag", "Tag for the Sprite Packing system."); + public readonly GUIContent spritePixelsPerUnit = new GUIContent("Pixels Per Unit", "How many pixels in the sprite correspond to one unit in the world."); + public readonly GUIContent spriteExtrude = new GUIContent("Extrude Edges", "How much empty area to leave around the sprite in the generated mesh."); + public readonly GUIContent spriteMeshType = new GUIContent("Mesh Type", "Type of sprite mesh to generate."); + public readonly GUIContent spriteAlignment = new GUIContent("Pivot", "Sprite pivot point in its local space. May be used for syncing animation frames of different sizes."); + public readonly GUIContent characterAlignment = new GUIContent("Pivot", "Character pivot point in its local space using normalized value i.e. 0 - 1"); + + public readonly GUIContent[] spriteAlignmentOptions = + { + new GUIContent("Center"), + new GUIContent("Top Left"), + new GUIContent("Top"), + new GUIContent("Top Right"), + new GUIContent("Left"), + new GUIContent("Right"), + new GUIContent("Bottom Left"), + new GUIContent("Bottom"), + new GUIContent("Bottom Right"), + new GUIContent("Custom"), + }; + + public readonly GUIContent warpNotSupportWarning = new GUIContent("Graphics device doesn't support Repeat wrap mode on NPOT textures. Falling back to Clamp."); + public readonly GUIContent anisoLevelLabel = new GUIContent("Aniso Level"); + public readonly GUIContent anisotropicDisableInfo = new GUIContent("Anisotropic filtering is disabled for all textures in Quality Settings."); + public readonly GUIContent anisotropicForceEnableInfo = new GUIContent("Anisotropic filtering is enabled for all textures in Quality Settings."); + public readonly GUIContent unappliedSettingsDialogTitle = new GUIContent("Unapplied import settings"); + public readonly GUIContent unappliedSettingsDialogContent = new GUIContent("Unapplied import settings for \'{0}\'.\nApply and continue to sprite editor or cancel."); + public readonly GUIContent applyButtonLabel = new GUIContent("Apply"); + public readonly GUIContent revertButtonLabel = new GUIContent("Revert"); + public readonly GUIContent spriteEditorButtonLabel = new GUIContent("Sprite Editor"); + public readonly GUIContent resliceFromLayerWarning = new GUIContent("This will reinitialize and recreate all Sprites based on the file’s layer data. Existing Sprite metadata from previously generated Sprites are copied over."); + public readonly GUIContent alphaIsTransparency = new GUIContent("Alpha Is Transparency", "If the provided alpha channel is transparency, enable this to pre-filter the color to avoid texture filtering artifacts. This is not supported for HDR textures."); + public readonly GUIContent etc1Compression = new GUIContent("Compress using ETC1 (split alpha channel)|Alpha for this texture will be preserved by splitting the alpha channel to another texture, and both resulting textures will be compressed using ETC1."); + public readonly GUIContent crunchedCompression = new GUIContent("Use Crunch Compression", "Texture is crunch-compressed to save space on disk when applicable."); + + public readonly GUIContent showAdvanced = new GUIContent("Advanced", "Show advanced settings."); + + public readonly GUIContent platformSettingsLabel = new GUIContent("Platform Setttings"); + + public readonly GUIContent[] platformSettingsSelection; + + public readonly GUIContent wrapModeLabel = new GUIContent("Wrap Mode"); + public readonly GUIContent wrapU = new GUIContent("U axis"); + public readonly GUIContent wrapV = new GUIContent("V axis"); + public readonly GUIContent wrapW = new GUIContent("W axis"); + + + public readonly GUIContent[] wrapModeContents = + { + new GUIContent("Repeat"), + new GUIContent("Clamp"), + new GUIContent("Mirror"), + new GUIContent("Mirror Once"), + new GUIContent("Per-axis") + }; + public readonly int[] wrapModeValues = + { + (int)TextureWrapMode.Repeat, + (int)TextureWrapMode.Clamp, + (int)TextureWrapMode.Mirror, + (int)TextureWrapMode.MirrorOnce, + -1 + }; + + public readonly GUIContent importHiddenLayer = new GUIContent(L10n.Tr("Import Hidden"), L10n.Tr("Import hidden layers")); + public readonly GUIContent mosaicLayers = new GUIContent(L10n.Tr("Mosaic"), L10n.Tr("Layers will be imported as individual Sprites")); + public readonly GUIContent characterMode = new GUIContent(L10n.Tr("Character Rig"), L10n.Tr("Enable to support 2D Animation character rigging")); + public readonly GUIContent generateGOHierarchy = new GUIContent(L10n.Tr("Use Layer Grouping"), L10n.Tr("GameObjects are grouped according to source file layer grouping")); + public readonly GUIContent resliceFromLayer = new GUIContent(L10n.Tr("Reslice"), L10n.Tr("Recreate Sprite rects from file")); + public readonly GUIContent paperDollMode = new GUIContent(L10n.Tr("Paper Doll Mode"), L10n.Tr("Special mode to generate a Prefab for Paper Doll use case")); + public readonly GUIContent experimental = new GUIContent(L10n.Tr("Experimental")); + public readonly GUIContent keepDuplicateSpriteName = new GUIContent(L10n.Tr("Keep Duplicate Name"), L10n.Tr("Keep Sprite name same as Layer Name even if there are duplicated Layer Name")); + + public Styles() + { + // This is far from ideal, but it's better than having tons of logic in the GUI code itself. + // The combination should not grow too much anyway since only Texture3D will be added later. + GUIContent[] s2D_Options = { textureShape2D }; + GUIContent[] sCube_Options = { textureShapeCube }; + GUIContent[] s2D_Cube_Options = { textureShape2D, textureShapeCube }; + textureShapeOptionsDictionnary.Add(TextureImporterShape.Texture2D, s2D_Options); + textureShapeOptionsDictionnary.Add(TextureImporterShape.TextureCube, sCube_Options); + textureShapeOptionsDictionnary.Add(TextureImporterShape.Texture2D | TextureImporterShape.TextureCube, s2D_Cube_Options); + + int[] s2D_Values = { (int)TextureImporterShape.Texture2D }; + int[] sCube_Values = { (int)TextureImporterShape.TextureCube }; + int[] s2D_Cube_Values = { (int)TextureImporterShape.Texture2D, (int)TextureImporterShape.TextureCube }; + textureShapeValuesDictionnary.Add(TextureImporterShape.Texture2D, s2D_Values); + textureShapeValuesDictionnary.Add(TextureImporterShape.TextureCube, sCube_Values); + textureShapeValuesDictionnary.Add(TextureImporterShape.Texture2D | TextureImporterShape.TextureCube, s2D_Cube_Values); + + platformSettingsSelection = new GUIContent[TexturePlatformSettingsModal.kValidBuildPlatform.Length]; + for (int i = 0; i < TexturePlatformSettingsModal.kValidBuildPlatform.Length; ++i) + { + platformSettingsSelection[i] = new GUIContent(TexturePlatformSettingsModal.kValidBuildPlatform[i].buildTargetName); + } + } + } + + internal static Styles s_Styles; + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.psdimporter@4.0.2/Editor/PSDImporterEditor.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.psdimporter@4.0.2/Editor/PSDImporterEditor.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..b9895fe25cc34d0fa5528053943e3730f77adb41 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.psdimporter@4.0.2/Editor/PSDImporterEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 18bf2b24e4cf52b4db1d73f71d4bd76b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Editor/Handles/Shaders/Sprites-Inspector.shader b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Editor/Handles/Shaders/Sprites-Inspector.shader new file mode 100644 index 0000000000000000000000000000000000000000..f742697ed37c984d4d192d26c011e213b39c55de --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Editor/Handles/Shaders/Sprites-Inspector.shader @@ -0,0 +1,83 @@ +// Texture is forced to be in Gamma space regardless of the active ColorSpace. +Shader "Hidden/InternalSpritesInspector" +{ + Properties + { + [PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {} + _Color("Tint", Color) = (1, 1, 1, 1) + [MaterialToggle] PixelSnap("Pixel snap", Float) = 0 + } + + SubShader + { + Tags + { + "Queue" = "Transparent" + "IgnoreProjector" = "True" + "RenderType" = "Transparent" + "PreviewType" = "Plane" + "CanUseSpriteAtlas" = "True" + } + + Cull Off + Lighting Off + ZWrite Off + Fog{ Mode Off } + Blend SrcAlpha OneMinusSrcAlpha + + Pass + { + + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + #pragma multi_compile DUMMY PIXELSNAP_ON + #include "UnityCG.cginc" + + uniform bool _AdjustLinearForGamma; + + struct appdata_t + { + float4 vertex : POSITION; + float4 color : COLOR; + float2 texcoord : TEXCOORD0; + }; + + struct v2f + { + float4 vertex : SV_POSITION; + fixed4 color : COLOR; + half2 texcoord : TEXCOORD0; + float2 clipUV : TEXCOORD1; + }; + + fixed4 _Color; + uniform float4x4 unity_GUIClipTextureMatrix; + + v2f vert(appdata_t IN) + { + float3 screenUV = UnityObjectToViewPos(IN.vertex); + v2f OUT; + OUT.vertex = UnityObjectToClipPos(IN.vertex); + OUT.texcoord = IN.texcoord; + OUT.color = IN.color * _Color; + OUT.clipUV = mul(unity_GUIClipTextureMatrix, float4(screenUV.xy, 0, 1.0)); + return OUT; + } + + sampler2D _MainTex; + sampler2D _GUIClipTexture; + + fixed4 frag(v2f IN) : COLOR + { + fixed4 col = tex2D(_MainTex, IN.texcoord); + fixed alpha = col.a; + if (_AdjustLinearForGamma) + col.rgb = LinearToGammaSpace(col.rgb); + col.a = alpha * tex2D(_GUIClipTexture, IN.clipUV).a; + return col * IN.color; + } + ENDCG + } + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Editor/ObjectMenuCreation/DefaultAssets/Textures/Sprite Shape Corner.png.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Editor/ObjectMenuCreation/DefaultAssets/Textures/Sprite Shape Corner.png.meta new file mode 100644 index 0000000000000000000000000000000000000000..8e0ee29a911e95798d9544e2504be0238114f716 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Editor/ObjectMenuCreation/DefaultAssets/Textures/Sprite Shape Corner.png.meta @@ -0,0 +1,130 @@ +fileFormatVersion: 2 +guid: 608e61deb05c54660bebf5a4dd2ee02d +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 0 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 256 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: iPhone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Editor/ObjectMenuCreation/DefaultAssets/Textures/Sprite Shape Fill.png.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Editor/ObjectMenuCreation/DefaultAssets/Textures/Sprite Shape Fill.png.meta new file mode 100644 index 0000000000000000000000000000000000000000..0a98f648a75ef95f6274f3f6e55e0a80a7701e64 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Editor/ObjectMenuCreation/DefaultAssets/Textures/Sprite Shape Fill.png.meta @@ -0,0 +1,130 @@ +fileFormatVersion: 2 +guid: b281b91a70a624a0da1c43adc1c30c7b +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 0 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 256 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: iPhone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Runtime/External/LibTessDotNet.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Runtime/External/LibTessDotNet.meta new file mode 100644 index 0000000000000000000000000000000000000000..9f4d85580906ab0bfa27e2fbf7111079118b4913 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Runtime/External/LibTessDotNet.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9214d94ab547c5447a11c7a7c6a59482 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Runtime/External/LibTessDotNet/Dict.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Runtime/External/LibTessDotNet/Dict.cs new file mode 100644 index 0000000000000000000000000000000000000000..5b848ccde45bfcfeac137c7683ca4bc887556f13 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Runtime/External/LibTessDotNet/Dict.cs @@ -0,0 +1,107 @@ +/* +** SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) +** Copyright (C) 2011 Silicon Graphics, Inc. +** All Rights Reserved. +** +** Permission is hereby granted, free of charge, to any person obtaining a copy +** of this software and associated documentation files (the "Software"), to deal +** in the Software without restriction, including without limitation the rights +** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +** of the Software, and to permit persons to whom the Software is furnished to do so, +** subject to the following conditions: +** +** The above copyright notice including the dates of first publication and either this +** permission notice or a reference to http://oss.sgi.com/projects/FreeB/ shall be +** included in all copies or substantial portions of the Software. +** +** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +** INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +** PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL SILICON GRAPHICS, INC. +** BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +** OR OTHER DEALINGS IN THE SOFTWARE. +** +** Except as contained in this notice, the name of Silicon Graphics, Inc. shall not +** be used in advertising or otherwise to promote the sale, use or other dealings in +** this Software without prior written authorization from Silicon Graphics, Inc. +*/ +/* +** Original Author: Eric Veach, July 1994. +** libtess2: Mikko Mononen, http://code.google.com/p/libtess2/. +** LibTessDotNet: Remi Gillig, https://github.com/speps/LibTessDotNet +*/ + +namespace Unity.SpriteShape.External +{ + +namespace LibTessDotNet +{ + internal class Dict where TValue : class + { + public class Node + { + internal TValue _key; + internal Node _prev, _next; + + public TValue Key { get { return _key; } } + public Node Prev { get { return _prev; } } + public Node Next { get { return _next; } } + } + + public delegate bool LessOrEqual(TValue lhs, TValue rhs); + + private LessOrEqual _leq; + Node _head; + + public Dict(LessOrEqual leq) + { + _leq = leq; + + _head = new Node { _key = null }; + _head._prev = _head; + _head._next = _head; + } + + public Node Insert(TValue key) + { + return InsertBefore(_head, key); + } + + public Node InsertBefore(Node node, TValue key) + { + do { + node = node._prev; + } while (node._key != null && !_leq(node._key, key)); + + var newNode = new Node { _key = key }; + newNode._next = node._next; + node._next._prev = newNode; + newNode._prev = node; + node._next = newNode; + + return newNode; + } + + public Node Find(TValue key) + { + var node = _head; + do { + node = node._next; + } while (node._key != null && !_leq(key, node._key)); + return node; + } + + public Node Min() + { + return _head._next; + } + + public void Remove(Node node) + { + node._next._prev = node._prev; + node._prev._next = node._next; + } + } +} + +} // namespace Unity.VectorGraphics.External \ No newline at end of file diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Runtime/External/LibTessDotNet/Dict.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Runtime/External/LibTessDotNet/Dict.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..457d986b588c6eb7daa29b2b39ac84714d62c729 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Runtime/External/LibTessDotNet/Dict.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d1f51a5b71c3ce943b689d3664e4d5fd +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Runtime/External/LibTessDotNet/Geom.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Runtime/External/LibTessDotNet/Geom.cs new file mode 100644 index 0000000000000000000000000000000000000000..b4b3b2d362a9a1acafc5ab05df036b58cd2d6d4c --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Runtime/External/LibTessDotNet/Geom.cs @@ -0,0 +1,301 @@ +/* +** SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) +** Copyright (C) 2011 Silicon Graphics, Inc. +** All Rights Reserved. +** +** Permission is hereby granted, free of charge, to any person obtaining a copy +** of this software and associated documentation files (the "Software"), to deal +** in the Software without restriction, including without limitation the rights +** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +** of the Software, and to permit persons to whom the Software is furnished to do so, +** subject to the following conditions: +** +** The above copyright notice including the dates of first publication and either this +** permission notice or a reference to http://oss.sgi.com/projects/FreeB/ shall be +** included in all copies or substantial portions of the Software. +** +** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +** INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +** PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL SILICON GRAPHICS, INC. +** BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +** OR OTHER DEALINGS IN THE SOFTWARE. +** +** Except as contained in this notice, the name of Silicon Graphics, Inc. shall not +** be used in advertising or otherwise to promote the sale, use or other dealings in +** this Software without prior written authorization from Silicon Graphics, Inc. +*/ +/* +** Original Author: Eric Veach, July 1994. +** libtess2: Mikko Mononen, http://code.google.com/p/libtess2/. +** LibTessDotNet: Remi Gillig, https://github.com/speps/LibTessDotNet +*/ + +using System; +using System.Diagnostics; + +namespace Unity.SpriteShape.External +{ + +using Real = System.Single; +namespace LibTessDotNet +{ + internal static class Geom + { + public static bool IsWindingInside(WindingRule rule, int n) + { + switch (rule) + { + case WindingRule.EvenOdd: + return (n & 1) == 1; + case WindingRule.NonZero: + return n != 0; + case WindingRule.Positive: + return n > 0; + case WindingRule.Negative: + return n < 0; + case WindingRule.AbsGeqTwo: + return n >= 2 || n <= -2; + } + throw new Exception("Wrong winding rule"); + } + + public static bool VertCCW(MeshUtils.Vertex u, MeshUtils.Vertex v, MeshUtils.Vertex w) + { + return (u._s * (v._t - w._t) + v._s * (w._t - u._t) + w._s * (u._t - v._t)) >= 0.0f; + } + public static bool VertEq(MeshUtils.Vertex lhs, MeshUtils.Vertex rhs) + { + return lhs._s == rhs._s && lhs._t == rhs._t; + } + public static bool VertLeq(MeshUtils.Vertex lhs, MeshUtils.Vertex rhs) + { + return (lhs._s < rhs._s) || (lhs._s == rhs._s && lhs._t <= rhs._t); + } + + /// + /// Given three vertices u,v,w such that VertLeq(u,v) && VertLeq(v,w), + /// evaluates the t-coord of the edge uw at the s-coord of the vertex v. + /// Returns v->t - (uw)(v->s), ie. the signed distance from uw to v. + /// If uw is vertical (and thus passes thru v), the result is zero. + /// + /// The calculation is extremely accurate and stable, even when v + /// is very close to u or w. In particular if we set v->t = 0 and + /// let r be the negated result (this evaluates (uw)(v->s)), then + /// r is guaranteed to satisfy MIN(u->t,w->t) <= r <= MAX(u->t,w->t). + /// + public static Real EdgeEval(MeshUtils.Vertex u, MeshUtils.Vertex v, MeshUtils.Vertex w) + { + Debug.Assert(VertLeq(u, v) && VertLeq(v, w)); + + var gapL = v._s - u._s; + var gapR = w._s - v._s; + + if (gapL + gapR > 0.0f) + { + if (gapL < gapR) + { + return (v._t - u._t) + (u._t - w._t) * (gapL / (gapL + gapR)); + } + else + { + return (v._t - w._t) + (w._t - u._t) * (gapR / (gapL + gapR)); + } + } + /* vertical line */ + return 0; + } + + /// + /// Returns a number whose sign matches EdgeEval(u,v,w) but which + /// is cheaper to evaluate. Returns > 0, == 0 , or < 0 + /// as v is above, on, or below the edge uw. + /// + public static Real EdgeSign(MeshUtils.Vertex u, MeshUtils.Vertex v, MeshUtils.Vertex w) + { + Debug.Assert(VertLeq(u, v) && VertLeq(v, w)); + + var gapL = v._s - u._s; + var gapR = w._s - v._s; + + if (gapL + gapR > 0.0f) + { + return (v._t - w._t) * gapL + (v._t - u._t) * gapR; + } + /* vertical line */ + return 0; + } + + public static bool TransLeq(MeshUtils.Vertex lhs, MeshUtils.Vertex rhs) + { + return (lhs._t < rhs._t) || (lhs._t == rhs._t && lhs._s <= rhs._s); + } + + public static Real TransEval(MeshUtils.Vertex u, MeshUtils.Vertex v, MeshUtils.Vertex w) + { + Debug.Assert(TransLeq(u, v) && TransLeq(v, w)); + + var gapL = v._t - u._t; + var gapR = w._t - v._t; + + if (gapL + gapR > 0.0f) + { + if (gapL < gapR) + { + return (v._s - u._s) + (u._s - w._s) * (gapL / (gapL + gapR)); + } + else + { + return (v._s - w._s) + (w._s - u._s) * (gapR / (gapL + gapR)); + } + } + /* vertical line */ + return 0; + } + + public static Real TransSign(MeshUtils.Vertex u, MeshUtils.Vertex v, MeshUtils.Vertex w) + { + Debug.Assert(TransLeq(u, v) && TransLeq(v, w)); + + var gapL = v._t - u._t; + var gapR = w._t - v._t; + + if (gapL + gapR > 0.0f) + { + return (v._s - w._s) * gapL + (v._s - u._s) * gapR; + } + /* vertical line */ + return 0; + } + + public static bool EdgeGoesLeft(MeshUtils.Edge e) + { + return VertLeq(e._Dst, e._Org); + } + + public static bool EdgeGoesRight(MeshUtils.Edge e) + { + return VertLeq(e._Org, e._Dst); + } + + public static Real VertL1dist(MeshUtils.Vertex u, MeshUtils.Vertex v) + { + return Math.Abs(u._s - v._s) + Math.Abs(u._t - v._t); + } + + public static void AddWinding(MeshUtils.Edge eDst, MeshUtils.Edge eSrc) + { + eDst._winding += eSrc._winding; + eDst._Sym._winding += eSrc._Sym._winding; + } + + public static Real Interpolate(Real a, Real x, Real b, Real y) + { + if (a < 0.0f) + { + a = 0.0f; + } + if (b < 0.0f) + { + b = 0.0f; + } + return ((a <= b) ? ((b == 0.0f) ? ((x+y) / 2.0f) + : (x + (y-x) * (a/(a+b)))) + : (y + (x-y) * (b/(a+b)))); + } + + static void Swap(ref MeshUtils.Vertex a, ref MeshUtils.Vertex b) + { + var tmp = a; + a = b; + b = tmp; + } + + /// + /// Given edges (o1,d1) and (o2,d2), compute their point of intersection. + /// The computed point is guaranteed to lie in the intersection of the + /// bounding rectangles defined by each edge. + /// + public static void EdgeIntersect(MeshUtils.Vertex o1, MeshUtils.Vertex d1, MeshUtils.Vertex o2, MeshUtils.Vertex d2, MeshUtils.Vertex v) + { + // This is certainly not the most efficient way to find the intersection + // of two line segments, but it is very numerically stable. + // + // Strategy: find the two middle vertices in the VertLeq ordering, + // and interpolate the intersection s-value from these. Then repeat + // using the TransLeq ordering to find the intersection t-value. + + if (!VertLeq(o1, d1)) { Swap(ref o1, ref d1); } + if (!VertLeq(o2, d2)) { Swap(ref o2, ref d2); } + if (!VertLeq(o1, o2)) { Swap(ref o1, ref o2); Swap(ref d1, ref d2); } + + if (!VertLeq(o2, d1)) + { + // Technically, no intersection -- do our best + v._s = (o2._s + d1._s) / 2.0f; + } + else if (VertLeq(d1, d2)) + { + // Interpolate between o2 and d1 + var z1 = EdgeEval(o1, o2, d1); + var z2 = EdgeEval(o2, d1, d2); + if (z1 + z2 < 0.0f) + { + z1 = -z1; + z2 = -z2; + } + v._s = Interpolate(z1, o2._s, z2, d1._s); + } + else + { + // Interpolate between o2 and d2 + var z1 = EdgeSign(o1, o2, d1); + var z2 = -EdgeSign(o1, d2, d1); + if (z1 + z2 < 0.0f) + { + z1 = -z1; + z2 = -z2; + } + v._s = Interpolate(z1, o2._s, z2, d2._s); + } + + // Now repeat the process for t + + if (!TransLeq(o1, d1)) { Swap(ref o1, ref d1); } + if (!TransLeq(o2, d2)) { Swap(ref o2, ref d2); } + if (!TransLeq(o1, o2)) { Swap(ref o1, ref o2); Swap(ref d1, ref d2); } + + if (!TransLeq(o2, d1)) + { + // Technically, no intersection -- do our best + v._t = (o2._t + d1._t) / 2.0f; + } + else if (TransLeq(d1, d2)) + { + // Interpolate between o2 and d1 + var z1 = TransEval(o1, o2, d1); + var z2 = TransEval(o2, d1, d2); + if (z1 + z2 < 0.0f) + { + z1 = -z1; + z2 = -z2; + } + v._t = Interpolate(z1, o2._t, z2, d1._t); + } + else + { + // Interpolate between o2 and d2 + var z1 = TransSign(o1, o2, d1); + var z2 = -TransSign(o1, d2, d1); + if (z1 + z2 < 0.0f) + { + z1 = -z1; + z2 = -z2; + } + v._t = Interpolate(z1, o2._t, z2, d2._t); + } + } + } +} + +} // namespace Unity.VectorGraphics.External \ No newline at end of file diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Runtime/External/LibTessDotNet/Geom.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Runtime/External/LibTessDotNet/Geom.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..6b342c1c96c920172458bd4ad0b16df916f880c3 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Runtime/External/LibTessDotNet/Geom.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8eb4e2609b653584b88dc0ee64a2ba24 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Runtime/External/LibTessDotNet/LICENSE.txt b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Runtime/External/LibTessDotNet/LICENSE.txt new file mode 100644 index 0000000000000000000000000000000000000000..74eabd94a8caf189f38fad64c2e0ee6d44c5e496 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Runtime/External/LibTessDotNet/LICENSE.txt @@ -0,0 +1,25 @@ +** SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) +** Copyright (C) 2011 Silicon Graphics, Inc. +** All Rights Reserved. +** +** Permission is hereby granted, free of charge, to any person obtaining a copy +** of this software and associated documentation files (the "Software"), to deal +** in the Software without restriction, including without limitation the rights +** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +** of the Software, and to permit persons to whom the Software is furnished to do so, +** subject to the following conditions: +** +** The above copyright notice including the dates of first publication and either this +** permission notice or a reference to http://oss.sgi.com/projects/FreeB/ shall be +** included in all copies or substantial portions of the Software. +** +** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +** INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +** PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL SILICON GRAPHICS, INC. +** BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +** OR OTHER DEALINGS IN THE SOFTWARE. +** +** Except as contained in this notice, the name of Silicon Graphics, Inc. shall not +** be used in advertising or otherwise to promote the sale, use or other dealings in +** this Software without prior written authorization from Silicon Graphics, Inc. diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Runtime/UTess2D/ArraySlice.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Runtime/UTess2D/ArraySlice.cs new file mode 100644 index 0000000000000000000000000000000000000000..c7a9d9e2bc13a9f7f7dfb2d56495e55d8145e65c --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Runtime/UTess2D/ArraySlice.cs @@ -0,0 +1,165 @@ +using System; +using System.Diagnostics; +using System.Runtime.InteropServices; +using Unity.Collections; +using Unity.Collections.LowLevel.Unsafe; + +namespace UnityEngine.U2D +{ + + namespace UTess + { + + [StructLayout(LayoutKind.Sequential)] + [DebuggerDisplay("Length = {Length}")] + internal unsafe struct ArraySlice : System.IEquatable> where T : struct + { + [NativeDisableUnsafePtrRestriction] internal byte* m_Buffer; + internal int m_Stride; + internal int m_Length; + +#if ENABLE_UNITY_COLLECTIONS_CHECKS + internal int m_MinIndex; + internal int m_MaxIndex; + internal AtomicSafetyHandle m_Safety; +#endif + + public ArraySlice(NativeArray array, int start, int length) + { +#if ENABLE_UNITY_COLLECTIONS_CHECKS + if (start < 0) + throw new ArgumentOutOfRangeException(nameof(start), $"Slice start {start} < 0."); + if (length < 0) + throw new ArgumentOutOfRangeException(nameof(length), $"Slice length {length} < 0."); + if (start + length > array.Length) + throw new ArgumentException( + $"Slice start + length ({start + length}) range must be <= array.Length ({array.Length})"); + m_MinIndex = 0; + m_MaxIndex = length - 1; + m_Safety = Unity.Collections.LowLevel.Unsafe.NativeArrayUnsafeUtility.GetAtomicSafetyHandle(array); +#endif + + m_Stride = UnsafeUtility.SizeOf(); + var ptr = (byte*) array.GetUnsafePtr() + m_Stride * start; + m_Buffer = ptr; + m_Length = length; + } + + public bool Equals(ArraySlice other) + { + return m_Buffer == other.m_Buffer && m_Stride == other.m_Stride && m_Length == other.m_Length; + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + return obj is ArraySlice && Equals((ArraySlice) obj); + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = (int) m_Buffer; + hashCode = (hashCode * 397) ^ m_Stride; + hashCode = (hashCode * 397) ^ m_Length; + return hashCode; + } + } + + public static bool operator ==(ArraySlice left, ArraySlice right) + { + return left.Equals(right); + } + + public static bool operator !=(ArraySlice left, ArraySlice right) + { + return !left.Equals(right); + } + +#if ENABLE_UNITY_COLLECTIONS_CHECKS + // These are double-whammy excluded to we can elide bounds checks in the Burst disassembly view + [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS")] + void CheckReadIndex(int index) + { +#if ENABLE_UNITY_COLLECTIONS_CHECKS + if (index < m_MinIndex || index > m_MaxIndex) + FailOutOfRangeError(index); +#endif + } + + [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS")] + void CheckWriteIndex(int index) + { +#if ENABLE_UNITY_COLLECTIONS_CHECKS + if (index < m_MinIndex || index > m_MaxIndex) + FailOutOfRangeError(index); +#endif + } + + [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS")] + private void FailOutOfRangeError(int index) + { + if (index < Length && (m_MinIndex != 0 || m_MaxIndex != Length - 1)) + throw new System.IndexOutOfRangeException( + $"Index {index} is out of restricted IJobParallelFor range [{m_MinIndex}...{m_MaxIndex}] in ReadWriteBuffer.\n" + + "ReadWriteBuffers are restricted to only read & write the element at the job index. " + + "You can use double buffering strategies to avoid race conditions due to " + + "reading & writing in parallel to the same elements from a job."); + + throw new System.IndexOutOfRangeException($"Index {index} is out of range of '{Length}' Length."); + } + +#endif + + public static unsafe ArraySlice ConvertExistingDataToArraySlice(void* dataPointer, int stride, int length) + { + if (length < 0) + throw new System.ArgumentException($"Invalid length of '{length}'. It must be greater than 0.", + nameof(length)); + if (stride < 0) + throw new System.ArgumentException($"Invalid stride '{stride}'. It must be greater than 0.", + nameof(stride)); + + var newSlice = new ArraySlice + { + m_Stride = stride, + m_Buffer = (byte*) dataPointer, + m_Length = length, +#if ENABLE_UNITY_COLLECTIONS_CHECKS + m_MinIndex = 0, + m_MaxIndex = length - 1, +#endif + }; + + return newSlice; + } + + public T this[int index] + { + get + { +#if ENABLE_UNITY_COLLECTIONS_CHECKS + CheckReadIndex(index); +#endif + return UnsafeUtility.ReadArrayElementWithStride(m_Buffer, index, m_Stride); + } + + [WriteAccessRequired] + set + { +#if ENABLE_UNITY_COLLECTIONS_CHECKS + CheckWriteIndex(index); +#endif + UnsafeUtility.WriteArrayElementWithStride(m_Buffer, index, m_Stride, value); + } + } + + public int Stride => m_Stride; + public int Length => m_Length; + + } + + } + +} \ No newline at end of file diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Runtime/UTess2D/ArraySlice.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Runtime/UTess2D/ArraySlice.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..44efd31b21266f7e5248493bd6021cb0cac1f13b --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Runtime/UTess2D/ArraySlice.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 39b2d71389cf61842bdac5523826301a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Runtime/UTess2D/Tessellator.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Runtime/UTess2D/Tessellator.cs new file mode 100644 index 0000000000000000000000000000000000000000..b7d623e1d2bd458719a944c266008bb144a4c0ac --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Runtime/UTess2D/Tessellator.cs @@ -0,0 +1,1117 @@ +using System; +using System.Collections.Generic; +using Unity.Collections; +using Unity.Mathematics; +using Unity.Collections.LowLevel.Unsafe; + +namespace UnityEngine.U2D +{ + + namespace UTess + { + + enum TessEventType + { + EVENT_POINT = 0, + EVENT_END = 1, + EVENT_START = 2, + }; + + struct TessEdge + { + public int a; + public int b; + }; + + struct TessEvent + { + public float2 a; + public float2 b; + public int idx; + public int type; + }; + + struct TessHull + { + public float2 a; + public float2 b; + public int idx; + + public ArraySlice ilarray; + public int ilcount; + public ArraySlice iuarray; + public int iucount; + }; + + struct TessCell + { + public int a; + public int b; + public int c; + }; + + struct TessStar + { + public ArraySlice points; + public int pointCount; + }; + + internal struct TessUtils + { + + // From https://www.cs.cmu.edu/afs/cs/project/quake/public/code/predicates.c and is public domain. Can't find one within Unity. + public static float OrientFast(float2 a, float2 b, float2 c) + { + float epsilon = 1.1102230246251565e-16f; + float errbound3 = (3.0f + 16.0f * epsilon) * epsilon; + float l = (a.y - c.y) * (b.x - c.x); + float r = (a.x - c.x) * (b.y - c.y); + float det = l - r; + float s = 0; + if (l > 0) + { + if (r <= 0) + { + return det; + } + else + { + s = l + r; + } + } + else if (l < 0) + { + if (r >= 0) + { + return det; + } + else + { + s = -(l + r); + } + } + else + { + return det; + } + + float tol = errbound3 * s; + if (det >= tol || det <= -tol) + { + return det; + } + + return epsilon; + } + + public static float Norm(float2 cV) + { + return cV.x * cV.x + cV.y * cV.y; + } + + public static float Dist(float2 cV1, float2 cV2) + { + return (cV1.x - cV2.x) * (cV1.x - cV2.x) + (cV1.y - cV2.y) * (cV1.y - cV2.y); + } + public static bool IsInsideCircle(float2 a, float2 b, float2 c, float2 p) + { + float ab = Norm(a); + float cd = Norm(b); + float ef = Norm(c); + + float ax = a.x; + float ay = a.y; + float bx = b.x; + float by = b.y; + float cx = c.x; + float cy = c.y; + + float circum_x = (ab * (cy - by) + cd * (ay - cy) + ef * (by - ay)) / + (ax * (cy - by) + bx * (ay - cy) + cx * (by - ay)); + float circum_y = (ab * (cx - bx) + cd * (ax - cx) + ef * (bx - ax)) / + (ay * (cx - bx) + by * (ax - cx) + cy * (bx - ax)); + + float2 circum = new float2(); + circum.x = circum_x / 2; + circum.y = circum_y / 2; + float circum_radius = Dist(a, circum); + float dist = Dist(p, circum); + return circum_radius - dist > 0.00001f; + } + + public unsafe static void InsertionSort(void* array, int lo, int hi, U comp) + where T : struct where U : IComparer + { + int i, j; + T t; + for (i = lo; i < hi; i++) + { + j = i; + t = UnsafeUtility.ReadArrayElement(array, i + 1); + while (j >= lo && comp.Compare(t, UnsafeUtility.ReadArrayElement(array, j)) < 0) + { + UnsafeUtility.WriteArrayElement(array, j + 1, UnsafeUtility.ReadArrayElement(array, j)); + j--; + } + + UnsafeUtility.WriteArrayElement(array, j + 1, t); + } + } + + } + + struct TessEventCompare : IComparer + { + public int Compare(TessEvent a, TessEvent b) + { + float f = (a.a.x - b.a.x); + if (0 != f) + return (f > 0) ? 1 : -1; + + f = (a.a.y - b.a.y); + if (0 != f) + return (f > 0) ? 1 : -1; + + int i = a.type - b.type; + if (0 != i) + return i; + + if (a.type != (int) TessEventType.EVENT_POINT) + { + float o = TessUtils.OrientFast(a.a, a.b, b.b); + if (0 != o) + { + return (o > 0) ? 1 : -1; + } + } + + return a.idx - b.idx; + } + } + + struct TessEdgeCompare : IComparer + { + public int Compare(TessEdge a, TessEdge b) + { + int i = a.a - b.a; + if (0 != i) + return i; + i = a.b - b.b; + return i; + } + } + + struct TessCellCompare : IComparer + { + public int Compare(TessCell a, TessCell b) + { + int i = a.a - b.a; + if (0 != i) + return i; + i = a.b - b.b; + if (0 != i) + return i; + i = a.c - b.c; + return i; + } + } + + internal struct Tessellator + { + // For Processing. + NativeArray m_Edges; + NativeArray m_Stars; + NativeArray m_Cells; + int m_CellCount; + + // For Storage. + NativeArray m_ILArray; + NativeArray m_IUArray; + NativeArray m_SPArray; + int m_NumPoints; + int m_StarCount; + + // Intermediates. + NativeArray m_Flags; + NativeArray m_Neighbors; + NativeArray m_Constraints; + + static float TestPoint(TessHull hull, float2 point) + { + return TessUtils.OrientFast(hull.a, hull.b, point); + } + + static int GetLowerHullForVector(NativeArray hulls, int hullCount, float2 p) + { + int i; + int l = 0; + int h = hullCount - 1; + i = l - 1; + while (l <= h) + { + int m; + m = ((int) (l + h)) >> 1; + if (TestPoint(hulls[m], p) < 0) + { + i = m; + l = m + 1; + } + else + h = m - 1; + } + + return i; + } + + static int GetUpperHullForVector(NativeArray hulls, int hullCount, float2 p) + { + int i; + int l = 0; + int h = hullCount - 1; + i = h + 1; + while (l <= h) + { + int m; + m = ((int) (l + h)) >> 1; + if (TestPoint(hulls[m], p) > 0) + { + i = m; + h = m - 1; + } + else + l = m + 1; + } + + return i; + } + + static float FindSplit(TessHull hull, TessEvent edge) + { + float d = 0; + if (hull.a.x < edge.a.x) + { + d = TessUtils.OrientFast(hull.a, hull.b, edge.a); + } + else + { + d = TessUtils.OrientFast(edge.b, edge.a, hull.a); + } + + if (0 != d) + { + return d; + } + + if (edge.b.x < hull.b.x) + { + d = TessUtils.OrientFast(hull.a, hull.b, edge.b); + } + else + { + d = TessUtils.OrientFast(edge.b, edge.a, hull.b); + } + + if (0 != d) + { + return d; + } + + return hull.idx - edge.idx; + } + + static int GetLowerEqualHullForEvent(NativeArray hulls, int hullCount, TessEvent p) + { + int i; + int l = 0; + int h = hullCount - 1; + i = l - 1; + while (l <= h) + { + int m; + m = ((int) (l + h)) >> 1; + if (FindSplit(hulls[m], p) <= 0) + { + i = m; + l = m + 1; + } + else + h = m - 1; + } + + return i; + } + + static int GetEqualHullForEvent(NativeArray hulls, int hullCount, TessEvent p) + { + int l = 0; + int h = hullCount - 1; + while (l <= h) + { + int m; + m = ((int) (l + h)) >> 1; + float f = FindSplit(hulls[m], p); + if (f == 0) + { + return m; + } + else if (f <= 0) + { + l = m + 1; + } + else + h = m - 1; + } + + return -1; + } + + void AddPoint(NativeArray hulls, int hullCount, NativeArray points, float2 p, + int idx) + { + int l = GetLowerHullForVector(hulls, hullCount, p); + int u = GetUpperHullForVector(hulls, hullCount, p); + for (int i = l; i < u; ++i) + { + TessHull hull = hulls[i]; + + int m = hull.ilcount; + while (m > 1 && TessUtils.OrientFast(points[hull.ilarray[m - 2]], points[hull.ilarray[m - 1]], p) > + 0) + { + TessCell c = new TessCell(); + c.a = hull.ilarray[m - 1]; + c.b = hull.ilarray[m - 2]; + c.c = idx; + m_Cells[m_CellCount++] = c; + m -= 1; + } + + hull.ilcount = m + 1; + hull.ilarray[m] = idx; + + m = hull.iucount; + while (m > 1 && TessUtils.OrientFast(points[hull.iuarray[m - 2]], points[hull.iuarray[m - 1]], p) < + 0) + { + TessCell c = new TessCell(); + c.a = hull.iuarray[m - 2]; + c.b = hull.iuarray[m - 1]; + c.c = idx; + m_Cells[m_CellCount++] = c; + m -= 1; + } + + hull.iucount = m + 1; + hull.iuarray[m] = idx; + + hulls[i] = hull; + } + } + + static void InsertHull(NativeArray Hulls, int Pos, ref int Count, TessHull Value) + { + if (Count < Hulls.Length - 1) + { + for (int i = Count; i > Pos; --i) + Hulls[i] = Hulls[i - 1]; + Hulls[Pos] = Value; + Count++; + } + } + + static void EraseHull(NativeArray Hulls, int Pos, ref int Count) + { + if (Count < Hulls.Length) + { + for (int i = Pos; i < Count - 1; ++i) + Hulls[i] = Hulls[i + 1]; + Count--; + } + } + + void SplitHulls(NativeArray hulls, ref int hullCount, NativeArray points, + TessEvent evt) + { + int index = GetLowerEqualHullForEvent(hulls, hullCount, evt); + TessHull hull = hulls[index]; + + TessHull newHull; + newHull.a = evt.a; + newHull.b = evt.b; + newHull.idx = evt.idx; + + int y = hull.iuarray[hull.iucount - 1]; + newHull.iuarray = new ArraySlice(m_IUArray, newHull.idx * m_NumPoints, m_NumPoints); + newHull.iucount = hull.iucount; + for (int i = 0; i < newHull.iucount; ++i) + newHull.iuarray[i] = hull.iuarray[i]; + hull.iuarray[0] = y; + hull.iucount = 1; + hulls[index] = hull; + + newHull.ilarray = new ArraySlice(m_ILArray, newHull.idx * m_NumPoints, m_NumPoints); + newHull.ilarray[0] = y; + newHull.ilcount = 1; + + InsertHull(hulls, index + 1, ref hullCount, newHull); + } + + void MergeHulls(NativeArray hulls, ref int hullCount, NativeArray points, + TessEvent evt) + { + float2 temp = evt.a; + evt.a = evt.b; + evt.b = temp; + int index = GetEqualHullForEvent(hulls, hullCount, evt); + + TessHull upper = hulls[index]; + TessHull lower = hulls[index - 1]; + + lower.iucount = upper.iucount; + for (int i = 0; i < lower.iucount; ++i) + lower.iuarray[i] = upper.iuarray[i]; + + hulls[index - 1] = lower; + EraseHull(hulls, index, ref hullCount); + } + + internal void Triangulate(NativeArray points, NativeArray edgesIn) + { + int numEdges = edgesIn.Length; + const int kStarEdges = 16; + + m_NumPoints = points.Length; + m_StarCount = m_NumPoints > kStarEdges ? m_NumPoints : kStarEdges; + m_StarCount = m_StarCount * 2; + m_CellCount = 0; + m_Cells = new NativeArray(m_NumPoints * (m_NumPoints + 1), Allocator.Temp); + m_ILArray = new NativeArray(m_NumPoints * (m_NumPoints + 1), Allocator.Temp); // Make room for -1 node. + m_IUArray = new NativeArray(m_NumPoints * (m_NumPoints + 1), Allocator.Temp); // Make room for -1 node. + m_SPArray = new NativeArray(m_NumPoints * (m_StarCount), Allocator.Temp); // Make room for -1 node. + + NativeArray hulls = new NativeArray(m_NumPoints * 8, Allocator.Temp); + int hullCount = 0; + + NativeArray events = new NativeArray(m_NumPoints + (numEdges * 2), Allocator.Temp); + int eventCount = 0; + + for (int i = 0; i < m_NumPoints; ++i) + { + TessEvent evt = new TessEvent(); + evt.a = points[i]; + evt.b = new float2(); + evt.idx = i; + evt.type = (int) TessEventType.EVENT_POINT; + events[eventCount++] = evt; + } + + for (int i = 0; i < numEdges; ++i) + { + TessEdge e = edgesIn[i]; + float2 a = points[e.a]; + float2 b = points[e.b]; + if (a.x < b.x) + { + TessEvent _s = new TessEvent(); + _s.a = a; + _s.b = b; + _s.idx = i; + _s.type = (int) TessEventType.EVENT_START; + + TessEvent _e = new TessEvent(); + _e.a = b; + _e.b = a; + _e.idx = i; + _e.type = (int) TessEventType.EVENT_END; + + events[eventCount++] = _s; + events[eventCount++] = _e; + } + else if (a.x > b.x) + { + TessEvent _s = new TessEvent(); + _s.a = b; + _s.b = a; + _s.idx = i; + _s.type = (int) TessEventType.EVENT_START; + + TessEvent _e = new TessEvent(); + _e.a = a; + _e.b = b; + _e.idx = i; + _e.type = (int) TessEventType.EVENT_END; + + events[eventCount++] = _s; + events[eventCount++] = _e; + } + } + + unsafe + { + TessUtils.InsertionSort( + NativeArrayUnsafeUtility.GetUnsafeBufferPointerWithoutChecks(events), 0, eventCount - 1, + new TessEventCompare()); + ; + } + + float minX = events[0].a.x - (1 + math.abs(events[0].a.x)) * math.pow(2.0f, -16.0f); + TessHull hull; + hull.a.x = minX; + hull.a.y = 1; + hull.b.x = minX; + hull.b.y = 0; + hull.idx = -1; + hull.ilarray = new ArraySlice(m_ILArray, m_NumPoints * m_NumPoints, m_NumPoints); // Last element + hull.iuarray = new ArraySlice(m_IUArray, m_NumPoints * m_NumPoints, m_NumPoints); + hull.ilcount = 0; + hull.iucount = 0; + hulls[hullCount++] = hull; + + for (int i = 0, numEvents = eventCount; i < numEvents; ++i) + { + switch (events[i].type) + { + case (int) TessEventType.EVENT_POINT: + { + AddPoint(hulls, hullCount, points, events[i].a, events[i].idx); + } + break; + + case (int) TessEventType.EVENT_START: + { + SplitHulls(hulls, ref hullCount, points, events[i]); + } + break; + + default: + { + MergeHulls(hulls, ref hullCount, points, events[i]); + } + break; + } + } + + hulls.Dispose(); + events.Dispose(); + } + + + void Prepare(NativeArray edgesIn) + { + m_Stars = new NativeArray(edgesIn.Length, Allocator.Temp); + + for (int i = 0; i < edgesIn.Length; ++i) + { + TessEdge e = edgesIn[i]; + e.a = (edgesIn[i].a < edgesIn[i].b) ? edgesIn[i].a : edgesIn[i].b; + e.b = (edgesIn[i].a > edgesIn[i].b) ? edgesIn[i].a : edgesIn[i].b; + edgesIn[i] = e; + TessStar s = m_Stars[i]; + s.points = new ArraySlice(m_SPArray, i * m_StarCount, m_StarCount); + s.pointCount = 0; + m_Stars[i] = s; + } + + unsafe + { + TessUtils.InsertionSort( + NativeArrayUnsafeUtility.GetUnsafeBufferPointerWithoutChecks(edgesIn), 0, edgesIn.Length - 1, + new TessEdgeCompare()); + } + + m_Edges = new NativeArray(edgesIn.Length, Allocator.Temp); + m_Edges.CopyFrom(edgesIn); + + // Fill stars. + for (int i = 0; i < m_CellCount; ++i) + { + int a = m_Cells[i].a; + int b = m_Cells[i].b; + int c = m_Cells[i].c; + TessStar sa = m_Stars[a]; + TessStar sb = m_Stars[b]; + TessStar sc = m_Stars[c]; + sa.points[sa.pointCount++] = b; + sa.points[sa.pointCount++] = c; + sb.points[sb.pointCount++] = c; + sb.points[sb.pointCount++] = a; + sc.points[sc.pointCount++] = a; + sc.points[sc.pointCount++] = b; + m_Stars[a] = sa; + m_Stars[b] = sb; + m_Stars[c] = sc; + } + } + + int OppositeOf(int a, int b) + { + ArraySlice points = m_Stars[b].points; + for (int k = 1, n = m_Stars[b].pointCount; k < n; k += 2) + { + if (points[k] == a) + { + return points[k - 1]; + } + } + + return -1; + } + + static int GetEqualHullForEdges(NativeArray edges, TessEdge p) + { + int l = 0; + int h = edges.Length - 1; + TessEdgeCompare tec = new TessEdgeCompare(); + while (l <= h) + { + int m; + m = ((int) (l + h)) >> 1; + int f = tec.Compare(edges[m], p); + if (f == 0) + { + return m; + } + else if (f <= 0) + { + l = m + 1; + } + else + h = m - 1; + } + + return -1; + } + + int FindConstraint(int a, int b) + { + TessEdge e; + e.a = a < b ? a : b; + e.b = a > b ? a : b; + return GetEqualHullForEdges(m_Edges, e); + } + + void AddTriangle(int i, int j, int k) + { + TessStar si = m_Stars[i]; + TessStar sj = m_Stars[j]; + TessStar sk = m_Stars[k]; + si.points[si.pointCount++] = j; + si.points[si.pointCount++] = k; + sj.points[sj.pointCount++] = k; + sj.points[sj.pointCount++] = i; + sk.points[sk.pointCount++] = i; + sk.points[sk.pointCount++] = j; + m_Stars[i] = si; + m_Stars[j] = sj; + m_Stars[k] = sk; + } + + void RemovePair(int r, int j, int k) + { + TessStar s = m_Stars[r]; + ArraySlice points = s.points; + for (int i = 1, n = s.pointCount; i < n; i += 2) + { + if (points[i - 1] == j && points[i] == k) + { + points[i - 1] = points[n - 2]; + points[i] = points[n - 1]; + s.points = points; + s.pointCount = s.pointCount - 2; + m_Stars[r] = s; + return; + } + } + } + + void RemoveTriangle(int i, int j, int k) + { + RemovePair(i, j, k); + RemovePair(j, k, i); + RemovePair(k, i, j); + } + + void EdgeFlip(int i, int j) + { + int a = OppositeOf(i, j); + int b = OppositeOf(j, i); + RemoveTriangle(i, j, a); + RemoveTriangle(j, i, b); + AddTriangle(i, b, a); + AddTriangle(j, a, b); + } + + void Flip(NativeArray points, ref NativeArray stack, ref int stackCount, + int a, int b, int x) + { + int y = OppositeOf(a, b); + + if (y < 0) + { + return; + } + + if (b < a) + { + int tmp = a; + a = b; + b = tmp; + tmp = x; + x = y; + y = tmp; + } + + if (FindConstraint(a, b) != -1) + { + return; + } + + if (TessUtils.IsInsideCircle(points[a], points[b], points[x], points[y])) + { + stack[stackCount++] = a; + stack[stackCount++] = b; + } + } + + NativeArray GetCells(ref int count) + { + NativeArray cellsOut = new NativeArray(m_NumPoints * (m_NumPoints + 1), Allocator.Temp); + count = 0; + for (int i = 0, n = m_Stars.Length; i < n; ++i) + { + ArraySlice points = m_Stars[i].points; + for (int j = 0, m = m_Stars[i].pointCount; j < m; j += 2) + { + int s = points[j]; + int t = points[j + 1]; + if (i < math.min(s, t)) + { + TessCell c = new TessCell(); + c.a = i; + c.b = s; + c.c = t; + cellsOut[count++] = c; + } + } + } + + return cellsOut; + } + + internal void ApplyDelaunay(NativeArray points, NativeArray edgesIn) + { + + NativeArray stack = new NativeArray(m_NumPoints * (m_NumPoints + 1), Allocator.Temp); + int stackCount = 0; + + Prepare(edgesIn); + for (int a = 0; a < m_NumPoints; ++a) + { + TessStar star = m_Stars[a]; + for (int j = 1; j < star.pointCount; j += 2) + { + int b = star.points[j]; + + if (b < a) + { + continue; + } + + if (FindConstraint(a, b) >= 0) + { + continue; + } + + int x = star.points[j - 1], y = -1; + for (int k = 1; k < star.pointCount; k += 2) + { + if (star.points[k - 1] == b) + { + y = star.points[k]; + break; + } + } + + if (y < 0) + { + continue; + } + + if (TessUtils.IsInsideCircle(points[a], points[b], points[x], points[y])) + { + stack[stackCount++] = a; + stack[stackCount++] = b; + } + } + } + + while (stackCount > 0) + { + int b = stack[stackCount - 1]; + stackCount--; + int a = stack[stackCount - 1]; + stackCount--; + + int x = -1, y = -1; + TessStar star = m_Stars[a]; + for (int i = 1; i < star.pointCount; i += 2) + { + int s = star.points[i - 1]; + int t = star.points[i]; + if (s == b) + { + y = t; + } + else if (t == b) + { + x = s; + } + } + + if (x < 0 || y < 0) + { + continue; + } + + if (!TessUtils.IsInsideCircle(points[a], points[b], points[x], points[y])) + { + continue; + } + + EdgeFlip(a, b); + + Flip(points, ref stack, ref stackCount, x, a, y); + Flip(points, ref stack, ref stackCount, a, y, x); + Flip(points, ref stack, ref stackCount, y, b, x); + Flip(points, ref stack, ref stackCount, b, x, y); + } + + stack.Dispose(); + } + + int GetEqualCellForCells(NativeArray cells, int count, TessCell p) + { + int l = 0; + int h = count - 1; + TessCellCompare tcc = new TessCellCompare(); + while (l <= h) + { + int m; + m = ((int) (l + h)) >> 1; + int f = tcc.Compare(cells[m], p); + if (f == 0) + { + return m; + } + else if (f <= 0) + { + l = m + 1; + } + else + h = m - 1; + } + + return -1; + } + + int FindNeighbor(NativeArray cells, int count, int a, int b, int c) + { + int x = a, y = b, z = c; + if (b < c) + { + if (b < a) + { + x = b; + y = c; + z = a; + } + } + else if (c < a) + { + x = c; + y = a; + z = b; + } + + if (x < 0) + { + return -1; + } + + TessCell key; + key.a = x; + key.b = y; + key.c = z; + return GetEqualCellForCells(cells, count, key); + } + + NativeArray Constrain(ref int count) + { + var cells = GetCells(ref count); + int nc = count; + for (int i = 0; i < nc; ++i) + { + TessCell c = cells[i]; + int x = c.a, y = c.b, z = c.c; + if (y < z) + { + if (y < x) + { + c.a = y; + c.b = z; + c.c = x; + } + } + else if (z < x) + { + c.a = z; + c.b = x; + c.c = y; + } + + cells[i] = c; + } + + unsafe + { + TessUtils.InsertionSort( + NativeArrayUnsafeUtility.GetUnsafeBufferPointerWithoutChecks(cells), 0, m_CellCount - 1, + new TessCellCompare()); + } + + // Out + m_Flags = new NativeArray(nc, Allocator.Temp); + m_Neighbors = new NativeArray(nc * 3, Allocator.Temp); + m_Constraints = new NativeArray(nc * 3, Allocator.Temp); + var next = new NativeArray(nc * 3, Allocator.Temp); + var active = new NativeArray(nc * 3, Allocator.Temp); + + int side = 1, nextCount = 0, activeCount = 0; + + for (int i = 0; i < nc; ++i) + { + TessCell c = cells[i]; + for (int j = 0; j < 3; ++j) + { + int x = j, y = (j + 1) % 3; + x = (x == 0) ? c.a : (j == 1) ? c.b : c.c; + y = (y == 0) ? c.a : (y == 1) ? c.b : c.c; + + int o = OppositeOf(y, x); + int a = m_Neighbors[3 * i + j] = FindNeighbor(cells, count, y, x, o); + int b = m_Constraints[3 * i + j] = (-1 != FindConstraint(x, y)) ? 1 : 0; + if (a < 0) + { + if (0 != b) + { + next[nextCount++] = i; + } + else + { + active[activeCount++] = i; + m_Flags[i] = 1; + } + } + } + } + + while (activeCount > 0 || nextCount > 0) + { + while (activeCount > 0) + { + int t = active[activeCount - 1]; + activeCount--; + if (m_Flags[t] == -side) + { + continue; + } + + m_Flags[t] = side; + TessCell c = cells[t]; + for (int j = 0; j < 3; ++j) + { + int f = m_Neighbors[3 * t + j]; + if (f >= 0 && m_Flags[f] == 0) + { + if (0 != m_Constraints[3 * t + j]) + { + next[nextCount++] = f; + } + else + { + active[activeCount++] = f; + m_Flags[f] = side; + } + } + } + } + + for (int e = 0; e < nextCount; e++) + active[e] = next[e]; + activeCount = nextCount; + nextCount = 0; + side = -side; + } + + active.Dispose(); + next.Dispose(); + return cells; + } + + internal NativeArray RemoveExterior(ref int cellCount) + { + int constrainedCount = 0; + NativeArray constrained = Constrain(ref constrainedCount); + + NativeArray cellsOut = new NativeArray(constrainedCount, Allocator.Temp); + cellCount = 0; + for (int i = 0; i < constrainedCount; ++i) + { + if (m_Flags[i] == -1) + { + cellsOut[cellCount++] = constrained[i]; + } + } + + constrained.Dispose(); + return cellsOut; + } + + internal NativeArray RemoveInterior(int cellCount) + { + int constrainedCount = 0; + NativeArray constrained = Constrain(ref constrainedCount); + + NativeArray cellsOut = new NativeArray(constrainedCount, Allocator.Temp); + cellCount = 0; + for (int i = 0; i < constrainedCount; ++i) + { + if (m_Flags[i] == 1) + { + cellsOut[cellCount++] = constrained[i]; + } + } + + constrained.Dispose(); + return cellsOut; + } + + internal void Cleanup() + { + m_Edges.Dispose(); + m_Stars.Dispose(); + m_ILArray.Dispose(); + m_IUArray.Dispose(); + m_SPArray.Dispose(); + m_Cells.Dispose(); + + m_Flags.Dispose(); + m_Neighbors.Dispose(); + m_Constraints.Dispose(); + } + + } + + } + +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Runtime/UTess2D/Tessellator.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Runtime/UTess2D/Tessellator.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..982ed49c6b9798e1b0247f0937cb4ad23680cf36 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Runtime/UTess2D/Tessellator.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d8287b2baa933c3439b7138b01b09648 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scenes/Colliders.unity.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scenes/Colliders.unity.meta new file mode 100644 index 0000000000000000000000000000000000000000..45ea8e4a1ad80aa85773d05032bdc602826f12cb --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scenes/Colliders.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 299e0b891b406a8409a068bd55ee5a1f +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scenes/ConformingSplineScene.unity b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scenes/ConformingSplineScene.unity new file mode 100644 index 0000000000000000000000000000000000000000..a82e3f095e6cc9a0b64523cf23e0b35ba3ae22ee --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scenes/ConformingSplineScene.unity @@ -0,0 +1,528 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_GIWorkflowMode: 0 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 0 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 500 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 500 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 2 + m_PVRDenoiserTypeDirect: 0 + m_PVRDenoiserTypeIndirect: 0 + m_PVRDenoiserTypeAO: 0 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 0 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ShowResolutionOverlay: 1 + m_ExportTrainingData: 0 + m_LightingDataAsset: {fileID: 0} + m_UseShadowmask: 1 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &400039572 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 400039576} + - component: {fileID: 400039575} + - component: {fileID: 400039574} + m_Layer: 0 + m_Name: Top + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &400039574 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 400039572} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 90539df1cd5704abcb25fec9f3f5f84b, type: 3} + m_Name: + m_EditorClassIdentifier: + m_LegacyGenerator: 0 + m_Spline: + m_IsOpenEnded: 1 + m_ControlPoints: + - position: {x: 0.37061024, y: 7.517852, z: 0} + leftTangent: {x: 0, y: 0, z: 0} + rightTangent: {x: 0, y: 0, z: 0} + mode: 0 + height: 1 + bevelCutoff: 0 + bevelSize: 0 + spriteIndex: 0 + corner: 0 + - position: {x: 0.41290092, y: -1.8726089, z: 0} + leftTangent: {x: -3.4678102, y: 1.8794639, z: 0} + rightTangent: {x: 3.4678102, y: -1.8794639, z: 0} + mode: 1 + height: 1 + bevelCutoff: 0 + bevelSize: 0 + spriteIndex: 0 + corner: 0 + - position: {x: 7.9664383, y: -6.63839, z: 0} + leftTangent: {x: -4.8397465, y: -0.030138493, z: 0} + rightTangent: {x: 4.8397465, y: 0.030138493, z: 0} + mode: 1 + height: 1 + bevelCutoff: 0 + bevelSize: 0 + spriteIndex: 0 + corner: 0 + - position: {x: 15, y: -1, z: 0} + leftTangent: {x: -3.2519875, y: -2.4569178, z: 0} + rightTangent: {x: 3.2519875, y: 2.4569178, z: 0} + mode: 1 + height: 1 + bevelCutoff: 0 + bevelSize: 0 + spriteIndex: 0 + corner: 0 + - position: {x: 14.186232, y: 7.786347, z: 0} + leftTangent: {x: 0, y: 0, z: 0} + rightTangent: {x: 0, y: 0, z: 0} + mode: 0 + height: 1 + bevelCutoff: 0 + bevelSize: 0 + spriteIndex: 0 + corner: 0 + m_SpriteShape: {fileID: 11400000, guid: 541c57e7ddb8adc46b7ca9573818a619, type: 2} + m_FillPixelPerUnit: 100 + m_StretchTiling: 1 + m_SplineDetail: 16 + m_AdaptiveUV: 1 + m_StretchUV: 0 + m_WorldSpaceUV: 0 + m_ColliderDetail: 4 + m_ColliderOffset: 0 + m_UpdateCollider: 0 + m_OptimizeCollider: 1 +--- !u!1971053207 &400039575 +SpriteShapeRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 400039572} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 4294967295 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_MaskInteraction: 0 + m_ShapeTexture: {fileID: 0} + m_Sprites: + - {fileID: 21300000, guid: e74b518a65bc45f4cace9a2fef6af29d, type: 3} + m_LocalAABB: + m_Center: {x: 7.558513, y: 0.5739784, z: -0.005} + m_Extent: {x: 8.697825, y: 7.2123685, z: 0.005} +--- !u!4 &400039576 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 400039572} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -7.61, y: -0.47, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1865283555} + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1865283552 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1865283555} + - component: {fileID: 1865283554} + - component: {fileID: 1865283553} + - component: {fileID: 1865283556} + m_Layer: 0 + m_Name: Bottom + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1865283553 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1865283552} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 90539df1cd5704abcb25fec9f3f5f84b, type: 3} + m_Name: + m_EditorClassIdentifier: + m_LegacyGenerator: 0 + m_Spline: + m_IsOpenEnded: 1 + m_ControlPoints: + - position: {x: 0.37061024, y: 7.517852, z: 0} + leftTangent: {x: 0, y: 0, z: 0} + rightTangent: {x: 0, y: 0, z: 0} + mode: 0 + height: 1 + bevelCutoff: 0 + bevelSize: 0 + spriteIndex: 0 + corner: 0 + - position: {x: 0.41290092, y: -1.8726089, z: 0} + leftTangent: {x: -3.4678102, y: 1.8794639, z: 0} + rightTangent: {x: 3.4678102, y: -1.8794639, z: 0} + mode: 1 + height: 1 + bevelCutoff: 0 + bevelSize: 0 + spriteIndex: 0 + corner: 0 + - position: {x: 7.9664383, y: -6.63839, z: 0} + leftTangent: {x: -4.8397465, y: -0.030138493, z: 0} + rightTangent: {x: 4.8397465, y: 0.030138493, z: 0} + mode: 1 + height: 1 + bevelCutoff: 0 + bevelSize: 0 + spriteIndex: 0 + corner: 0 + - position: {x: 15, y: -1, z: 0} + leftTangent: {x: -3.2519875, y: -2.4569178, z: 0} + rightTangent: {x: 3.2519875, y: 2.4569178, z: 0} + mode: 1 + height: 1 + bevelCutoff: 0 + bevelSize: 0 + spriteIndex: 0 + corner: 0 + - position: {x: 14.186232, y: 7.786347, z: 0} + leftTangent: {x: 0, y: 0, z: 0} + rightTangent: {x: 0, y: 0, z: 0} + mode: 0 + height: 1 + bevelCutoff: 0 + bevelSize: 0 + spriteIndex: 0 + corner: 0 + m_SpriteShape: {fileID: 11400000, guid: e03579ec9d1b6c54ea364bd8ee0bcfd8, type: 2} + m_FillPixelPerUnit: 100 + m_StretchTiling: 1 + m_SplineDetail: 16 + m_AdaptiveUV: 1 + m_StretchUV: 0 + m_WorldSpaceUV: 0 + m_ColliderDetail: 4 + m_ColliderOffset: 0 + m_UpdateCollider: 0 + m_OptimizeCollider: 1 +--- !u!1971053207 &1865283554 +SpriteShapeRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1865283552} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 4294967295 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_MaskInteraction: 0 + m_ShapeTexture: {fileID: 0} + m_Sprites: + - {fileID: 21300000, guid: 418ab5c27d3054eb89959d9c715e00c9, type: 3} + - {fileID: 21300000, guid: e74b518a65bc45f4cace9a2fef6af29d, type: 3} + m_LocalAABB: + m_Center: {x: 7.5582957, y: 0.47995615, z: -0.005} + m_Extent: {x: 9.09759, y: 7.5183325, z: 0.005} +--- !u!4 &1865283555 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1865283552} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 400039576} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1865283556 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1865283552} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: db6f6067a1e6dd34ca4e2c4b7145e79b, type: 3} + m_Name: + m_EditorClassIdentifier: + m_ParentObject: {fileID: 400039572} +--- !u!1 &1990748034 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1990748038} + - component: {fileID: 1990748037} + - component: {fileID: 1990748036} + - component: {fileID: 1990748035} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &1990748035 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1990748034} + m_Enabled: 1 +--- !u!124 &1990748036 +Behaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1990748034} + m_Enabled: 1 +--- !u!20 &1990748037 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1990748034} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 1 + orthographic size: 15 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &1990748038 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1990748034} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scenes/ConformingSplineScene.unity.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scenes/ConformingSplineScene.unity.meta new file mode 100644 index 0000000000000000000000000000000000000000..f9452f7ae491e3c9a79efde1780e93748be1dba0 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scenes/ConformingSplineScene.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: b8529774cb716f645b682951a7aae689 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scenes/SimpleDrawScene.unity b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scenes/SimpleDrawScene.unity new file mode 100644 index 0000000000000000000000000000000000000000..0392a5a01ab73185b5588997379a492a4e650682 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scenes/SimpleDrawScene.unity @@ -0,0 +1,326 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_GIWorkflowMode: 0 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 10 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 500 + m_PVRBounces: 2 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVRFilteringMode: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ShowResolutionOverlay: 1 + m_LightingDataAsset: {fileID: 0} + m_UseShadowmask: 1 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &1048079211 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1048079214} + - component: {fileID: 1048079213} + - component: {fileID: 1048079212} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &1048079212 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1048079211} + m_Enabled: 1 +--- !u!20 &1048079213 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1048079211} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 1 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &1048079214 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1048079211} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1480543089 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1480543093} + - component: {fileID: 1480543092} + - component: {fileID: 1480543091} + - component: {fileID: 1480543090} + m_Layer: 0 + m_Name: SpriteShape + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1480543090 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1480543089} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 922bb1bbfeaeb9a4c9204b7d0bc3d8c8, type: 3} + m_Name: + m_EditorClassIdentifier: + minimumDistance: 1 +--- !u!114 &1480543091 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1480543089} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 90539df1cd5704abcb25fec9f3f5f84b, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Spline: + m_IsOpenEnded: 1 + m_ControlPoints: + - position: {x: -1, y: 0, z: 0} + leftTangent: {x: 0, y: 0, z: 0} + rightTangent: {x: 0, y: 0, z: 0} + mode: 0 + height: 1 + bevelCutoff: 0 + bevelSize: 0 + spriteIndex: 1 + corner: 0 + - position: {x: 1, y: 0, z: 0} + leftTangent: {x: 0, y: 0, z: 0} + rightTangent: {x: 0, y: 0, z: 0} + mode: 0 + height: 1 + bevelCutoff: 0 + bevelSize: 0.216 + spriteIndex: 0 + corner: 0 + m_SpriteShape: {fileID: 11400000, guid: e03579ec9d1b6c54ea364bd8ee0bcfd8, type: 2} + m_SplineDetail: 16 + m_AdaptiveUV: 1 + m_UpdateCollider: 0 + m_ColliderDetail: 4 + m_ColliderOffset: 0 + m_ColliderCornerType: 0 +--- !u!1971053207 &1480543092 +SpriteShapeRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1480543089} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 4294967295 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_MaskInteraction: 0 + m_ShapeTexture: {fileID: 0} + m_Sprites: + - {fileID: 21300000, guid: 418ab5c27d3054eb89959d9c715e00c9, type: 3} + - {fileID: 21300000, guid: e74b518a65bc45f4cace9a2fef6af29d, type: 3} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + m_LocalAABB: + m_Center: {x: 0, y: 0.20000002, z: 0} + m_Extent: {x: 1, y: 0.20000002, z: 0} +--- !u!4 &1480543093 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1480543089} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scenes/SimpleDrawScene.unity.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scenes/SimpleDrawScene.unity.meta new file mode 100644 index 0000000000000000000000000000000000000000..a3f9521ab30c82bead2da943d94c4a732b35b625 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scenes/SimpleDrawScene.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: e182160e1c8c64844872387ebf59c6e9 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scenes/SimplifiedSpriteShape.unity b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scenes/SimplifiedSpriteShape.unity new file mode 100644 index 0000000000000000000000000000000000000000..34a56dd017951aa0328222024f8689107ff2cf40 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scenes/SimplifiedSpriteShape.unity @@ -0,0 +1,382 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_GIWorkflowMode: 0 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 500 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 500 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 2 + m_PVRDenoiserTypeDirect: 0 + m_PVRDenoiserTypeIndirect: 0 + m_PVRDenoiserTypeAO: 0 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 0 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightingDataAsset: {fileID: 0} + m_UseShadowmask: 1 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &53845803 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 53845806} + - component: {fileID: 53845805} + - component: {fileID: 53845804} + m_Layer: 0 + m_Name: SpriteShape + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &53845804 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 53845803} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 90539df1cd5704abcb25fec9f3f5f84b, type: 3} + m_Name: + m_EditorClassIdentifier: + m_LegacyGenerator: 0 + m_Spline: + m_IsOpenEnded: 0 + m_ControlPoints: + - position: {x: 0.12956464, y: 1.8859321, z: 0} + leftTangent: {x: 0.87607896, y: -0.028361678, z: 0} + rightTangent: {x: -0.876079, y: 0.028361678, z: 0} + mode: 1 + height: 1 + bevelCutoff: 180 + bevelSize: 0.5 + spriteIndex: 0 + corner: 0 + - position: {x: -2, y: 0, z: 0} + leftTangent: {x: 0.7276257, y: 0.5038886, z: 0} + rightTangent: {x: -0.72762585, y: -0.5038886, z: 0} + mode: 1 + height: 1 + bevelCutoff: 0 + bevelSize: 0 + spriteIndex: 0 + corner: 0 + - position: {x: -4.370756, y: -1.2540917, z: 0} + leftTangent: {x: 0.27876043, y: 0.84002125, z: 0} + rightTangent: {x: -0.27876043, y: -0.84002113, z: 0} + mode: 1 + height: 1 + bevelCutoff: 180 + bevelSize: 0.424 + spriteIndex: 0 + corner: 0 + - position: {x: -2.9905427, y: -4.1601443, z: 0} + leftTangent: {x: -1.0090494, y: 0.19818997, z: 0} + rightTangent: {x: 1.0090494, y: -0.19819021, z: 0} + mode: 1 + height: 1 + bevelCutoff: 175 + bevelSize: 0.473 + spriteIndex: 0 + corner: 0 + - position: {x: -0.68832755, y: -2.0601013, z: 0} + leftTangent: {x: -1.020073, y: -0.13004279, z: 0} + rightTangent: {x: 1.020073, y: 0.13004267, z: 0} + mode: 1 + height: 1 + bevelCutoff: 0 + bevelSize: 0 + spriteIndex: 0 + corner: 0 + - position: {x: 2.4391866, y: -3.7118704, z: 0} + leftTangent: {x: -1.0588536, y: -0.24282193, z: 0} + rightTangent: {x: 1.0588536, y: 0.24282193, z: 0} + mode: 1 + height: 1 + bevelCutoff: 0 + bevelSize: 0 + spriteIndex: 0 + corner: 0 + - position: {x: 4.389332, y: -1.0597417, z: 0} + leftTangent: {x: 0.22145462, y: -0.83364165, z: 0} + rightTangent: {x: -0.22145462, y: 0.83364165, z: 0} + mode: 1 + height: 1 + bevelCutoff: 180 + bevelSize: 0.407 + spriteIndex: 0 + corner: 0 + - position: {x: 2, y: 0, z: 0} + leftTangent: {x: 0.71019197, y: -0.4895181, z: 0} + rightTangent: {x: -0.71019197, y: 0.4895181, z: 0} + mode: 1 + height: 1 + bevelCutoff: 0 + bevelSize: 0 + spriteIndex: 0 + corner: 0 + m_SpriteShape: {fileID: 11400000, guid: 19b9cf308de41834c9968d12bec673b1, type: 2} + m_FillPixelPerUnit: 100 + m_StretchTiling: 1 + m_SplineDetail: 16 + m_AdaptiveUV: 1 + m_StretchUV: 0 + m_WorldSpaceUV: 0 + m_ColliderDetail: 4 + m_ColliderOffset: 0 + m_UpdateCollider: 0 + m_OptimizeCollider: 1 +--- !u!1971053207 &53845805 +SpriteShapeRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 53845803} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 4294967295 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_MaskInteraction: 0 + m_ShapeTexture: {fileID: 0} + m_Sprites: + - {fileID: 21300000, guid: c6dabd295b8ab514fa47b5d4e2b0266e, type: 3} + m_LocalAABB: + m_Center: {x: -0.009027481, y: -1.1412225, z: -0.005} + m_Extent: {x: 4.6648436, y: 3.2670288, z: 0.005} +--- !u!4 &53845806 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 53845803} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &408902805 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 408902808} + - component: {fileID: 408902807} + - component: {fileID: 408902806} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &408902806 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 408902805} + m_Enabled: 1 +--- !u!20 &408902807 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 408902805} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 1 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &408902808 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 408902805} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scenes/SimplifiedSpriteShape.unity.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scenes/SimplifiedSpriteShape.unity.meta new file mode 100644 index 0000000000000000000000000000000000000000..e546ea9f3a969dd12703bb4a85a556ebca3b6467 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scenes/SimplifiedSpriteShape.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 254bf62203b7710419a1e6283f7e049b +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scenes/SprinklePrefabs.unity b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scenes/SprinklePrefabs.unity new file mode 100644 index 0000000000000000000000000000000000000000..12e7c370eafc66014d28168679b8a6a0f375ef72 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scenes/SprinklePrefabs.unity @@ -0,0 +1,373 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_GIWorkflowMode: 0 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 10 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 500 + m_PVRBounces: 2 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVRFilteringMode: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ShowResolutionOverlay: 1 + m_LightingDataAsset: {fileID: 0} + m_UseShadowmask: 1 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &408902805 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 408902808} + - component: {fileID: 408902807} + - component: {fileID: 408902806} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &408902806 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 408902805} + m_Enabled: 1 +--- !u!20 &408902807 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 408902805} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 1 + orthographic size: 15 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &408902808 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 408902805} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &2103414715 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2103414719} + - component: {fileID: 2103414718} + - component: {fileID: 2103414717} + - component: {fileID: 2103414716} + m_Layer: 0 + m_Name: New SpriteShapeController + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &2103414716 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 2103414715} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1c3eb1d33a6f9114bb5b51099948d2ce, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Prefab: {fileID: 1791732276458280, guid: 91b2663493e1ab642b1b60fc7955f947, type: 2} + m_RandomFactor: 90 + m_UseNormals: 1 +--- !u!114 &2103414717 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 2103414715} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 90539df1cd5704abcb25fec9f3f5f84b, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Spline: + m_IsOpenEnded: 1 + m_ControlPoints: + - position: {x: 26.488874, y: -2.6975656, z: 0} + leftTangent: {x: 0, y: 0, z: 0} + rightTangent: {x: 0, y: 0, z: 0} + mode: 0 + height: 1 + bevelCutoff: 0 + bevelSize: 0 + spriteIndex: 0 + corner: 0 + - position: {x: 10.016745, y: -9.5673275, z: 0} + leftTangent: {x: 5.787901, y: 1.0897436, z: -0} + rightTangent: {x: -5.787901, y: -1.0897436, z: 0} + mode: 1 + height: 1 + bevelCutoff: 0 + bevelSize: 0 + spriteIndex: 0 + corner: 0 + - position: {x: -9.3538, y: -9.1233, z: 0} + leftTangent: {x: 0, y: 0, z: 0} + rightTangent: {x: 0, y: 0, z: 0} + mode: 0 + height: 1 + bevelCutoff: 0 + bevelSize: 0 + spriteIndex: 0 + corner: 0 + - position: {x: -15.8531, y: 1.9792956, z: 0} + leftTangent: {x: -0.88264585, y: -3.0461369, z: -0} + rightTangent: {x: 0.88264585, y: 3.0461369, z: 0} + mode: 1 + height: 1 + bevelCutoff: 0 + bevelSize: 0 + spriteIndex: 0 + corner: 0 + - position: {x: -4.864938, y: 10.117959, z: 0} + leftTangent: {x: 0, y: 0, z: 0} + rightTangent: {x: 0, y: 0, z: 0} + mode: 0 + height: 1 + bevelCutoff: 0 + bevelSize: 0 + spriteIndex: 0 + corner: 0 + - position: {x: 10.084305, y: -0.2951008, z: 0} + leftTangent: {x: -1.3592644, y: -0.46925667, z: -0} + rightTangent: {x: 1.3592644, y: 0.46925667, z: 0} + mode: 1 + height: 1 + bevelCutoff: 0 + bevelSize: 0 + spriteIndex: 0 + corner: 0 + - position: {x: 25.481283, y: 4.9277797, z: 0} + leftTangent: {x: 0, y: 0, z: 0} + rightTangent: {x: 0, y: 0, z: 0} + mode: 0 + height: 1 + bevelCutoff: 0 + bevelSize: 0 + spriteIndex: 0 + corner: 0 + m_SpriteShape: {fileID: 11400000, guid: e03579ec9d1b6c54ea364bd8ee0bcfd8, type: 2} + m_SplineDetail: 16 + m_AdaptiveUV: 1 + m_UpdateCollider: 0 + m_ColliderDetail: 4 + m_ColliderOffset: 0 + m_ColliderCornerType: 0 +--- !u!1971053207 &2103414718 +SpriteShapeRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 2103414715} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 4294967295 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_MaskInteraction: 0 + m_ShapeTexture: {fileID: 0} + m_Sprites: + - {fileID: 21300000, guid: 418ab5c27d3054eb89959d9c715e00c9, type: 3} + - {fileID: 21300000, guid: e74b518a65bc45f4cace9a2fef6af29d, type: 3} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + m_LocalAABB: + m_Center: {x: 5.282402, y: 0.079841614, z: 0} + m_Extent: {x: 21.206472, y: 10.038117, z: 0} +--- !u!4 &2103414719 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 2103414715} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -0.08430457, y: 0.2951008, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scenes/SprinklePrefabs.unity.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scenes/SprinklePrefabs.unity.meta new file mode 100644 index 0000000000000000000000000000000000000000..6f87f9c658fcecd4eeb76f32af4bc5d652ccd5fa --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scenes/SprinklePrefabs.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 486575d9cb65b134fad35b06df9ae993 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/Clipper.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/Clipper.cs new file mode 100644 index 0000000000000000000000000000000000000000..49f84ca6ce7ee0459739f2aec09e01771323cd67 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/Clipper.cs @@ -0,0 +1,5078 @@ +/******************************************************************************* +* * +* Author : Angus Johnson * +* Version : 6.4.2 * +* Date : 27 February 2017 * +* Website : http://www.angusj.com * +* Copyright : Angus Johnson 2010-2017 * +* * +* License: * +* Use, modification & distribution is subject to Boost Software License Ver 1. * +* http://www.boost.org/LICENSE_1_0.txt * +* * +* Attributions: * +* The code in this library is an extension of Bala Vatti's clipping algorithm: * +* "A generic solution to polygon clipping" * +* Communications of the ACM, Vol 35, Issue 7 (July 1992) pp 56-63. * +* http://portal.acm.org/citation.cfm?id=129906 * +* * +* Computer graphics and geometric modeling: implementation and algorithms * +* By Max K. Agoston * +* Springer; 1 edition (January 4, 2005) * +* http://books.google.com/books?q=vatti+clipping+agoston * +* * +* See also: * +* "Polygon Offsetting by Computing Winding Numbers" * +* Paper no. DETC2005-85513 pp. 565-575 * +* ASME 2005 International Design Engineering Technical Conferences * +* and Computers and Information in Engineering Conference (IDETC/CIE2005) * +* September 24-28, 2005 , Long Beach, California, USA * +* http://www.me.berkeley.edu/~mcmains/pubs/DAC05OffsetPolygon.pdf * +* * +*******************************************************************************/ + +/******************************************************************************* +* * +* This is a translation of the Delphi Clipper library and the naming style * +* used has retained a Delphi flavour. * +* * +*******************************************************************************/ + +//use_int32: When enabled 32bit ints are used instead of 64bit ints. This +//improve performance but coordinate values are limited to the range +/- 46340 +//#define use_int32 + +//use_xyz: adds a Z member to IntPoint. Adds a minor cost to performance. +//#define use_xyz + +//use_lines: Enables open path clipping. Adds a very minor cost to performance. +#define use_lines + + +using System; +using System.Collections.Generic; +//using System.Text; //for Int128.AsString() & StringBuilder +//using System.IO; //debugging with streamReader & StreamWriter +//using System.Windows.Forms; //debugging to clipboard + +namespace ExtrasClipperLib +{ +#if use_int32 + using cInt = Int32; +#else + using cInt = Int64; +#endif + + using Path = List; + using Paths = List>; + + public struct DoublePoint + { + public double X; + public double Y; + + public DoublePoint(double x = 0, double y = 0) + { + this.X = x; this.Y = y; + } + + public DoublePoint(DoublePoint dp) + { + this.X = dp.X; this.Y = dp.Y; + } + + public DoublePoint(IntPoint ip) + { + this.X = ip.X; this.Y = ip.Y; + } + }; + + + //------------------------------------------------------------------------------ + // PolyTree & PolyNode classes + //------------------------------------------------------------------------------ + + public class PolyTree : PolyNode + { + internal List m_AllPolys = new List(); + + //The GC probably handles this cleanup more efficiently ... + //~PolyTree(){Clear();} + + public void Clear() + { + for (int i = 0; i < m_AllPolys.Count; i++) + m_AllPolys[i] = null; + m_AllPolys.Clear(); + m_Childs.Clear(); + } + + public PolyNode GetFirst() + { + if (m_Childs.Count > 0) + return m_Childs[0]; + else + return null; + } + + public int Total + { + get + { + int result = m_AllPolys.Count; + //with negative offsets, ignore the hidden outer polygon ... + if (result > 0 && m_Childs[0] != m_AllPolys[0]) result--; + return result; + } + } + } + + public class PolyNode + { + internal PolyNode m_Parent; + internal Path m_polygon = new Path(); + internal int m_Index; + internal JoinType m_jointype; + internal EndType m_endtype; + internal List m_Childs = new List(); + + private bool IsHoleNode() + { + bool result = true; + PolyNode node = m_Parent; + while (node != null) + { + result = !result; + node = node.m_Parent; + } + return result; + } + + public int ChildCount + { + get { return m_Childs.Count; } + } + + public Path Contour + { + get { return m_polygon; } + } + + internal void AddChild(PolyNode Child) + { + int cnt = m_Childs.Count; + m_Childs.Add(Child); + Child.m_Parent = this; + Child.m_Index = cnt; + } + + public PolyNode GetNext() + { + if (m_Childs.Count > 0) + return m_Childs[0]; + else + return GetNextSiblingUp(); + } + + internal PolyNode GetNextSiblingUp() + { + if (m_Parent == null) + return null; + else if (m_Index == m_Parent.m_Childs.Count - 1) + return m_Parent.GetNextSiblingUp(); + else + return m_Parent.m_Childs[m_Index + 1]; + } + + public List Childs + { + get { return m_Childs; } + } + + public PolyNode Parent + { + get { return m_Parent; } + } + + public bool IsHole + { + get { return IsHoleNode(); } + } + + public bool IsOpen { get; set; } + } + + + //------------------------------------------------------------------------------ + // Int128 struct (enables safe math on signed 64bit integers) + // eg Int128 val1((Int64)9223372036854775807); //ie 2^63 -1 + // Int128 val2((Int64)9223372036854775807); + // Int128 val3 = val1 * val2; + // val3.ToString => "85070591730234615847396907784232501249" (8.5e+37) + //------------------------------------------------------------------------------ + + internal struct Int128 + { + private Int64 hi; + private UInt64 lo; + + public Int128(Int64 _lo) + { + lo = (UInt64)_lo; + if (_lo < 0) hi = -1; + else hi = 0; + } + + public Int128(Int64 _hi, UInt64 _lo) + { + lo = _lo; + hi = _hi; + } + + public Int128(Int128 val) + { + hi = val.hi; + lo = val.lo; + } + + public bool IsNegative() + { + return hi < 0; + } + + public static bool operator==(Int128 val1, Int128 val2) + { + if ((object)val1 == (object)val2) return true; + else if ((object)val1 == null || (object)val2 == null) return false; + return (val1.hi == val2.hi && val1.lo == val2.lo); + } + + public static bool operator!=(Int128 val1, Int128 val2) + { + return !(val1 == val2); + } + + public override bool Equals(System.Object obj) + { + if (obj == null || !(obj is Int128)) + return false; + Int128 i128 = (Int128)obj; + return (i128.hi == hi && i128.lo == lo); + } + + public override int GetHashCode() + { + return hi.GetHashCode() ^ lo.GetHashCode(); + } + + public static bool operator>(Int128 val1, Int128 val2) + { + if (val1.hi != val2.hi) + return val1.hi > val2.hi; + else + return val1.lo > val2.lo; + } + + public static bool operator<(Int128 val1, Int128 val2) + { + if (val1.hi != val2.hi) + return val1.hi < val2.hi; + else + return val1.lo < val2.lo; + } + + public static Int128 operator+(Int128 lhs, Int128 rhs) + { + lhs.hi += rhs.hi; + lhs.lo += rhs.lo; + if (lhs.lo < rhs.lo) lhs.hi++; + return lhs; + } + + public static Int128 operator-(Int128 lhs, Int128 rhs) + { + return lhs + -rhs; + } + + public static Int128 operator-(Int128 val) + { + if (val.lo == 0) + return new Int128(-val.hi, 0); + else + return new Int128(~val.hi, ~val.lo + 1); + } + + public static explicit operator double(Int128 val) + { + const double shift64 = 18446744073709551616.0; //2^64 + if (val.hi < 0) + { + if (val.lo == 0) + return (double)val.hi * shift64; + else + return -(double)(~val.lo + ~val.hi * shift64); + } + else + return (double)(val.lo + val.hi * shift64); + } + + //nb: Constructing two new Int128 objects every time we want to multiply longs + //is slow. So, although calling the Int128Mul method doesn't look as clean, the + //code runs significantly faster than if we'd used the * operator. + + public static Int128 Int128Mul(Int64 lhs, Int64 rhs) + { + bool negate = (lhs < 0) != (rhs < 0); + if (lhs < 0) lhs = -lhs; + if (rhs < 0) rhs = -rhs; + UInt64 int1Hi = (UInt64)lhs >> 32; + UInt64 int1Lo = (UInt64)lhs & 0xFFFFFFFF; + UInt64 int2Hi = (UInt64)rhs >> 32; + UInt64 int2Lo = (UInt64)rhs & 0xFFFFFFFF; + + //nb: see comments in clipper.pas + UInt64 a = int1Hi * int2Hi; + UInt64 b = int1Lo * int2Lo; + UInt64 c = int1Hi * int2Lo + int1Lo * int2Hi; + + UInt64 lo; + Int64 hi; + hi = (Int64)(a + (c >> 32)); + + unchecked { lo = (c << 32) + b; } + if (lo < b) hi++; + Int128 result = new Int128(hi, lo); + return negate ? -result : result; + } + }; + + //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ + + public struct IntPoint + { + public cInt X; + public cInt Y; +#if use_xyz + public cInt Z; + + public IntPoint(cInt x, cInt y, cInt z = 0) + { + this.X = x; this.Y = y; this.Z = z; + } + + public IntPoint(double x, double y, double z = 0) + { + this.X = (cInt)x; this.Y = (cInt)y; this.Z = (cInt)z; + } + + public IntPoint(DoublePoint dp) + { + this.X = (cInt)dp.X; this.Y = (cInt)dp.Y; this.Z = 0; + } + + public IntPoint(IntPoint pt) + { + this.X = pt.X; this.Y = pt.Y; this.Z = pt.Z; + } + +#else + public IntPoint(cInt X, cInt Y) + { + this.X = X; this.Y = Y; + } + + public IntPoint(double x, double y) + { + this.X = (cInt)x; this.Y = (cInt)y; + } + + public IntPoint(IntPoint pt) + { + this.X = pt.X; this.Y = pt.Y; + } + +#endif + + public static bool operator==(IntPoint a, IntPoint b) + { + return a.X == b.X && a.Y == b.Y; + } + + public static bool operator!=(IntPoint a, IntPoint b) + { + return a.X != b.X || a.Y != b.Y; + } + + public override bool Equals(object obj) + { + if (obj == null) return false; + if (obj is IntPoint) + { + IntPoint a = (IntPoint)obj; + return (X == a.X) && (Y == a.Y); + } + else return false; + } + + public override int GetHashCode() + { + //simply prevents a compiler warning + return base.GetHashCode(); + } + }// end struct IntPoint + + public struct IntRect + { + public cInt left; + public cInt top; + public cInt right; + public cInt bottom; + + public IntRect(cInt l, cInt t, cInt r, cInt b) + { + this.left = l; this.top = t; + this.right = r; this.bottom = b; + } + + public IntRect(IntRect ir) + { + this.left = ir.left; this.top = ir.top; + this.right = ir.right; this.bottom = ir.bottom; + } + } + + public enum ClipType { ctIntersection, ctUnion, ctDifference, ctXor }; + public enum PolyType { ptSubject, ptClip }; + + //By far the most widely used winding rules for polygon filling are + //EvenOdd & NonZero (GDI, GDI+, XLib, OpenGL, Cairo, AGG, Quartz, SVG, Gr32) + //Others rules include Positive, Negative and ABS_GTR_EQ_TWO (only in OpenGL) + //see http://glprogramming.com/red/chapter11.html + public enum PolyFillType { pftEvenOdd, pftNonZero, pftPositive, pftNegative }; + + public enum JoinType { jtSquare, jtRound, jtMiter }; + public enum EndType { etClosedPolygon, etClosedLine, etOpenButt, etOpenSquare, etOpenRound }; + + internal enum EdgeSide { esLeft, esRight }; + internal enum Direction { dRightToLeft, dLeftToRight }; + + internal class TEdge + { + internal IntPoint Bot; + internal IntPoint Curr; //current (updated for every new scanbeam) + internal IntPoint Top; + internal IntPoint Delta; + internal double Dx; + internal PolyType PolyTyp; + internal EdgeSide Side; //side only refers to current side of solution poly + internal int WindDelta; //1 or -1 depending on winding direction + internal int WindCnt; + internal int WindCnt2; //winding count of the opposite polytype + internal int OutIdx; + internal TEdge Next; + internal TEdge Prev; + internal TEdge NextInLML; + internal TEdge NextInAEL; + internal TEdge PrevInAEL; + internal TEdge NextInSEL; + internal TEdge PrevInSEL; + }; + + public class IntersectNode + { + internal TEdge Edge1; + internal TEdge Edge2; + internal IntPoint Pt; + }; + + public class MyIntersectNodeSort : IComparer + { + public int Compare(IntersectNode node1, IntersectNode node2) + { + cInt i = node2.Pt.Y - node1.Pt.Y; + if (i > 0) return 1; + else if (i < 0) return -1; + else return 0; + } + } + + internal class LocalMinima + { + internal cInt Y; + internal TEdge LeftBound; + internal TEdge RightBound; + internal LocalMinima Next; + }; + + internal class Scanbeam + { + internal cInt Y; + internal Scanbeam Next; + }; + + internal class Maxima + { + internal cInt X; + internal Maxima Next; + internal Maxima Prev; + }; + + //OutRec: contains a path in the clipping solution. Edges in the AEL will + //carry a pointer to an OutRec when they are part of the clipping solution. + internal class OutRec + { + internal int Idx; + internal bool IsHole; + internal bool IsOpen; + internal OutRec FirstLeft; //see comments in clipper.pas + internal OutPt Pts; + internal OutPt BottomPt; + internal PolyNode PolyNode; + }; + + internal class OutPt + { + internal int Idx; + internal IntPoint Pt; + internal OutPt Next; + internal OutPt Prev; + }; + + internal class Join + { + internal OutPt OutPt1; + internal OutPt OutPt2; + internal IntPoint OffPt; + }; + + public class ClipperBase + { + internal const double horizontal = -3.4E+38; + internal const int Skip = -2; + internal const int Unassigned = -1; + internal const double tolerance = 1.0E-20; + internal static bool near_zero(double val) {return (val > -tolerance) && (val < tolerance); } + +#if use_int32 + public const cInt loRange = 0x7FFF; + public const cInt hiRange = 0x7FFF; +#else + public const cInt loRange = 0x3FFFFFFF; + public const cInt hiRange = 0x3FFFFFFFFFFFFFFFL; +#endif + + internal LocalMinima m_MinimaList; + internal LocalMinima m_CurrentLM; + internal List> m_edges = new List>(); + internal Scanbeam m_Scanbeam; + internal List m_PolyOuts; + internal TEdge m_ActiveEdges; + internal bool m_UseFullRange; + internal bool m_HasOpenPaths; + + //------------------------------------------------------------------------------ + + public bool PreserveCollinear + { + get; + set; + } + //------------------------------------------------------------------------------ + + public void Swap(ref cInt val1, ref cInt val2) + { + cInt tmp = val1; + val1 = val2; + val2 = tmp; + } + + //------------------------------------------------------------------------------ + + internal static bool IsHorizontal(TEdge e) + { + return e.Delta.Y == 0; + } + + //------------------------------------------------------------------------------ + + internal bool PointIsVertex(IntPoint pt, OutPt pp) + { + OutPt pp2 = pp; + do + { + if (pp2.Pt == pt) return true; + pp2 = pp2.Next; + } + while (pp2 != pp); + return false; + } + + //------------------------------------------------------------------------------ + + internal bool PointOnLineSegment(IntPoint pt, + IntPoint linePt1, IntPoint linePt2, bool UseFullRange) + { + if (UseFullRange) + return ((pt.X == linePt1.X) && (pt.Y == linePt1.Y)) || + ((pt.X == linePt2.X) && (pt.Y == linePt2.Y)) || + (((pt.X > linePt1.X) == (pt.X < linePt2.X)) && + ((pt.Y > linePt1.Y) == (pt.Y < linePt2.Y)) && + ((Int128.Int128Mul((pt.X - linePt1.X), (linePt2.Y - linePt1.Y)) == + Int128.Int128Mul((linePt2.X - linePt1.X), (pt.Y - linePt1.Y))))); + else + return ((pt.X == linePt1.X) && (pt.Y == linePt1.Y)) || + ((pt.X == linePt2.X) && (pt.Y == linePt2.Y)) || + (((pt.X > linePt1.X) == (pt.X < linePt2.X)) && + ((pt.Y > linePt1.Y) == (pt.Y < linePt2.Y)) && + ((pt.X - linePt1.X) * (linePt2.Y - linePt1.Y) == + (linePt2.X - linePt1.X) * (pt.Y - linePt1.Y))); + } + + //------------------------------------------------------------------------------ + + internal bool PointOnPolygon(IntPoint pt, OutPt pp, bool UseFullRange) + { + OutPt pp2 = pp; + while (true) + { + if (PointOnLineSegment(pt, pp2.Pt, pp2.Next.Pt, UseFullRange)) + return true; + pp2 = pp2.Next; + if (pp2 == pp) break; + } + return false; + } + + //------------------------------------------------------------------------------ + + internal static bool SlopesEqual(TEdge e1, TEdge e2, bool UseFullRange) + { + if (UseFullRange) + return Int128.Int128Mul(e1.Delta.Y, e2.Delta.X) == + Int128.Int128Mul(e1.Delta.X, e2.Delta.Y); + else + return (cInt)(e1.Delta.Y) * (e2.Delta.X) == + (cInt)(e1.Delta.X) * (e2.Delta.Y); + } + + //------------------------------------------------------------------------------ + + internal static bool SlopesEqual(IntPoint pt1, IntPoint pt2, + IntPoint pt3, bool UseFullRange) + { + if (UseFullRange) + return Int128.Int128Mul(pt1.Y - pt2.Y, pt2.X - pt3.X) == + Int128.Int128Mul(pt1.X - pt2.X, pt2.Y - pt3.Y); + else + return + (cInt)(pt1.Y - pt2.Y) * (pt2.X - pt3.X) - (cInt)(pt1.X - pt2.X) * (pt2.Y - pt3.Y) == 0; + } + + //------------------------------------------------------------------------------ + + internal static bool SlopesEqual(IntPoint pt1, IntPoint pt2, + IntPoint pt3, IntPoint pt4, bool UseFullRange) + { + if (UseFullRange) + return Int128.Int128Mul(pt1.Y - pt2.Y, pt3.X - pt4.X) == + Int128.Int128Mul(pt1.X - pt2.X, pt3.Y - pt4.Y); + else + return + (cInt)(pt1.Y - pt2.Y) * (pt3.X - pt4.X) - (cInt)(pt1.X - pt2.X) * (pt3.Y - pt4.Y) == 0; + } + + //------------------------------------------------------------------------------ + + internal ClipperBase() //constructor (nb: no external instantiation) + { + m_MinimaList = null; + m_CurrentLM = null; + m_UseFullRange = false; + m_HasOpenPaths = false; + } + + //------------------------------------------------------------------------------ + + public virtual void Clear() + { + DisposeLocalMinimaList(); + for (int i = 0; i < m_edges.Count; ++i) + { + for (int j = 0; j < m_edges[i].Count; ++j) m_edges[i][j] = null; + m_edges[i].Clear(); + } + m_edges.Clear(); + m_UseFullRange = false; + m_HasOpenPaths = false; + } + + //------------------------------------------------------------------------------ + + private void DisposeLocalMinimaList() + { + while (m_MinimaList != null) + { + LocalMinima tmpLm = m_MinimaList.Next; + m_MinimaList = null; + m_MinimaList = tmpLm; + } + m_CurrentLM = null; + } + + //------------------------------------------------------------------------------ + + void RangeTest(IntPoint Pt, ref bool useFullRange) + { + if (useFullRange) + { + if (Pt.X > hiRange || Pt.Y > hiRange || -Pt.X > hiRange || -Pt.Y > hiRange) + throw new ClipperException("Coordinate outside allowed range"); + } + else if (Pt.X > loRange || Pt.Y > loRange || -Pt.X > loRange || -Pt.Y > loRange) + { + useFullRange = true; + RangeTest(Pt, ref useFullRange); + } + } + + //------------------------------------------------------------------------------ + + private void InitEdge(TEdge e, TEdge eNext, + TEdge ePrev, IntPoint pt) + { + e.Next = eNext; + e.Prev = ePrev; + e.Curr = pt; + e.OutIdx = Unassigned; + } + + //------------------------------------------------------------------------------ + + private void InitEdge2(TEdge e, PolyType polyType) + { + if (e.Curr.Y >= e.Next.Curr.Y) + { + e.Bot = e.Curr; + e.Top = e.Next.Curr; + } + else + { + e.Top = e.Curr; + e.Bot = e.Next.Curr; + } + SetDx(e); + e.PolyTyp = polyType; + } + + //------------------------------------------------------------------------------ + + private TEdge FindNextLocMin(TEdge E) + { + TEdge E2; + for (;;) + { + while (E.Bot != E.Prev.Bot || E.Curr == E.Top) E = E.Next; + if (E.Dx != horizontal && E.Prev.Dx != horizontal) break; + while (E.Prev.Dx == horizontal) E = E.Prev; + E2 = E; + while (E.Dx == horizontal) E = E.Next; + if (E.Top.Y == E.Prev.Bot.Y) continue; //ie just an intermediate horz. + if (E2.Prev.Bot.X < E.Bot.X) E = E2; + break; + } + return E; + } + + //------------------------------------------------------------------------------ + + private TEdge ProcessBound(TEdge E, bool LeftBoundIsForward) + { + TEdge EStart, Result = E; + TEdge Horz; + + if (Result.OutIdx == Skip) + { + //check if there are edges beyond the skip edge in the bound and if so + //create another LocMin and calling ProcessBound once more ... + E = Result; + if (LeftBoundIsForward) + { + while (E.Top.Y == E.Next.Bot.Y) E = E.Next; + while (E != Result && E.Dx == horizontal) E = E.Prev; + } + else + { + while (E.Top.Y == E.Prev.Bot.Y) E = E.Prev; + while (E != Result && E.Dx == horizontal) E = E.Next; + } + if (E == Result) + { + if (LeftBoundIsForward) Result = E.Next; + else Result = E.Prev; + } + else + { + //there are more edges in the bound beyond result starting with E + if (LeftBoundIsForward) + E = Result.Next; + else + E = Result.Prev; + LocalMinima locMin = new LocalMinima(); + locMin.Next = null; + locMin.Y = E.Bot.Y; + locMin.LeftBound = null; + locMin.RightBound = E; + E.WindDelta = 0; + Result = ProcessBound(E, LeftBoundIsForward); + InsertLocalMinima(locMin); + } + return Result; + } + + if (E.Dx == horizontal) + { + //We need to be careful with open paths because this may not be a + //true local minima (ie E may be following a skip edge). + //Also, consecutive horz. edges may start heading left before going right. + if (LeftBoundIsForward) EStart = E.Prev; + else EStart = E.Next; + if (EStart.Dx == horizontal) //ie an adjoining horizontal skip edge + { + if (EStart.Bot.X != E.Bot.X && EStart.Top.X != E.Bot.X) + ReverseHorizontal(E); + } + else if (EStart.Bot.X != E.Bot.X) + ReverseHorizontal(E); + } + + EStart = E; + if (LeftBoundIsForward) + { + while (Result.Top.Y == Result.Next.Bot.Y && Result.Next.OutIdx != Skip) + Result = Result.Next; + if (Result.Dx == horizontal && Result.Next.OutIdx != Skip) + { + //nb: at the top of a bound, horizontals are added to the bound + //only when the preceding edge attaches to the horizontal's left vertex + //unless a Skip edge is encountered when that becomes the top divide + Horz = Result; + while (Horz.Prev.Dx == horizontal) Horz = Horz.Prev; + if (Horz.Prev.Top.X > Result.Next.Top.X) Result = Horz.Prev; + } + while (E != Result) + { + E.NextInLML = E.Next; + if (E.Dx == horizontal && E != EStart && E.Bot.X != E.Prev.Top.X) + ReverseHorizontal(E); + E = E.Next; + } + if (E.Dx == horizontal && E != EStart && E.Bot.X != E.Prev.Top.X) + ReverseHorizontal(E); + Result = Result.Next; //move to the edge just beyond current bound + } + else + { + while (Result.Top.Y == Result.Prev.Bot.Y && Result.Prev.OutIdx != Skip) + Result = Result.Prev; + if (Result.Dx == horizontal && Result.Prev.OutIdx != Skip) + { + Horz = Result; + while (Horz.Next.Dx == horizontal) Horz = Horz.Next; + if (Horz.Next.Top.X == Result.Prev.Top.X || + Horz.Next.Top.X > Result.Prev.Top.X) Result = Horz.Next; + } + + while (E != Result) + { + E.NextInLML = E.Prev; + if (E.Dx == horizontal && E != EStart && E.Bot.X != E.Next.Top.X) + ReverseHorizontal(E); + E = E.Prev; + } + if (E.Dx == horizontal && E != EStart && E.Bot.X != E.Next.Top.X) + ReverseHorizontal(E); + Result = Result.Prev; //move to the edge just beyond current bound + } + return Result; + } + + //------------------------------------------------------------------------------ + + + public bool AddPath(Path pg, PolyType polyType, bool Closed) + { +#if use_lines + if (!Closed && polyType == PolyType.ptClip) + throw new ClipperException("AddPath: Open paths must be subject."); +#else + if (!Closed) + throw new ClipperException("AddPath: Open paths have been disabled."); +#endif + + int highI = (int)pg.Count - 1; + if (Closed) while (highI > 0 && (pg[highI] == pg[0])) --highI; + while (highI > 0 && (pg[highI] == pg[highI - 1])) --highI; + if ((Closed && highI < 2) || (!Closed && highI < 1)) return false; + + //create a new edge array ... + List edges = new List(highI + 1); + for (int i = 0; i <= highI; i++) edges.Add(new TEdge()); + + bool IsFlat = true; + + //1. Basic (first) edge initialization ... + edges[1].Curr = pg[1]; + RangeTest(pg[0], ref m_UseFullRange); + RangeTest(pg[highI], ref m_UseFullRange); + InitEdge(edges[0], edges[1], edges[highI], pg[0]); + InitEdge(edges[highI], edges[0], edges[highI - 1], pg[highI]); + for (int i = highI - 1; i >= 1; --i) + { + RangeTest(pg[i], ref m_UseFullRange); + InitEdge(edges[i], edges[i + 1], edges[i - 1], pg[i]); + } + TEdge eStart = edges[0]; + + //2. Remove duplicate vertices, and (when closed) collinear edges ... + TEdge E = eStart, eLoopStop = eStart; + for (;;) + { + //nb: allows matching start and end points when not Closed ... + if (E.Curr == E.Next.Curr && (Closed || E.Next != eStart)) + { + if (E == E.Next) break; + if (E == eStart) eStart = E.Next; + E = RemoveEdge(E); + eLoopStop = E; + continue; + } + if (E.Prev == E.Next) + break; //only two vertices + else if (Closed && + SlopesEqual(E.Prev.Curr, E.Curr, E.Next.Curr, m_UseFullRange) && + (!PreserveCollinear || + !Pt2IsBetweenPt1AndPt3(E.Prev.Curr, E.Curr, E.Next.Curr))) + { + //Collinear edges are allowed for open paths but in closed paths + //the default is to merge adjacent collinear edges into a single edge. + //However, if the PreserveCollinear property is enabled, only overlapping + //collinear edges (ie spikes) will be removed from closed paths. + if (E == eStart) eStart = E.Next; + E = RemoveEdge(E); + E = E.Prev; + eLoopStop = E; + continue; + } + E = E.Next; + if ((E == eLoopStop) || (!Closed && E.Next == eStart)) break; + } + + if ((!Closed && (E == E.Next)) || (Closed && (E.Prev == E.Next))) + return false; + + if (!Closed) + { + m_HasOpenPaths = true; + eStart.Prev.OutIdx = Skip; + } + + //3. Do second stage of edge initialization ... + E = eStart; + do + { + InitEdge2(E, polyType); + E = E.Next; + if (IsFlat && E.Curr.Y != eStart.Curr.Y) IsFlat = false; + } + while (E != eStart); + + //4. Finally, add edge bounds to LocalMinima list ... + + //Totally flat paths must be handled differently when adding them + //to LocalMinima list to avoid endless loops etc ... + if (IsFlat) + { + if (Closed) return false; + E.Prev.OutIdx = Skip; + LocalMinima locMin = new LocalMinima(); + locMin.Next = null; + locMin.Y = E.Bot.Y; + locMin.LeftBound = null; + locMin.RightBound = E; + locMin.RightBound.Side = EdgeSide.esRight; + locMin.RightBound.WindDelta = 0; + for (;;) + { + if (E.Bot.X != E.Prev.Top.X) ReverseHorizontal(E); + if (E.Next.OutIdx == Skip) break; + E.NextInLML = E.Next; + E = E.Next; + } + InsertLocalMinima(locMin); + m_edges.Add(edges); + return true; + } + + m_edges.Add(edges); + bool leftBoundIsForward; + TEdge EMin = null; + + //workaround to avoid an endless loop in the while loop below when + //open paths have matching start and end points ... + if (E.Prev.Bot == E.Prev.Top) E = E.Next; + + for (;;) + { + E = FindNextLocMin(E); + if (E == EMin) break; + else if (EMin == null) EMin = E; + + //E and E.Prev now share a local minima (left aligned if horizontal). + //Compare their slopes to find which starts which bound ... + LocalMinima locMin = new LocalMinima(); + locMin.Next = null; + locMin.Y = E.Bot.Y; + if (E.Dx < E.Prev.Dx) + { + locMin.LeftBound = E.Prev; + locMin.RightBound = E; + leftBoundIsForward = false; //Q.nextInLML = Q.prev + } + else + { + locMin.LeftBound = E; + locMin.RightBound = E.Prev; + leftBoundIsForward = true; //Q.nextInLML = Q.next + } + locMin.LeftBound.Side = EdgeSide.esLeft; + locMin.RightBound.Side = EdgeSide.esRight; + + if (!Closed) locMin.LeftBound.WindDelta = 0; + else if (locMin.LeftBound.Next == locMin.RightBound) + locMin.LeftBound.WindDelta = -1; + else locMin.LeftBound.WindDelta = 1; + locMin.RightBound.WindDelta = -locMin.LeftBound.WindDelta; + + E = ProcessBound(locMin.LeftBound, leftBoundIsForward); + if (E.OutIdx == Skip) E = ProcessBound(E, leftBoundIsForward); + + TEdge E2 = ProcessBound(locMin.RightBound, !leftBoundIsForward); + if (E2.OutIdx == Skip) E2 = ProcessBound(E2, !leftBoundIsForward); + + if (locMin.LeftBound.OutIdx == Skip) + locMin.LeftBound = null; + else if (locMin.RightBound.OutIdx == Skip) + locMin.RightBound = null; + InsertLocalMinima(locMin); + if (!leftBoundIsForward) E = E2; + } + return true; + } + + //------------------------------------------------------------------------------ + + public bool AddPaths(Paths ppg, PolyType polyType, bool closed) + { + bool result = false; + for (int i = 0; i < ppg.Count; ++i) + if (AddPath(ppg[i], polyType, closed)) result = true; + return result; + } + + //------------------------------------------------------------------------------ + + internal bool Pt2IsBetweenPt1AndPt3(IntPoint pt1, IntPoint pt2, IntPoint pt3) + { + if ((pt1 == pt3) || (pt1 == pt2) || (pt3 == pt2)) return false; + else if (pt1.X != pt3.X) return (pt2.X > pt1.X) == (pt2.X < pt3.X); + else return (pt2.Y > pt1.Y) == (pt2.Y < pt3.Y); + } + + //------------------------------------------------------------------------------ + + TEdge RemoveEdge(TEdge e) + { + //removes e from double_linked_list (but without removing from memory) + e.Prev.Next = e.Next; + e.Next.Prev = e.Prev; + TEdge result = e.Next; + e.Prev = null; //flag as removed (see ClipperBase.Clear) + return result; + } + + //------------------------------------------------------------------------------ + + private void SetDx(TEdge e) + { + e.Delta.X = (e.Top.X - e.Bot.X); + e.Delta.Y = (e.Top.Y - e.Bot.Y); + if (e.Delta.Y == 0) e.Dx = horizontal; + else e.Dx = (double)(e.Delta.X) / (e.Delta.Y); + } + + //--------------------------------------------------------------------------- + + private void InsertLocalMinima(LocalMinima newLm) + { + if (m_MinimaList == null) + { + m_MinimaList = newLm; + } + else if (newLm.Y >= m_MinimaList.Y) + { + newLm.Next = m_MinimaList; + m_MinimaList = newLm; + } + else + { + LocalMinima tmpLm = m_MinimaList; + while (tmpLm.Next != null && (newLm.Y < tmpLm.Next.Y)) + tmpLm = tmpLm.Next; + newLm.Next = tmpLm.Next; + tmpLm.Next = newLm; + } + } + + //------------------------------------------------------------------------------ + + internal Boolean PopLocalMinima(cInt Y, out LocalMinima current) + { + current = m_CurrentLM; + if (m_CurrentLM != null && m_CurrentLM.Y == Y) + { + m_CurrentLM = m_CurrentLM.Next; + return true; + } + return false; + } + + //------------------------------------------------------------------------------ + + private void ReverseHorizontal(TEdge e) + { + //swap horizontal edges' top and bottom x's so they follow the natural + //progression of the bounds - ie so their xbots will align with the + //adjoining lower edge. [Helpful in the ProcessHorizontal() method.] + Swap(ref e.Top.X, ref e.Bot.X); +#if use_xyz + Swap(ref e.Top.Z, ref e.Bot.Z); +#endif + } + + //------------------------------------------------------------------------------ + + internal virtual void Reset() + { + m_CurrentLM = m_MinimaList; + if (m_CurrentLM == null) return; //ie nothing to process + + //reset all edges ... + m_Scanbeam = null; + LocalMinima lm = m_MinimaList; + while (lm != null) + { + InsertScanbeam(lm.Y); + TEdge e = lm.LeftBound; + if (e != null) + { + e.Curr = e.Bot; + e.OutIdx = Unassigned; + } + e = lm.RightBound; + if (e != null) + { + e.Curr = e.Bot; + e.OutIdx = Unassigned; + } + lm = lm.Next; + } + m_ActiveEdges = null; + } + + //------------------------------------------------------------------------------ + + public static IntRect GetBounds(Paths paths) + { + int i = 0, cnt = paths.Count; + while (i < cnt && paths[i].Count == 0) i++; + if (i == cnt) return new IntRect(0, 0, 0, 0); + IntRect result = new IntRect(); + result.left = paths[i][0].X; + result.right = result.left; + result.top = paths[i][0].Y; + result.bottom = result.top; + for (; i < cnt; i++) + for (int j = 0; j < paths[i].Count; j++) + { + if (paths[i][j].X < result.left) result.left = paths[i][j].X; + else if (paths[i][j].X > result.right) result.right = paths[i][j].X; + if (paths[i][j].Y < result.top) result.top = paths[i][j].Y; + else if (paths[i][j].Y > result.bottom) result.bottom = paths[i][j].Y; + } + return result; + } + + //------------------------------------------------------------------------------ + + internal void InsertScanbeam(cInt Y) + { + //single-linked list: sorted descending, ignoring dups. + if (m_Scanbeam == null) + { + m_Scanbeam = new Scanbeam(); + m_Scanbeam.Next = null; + m_Scanbeam.Y = Y; + } + else if (Y > m_Scanbeam.Y) + { + Scanbeam newSb = new Scanbeam(); + newSb.Y = Y; + newSb.Next = m_Scanbeam; + m_Scanbeam = newSb; + } + else + { + Scanbeam sb2 = m_Scanbeam; + while (sb2.Next != null && (Y <= sb2.Next.Y)) sb2 = sb2.Next; + if (Y == sb2.Y) return; //ie ignores duplicates + Scanbeam newSb = new Scanbeam(); + newSb.Y = Y; + newSb.Next = sb2.Next; + sb2.Next = newSb; + } + } + + //------------------------------------------------------------------------------ + + internal Boolean PopScanbeam(out cInt Y) + { + if (m_Scanbeam == null) + { + Y = 0; + return false; + } + Y = m_Scanbeam.Y; + m_Scanbeam = m_Scanbeam.Next; + return true; + } + + //------------------------------------------------------------------------------ + + internal Boolean LocalMinimaPending() + { + return (m_CurrentLM != null); + } + + //------------------------------------------------------------------------------ + + internal OutRec CreateOutRec() + { + OutRec result = new OutRec(); + result.Idx = Unassigned; + result.IsHole = false; + result.IsOpen = false; + result.FirstLeft = null; + result.Pts = null; + result.BottomPt = null; + result.PolyNode = null; + m_PolyOuts.Add(result); + result.Idx = m_PolyOuts.Count - 1; + return result; + } + + //------------------------------------------------------------------------------ + + internal void DisposeOutRec(int index) + { + OutRec outRec = m_PolyOuts[index]; + outRec.Pts = null; + outRec = null; + m_PolyOuts[index] = null; + } + + //------------------------------------------------------------------------------ + + internal void UpdateEdgeIntoAEL(ref TEdge e) + { + if (e.NextInLML == null) + throw new ClipperException("UpdateEdgeIntoAEL: invalid call"); + TEdge AelPrev = e.PrevInAEL; + TEdge AelNext = e.NextInAEL; + e.NextInLML.OutIdx = e.OutIdx; + if (AelPrev != null) + AelPrev.NextInAEL = e.NextInLML; + else m_ActiveEdges = e.NextInLML; + if (AelNext != null) + AelNext.PrevInAEL = e.NextInLML; + e.NextInLML.Side = e.Side; + e.NextInLML.WindDelta = e.WindDelta; + e.NextInLML.WindCnt = e.WindCnt; + e.NextInLML.WindCnt2 = e.WindCnt2; + e = e.NextInLML; + e.Curr = e.Bot; + e.PrevInAEL = AelPrev; + e.NextInAEL = AelNext; + if (!IsHorizontal(e)) InsertScanbeam(e.Top.Y); + } + + //------------------------------------------------------------------------------ + + internal void SwapPositionsInAEL(TEdge edge1, TEdge edge2) + { + //check that one or other edge hasn't already been removed from AEL ... + if (edge1.NextInAEL == edge1.PrevInAEL || + edge2.NextInAEL == edge2.PrevInAEL) return; + + if (edge1.NextInAEL == edge2) + { + TEdge next = edge2.NextInAEL; + if (next != null) + next.PrevInAEL = edge1; + TEdge prev = edge1.PrevInAEL; + if (prev != null) + prev.NextInAEL = edge2; + edge2.PrevInAEL = prev; + edge2.NextInAEL = edge1; + edge1.PrevInAEL = edge2; + edge1.NextInAEL = next; + } + else if (edge2.NextInAEL == edge1) + { + TEdge next = edge1.NextInAEL; + if (next != null) + next.PrevInAEL = edge2; + TEdge prev = edge2.PrevInAEL; + if (prev != null) + prev.NextInAEL = edge1; + edge1.PrevInAEL = prev; + edge1.NextInAEL = edge2; + edge2.PrevInAEL = edge1; + edge2.NextInAEL = next; + } + else + { + TEdge next = edge1.NextInAEL; + TEdge prev = edge1.PrevInAEL; + edge1.NextInAEL = edge2.NextInAEL; + if (edge1.NextInAEL != null) + edge1.NextInAEL.PrevInAEL = edge1; + edge1.PrevInAEL = edge2.PrevInAEL; + if (edge1.PrevInAEL != null) + edge1.PrevInAEL.NextInAEL = edge1; + edge2.NextInAEL = next; + if (edge2.NextInAEL != null) + edge2.NextInAEL.PrevInAEL = edge2; + edge2.PrevInAEL = prev; + if (edge2.PrevInAEL != null) + edge2.PrevInAEL.NextInAEL = edge2; + } + + if (edge1.PrevInAEL == null) + m_ActiveEdges = edge1; + else if (edge2.PrevInAEL == null) + m_ActiveEdges = edge2; + } + + //------------------------------------------------------------------------------ + + internal void DeleteFromAEL(TEdge e) + { + TEdge AelPrev = e.PrevInAEL; + TEdge AelNext = e.NextInAEL; + if (AelPrev == null && AelNext == null && (e != m_ActiveEdges)) + return; //already deleted + if (AelPrev != null) + AelPrev.NextInAEL = AelNext; + else m_ActiveEdges = AelNext; + if (AelNext != null) + AelNext.PrevInAEL = AelPrev; + e.NextInAEL = null; + e.PrevInAEL = null; + } + + //------------------------------------------------------------------------------ + } //end ClipperBase + + public class Clipper : ClipperBase + { + //InitOptions that can be passed to the constructor ... + public const int ioReverseSolution = 1; + public const int ioStrictlySimple = 2; + public const int ioPreserveCollinear = 4; + + private ClipType m_ClipType; + private Maxima m_Maxima; + private TEdge m_SortedEdges; + private List m_IntersectList; + IComparer m_IntersectNodeComparer; + private bool m_ExecuteLocked; + private PolyFillType m_ClipFillType; + private PolyFillType m_SubjFillType; + private List m_Joins; + private List m_GhostJoins; + private bool m_UsingPolyTree; +#if use_xyz + public delegate void ZFillCallback(IntPoint bot1, IntPoint top1, + IntPoint bot2, IntPoint top2, ref IntPoint pt); + public ZFillCallback ZFillFunction { get; set; } +#endif + public Clipper(int InitOptions = 0) : base() //constructor + { + m_Scanbeam = null; + m_Maxima = null; + m_ActiveEdges = null; + m_SortedEdges = null; + m_IntersectList = new List(); + m_IntersectNodeComparer = new MyIntersectNodeSort(); + m_ExecuteLocked = false; + m_UsingPolyTree = false; + m_PolyOuts = new List(); + m_Joins = new List(); + m_GhostJoins = new List(); + ReverseSolution = (ioReverseSolution & InitOptions) != 0; + StrictlySimple = (ioStrictlySimple & InitOptions) != 0; + PreserveCollinear = (ioPreserveCollinear & InitOptions) != 0; +#if use_xyz + ZFillFunction = null; +#endif + } + + //------------------------------------------------------------------------------ + + private void InsertMaxima(cInt X) + { + //double-linked list: sorted ascending, ignoring dups. + Maxima newMax = new Maxima(); + newMax.X = X; + if (m_Maxima == null) + { + m_Maxima = newMax; + m_Maxima.Next = null; + m_Maxima.Prev = null; + } + else if (X < m_Maxima.X) + { + newMax.Next = m_Maxima; + newMax.Prev = null; + m_Maxima = newMax; + } + else + { + Maxima m = m_Maxima; + while (m.Next != null && (X >= m.Next.X)) m = m.Next; + if (X == m.X) return; //ie ignores duplicates (& CG to clean up newMax) + //insert newMax between m and m.Next ... + newMax.Next = m.Next; + newMax.Prev = m; + if (m.Next != null) m.Next.Prev = newMax; + m.Next = newMax; + } + } + + //------------------------------------------------------------------------------ + + public bool ReverseSolution + { + get; + set; + } + //------------------------------------------------------------------------------ + + public bool StrictlySimple + { + get; + set; + } + //------------------------------------------------------------------------------ + + public bool Execute(ClipType clipType, Paths solution, + PolyFillType FillType = PolyFillType.pftEvenOdd) + { + return Execute(clipType, solution, FillType, FillType); + } + + //------------------------------------------------------------------------------ + + public bool Execute(ClipType clipType, PolyTree polytree, + PolyFillType FillType = PolyFillType.pftEvenOdd) + { + return Execute(clipType, polytree, FillType, FillType); + } + + //------------------------------------------------------------------------------ + + public bool Execute(ClipType clipType, Paths solution, + PolyFillType subjFillType, PolyFillType clipFillType) + { + if (m_ExecuteLocked) return false; + if (m_HasOpenPaths) + throw + new ClipperException("Error: PolyTree struct is needed for open path clipping."); + + m_ExecuteLocked = true; + solution.Clear(); + m_SubjFillType = subjFillType; + m_ClipFillType = clipFillType; + m_ClipType = clipType; + m_UsingPolyTree = false; + bool succeeded; + try + { + succeeded = ExecuteInternal(); + //build the return polygons ... + if (succeeded) BuildResult(solution); + } + finally + { + DisposeAllPolyPts(); + m_ExecuteLocked = false; + } + return succeeded; + } + + //------------------------------------------------------------------------------ + + public bool Execute(ClipType clipType, PolyTree polytree, + PolyFillType subjFillType, PolyFillType clipFillType) + { + if (m_ExecuteLocked) return false; + m_ExecuteLocked = true; + m_SubjFillType = subjFillType; + m_ClipFillType = clipFillType; + m_ClipType = clipType; + m_UsingPolyTree = true; + bool succeeded; + try + { + succeeded = ExecuteInternal(); + //build the return polygons ... + if (succeeded) BuildResult2(polytree); + } + finally + { + DisposeAllPolyPts(); + m_ExecuteLocked = false; + } + return succeeded; + } + + //------------------------------------------------------------------------------ + + internal void FixHoleLinkage(OutRec outRec) + { + //skip if an outermost polygon or + //already already points to the correct FirstLeft ... + if (outRec.FirstLeft == null || + (outRec.IsHole != outRec.FirstLeft.IsHole && + outRec.FirstLeft.Pts != null)) return; + + OutRec orfl = outRec.FirstLeft; + while (orfl != null && ((orfl.IsHole == outRec.IsHole) || orfl.Pts == null)) + orfl = orfl.FirstLeft; + outRec.FirstLeft = orfl; + } + + //------------------------------------------------------------------------------ + + private bool ExecuteInternal() + { + try + { + Reset(); + m_SortedEdges = null; + m_Maxima = null; + + cInt botY, topY; + if (!PopScanbeam(out botY)) return false; + InsertLocalMinimaIntoAEL(botY); + while (PopScanbeam(out topY) || LocalMinimaPending()) + { + ProcessHorizontals(); + m_GhostJoins.Clear(); + if (!ProcessIntersections(topY)) return false; + ProcessEdgesAtTopOfScanbeam(topY); + botY = topY; + InsertLocalMinimaIntoAEL(botY); + } + + //fix orientations ... + foreach (OutRec outRec in m_PolyOuts) + { + if (outRec.Pts == null || outRec.IsOpen) continue; + if ((outRec.IsHole ^ ReverseSolution) == (Area(outRec) > 0)) + ReversePolyPtLinks(outRec.Pts); + } + + JoinCommonEdges(); + + foreach (OutRec outRec in m_PolyOuts) + { + if (outRec.Pts == null) + continue; + else if (outRec.IsOpen) + FixupOutPolyline(outRec); + else + FixupOutPolygon(outRec); + } + + if (StrictlySimple) DoSimplePolygons(); + return true; + } + //catch { return false; } + finally + { + m_Joins.Clear(); + m_GhostJoins.Clear(); + } + } + + //------------------------------------------------------------------------------ + + private void DisposeAllPolyPts() + { + for (int i = 0; i < m_PolyOuts.Count; ++i) DisposeOutRec(i); + m_PolyOuts.Clear(); + } + + //------------------------------------------------------------------------------ + + private void AddJoin(OutPt Op1, OutPt Op2, IntPoint OffPt) + { + Join j = new Join(); + j.OutPt1 = Op1; + j.OutPt2 = Op2; + j.OffPt = OffPt; + m_Joins.Add(j); + } + + //------------------------------------------------------------------------------ + + private void AddGhostJoin(OutPt Op, IntPoint OffPt) + { + Join j = new Join(); + j.OutPt1 = Op; + j.OffPt = OffPt; + m_GhostJoins.Add(j); + } + + //------------------------------------------------------------------------------ + +#if use_xyz + internal void SetZ(ref IntPoint pt, TEdge e1, TEdge e2) + { + if (pt.Z != 0 || ZFillFunction == null) return; + else if (pt == e1.Bot) pt.Z = e1.Bot.Z; + else if (pt == e1.Top) pt.Z = e1.Top.Z; + else if (pt == e2.Bot) pt.Z = e2.Bot.Z; + else if (pt == e2.Top) pt.Z = e2.Top.Z; + else ZFillFunction(e1.Bot, e1.Top, e2.Bot, e2.Top, ref pt); + } + + //------------------------------------------------------------------------------ +#endif + + private void InsertLocalMinimaIntoAEL(cInt botY) + { + LocalMinima lm; + while (PopLocalMinima(botY, out lm)) + { + TEdge lb = lm.LeftBound; + TEdge rb = lm.RightBound; + + OutPt Op1 = null; + if (lb == null) + { + InsertEdgeIntoAEL(rb, null); + SetWindingCount(rb); + if (IsContributing(rb)) + Op1 = AddOutPt(rb, rb.Bot); + } + else if (rb == null) + { + InsertEdgeIntoAEL(lb, null); + SetWindingCount(lb); + if (IsContributing(lb)) + Op1 = AddOutPt(lb, lb.Bot); + InsertScanbeam(lb.Top.Y); + } + else + { + InsertEdgeIntoAEL(lb, null); + InsertEdgeIntoAEL(rb, lb); + SetWindingCount(lb); + rb.WindCnt = lb.WindCnt; + rb.WindCnt2 = lb.WindCnt2; + if (IsContributing(lb)) + Op1 = AddLocalMinPoly(lb, rb, lb.Bot); + InsertScanbeam(lb.Top.Y); + } + + if (rb != null) + { + if (IsHorizontal(rb)) + { + if (rb.NextInLML != null) + InsertScanbeam(rb.NextInLML.Top.Y); + AddEdgeToSEL(rb); + } + else + InsertScanbeam(rb.Top.Y); + } + + if (lb == null || rb == null) continue; + + //if output polygons share an Edge with a horizontal rb, they'll need joining later ... + if (Op1 != null && IsHorizontal(rb) && + m_GhostJoins.Count > 0 && rb.WindDelta != 0) + { + for (int i = 0; i < m_GhostJoins.Count; i++) + { + //if the horizontal Rb and a 'ghost' horizontal overlap, then convert + //the 'ghost' join to a real join ready for later ... + Join j = m_GhostJoins[i]; + if (HorzSegmentsOverlap(j.OutPt1.Pt.X, j.OffPt.X, rb.Bot.X, rb.Top.X)) + AddJoin(j.OutPt1, Op1, j.OffPt); + } + } + + if (lb.OutIdx >= 0 && lb.PrevInAEL != null && + lb.PrevInAEL.Curr.X == lb.Bot.X && + lb.PrevInAEL.OutIdx >= 0 && + SlopesEqual(lb.PrevInAEL.Curr, lb.PrevInAEL.Top, lb.Curr, lb.Top, m_UseFullRange) && + lb.WindDelta != 0 && lb.PrevInAEL.WindDelta != 0) + { + OutPt Op2 = AddOutPt(lb.PrevInAEL, lb.Bot); + AddJoin(Op1, Op2, lb.Top); + } + + if (lb.NextInAEL != rb) + { + if (rb.OutIdx >= 0 && rb.PrevInAEL.OutIdx >= 0 && + SlopesEqual(rb.PrevInAEL.Curr, rb.PrevInAEL.Top, rb.Curr, rb.Top, m_UseFullRange) && + rb.WindDelta != 0 && rb.PrevInAEL.WindDelta != 0) + { + OutPt Op2 = AddOutPt(rb.PrevInAEL, rb.Bot); + AddJoin(Op1, Op2, rb.Top); + } + + TEdge e = lb.NextInAEL; + if (e != null) + while (e != rb) + { + //nb: For calculating winding counts etc, IntersectEdges() assumes + //that param1 will be to the right of param2 ABOVE the intersection ... + IntersectEdges(rb, e, lb.Curr); //order important here + e = e.NextInAEL; + } + } + } + } + + //------------------------------------------------------------------------------ + + private void InsertEdgeIntoAEL(TEdge edge, TEdge startEdge) + { + if (m_ActiveEdges == null) + { + edge.PrevInAEL = null; + edge.NextInAEL = null; + m_ActiveEdges = edge; + } + else if (startEdge == null && E2InsertsBeforeE1(m_ActiveEdges, edge)) + { + edge.PrevInAEL = null; + edge.NextInAEL = m_ActiveEdges; + m_ActiveEdges.PrevInAEL = edge; + m_ActiveEdges = edge; + } + else + { + if (startEdge == null) startEdge = m_ActiveEdges; + while (startEdge.NextInAEL != null && + !E2InsertsBeforeE1(startEdge.NextInAEL, edge)) + startEdge = startEdge.NextInAEL; + edge.NextInAEL = startEdge.NextInAEL; + if (startEdge.NextInAEL != null) startEdge.NextInAEL.PrevInAEL = edge; + edge.PrevInAEL = startEdge; + startEdge.NextInAEL = edge; + } + } + + //---------------------------------------------------------------------- + + private bool E2InsertsBeforeE1(TEdge e1, TEdge e2) + { + if (e2.Curr.X == e1.Curr.X) + { + if (e2.Top.Y > e1.Top.Y) + return e2.Top.X < TopX(e1, e2.Top.Y); + else return e1.Top.X > TopX(e2, e1.Top.Y); + } + else return e2.Curr.X < e1.Curr.X; + } + + //------------------------------------------------------------------------------ + + private bool IsEvenOddFillType(TEdge edge) + { + if (edge.PolyTyp == PolyType.ptSubject) + return m_SubjFillType == PolyFillType.pftEvenOdd; + else + return m_ClipFillType == PolyFillType.pftEvenOdd; + } + + //------------------------------------------------------------------------------ + + private bool IsEvenOddAltFillType(TEdge edge) + { + if (edge.PolyTyp == PolyType.ptSubject) + return m_ClipFillType == PolyFillType.pftEvenOdd; + else + return m_SubjFillType == PolyFillType.pftEvenOdd; + } + + //------------------------------------------------------------------------------ + + private bool IsContributing(TEdge edge) + { + PolyFillType pft, pft2; + if (edge.PolyTyp == PolyType.ptSubject) + { + pft = m_SubjFillType; + pft2 = m_ClipFillType; + } + else + { + pft = m_ClipFillType; + pft2 = m_SubjFillType; + } + + switch (pft) + { + case PolyFillType.pftEvenOdd: + //return false if a subj line has been flagged as inside a subj polygon + if (edge.WindDelta == 0 && edge.WindCnt != 1) return false; + break; + case PolyFillType.pftNonZero: + if (Math.Abs(edge.WindCnt) != 1) return false; + break; + case PolyFillType.pftPositive: + if (edge.WindCnt != 1) return false; + break; + default: //PolyFillType.pftNegative + if (edge.WindCnt != -1) return false; + break; + } + + switch (m_ClipType) + { + case ClipType.ctIntersection: + switch (pft2) + { + case PolyFillType.pftEvenOdd: + case PolyFillType.pftNonZero: + return (edge.WindCnt2 != 0); + case PolyFillType.pftPositive: + return (edge.WindCnt2 > 0); + default: + return (edge.WindCnt2 < 0); + } + case ClipType.ctUnion: + switch (pft2) + { + case PolyFillType.pftEvenOdd: + case PolyFillType.pftNonZero: + return (edge.WindCnt2 == 0); + case PolyFillType.pftPositive: + return (edge.WindCnt2 <= 0); + default: + return (edge.WindCnt2 >= 0); + } + case ClipType.ctDifference: + if (edge.PolyTyp == PolyType.ptSubject) + switch (pft2) + { + case PolyFillType.pftEvenOdd: + case PolyFillType.pftNonZero: + return (edge.WindCnt2 == 0); + case PolyFillType.pftPositive: + return (edge.WindCnt2 <= 0); + default: + return (edge.WindCnt2 >= 0); + } + else + switch (pft2) + { + case PolyFillType.pftEvenOdd: + case PolyFillType.pftNonZero: + return (edge.WindCnt2 != 0); + case PolyFillType.pftPositive: + return (edge.WindCnt2 > 0); + default: + return (edge.WindCnt2 < 0); + } + case ClipType.ctXor: + if (edge.WindDelta == 0) //XOr always contributing unless open + switch (pft2) + { + case PolyFillType.pftEvenOdd: + case PolyFillType.pftNonZero: + return (edge.WindCnt2 == 0); + case PolyFillType.pftPositive: + return (edge.WindCnt2 <= 0); + default: + return (edge.WindCnt2 >= 0); + } + else + return true; + } + return true; + } + + //------------------------------------------------------------------------------ + + private void SetWindingCount(TEdge edge) + { + TEdge e = edge.PrevInAEL; + //find the edge of the same polytype that immediately preceeds 'edge' in AEL + while (e != null && ((e.PolyTyp != edge.PolyTyp) || (e.WindDelta == 0))) e = e.PrevInAEL; + if (e == null) + { + PolyFillType pft; + pft = (edge.PolyTyp == PolyType.ptSubject ? m_SubjFillType : m_ClipFillType); + if (edge.WindDelta == 0) edge.WindCnt = (pft == PolyFillType.pftNegative ? -1 : 1); + else edge.WindCnt = edge.WindDelta; + edge.WindCnt2 = 0; + e = m_ActiveEdges; //ie get ready to calc WindCnt2 + } + else if (edge.WindDelta == 0 && m_ClipType != ClipType.ctUnion) + { + edge.WindCnt = 1; + edge.WindCnt2 = e.WindCnt2; + e = e.NextInAEL; //ie get ready to calc WindCnt2 + } + else if (IsEvenOddFillType(edge)) + { + //EvenOdd filling ... + if (edge.WindDelta == 0) + { + //are we inside a subj polygon ... + bool Inside = true; + TEdge e2 = e.PrevInAEL; + while (e2 != null) + { + if (e2.PolyTyp == e.PolyTyp && e2.WindDelta != 0) + Inside = !Inside; + e2 = e2.PrevInAEL; + } + edge.WindCnt = (Inside ? 0 : 1); + } + else + { + edge.WindCnt = edge.WindDelta; + } + edge.WindCnt2 = e.WindCnt2; + e = e.NextInAEL; //ie get ready to calc WindCnt2 + } + else + { + //nonZero, Positive or Negative filling ... + if (e.WindCnt * e.WindDelta < 0) + { + //prev edge is 'decreasing' WindCount (WC) toward zero + //so we're outside the previous polygon ... + if (Math.Abs(e.WindCnt) > 1) + { + //outside prev poly but still inside another. + //when reversing direction of prev poly use the same WC + if (e.WindDelta * edge.WindDelta < 0) edge.WindCnt = e.WindCnt; + //otherwise continue to 'decrease' WC ... + else edge.WindCnt = e.WindCnt + edge.WindDelta; + } + else + //now outside all polys of same polytype so set own WC ... + edge.WindCnt = (edge.WindDelta == 0 ? 1 : edge.WindDelta); + } + else + { + //prev edge is 'increasing' WindCount (WC) away from zero + //so we're inside the previous polygon ... + if (edge.WindDelta == 0) + edge.WindCnt = (e.WindCnt < 0 ? e.WindCnt - 1 : e.WindCnt + 1); + //if wind direction is reversing prev then use same WC + else if (e.WindDelta * edge.WindDelta < 0) + edge.WindCnt = e.WindCnt; + //otherwise add to WC ... + else edge.WindCnt = e.WindCnt + edge.WindDelta; + } + edge.WindCnt2 = e.WindCnt2; + e = e.NextInAEL; //ie get ready to calc WindCnt2 + } + + //update WindCnt2 ... + if (IsEvenOddAltFillType(edge)) + { + //EvenOdd filling ... + while (e != edge) + { + if (e.WindDelta != 0) + edge.WindCnt2 = (edge.WindCnt2 == 0 ? 1 : 0); + e = e.NextInAEL; + } + } + else + { + //nonZero, Positive or Negative filling ... + while (e != edge) + { + edge.WindCnt2 += e.WindDelta; + e = e.NextInAEL; + } + } + } + + //------------------------------------------------------------------------------ + + private void AddEdgeToSEL(TEdge edge) + { + //SEL pointers in PEdge are use to build transient lists of horizontal edges. + //However, since we don't need to worry about processing order, all additions + //are made to the front of the list ... + if (m_SortedEdges == null) + { + m_SortedEdges = edge; + edge.PrevInSEL = null; + edge.NextInSEL = null; + } + else + { + edge.NextInSEL = m_SortedEdges; + edge.PrevInSEL = null; + m_SortedEdges.PrevInSEL = edge; + m_SortedEdges = edge; + } + } + + //------------------------------------------------------------------------------ + + internal Boolean PopEdgeFromSEL(out TEdge e) + { + //Pop edge from front of SEL (ie SEL is a FILO list) + e = m_SortedEdges; + if (e == null) return false; + TEdge oldE = e; + m_SortedEdges = e.NextInSEL; + if (m_SortedEdges != null) m_SortedEdges.PrevInSEL = null; + oldE.NextInSEL = null; + oldE.PrevInSEL = null; + return true; + } + + //------------------------------------------------------------------------------ + + private void CopyAELToSEL() + { + TEdge e = m_ActiveEdges; + m_SortedEdges = e; + while (e != null) + { + e.PrevInSEL = e.PrevInAEL; + e.NextInSEL = e.NextInAEL; + e = e.NextInAEL; + } + } + + //------------------------------------------------------------------------------ + + private void SwapPositionsInSEL(TEdge edge1, TEdge edge2) + { + if (edge1.NextInSEL == null && edge1.PrevInSEL == null) + return; + if (edge2.NextInSEL == null && edge2.PrevInSEL == null) + return; + + if (edge1.NextInSEL == edge2) + { + TEdge next = edge2.NextInSEL; + if (next != null) + next.PrevInSEL = edge1; + TEdge prev = edge1.PrevInSEL; + if (prev != null) + prev.NextInSEL = edge2; + edge2.PrevInSEL = prev; + edge2.NextInSEL = edge1; + edge1.PrevInSEL = edge2; + edge1.NextInSEL = next; + } + else if (edge2.NextInSEL == edge1) + { + TEdge next = edge1.NextInSEL; + if (next != null) + next.PrevInSEL = edge2; + TEdge prev = edge2.PrevInSEL; + if (prev != null) + prev.NextInSEL = edge1; + edge1.PrevInSEL = prev; + edge1.NextInSEL = edge2; + edge2.PrevInSEL = edge1; + edge2.NextInSEL = next; + } + else + { + TEdge next = edge1.NextInSEL; + TEdge prev = edge1.PrevInSEL; + edge1.NextInSEL = edge2.NextInSEL; + if (edge1.NextInSEL != null) + edge1.NextInSEL.PrevInSEL = edge1; + edge1.PrevInSEL = edge2.PrevInSEL; + if (edge1.PrevInSEL != null) + edge1.PrevInSEL.NextInSEL = edge1; + edge2.NextInSEL = next; + if (edge2.NextInSEL != null) + edge2.NextInSEL.PrevInSEL = edge2; + edge2.PrevInSEL = prev; + if (edge2.PrevInSEL != null) + edge2.PrevInSEL.NextInSEL = edge2; + } + + if (edge1.PrevInSEL == null) + m_SortedEdges = edge1; + else if (edge2.PrevInSEL == null) + m_SortedEdges = edge2; + } + + //------------------------------------------------------------------------------ + + + private void AddLocalMaxPoly(TEdge e1, TEdge e2, IntPoint pt) + { + AddOutPt(e1, pt); + if (e2.WindDelta == 0) AddOutPt(e2, pt); + if (e1.OutIdx == e2.OutIdx) + { + e1.OutIdx = Unassigned; + e2.OutIdx = Unassigned; + } + else if (e1.OutIdx < e2.OutIdx) + AppendPolygon(e1, e2); + else + AppendPolygon(e2, e1); + } + + //------------------------------------------------------------------------------ + + private OutPt AddLocalMinPoly(TEdge e1, TEdge e2, IntPoint pt) + { + OutPt result; + TEdge e, prevE; + if (IsHorizontal(e2) || (e1.Dx > e2.Dx)) + { + result = AddOutPt(e1, pt); + e2.OutIdx = e1.OutIdx; + e1.Side = EdgeSide.esLeft; + e2.Side = EdgeSide.esRight; + e = e1; + if (e.PrevInAEL == e2) + prevE = e2.PrevInAEL; + else + prevE = e.PrevInAEL; + } + else + { + result = AddOutPt(e2, pt); + e1.OutIdx = e2.OutIdx; + e1.Side = EdgeSide.esRight; + e2.Side = EdgeSide.esLeft; + e = e2; + if (e.PrevInAEL == e1) + prevE = e1.PrevInAEL; + else + prevE = e.PrevInAEL; + } + + if (prevE != null && prevE.OutIdx >= 0 && prevE.Top.Y < pt.Y && e.Top.Y < pt.Y) + { + cInt xPrev = TopX(prevE, pt.Y); + cInt xE = TopX(e, pt.Y); + if ((xPrev == xE) && (e.WindDelta != 0) && (prevE.WindDelta != 0) && + SlopesEqual(new IntPoint(xPrev, pt.Y), prevE.Top, new IntPoint(xE, pt.Y), e.Top, m_UseFullRange)) + { + OutPt outPt = AddOutPt(prevE, pt); + AddJoin(result, outPt, e.Top); + } + } + return result; + } + + //------------------------------------------------------------------------------ + + private OutPt AddOutPt(TEdge e, IntPoint pt) + { + if (e.OutIdx < 0) + { + OutRec outRec = CreateOutRec(); + outRec.IsOpen = (e.WindDelta == 0); + OutPt newOp = new OutPt(); + outRec.Pts = newOp; + newOp.Idx = outRec.Idx; + newOp.Pt = pt; + newOp.Next = newOp; + newOp.Prev = newOp; + if (!outRec.IsOpen) + SetHoleState(e, outRec); + e.OutIdx = outRec.Idx; //nb: do this after SetZ ! + return newOp; + } + else + { + OutRec outRec = m_PolyOuts[e.OutIdx]; + //OutRec.Pts is the 'Left-most' point & OutRec.Pts.Prev is the 'Right-most' + OutPt op = outRec.Pts; + bool ToFront = (e.Side == EdgeSide.esLeft); + if (ToFront && pt == op.Pt) return op; + else if (!ToFront && pt == op.Prev.Pt) return op.Prev; + + OutPt newOp = new OutPt(); + newOp.Idx = outRec.Idx; + newOp.Pt = pt; + newOp.Next = op; + newOp.Prev = op.Prev; + newOp.Prev.Next = newOp; + op.Prev = newOp; + if (ToFront) outRec.Pts = newOp; + return newOp; + } + } + + //------------------------------------------------------------------------------ + + private OutPt GetLastOutPt(TEdge e) + { + OutRec outRec = m_PolyOuts[e.OutIdx]; + if (e.Side == EdgeSide.esLeft) + return outRec.Pts; + else + return outRec.Pts.Prev; + } + + //------------------------------------------------------------------------------ + + internal void SwapPoints(ref IntPoint pt1, ref IntPoint pt2) + { + IntPoint tmp = new IntPoint(pt1); + pt1 = pt2; + pt2 = tmp; + } + + //------------------------------------------------------------------------------ + + private bool HorzSegmentsOverlap(cInt seg1a, cInt seg1b, cInt seg2a, cInt seg2b) + { + if (seg1a > seg1b) Swap(ref seg1a, ref seg1b); + if (seg2a > seg2b) Swap(ref seg2a, ref seg2b); + return (seg1a < seg2b) && (seg2a < seg1b); + } + + //------------------------------------------------------------------------------ + + private void SetHoleState(TEdge e, OutRec outRec) + { + TEdge e2 = e.PrevInAEL; + TEdge eTmp = null; + while (e2 != null) + { + if (e2.OutIdx >= 0 && e2.WindDelta != 0) + { + if (eTmp == null) + eTmp = e2; + else if (eTmp.OutIdx == e2.OutIdx) + eTmp = null; //paired + } + e2 = e2.PrevInAEL; + } + + if (eTmp == null) + { + outRec.FirstLeft = null; + outRec.IsHole = false; + } + else + { + outRec.FirstLeft = m_PolyOuts[eTmp.OutIdx]; + outRec.IsHole = !outRec.FirstLeft.IsHole; + } + } + + //------------------------------------------------------------------------------ + + private double GetDx(IntPoint pt1, IntPoint pt2) + { + if (pt1.Y == pt2.Y) return horizontal; + else return (double)(pt2.X - pt1.X) / (pt2.Y - pt1.Y); + } + + //--------------------------------------------------------------------------- + + private bool FirstIsBottomPt(OutPt btmPt1, OutPt btmPt2) + { + OutPt p = btmPt1.Prev; + while ((p.Pt == btmPt1.Pt) && (p != btmPt1)) p = p.Prev; + double dx1p = Math.Abs(GetDx(btmPt1.Pt, p.Pt)); + p = btmPt1.Next; + while ((p.Pt == btmPt1.Pt) && (p != btmPt1)) p = p.Next; + double dx1n = Math.Abs(GetDx(btmPt1.Pt, p.Pt)); + + p = btmPt2.Prev; + while ((p.Pt == btmPt2.Pt) && (p != btmPt2)) p = p.Prev; + double dx2p = Math.Abs(GetDx(btmPt2.Pt, p.Pt)); + p = btmPt2.Next; + while ((p.Pt == btmPt2.Pt) && (p != btmPt2)) p = p.Next; + double dx2n = Math.Abs(GetDx(btmPt2.Pt, p.Pt)); + + if (Math.Max(dx1p, dx1n) == Math.Max(dx2p, dx2n) && + Math.Min(dx1p, dx1n) == Math.Min(dx2p, dx2n)) + return Area(btmPt1) > 0; //if otherwise identical use orientation + else + return (dx1p >= dx2p && dx1p >= dx2n) || (dx1n >= dx2p && dx1n >= dx2n); + } + + //------------------------------------------------------------------------------ + + private OutPt GetBottomPt(OutPt pp) + { + OutPt dups = null; + OutPt p = pp.Next; + while (p != pp) + { + if (p.Pt.Y > pp.Pt.Y) + { + pp = p; + dups = null; + } + else if (p.Pt.Y == pp.Pt.Y && p.Pt.X <= pp.Pt.X) + { + if (p.Pt.X < pp.Pt.X) + { + dups = null; + pp = p; + } + else + { + if (p.Next != pp && p.Prev != pp) dups = p; + } + } + p = p.Next; + } + if (dups != null) + { + //there appears to be at least 2 vertices at bottomPt so ... + while (dups != p) + { + if (!FirstIsBottomPt(p, dups)) pp = dups; + dups = dups.Next; + while (dups.Pt != pp.Pt) dups = dups.Next; + } + } + return pp; + } + + //------------------------------------------------------------------------------ + + private OutRec GetLowermostRec(OutRec outRec1, OutRec outRec2) + { + //work out which polygon fragment has the correct hole state ... + if (outRec1.BottomPt == null) + outRec1.BottomPt = GetBottomPt(outRec1.Pts); + if (outRec2.BottomPt == null) + outRec2.BottomPt = GetBottomPt(outRec2.Pts); + OutPt bPt1 = outRec1.BottomPt; + OutPt bPt2 = outRec2.BottomPt; + if (bPt1.Pt.Y > bPt2.Pt.Y) return outRec1; + else if (bPt1.Pt.Y < bPt2.Pt.Y) return outRec2; + else if (bPt1.Pt.X < bPt2.Pt.X) return outRec1; + else if (bPt1.Pt.X > bPt2.Pt.X) return outRec2; + else if (bPt1.Next == bPt1) return outRec2; + else if (bPt2.Next == bPt2) return outRec1; + else if (FirstIsBottomPt(bPt1, bPt2)) return outRec1; + else return outRec2; + } + + //------------------------------------------------------------------------------ + + bool OutRec1RightOfOutRec2(OutRec outRec1, OutRec outRec2) + { + do + { + outRec1 = outRec1.FirstLeft; + if (outRec1 == outRec2) return true; + } + while (outRec1 != null); + return false; + } + + //------------------------------------------------------------------------------ + + private OutRec GetOutRec(int idx) + { + OutRec outrec = m_PolyOuts[idx]; + while (outrec != m_PolyOuts[outrec.Idx]) + outrec = m_PolyOuts[outrec.Idx]; + return outrec; + } + + //------------------------------------------------------------------------------ + + private void AppendPolygon(TEdge e1, TEdge e2) + { + OutRec outRec1 = m_PolyOuts[e1.OutIdx]; + OutRec outRec2 = m_PolyOuts[e2.OutIdx]; + + OutRec holeStateRec; + if (OutRec1RightOfOutRec2(outRec1, outRec2)) + holeStateRec = outRec2; + else if (OutRec1RightOfOutRec2(outRec2, outRec1)) + holeStateRec = outRec1; + else + holeStateRec = GetLowermostRec(outRec1, outRec2); + + //get the start and ends of both output polygons and + //join E2 poly onto E1 poly and delete pointers to E2 ... + OutPt p1_lft = outRec1.Pts; + OutPt p1_rt = p1_lft.Prev; + OutPt p2_lft = outRec2.Pts; + OutPt p2_rt = p2_lft.Prev; + + //join e2 poly onto e1 poly and delete pointers to e2 ... + if (e1.Side == EdgeSide.esLeft) + { + if (e2.Side == EdgeSide.esLeft) + { + //z y x a b c + ReversePolyPtLinks(p2_lft); + p2_lft.Next = p1_lft; + p1_lft.Prev = p2_lft; + p1_rt.Next = p2_rt; + p2_rt.Prev = p1_rt; + outRec1.Pts = p2_rt; + } + else + { + //x y z a b c + p2_rt.Next = p1_lft; + p1_lft.Prev = p2_rt; + p2_lft.Prev = p1_rt; + p1_rt.Next = p2_lft; + outRec1.Pts = p2_lft; + } + } + else + { + if (e2.Side == EdgeSide.esRight) + { + //a b c z y x + ReversePolyPtLinks(p2_lft); + p1_rt.Next = p2_rt; + p2_rt.Prev = p1_rt; + p2_lft.Next = p1_lft; + p1_lft.Prev = p2_lft; + } + else + { + //a b c x y z + p1_rt.Next = p2_lft; + p2_lft.Prev = p1_rt; + p1_lft.Prev = p2_rt; + p2_rt.Next = p1_lft; + } + } + + outRec1.BottomPt = null; + if (holeStateRec == outRec2) + { + if (outRec2.FirstLeft != outRec1) + outRec1.FirstLeft = outRec2.FirstLeft; + outRec1.IsHole = outRec2.IsHole; + } + outRec2.Pts = null; + outRec2.BottomPt = null; + + outRec2.FirstLeft = outRec1; + + int OKIdx = e1.OutIdx; + int ObsoleteIdx = e2.OutIdx; + + e1.OutIdx = Unassigned; //nb: safe because we only get here via AddLocalMaxPoly + e2.OutIdx = Unassigned; + + TEdge e = m_ActiveEdges; + while (e != null) + { + if (e.OutIdx == ObsoleteIdx) + { + e.OutIdx = OKIdx; + e.Side = e1.Side; + break; + } + e = e.NextInAEL; + } + outRec2.Idx = outRec1.Idx; + } + + //------------------------------------------------------------------------------ + + private void ReversePolyPtLinks(OutPt pp) + { + if (pp == null) return; + OutPt pp1; + OutPt pp2; + pp1 = pp; + do + { + pp2 = pp1.Next; + pp1.Next = pp1.Prev; + pp1.Prev = pp2; + pp1 = pp2; + } + while (pp1 != pp); + } + + //------------------------------------------------------------------------------ + + private static void SwapSides(TEdge edge1, TEdge edge2) + { + EdgeSide side = edge1.Side; + edge1.Side = edge2.Side; + edge2.Side = side; + } + + //------------------------------------------------------------------------------ + + private static void SwapPolyIndexes(TEdge edge1, TEdge edge2) + { + int outIdx = edge1.OutIdx; + edge1.OutIdx = edge2.OutIdx; + edge2.OutIdx = outIdx; + } + + //------------------------------------------------------------------------------ + + private void IntersectEdges(TEdge e1, TEdge e2, IntPoint pt) + { + //e1 will be to the left of e2 BELOW the intersection. Therefore e1 is before + //e2 in AEL except when e1 is being inserted at the intersection point ... + + bool e1Contributing = (e1.OutIdx >= 0); + bool e2Contributing = (e2.OutIdx >= 0); + +#if use_xyz + SetZ(ref pt, e1, e2); +#endif + +#if use_lines + //if either edge is on an OPEN path ... + if (e1.WindDelta == 0 || e2.WindDelta == 0) + { + //ignore subject-subject open path intersections UNLESS they + //are both open paths, AND they are both 'contributing maximas' ... + if (e1.WindDelta == 0 && e2.WindDelta == 0) return; + //if intersecting a subj line with a subj poly ... + else if (e1.PolyTyp == e2.PolyTyp && + e1.WindDelta != e2.WindDelta && m_ClipType == ClipType.ctUnion) + { + if (e1.WindDelta == 0) + { + if (e2Contributing) + { + AddOutPt(e1, pt); + if (e1Contributing) e1.OutIdx = Unassigned; + } + } + else + { + if (e1Contributing) + { + AddOutPt(e2, pt); + if (e2Contributing) e2.OutIdx = Unassigned; + } + } + } + else if (e1.PolyTyp != e2.PolyTyp) + { + if ((e1.WindDelta == 0) && Math.Abs(e2.WindCnt) == 1 && + (m_ClipType != ClipType.ctUnion || e2.WindCnt2 == 0)) + { + AddOutPt(e1, pt); + if (e1Contributing) e1.OutIdx = Unassigned; + } + else if ((e2.WindDelta == 0) && (Math.Abs(e1.WindCnt) == 1) && + (m_ClipType != ClipType.ctUnion || e1.WindCnt2 == 0)) + { + AddOutPt(e2, pt); + if (e2Contributing) e2.OutIdx = Unassigned; + } + } + return; + } +#endif + + //update winding counts... + //assumes that e1 will be to the Right of e2 ABOVE the intersection + if (e1.PolyTyp == e2.PolyTyp) + { + if (IsEvenOddFillType(e1)) + { + int oldE1WindCnt = e1.WindCnt; + e1.WindCnt = e2.WindCnt; + e2.WindCnt = oldE1WindCnt; + } + else + { + if (e1.WindCnt + e2.WindDelta == 0) e1.WindCnt = -e1.WindCnt; + else e1.WindCnt += e2.WindDelta; + if (e2.WindCnt - e1.WindDelta == 0) e2.WindCnt = -e2.WindCnt; + else e2.WindCnt -= e1.WindDelta; + } + } + else + { + if (!IsEvenOddFillType(e2)) e1.WindCnt2 += e2.WindDelta; + else e1.WindCnt2 = (e1.WindCnt2 == 0) ? 1 : 0; + if (!IsEvenOddFillType(e1)) e2.WindCnt2 -= e1.WindDelta; + else e2.WindCnt2 = (e2.WindCnt2 == 0) ? 1 : 0; + } + + PolyFillType e1FillType, e2FillType, e1FillType2, e2FillType2; + if (e1.PolyTyp == PolyType.ptSubject) + { + e1FillType = m_SubjFillType; + e1FillType2 = m_ClipFillType; + } + else + { + e1FillType = m_ClipFillType; + e1FillType2 = m_SubjFillType; + } + if (e2.PolyTyp == PolyType.ptSubject) + { + e2FillType = m_SubjFillType; + e2FillType2 = m_ClipFillType; + } + else + { + e2FillType = m_ClipFillType; + e2FillType2 = m_SubjFillType; + } + + int e1Wc, e2Wc; + switch (e1FillType) + { + case PolyFillType.pftPositive: e1Wc = e1.WindCnt; break; + case PolyFillType.pftNegative: e1Wc = -e1.WindCnt; break; + default: e1Wc = Math.Abs(e1.WindCnt); break; + } + switch (e2FillType) + { + case PolyFillType.pftPositive: e2Wc = e2.WindCnt; break; + case PolyFillType.pftNegative: e2Wc = -e2.WindCnt; break; + default: e2Wc = Math.Abs(e2.WindCnt); break; + } + + if (e1Contributing && e2Contributing) + { + if ((e1Wc != 0 && e1Wc != 1) || (e2Wc != 0 && e2Wc != 1) || + (e1.PolyTyp != e2.PolyTyp && m_ClipType != ClipType.ctXor)) + { + AddLocalMaxPoly(e1, e2, pt); + } + else + { + AddOutPt(e1, pt); + AddOutPt(e2, pt); + SwapSides(e1, e2); + SwapPolyIndexes(e1, e2); + } + } + else if (e1Contributing) + { + if (e2Wc == 0 || e2Wc == 1) + { + AddOutPt(e1, pt); + SwapSides(e1, e2); + SwapPolyIndexes(e1, e2); + } + } + else if (e2Contributing) + { + if (e1Wc == 0 || e1Wc == 1) + { + AddOutPt(e2, pt); + SwapSides(e1, e2); + SwapPolyIndexes(e1, e2); + } + } + else if ((e1Wc == 0 || e1Wc == 1) && (e2Wc == 0 || e2Wc == 1)) + { + //neither edge is currently contributing ... + cInt e1Wc2, e2Wc2; + switch (e1FillType2) + { + case PolyFillType.pftPositive: e1Wc2 = e1.WindCnt2; break; + case PolyFillType.pftNegative: e1Wc2 = -e1.WindCnt2; break; + default: e1Wc2 = Math.Abs(e1.WindCnt2); break; + } + switch (e2FillType2) + { + case PolyFillType.pftPositive: e2Wc2 = e2.WindCnt2; break; + case PolyFillType.pftNegative: e2Wc2 = -e2.WindCnt2; break; + default: e2Wc2 = Math.Abs(e2.WindCnt2); break; + } + + if (e1.PolyTyp != e2.PolyTyp) + { + AddLocalMinPoly(e1, e2, pt); + } + else if (e1Wc == 1 && e2Wc == 1) + switch (m_ClipType) + { + case ClipType.ctIntersection: + if (e1Wc2 > 0 && e2Wc2 > 0) + AddLocalMinPoly(e1, e2, pt); + break; + case ClipType.ctUnion: + if (e1Wc2 <= 0 && e2Wc2 <= 0) + AddLocalMinPoly(e1, e2, pt); + break; + case ClipType.ctDifference: + if (((e1.PolyTyp == PolyType.ptClip) && (e1Wc2 > 0) && (e2Wc2 > 0)) || + ((e1.PolyTyp == PolyType.ptSubject) && (e1Wc2 <= 0) && (e2Wc2 <= 0))) + AddLocalMinPoly(e1, e2, pt); + break; + case ClipType.ctXor: + AddLocalMinPoly(e1, e2, pt); + break; + } + else + SwapSides(e1, e2); + } + } + + //------------------------------------------------------------------------------ + + private void DeleteFromSEL(TEdge e) + { + TEdge SelPrev = e.PrevInSEL; + TEdge SelNext = e.NextInSEL; + if (SelPrev == null && SelNext == null && (e != m_SortedEdges)) + return; //already deleted + if (SelPrev != null) + SelPrev.NextInSEL = SelNext; + else m_SortedEdges = SelNext; + if (SelNext != null) + SelNext.PrevInSEL = SelPrev; + e.NextInSEL = null; + e.PrevInSEL = null; + } + + //------------------------------------------------------------------------------ + + private void ProcessHorizontals() + { + TEdge horzEdge; //m_SortedEdges; + while (PopEdgeFromSEL(out horzEdge)) + ProcessHorizontal(horzEdge); + } + + //------------------------------------------------------------------------------ + + void GetHorzDirection(TEdge HorzEdge, out Direction Dir, out cInt Left, out cInt Right) + { + if (HorzEdge.Bot.X < HorzEdge.Top.X) + { + Left = HorzEdge.Bot.X; + Right = HorzEdge.Top.X; + Dir = Direction.dLeftToRight; + } + else + { + Left = HorzEdge.Top.X; + Right = HorzEdge.Bot.X; + Dir = Direction.dRightToLeft; + } + } + + //------------------------------------------------------------------------ + + private void ProcessHorizontal(TEdge horzEdge) + { + Direction dir; + cInt horzLeft, horzRight; + bool IsOpen = horzEdge.WindDelta == 0; + + GetHorzDirection(horzEdge, out dir, out horzLeft, out horzRight); + + TEdge eLastHorz = horzEdge, eMaxPair = null; + while (eLastHorz.NextInLML != null && IsHorizontal(eLastHorz.NextInLML)) + eLastHorz = eLastHorz.NextInLML; + if (eLastHorz.NextInLML == null) + eMaxPair = GetMaximaPair(eLastHorz); + + Maxima currMax = m_Maxima; + if (currMax != null) + { + //get the first maxima in range (X) ... + if (dir == Direction.dLeftToRight) + { + while (currMax != null && currMax.X <= horzEdge.Bot.X) + currMax = currMax.Next; + if (currMax != null && currMax.X >= eLastHorz.Top.X) + currMax = null; + } + else + { + while (currMax.Next != null && currMax.Next.X < horzEdge.Bot.X) + currMax = currMax.Next; + if (currMax.X <= eLastHorz.Top.X) currMax = null; + } + } + + OutPt op1 = null; + for (;;) //loop through consec. horizontal edges + { + bool IsLastHorz = (horzEdge == eLastHorz); + TEdge e = GetNextInAEL(horzEdge, dir); + while (e != null) + { + //this code block inserts extra coords into horizontal edges (in output + //polygons) whereever maxima touch these horizontal edges. This helps + //'simplifying' polygons (ie if the Simplify property is set). + if (currMax != null) + { + if (dir == Direction.dLeftToRight) + { + while (currMax != null && currMax.X < e.Curr.X) + { + if (horzEdge.OutIdx >= 0 && !IsOpen) + AddOutPt(horzEdge, new IntPoint(currMax.X, horzEdge.Bot.Y)); + currMax = currMax.Next; + } + } + else + { + while (currMax != null && currMax.X > e.Curr.X) + { + if (horzEdge.OutIdx >= 0 && !IsOpen) + AddOutPt(horzEdge, new IntPoint(currMax.X, horzEdge.Bot.Y)); + currMax = currMax.Prev; + } + } + } + + if ((dir == Direction.dLeftToRight && e.Curr.X > horzRight) || + (dir == Direction.dRightToLeft && e.Curr.X < horzLeft)) break; + + //Also break if we've got to the end of an intermediate horizontal edge ... + //nb: Smaller Dx's are to the right of larger Dx's ABOVE the horizontal. + if (e.Curr.X == horzEdge.Top.X && horzEdge.NextInLML != null && + e.Dx < horzEdge.NextInLML.Dx) break; + + if (horzEdge.OutIdx >= 0 && !IsOpen) //note: may be done multiple times + { +#if use_xyz + if (dir == Direction.dLeftToRight) SetZ(ref e.Curr, horzEdge, e); + else SetZ(ref e.Curr, e, horzEdge); +#endif + + op1 = AddOutPt(horzEdge, e.Curr); + TEdge eNextHorz = m_SortedEdges; + while (eNextHorz != null) + { + if (eNextHorz.OutIdx >= 0 && + HorzSegmentsOverlap(horzEdge.Bot.X, + horzEdge.Top.X, eNextHorz.Bot.X, eNextHorz.Top.X)) + { + OutPt op2 = GetLastOutPt(eNextHorz); + AddJoin(op2, op1, eNextHorz.Top); + } + eNextHorz = eNextHorz.NextInSEL; + } + AddGhostJoin(op1, horzEdge.Bot); + } + + //OK, so far we're still in range of the horizontal Edge but make sure + //we're at the last of consec. horizontals when matching with eMaxPair + if (e == eMaxPair && IsLastHorz) + { + if (horzEdge.OutIdx >= 0) + AddLocalMaxPoly(horzEdge, eMaxPair, horzEdge.Top); + DeleteFromAEL(horzEdge); + DeleteFromAEL(eMaxPair); + return; + } + + if (dir == Direction.dLeftToRight) + { + IntPoint Pt = new IntPoint(e.Curr.X, horzEdge.Curr.Y); + IntersectEdges(horzEdge, e, Pt); + } + else + { + IntPoint Pt = new IntPoint(e.Curr.X, horzEdge.Curr.Y); + IntersectEdges(e, horzEdge, Pt); + } + TEdge eNext = GetNextInAEL(e, dir); + SwapPositionsInAEL(horzEdge, e); + e = eNext; + } //end while(e != null) + + //Break out of loop if HorzEdge.NextInLML is not also horizontal ... + if (horzEdge.NextInLML == null || !IsHorizontal(horzEdge.NextInLML)) break; + + UpdateEdgeIntoAEL(ref horzEdge); + if (horzEdge.OutIdx >= 0) AddOutPt(horzEdge, horzEdge.Bot); + GetHorzDirection(horzEdge, out dir, out horzLeft, out horzRight); + } //end for (;;) + + if (horzEdge.OutIdx >= 0 && op1 == null) + { + op1 = GetLastOutPt(horzEdge); + TEdge eNextHorz = m_SortedEdges; + while (eNextHorz != null) + { + if (eNextHorz.OutIdx >= 0 && + HorzSegmentsOverlap(horzEdge.Bot.X, + horzEdge.Top.X, eNextHorz.Bot.X, eNextHorz.Top.X)) + { + OutPt op2 = GetLastOutPt(eNextHorz); + AddJoin(op2, op1, eNextHorz.Top); + } + eNextHorz = eNextHorz.NextInSEL; + } + AddGhostJoin(op1, horzEdge.Top); + } + + if (horzEdge.NextInLML != null) + { + if (horzEdge.OutIdx >= 0) + { + op1 = AddOutPt(horzEdge, horzEdge.Top); + + UpdateEdgeIntoAEL(ref horzEdge); + if (horzEdge.WindDelta == 0) return; + //nb: HorzEdge is no longer horizontal here + TEdge ePrev = horzEdge.PrevInAEL; + TEdge eNext = horzEdge.NextInAEL; + if (ePrev != null && ePrev.Curr.X == horzEdge.Bot.X && + ePrev.Curr.Y == horzEdge.Bot.Y && ePrev.WindDelta != 0 && + (ePrev.OutIdx >= 0 && ePrev.Curr.Y > ePrev.Top.Y && + SlopesEqual(horzEdge, ePrev, m_UseFullRange))) + { + OutPt op2 = AddOutPt(ePrev, horzEdge.Bot); + AddJoin(op1, op2, horzEdge.Top); + } + else if (eNext != null && eNext.Curr.X == horzEdge.Bot.X && + eNext.Curr.Y == horzEdge.Bot.Y && eNext.WindDelta != 0 && + eNext.OutIdx >= 0 && eNext.Curr.Y > eNext.Top.Y && + SlopesEqual(horzEdge, eNext, m_UseFullRange)) + { + OutPt op2 = AddOutPt(eNext, horzEdge.Bot); + AddJoin(op1, op2, horzEdge.Top); + } + } + else + UpdateEdgeIntoAEL(ref horzEdge); + } + else + { + if (horzEdge.OutIdx >= 0) AddOutPt(horzEdge, horzEdge.Top); + DeleteFromAEL(horzEdge); + } + } + + //------------------------------------------------------------------------------ + + private TEdge GetNextInAEL(TEdge e, Direction Direction) + { + return Direction == Direction.dLeftToRight ? e.NextInAEL : e.PrevInAEL; + } + + //------------------------------------------------------------------------------ + + private bool IsMinima(TEdge e) + { + return e != null && (e.Prev.NextInLML != e) && (e.Next.NextInLML != e); + } + + //------------------------------------------------------------------------------ + + private bool IsMaxima(TEdge e, double Y) + { + return (e != null && e.Top.Y == Y && e.NextInLML == null); + } + + //------------------------------------------------------------------------------ + + private bool IsIntermediate(TEdge e, double Y) + { + return (e.Top.Y == Y && e.NextInLML != null); + } + + //------------------------------------------------------------------------------ + + internal TEdge GetMaximaPair(TEdge e) + { + if ((e.Next.Top == e.Top) && e.Next.NextInLML == null) + return e.Next; + else if ((e.Prev.Top == e.Top) && e.Prev.NextInLML == null) + return e.Prev; + else + return null; + } + + //------------------------------------------------------------------------------ + + internal TEdge GetMaximaPairEx(TEdge e) + { + //as above but returns null if MaxPair isn't in AEL (unless it's horizontal) + TEdge result = GetMaximaPair(e); + if (result == null || result.OutIdx == Skip || + ((result.NextInAEL == result.PrevInAEL) && !IsHorizontal(result))) return null; + return result; + } + + //------------------------------------------------------------------------------ + + private bool ProcessIntersections(cInt topY) + { + if (m_ActiveEdges == null) return true; + try + { + BuildIntersectList(topY); + if (m_IntersectList.Count == 0) return true; + if (m_IntersectList.Count == 1 || FixupIntersectionOrder()) + ProcessIntersectList(); + else + return false; + } + catch + { + m_SortedEdges = null; + m_IntersectList.Clear(); + throw new ClipperException("ProcessIntersections error"); + } + m_SortedEdges = null; + return true; + } + + //------------------------------------------------------------------------------ + + private void BuildIntersectList(cInt topY) + { + if (m_ActiveEdges == null) return; + + //prepare for sorting ... + TEdge e = m_ActiveEdges; + m_SortedEdges = e; + while (e != null) + { + e.PrevInSEL = e.PrevInAEL; + e.NextInSEL = e.NextInAEL; + e.Curr.X = TopX(e, topY); + e = e.NextInAEL; + } + + //bubblesort ... + bool isModified = true; + while (isModified && m_SortedEdges != null) + { + isModified = false; + e = m_SortedEdges; + while (e.NextInSEL != null) + { + TEdge eNext = e.NextInSEL; + IntPoint pt; + if (e.Curr.X > eNext.Curr.X) + { + IntersectPoint(e, eNext, out pt); + if (pt.Y < topY) + pt = new IntPoint(TopX(e, topY), topY); + IntersectNode newNode = new IntersectNode(); + newNode.Edge1 = e; + newNode.Edge2 = eNext; + newNode.Pt = pt; + m_IntersectList.Add(newNode); + + SwapPositionsInSEL(e, eNext); + isModified = true; + } + else + e = eNext; + } + if (e.PrevInSEL != null) e.PrevInSEL.NextInSEL = null; + else break; + } + m_SortedEdges = null; + } + + //------------------------------------------------------------------------------ + + private bool EdgesAdjacent(IntersectNode inode) + { + return (inode.Edge1.NextInSEL == inode.Edge2) || + (inode.Edge1.PrevInSEL == inode.Edge2); + } + + //------------------------------------------------------------------------------ + + private static int IntersectNodeSort(IntersectNode node1, IntersectNode node2) + { + //the following typecast is safe because the differences in Pt.Y will + //be limited to the height of the scanbeam. + return (int)(node2.Pt.Y - node1.Pt.Y); + } + + //------------------------------------------------------------------------------ + + private bool FixupIntersectionOrder() + { + //pre-condition: intersections are sorted bottom-most first. + //Now it's crucial that intersections are made only between adjacent edges, + //so to ensure this the order of intersections may need adjusting ... + m_IntersectList.Sort(m_IntersectNodeComparer); + + CopyAELToSEL(); + int cnt = m_IntersectList.Count; + for (int i = 0; i < cnt; i++) + { + if (!EdgesAdjacent(m_IntersectList[i])) + { + int j = i + 1; + while (j < cnt && !EdgesAdjacent(m_IntersectList[j])) j++; + if (j == cnt) return false; + + IntersectNode tmp = m_IntersectList[i]; + m_IntersectList[i] = m_IntersectList[j]; + m_IntersectList[j] = tmp; + } + SwapPositionsInSEL(m_IntersectList[i].Edge1, m_IntersectList[i].Edge2); + } + return true; + } + + //------------------------------------------------------------------------------ + + private void ProcessIntersectList() + { + for (int i = 0; i < m_IntersectList.Count; i++) + { + IntersectNode iNode = m_IntersectList[i]; + { + IntersectEdges(iNode.Edge1, iNode.Edge2, iNode.Pt); + SwapPositionsInAEL(iNode.Edge1, iNode.Edge2); + } + } + m_IntersectList.Clear(); + } + + //------------------------------------------------------------------------------ + + internal static cInt Round(double value) + { + return value < 0 ? (cInt)(value - 0.5) : (cInt)(value + 0.5); + } + + //------------------------------------------------------------------------------ + + private static cInt TopX(TEdge edge, cInt currentY) + { + if (currentY == edge.Top.Y) + return edge.Top.X; + return edge.Bot.X + Round(edge.Dx * (currentY - edge.Bot.Y)); + } + + //------------------------------------------------------------------------------ + + private void IntersectPoint(TEdge edge1, TEdge edge2, out IntPoint ip) + { + ip = new IntPoint(); + double b1, b2; + //nb: with very large coordinate values, it's possible for SlopesEqual() to + //return false but for the edge.Dx value be equal due to double precision rounding. + if (edge1.Dx == edge2.Dx) + { + ip.Y = edge1.Curr.Y; + ip.X = TopX(edge1, ip.Y); + return; + } + + if (edge1.Delta.X == 0) + { + ip.X = edge1.Bot.X; + if (IsHorizontal(edge2)) + { + ip.Y = edge2.Bot.Y; + } + else + { + b2 = edge2.Bot.Y - (edge2.Bot.X / edge2.Dx); + ip.Y = Round(ip.X / edge2.Dx + b2); + } + } + else if (edge2.Delta.X == 0) + { + ip.X = edge2.Bot.X; + if (IsHorizontal(edge1)) + { + ip.Y = edge1.Bot.Y; + } + else + { + b1 = edge1.Bot.Y - (edge1.Bot.X / edge1.Dx); + ip.Y = Round(ip.X / edge1.Dx + b1); + } + } + else + { + b1 = edge1.Bot.X - edge1.Bot.Y * edge1.Dx; + b2 = edge2.Bot.X - edge2.Bot.Y * edge2.Dx; + double q = (b2 - b1) / (edge1.Dx - edge2.Dx); + ip.Y = Round(q); + if (Math.Abs(edge1.Dx) < Math.Abs(edge2.Dx)) + ip.X = Round(edge1.Dx * q + b1); + else + ip.X = Round(edge2.Dx * q + b2); + } + + if (ip.Y < edge1.Top.Y || ip.Y < edge2.Top.Y) + { + if (edge1.Top.Y > edge2.Top.Y) + ip.Y = edge1.Top.Y; + else + ip.Y = edge2.Top.Y; + if (Math.Abs(edge1.Dx) < Math.Abs(edge2.Dx)) + ip.X = TopX(edge1, ip.Y); + else + ip.X = TopX(edge2, ip.Y); + } + //finally, don't allow 'ip' to be BELOW curr.Y (ie bottom of scanbeam) ... + if (ip.Y > edge1.Curr.Y) + { + ip.Y = edge1.Curr.Y; + //better to use the more vertical edge to derive X ... + if (Math.Abs(edge1.Dx) > Math.Abs(edge2.Dx)) + ip.X = TopX(edge2, ip.Y); + else + ip.X = TopX(edge1, ip.Y); + } + } + + //------------------------------------------------------------------------------ + + private void ProcessEdgesAtTopOfScanbeam(cInt topY) + { + TEdge e = m_ActiveEdges; + while (e != null) + { + //1. process maxima, treating them as if they're 'bent' horizontal edges, + // but exclude maxima with horizontal edges. nb: e can't be a horizontal. + bool IsMaximaEdge = IsMaxima(e, topY); + + if (IsMaximaEdge) + { + TEdge eMaxPair = GetMaximaPairEx(e); + IsMaximaEdge = (eMaxPair == null || !IsHorizontal(eMaxPair)); + } + + if (IsMaximaEdge) + { + if (StrictlySimple) InsertMaxima(e.Top.X); + TEdge ePrev = e.PrevInAEL; + DoMaxima(e); + if (ePrev == null) e = m_ActiveEdges; + else e = ePrev.NextInAEL; + } + else + { + //2. promote horizontal edges, otherwise update Curr.X and Curr.Y ... + if (IsIntermediate(e, topY) && IsHorizontal(e.NextInLML)) + { + UpdateEdgeIntoAEL(ref e); + if (e.OutIdx >= 0) + AddOutPt(e, e.Bot); + AddEdgeToSEL(e); + } + else + { + e.Curr.X = TopX(e, topY); + e.Curr.Y = topY; +#if use_xyz + if (e.Top.Y == topY) e.Curr.Z = e.Top.Z; + else if (e.Bot.Y == topY) e.Curr.Z = e.Bot.Z; + else e.Curr.Z = 0; +#endif + } + //When StrictlySimple and 'e' is being touched by another edge, then + //make sure both edges have a vertex here ... + if (StrictlySimple) + { + TEdge ePrev = e.PrevInAEL; + if ((e.OutIdx >= 0) && (e.WindDelta != 0) && ePrev != null && + (ePrev.OutIdx >= 0) && (ePrev.Curr.X == e.Curr.X) && + (ePrev.WindDelta != 0)) + { + IntPoint ip = new IntPoint(e.Curr); +#if use_xyz + SetZ(ref ip, ePrev, e); +#endif + OutPt op = AddOutPt(ePrev, ip); + OutPt op2 = AddOutPt(e, ip); + AddJoin(op, op2, ip); //StrictlySimple (type-3) join + } + } + + e = e.NextInAEL; + } + } + + //3. Process horizontals at the Top of the scanbeam ... + ProcessHorizontals(); + m_Maxima = null; + + //4. Promote intermediate vertices ... + e = m_ActiveEdges; + while (e != null) + { + if (IsIntermediate(e, topY)) + { + OutPt op = null; + if (e.OutIdx >= 0) + op = AddOutPt(e, e.Top); + UpdateEdgeIntoAEL(ref e); + + //if output polygons share an edge, they'll need joining later ... + TEdge ePrev = e.PrevInAEL; + TEdge eNext = e.NextInAEL; + if (ePrev != null && ePrev.Curr.X == e.Bot.X && + ePrev.Curr.Y == e.Bot.Y && op != null && + ePrev.OutIdx >= 0 && ePrev.Curr.Y > ePrev.Top.Y && + SlopesEqual(e.Curr, e.Top, ePrev.Curr, ePrev.Top, m_UseFullRange) && + (e.WindDelta != 0) && (ePrev.WindDelta != 0)) + { + OutPt op2 = AddOutPt(ePrev, e.Bot); + AddJoin(op, op2, e.Top); + } + else if (eNext != null && eNext.Curr.X == e.Bot.X && + eNext.Curr.Y == e.Bot.Y && op != null && + eNext.OutIdx >= 0 && eNext.Curr.Y > eNext.Top.Y && + SlopesEqual(e.Curr, e.Top, eNext.Curr, eNext.Top, m_UseFullRange) && + (e.WindDelta != 0) && (eNext.WindDelta != 0)) + { + OutPt op2 = AddOutPt(eNext, e.Bot); + AddJoin(op, op2, e.Top); + } + } + e = e.NextInAEL; + } + } + + //------------------------------------------------------------------------------ + + private void DoMaxima(TEdge e) + { + TEdge eMaxPair = GetMaximaPairEx(e); + if (eMaxPair == null) + { + if (e.OutIdx >= 0) + AddOutPt(e, e.Top); + DeleteFromAEL(e); + return; + } + + TEdge eNext = e.NextInAEL; + while (eNext != null && eNext != eMaxPair) + { + IntersectEdges(e, eNext, e.Top); + SwapPositionsInAEL(e, eNext); + eNext = e.NextInAEL; + } + + if (e.OutIdx == Unassigned && eMaxPair.OutIdx == Unassigned) + { + DeleteFromAEL(e); + DeleteFromAEL(eMaxPair); + } + else if (e.OutIdx >= 0 && eMaxPair.OutIdx >= 0) + { + if (e.OutIdx >= 0) AddLocalMaxPoly(e, eMaxPair, e.Top); + DeleteFromAEL(e); + DeleteFromAEL(eMaxPair); + } +#if use_lines + else if (e.WindDelta == 0) + { + if (e.OutIdx >= 0) + { + AddOutPt(e, e.Top); + e.OutIdx = Unassigned; + } + DeleteFromAEL(e); + + if (eMaxPair.OutIdx >= 0) + { + AddOutPt(eMaxPair, e.Top); + eMaxPair.OutIdx = Unassigned; + } + DeleteFromAEL(eMaxPair); + } +#endif + else throw new ClipperException("DoMaxima error"); + } + + //------------------------------------------------------------------------------ + + public static void ReversePaths(Paths polys) + { + foreach (var poly in polys) { poly.Reverse(); } + } + + //------------------------------------------------------------------------------ + + public static bool Orientation(Path poly) + { + return Area(poly) >= 0; + } + + //------------------------------------------------------------------------------ + + private int PointCount(OutPt pts) + { + if (pts == null) return 0; + int result = 0; + OutPt p = pts; + do + { + result++; + p = p.Next; + } + while (p != pts); + return result; + } + + //------------------------------------------------------------------------------ + + private void BuildResult(Paths polyg) + { + polyg.Clear(); + polyg.Capacity = m_PolyOuts.Count; + for (int i = 0; i < m_PolyOuts.Count; i++) + { + OutRec outRec = m_PolyOuts[i]; + if (outRec.Pts == null) continue; + OutPt p = outRec.Pts.Prev; + int cnt = PointCount(p); + if (cnt < 2) continue; + Path pg = new Path(cnt); + for (int j = 0; j < cnt; j++) + { + pg.Add(p.Pt); + p = p.Prev; + } + polyg.Add(pg); + } + } + + //------------------------------------------------------------------------------ + + private void BuildResult2(PolyTree polytree) + { + polytree.Clear(); + + //add each output polygon/contour to polytree ... + polytree.m_AllPolys.Capacity = m_PolyOuts.Count; + for (int i = 0; i < m_PolyOuts.Count; i++) + { + OutRec outRec = m_PolyOuts[i]; + int cnt = PointCount(outRec.Pts); + if ((outRec.IsOpen && cnt < 2) || + (!outRec.IsOpen && cnt < 3)) continue; + FixHoleLinkage(outRec); + PolyNode pn = new PolyNode(); + polytree.m_AllPolys.Add(pn); + outRec.PolyNode = pn; + pn.m_polygon.Capacity = cnt; + OutPt op = outRec.Pts.Prev; + for (int j = 0; j < cnt; j++) + { + pn.m_polygon.Add(op.Pt); + op = op.Prev; + } + } + + //fixup PolyNode links etc ... + polytree.m_Childs.Capacity = m_PolyOuts.Count; + for (int i = 0; i < m_PolyOuts.Count; i++) + { + OutRec outRec = m_PolyOuts[i]; + if (outRec.PolyNode == null) continue; + else if (outRec.IsOpen) + { + outRec.PolyNode.IsOpen = true; + polytree.AddChild(outRec.PolyNode); + } + else if (outRec.FirstLeft != null && + outRec.FirstLeft.PolyNode != null) + outRec.FirstLeft.PolyNode.AddChild(outRec.PolyNode); + else + polytree.AddChild(outRec.PolyNode); + } + } + + //------------------------------------------------------------------------------ + + private void FixupOutPolyline(OutRec outrec) + { + OutPt pp = outrec.Pts; + OutPt lastPP = pp.Prev; + while (pp != lastPP) + { + pp = pp.Next; + if (pp.Pt == pp.Prev.Pt) + { + if (pp == lastPP) lastPP = pp.Prev; + OutPt tmpPP = pp.Prev; + tmpPP.Next = pp.Next; + pp.Next.Prev = tmpPP; + pp = tmpPP; + } + } + if (pp == pp.Prev) outrec.Pts = null; + } + + //------------------------------------------------------------------------------ + + private void FixupOutPolygon(OutRec outRec) + { + //FixupOutPolygon() - removes duplicate points and simplifies consecutive + //parallel edges by removing the middle vertex. + OutPt lastOK = null; + outRec.BottomPt = null; + OutPt pp = outRec.Pts; + bool preserveCol = PreserveCollinear || StrictlySimple; + for (;;) + { + if (pp.Prev == pp || pp.Prev == pp.Next) + { + outRec.Pts = null; + return; + } + //test for duplicate points and collinear edges ... + if ((pp.Pt == pp.Next.Pt) || (pp.Pt == pp.Prev.Pt) || + (SlopesEqual(pp.Prev.Pt, pp.Pt, pp.Next.Pt, m_UseFullRange) && + (!preserveCol || !Pt2IsBetweenPt1AndPt3(pp.Prev.Pt, pp.Pt, pp.Next.Pt)))) + { + lastOK = null; + pp.Prev.Next = pp.Next; + pp.Next.Prev = pp.Prev; + pp = pp.Prev; + } + else if (pp == lastOK) break; + else + { + if (lastOK == null) lastOK = pp; + pp = pp.Next; + } + } + outRec.Pts = pp; + } + + //------------------------------------------------------------------------------ + + OutPt DupOutPt(OutPt outPt, bool InsertAfter) + { + OutPt result = new OutPt(); + result.Pt = outPt.Pt; + result.Idx = outPt.Idx; + if (InsertAfter) + { + result.Next = outPt.Next; + result.Prev = outPt; + outPt.Next.Prev = result; + outPt.Next = result; + } + else + { + result.Prev = outPt.Prev; + result.Next = outPt; + outPt.Prev.Next = result; + outPt.Prev = result; + } + return result; + } + + //------------------------------------------------------------------------------ + + bool GetOverlap(cInt a1, cInt a2, cInt b1, cInt b2, out cInt Left, out cInt Right) + { + if (a1 < a2) + { + if (b1 < b2) {Left = Math.Max(a1, b1); Right = Math.Min(a2, b2); } + else {Left = Math.Max(a1, b2); Right = Math.Min(a2, b1); } + } + else + { + if (b1 < b2) {Left = Math.Max(a2, b1); Right = Math.Min(a1, b2); } + else { Left = Math.Max(a2, b2); Right = Math.Min(a1, b1); } + } + return Left < Right; + } + + //------------------------------------------------------------------------------ + + bool JoinHorz(OutPt op1, OutPt op1b, OutPt op2, OutPt op2b, + IntPoint Pt, bool DiscardLeft) + { + Direction Dir1 = (op1.Pt.X > op1b.Pt.X ? + Direction.dRightToLeft : Direction.dLeftToRight); + Direction Dir2 = (op2.Pt.X > op2b.Pt.X ? + Direction.dRightToLeft : Direction.dLeftToRight); + if (Dir1 == Dir2) return false; + + //When DiscardLeft, we want Op1b to be on the Left of Op1, otherwise we + //want Op1b to be on the Right. (And likewise with Op2 and Op2b.) + //So, to facilitate this while inserting Op1b and Op2b ... + //when DiscardLeft, make sure we're AT or RIGHT of Pt before adding Op1b, + //otherwise make sure we're AT or LEFT of Pt. (Likewise with Op2b.) + if (Dir1 == Direction.dLeftToRight) + { + while (op1.Next.Pt.X <= Pt.X && + op1.Next.Pt.X >= op1.Pt.X && op1.Next.Pt.Y == Pt.Y) + op1 = op1.Next; + if (DiscardLeft && (op1.Pt.X != Pt.X)) op1 = op1.Next; + op1b = DupOutPt(op1, !DiscardLeft); + if (op1b.Pt != Pt) + { + op1 = op1b; + op1.Pt = Pt; + op1b = DupOutPt(op1, !DiscardLeft); + } + } + else + { + while (op1.Next.Pt.X >= Pt.X && + op1.Next.Pt.X <= op1.Pt.X && op1.Next.Pt.Y == Pt.Y) + op1 = op1.Next; + if (!DiscardLeft && (op1.Pt.X != Pt.X)) op1 = op1.Next; + op1b = DupOutPt(op1, DiscardLeft); + if (op1b.Pt != Pt) + { + op1 = op1b; + op1.Pt = Pt; + op1b = DupOutPt(op1, DiscardLeft); + } + } + + if (Dir2 == Direction.dLeftToRight) + { + while (op2.Next.Pt.X <= Pt.X && + op2.Next.Pt.X >= op2.Pt.X && op2.Next.Pt.Y == Pt.Y) + op2 = op2.Next; + if (DiscardLeft && (op2.Pt.X != Pt.X)) op2 = op2.Next; + op2b = DupOutPt(op2, !DiscardLeft); + if (op2b.Pt != Pt) + { + op2 = op2b; + op2.Pt = Pt; + op2b = DupOutPt(op2, !DiscardLeft); + } + } + else + { + while (op2.Next.Pt.X >= Pt.X && + op2.Next.Pt.X <= op2.Pt.X && op2.Next.Pt.Y == Pt.Y) + op2 = op2.Next; + if (!DiscardLeft && (op2.Pt.X != Pt.X)) op2 = op2.Next; + op2b = DupOutPt(op2, DiscardLeft); + if (op2b.Pt != Pt) + { + op2 = op2b; + op2.Pt = Pt; + op2b = DupOutPt(op2, DiscardLeft); + } + } + + if ((Dir1 == Direction.dLeftToRight) == DiscardLeft) + { + op1.Prev = op2; + op2.Next = op1; + op1b.Next = op2b; + op2b.Prev = op1b; + } + else + { + op1.Next = op2; + op2.Prev = op1; + op1b.Prev = op2b; + op2b.Next = op1b; + } + return true; + } + + //------------------------------------------------------------------------------ + + private bool JoinPoints(Join j, OutRec outRec1, OutRec outRec2) + { + OutPt op1 = j.OutPt1, op1b; + OutPt op2 = j.OutPt2, op2b; + + //There are 3 kinds of joins for output polygons ... + //1. Horizontal joins where Join.OutPt1 & Join.OutPt2 are vertices anywhere + //along (horizontal) collinear edges (& Join.OffPt is on the same horizontal). + //2. Non-horizontal joins where Join.OutPt1 & Join.OutPt2 are at the same + //location at the Bottom of the overlapping segment (& Join.OffPt is above). + //3. StrictlySimple joins where edges touch but are not collinear and where + //Join.OutPt1, Join.OutPt2 & Join.OffPt all share the same point. + bool isHorizontal = (j.OutPt1.Pt.Y == j.OffPt.Y); + + if (isHorizontal && (j.OffPt == j.OutPt1.Pt) && (j.OffPt == j.OutPt2.Pt)) + { + //Strictly Simple join ... + if (outRec1 != outRec2) return false; + op1b = j.OutPt1.Next; + while (op1b != op1 && (op1b.Pt == j.OffPt)) + op1b = op1b.Next; + bool reverse1 = (op1b.Pt.Y > j.OffPt.Y); + op2b = j.OutPt2.Next; + while (op2b != op2 && (op2b.Pt == j.OffPt)) + op2b = op2b.Next; + bool reverse2 = (op2b.Pt.Y > j.OffPt.Y); + if (reverse1 == reverse2) return false; + if (reverse1) + { + op1b = DupOutPt(op1, false); + op2b = DupOutPt(op2, true); + op1.Prev = op2; + op2.Next = op1; + op1b.Next = op2b; + op2b.Prev = op1b; + j.OutPt1 = op1; + j.OutPt2 = op1b; + return true; + } + else + { + op1b = DupOutPt(op1, true); + op2b = DupOutPt(op2, false); + op1.Next = op2; + op2.Prev = op1; + op1b.Prev = op2b; + op2b.Next = op1b; + j.OutPt1 = op1; + j.OutPt2 = op1b; + return true; + } + } + else if (isHorizontal) + { + //treat horizontal joins differently to non-horizontal joins since with + //them we're not yet sure where the overlapping is. OutPt1.Pt & OutPt2.Pt + //may be anywhere along the horizontal edge. + op1b = op1; + while (op1.Prev.Pt.Y == op1.Pt.Y && op1.Prev != op1b && op1.Prev != op2) + op1 = op1.Prev; + while (op1b.Next.Pt.Y == op1b.Pt.Y && op1b.Next != op1 && op1b.Next != op2) + op1b = op1b.Next; + if (op1b.Next == op1 || op1b.Next == op2) return false; //a flat 'polygon' + + op2b = op2; + while (op2.Prev.Pt.Y == op2.Pt.Y && op2.Prev != op2b && op2.Prev != op1b) + op2 = op2.Prev; + while (op2b.Next.Pt.Y == op2b.Pt.Y && op2b.Next != op2 && op2b.Next != op1) + op2b = op2b.Next; + if (op2b.Next == op2 || op2b.Next == op1) return false; //a flat 'polygon' + + cInt Left, Right; + //Op1 -. Op1b & Op2 -. Op2b are the extremites of the horizontal edges + if (!GetOverlap(op1.Pt.X, op1b.Pt.X, op2.Pt.X, op2b.Pt.X, out Left, out Right)) + return false; + + //DiscardLeftSide: when overlapping edges are joined, a spike will created + //which needs to be cleaned up. However, we don't want Op1 or Op2 caught up + //on the discard Side as either may still be needed for other joins ... + IntPoint Pt; + bool DiscardLeftSide; + if (op1.Pt.X >= Left && op1.Pt.X <= Right) + { + Pt = op1.Pt; DiscardLeftSide = (op1.Pt.X > op1b.Pt.X); + } + else if (op2.Pt.X >= Left && op2.Pt.X <= Right) + { + Pt = op2.Pt; DiscardLeftSide = (op2.Pt.X > op2b.Pt.X); + } + else if (op1b.Pt.X >= Left && op1b.Pt.X <= Right) + { + Pt = op1b.Pt; DiscardLeftSide = op1b.Pt.X > op1.Pt.X; + } + else + { + Pt = op2b.Pt; DiscardLeftSide = (op2b.Pt.X > op2.Pt.X); + } + j.OutPt1 = op1; + j.OutPt2 = op2; + return JoinHorz(op1, op1b, op2, op2b, Pt, DiscardLeftSide); + } + else + { + //nb: For non-horizontal joins ... + // 1. Jr.OutPt1.Pt.Y == Jr.OutPt2.Pt.Y + // 2. Jr.OutPt1.Pt > Jr.OffPt.Y + + //make sure the polygons are correctly oriented ... + op1b = op1.Next; + while ((op1b.Pt == op1.Pt) && (op1b != op1)) op1b = op1b.Next; + bool Reverse1 = ((op1b.Pt.Y > op1.Pt.Y) || + !SlopesEqual(op1.Pt, op1b.Pt, j.OffPt, m_UseFullRange)); + if (Reverse1) + { + op1b = op1.Prev; + while ((op1b.Pt == op1.Pt) && (op1b != op1)) op1b = op1b.Prev; + if ((op1b.Pt.Y > op1.Pt.Y) || + !SlopesEqual(op1.Pt, op1b.Pt, j.OffPt, m_UseFullRange)) return false; + } + op2b = op2.Next; + while ((op2b.Pt == op2.Pt) && (op2b != op2)) op2b = op2b.Next; + bool Reverse2 = ((op2b.Pt.Y > op2.Pt.Y) || + !SlopesEqual(op2.Pt, op2b.Pt, j.OffPt, m_UseFullRange)); + if (Reverse2) + { + op2b = op2.Prev; + while ((op2b.Pt == op2.Pt) && (op2b != op2)) op2b = op2b.Prev; + if ((op2b.Pt.Y > op2.Pt.Y) || + !SlopesEqual(op2.Pt, op2b.Pt, j.OffPt, m_UseFullRange)) return false; + } + + if ((op1b == op1) || (op2b == op2) || (op1b == op2b) || + ((outRec1 == outRec2) && (Reverse1 == Reverse2))) return false; + + if (Reverse1) + { + op1b = DupOutPt(op1, false); + op2b = DupOutPt(op2, true); + op1.Prev = op2; + op2.Next = op1; + op1b.Next = op2b; + op2b.Prev = op1b; + j.OutPt1 = op1; + j.OutPt2 = op1b; + return true; + } + else + { + op1b = DupOutPt(op1, true); + op2b = DupOutPt(op2, false); + op1.Next = op2; + op2.Prev = op1; + op1b.Prev = op2b; + op2b.Next = op1b; + j.OutPt1 = op1; + j.OutPt2 = op1b; + return true; + } + } + } + + //---------------------------------------------------------------------- + + public static int PointInPolygon(IntPoint pt, Path path) + { + //returns 0 if false, +1 if true, -1 if pt ON polygon boundary + //See "The Point in Polygon Problem for Arbitrary Polygons" by Hormann & Agathos + //http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.88.5498&rep=rep1&type=pdf + int result = 0, cnt = path.Count; + if (cnt < 3) return 0; + IntPoint ip = path[0]; + for (int i = 1; i <= cnt; ++i) + { + IntPoint ipNext = (i == cnt ? path[0] : path[i]); + if (ipNext.Y == pt.Y) + { + if ((ipNext.X == pt.X) || (ip.Y == pt.Y && + ((ipNext.X > pt.X) == (ip.X < pt.X)))) return -1; + } + if ((ip.Y < pt.Y) != (ipNext.Y < pt.Y)) + { + if (ip.X >= pt.X) + { + if (ipNext.X > pt.X) result = 1 - result; + else + { + double d = (double)(ip.X - pt.X) * (ipNext.Y - pt.Y) - + (double)(ipNext.X - pt.X) * (ip.Y - pt.Y); + if (d == 0) return -1; + else if ((d > 0) == (ipNext.Y > ip.Y)) result = 1 - result; + } + } + else + { + if (ipNext.X > pt.X) + { + double d = (double)(ip.X - pt.X) * (ipNext.Y - pt.Y) - + (double)(ipNext.X - pt.X) * (ip.Y - pt.Y); + if (d == 0) return -1; + else if ((d > 0) == (ipNext.Y > ip.Y)) result = 1 - result; + } + } + } + ip = ipNext; + } + return result; + } + + //------------------------------------------------------------------------------ + + //See "The Point in Polygon Problem for Arbitrary Polygons" by Hormann & Agathos + //http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.88.5498&rep=rep1&type=pdf + private static int PointInPolygon(IntPoint pt, OutPt op) + { + //returns 0 if false, +1 if true, -1 if pt ON polygon boundary + int result = 0; + OutPt startOp = op; + cInt ptx = pt.X, pty = pt.Y; + cInt poly0x = op.Pt.X, poly0y = op.Pt.Y; + do + { + op = op.Next; + cInt poly1x = op.Pt.X, poly1y = op.Pt.Y; + + if (poly1y == pty) + { + if ((poly1x == ptx) || (poly0y == pty && + ((poly1x > ptx) == (poly0x < ptx)))) return -1; + } + if ((poly0y < pty) != (poly1y < pty)) + { + if (poly0x >= ptx) + { + if (poly1x > ptx) result = 1 - result; + else + { + double d = (double)(poly0x - ptx) * (poly1y - pty) - + (double)(poly1x - ptx) * (poly0y - pty); + if (d == 0) return -1; + if ((d > 0) == (poly1y > poly0y)) result = 1 - result; + } + } + else + { + if (poly1x > ptx) + { + double d = (double)(poly0x - ptx) * (poly1y - pty) - + (double)(poly1x - ptx) * (poly0y - pty); + if (d == 0) return -1; + if ((d > 0) == (poly1y > poly0y)) result = 1 - result; + } + } + } + poly0x = poly1x; poly0y = poly1y; + } + while (startOp != op); + return result; + } + + //------------------------------------------------------------------------------ + + private static bool Poly2ContainsPoly1(OutPt outPt1, OutPt outPt2) + { + OutPt op = outPt1; + do + { + //nb: PointInPolygon returns 0 if false, +1 if true, -1 if pt on polygon + int res = PointInPolygon(op.Pt, outPt2); + if (res >= 0) return res > 0; + op = op.Next; + } + while (op != outPt1); + return true; + } + + //---------------------------------------------------------------------- + + private void FixupFirstLefts1(OutRec OldOutRec, OutRec NewOutRec) + { + foreach (OutRec outRec in m_PolyOuts) + { + OutRec firstLeft = ParseFirstLeft(outRec.FirstLeft); + if (outRec.Pts != null && firstLeft == OldOutRec) + { + if (Poly2ContainsPoly1(outRec.Pts, NewOutRec.Pts)) + outRec.FirstLeft = NewOutRec; + } + } + } + + //---------------------------------------------------------------------- + + private void FixupFirstLefts2(OutRec innerOutRec, OutRec outerOutRec) + { + //A polygon has split into two such that one is now the inner of the other. + //It's possible that these polygons now wrap around other polygons, so check + //every polygon that's also contained by OuterOutRec's FirstLeft container + //(including nil) to see if they've become inner to the new inner polygon ... + OutRec orfl = outerOutRec.FirstLeft; + foreach (OutRec outRec in m_PolyOuts) + { + if (outRec.Pts == null || outRec == outerOutRec || outRec == innerOutRec) + continue; + OutRec firstLeft = ParseFirstLeft(outRec.FirstLeft); + if (firstLeft != orfl && firstLeft != innerOutRec && firstLeft != outerOutRec) + continue; + if (Poly2ContainsPoly1(outRec.Pts, innerOutRec.Pts)) + outRec.FirstLeft = innerOutRec; + else if (Poly2ContainsPoly1(outRec.Pts, outerOutRec.Pts)) + outRec.FirstLeft = outerOutRec; + else if (outRec.FirstLeft == innerOutRec || outRec.FirstLeft == outerOutRec) + outRec.FirstLeft = orfl; + } + } + + //---------------------------------------------------------------------- + + private void FixupFirstLefts3(OutRec OldOutRec, OutRec NewOutRec) + { + //same as FixupFirstLefts1 but doesn't call Poly2ContainsPoly1() + foreach (OutRec outRec in m_PolyOuts) + { + OutRec firstLeft = ParseFirstLeft(outRec.FirstLeft); + if (outRec.Pts != null && firstLeft == OldOutRec) + outRec.FirstLeft = NewOutRec; + } + } + + //---------------------------------------------------------------------- + + private static OutRec ParseFirstLeft(OutRec FirstLeft) + { + while (FirstLeft != null && FirstLeft.Pts == null) + FirstLeft = FirstLeft.FirstLeft; + return FirstLeft; + } + + //------------------------------------------------------------------------------ + + private void JoinCommonEdges() + { + for (int i = 0; i < m_Joins.Count; i++) + { + Join join = m_Joins[i]; + + OutRec outRec1 = GetOutRec(join.OutPt1.Idx); + OutRec outRec2 = GetOutRec(join.OutPt2.Idx); + + if (outRec1.Pts == null || outRec2.Pts == null) continue; + if (outRec1.IsOpen || outRec2.IsOpen) continue; + + //get the polygon fragment with the correct hole state (FirstLeft) + //before calling JoinPoints() ... + OutRec holeStateRec; + if (outRec1 == outRec2) holeStateRec = outRec1; + else if (OutRec1RightOfOutRec2(outRec1, outRec2)) holeStateRec = outRec2; + else if (OutRec1RightOfOutRec2(outRec2, outRec1)) holeStateRec = outRec1; + else holeStateRec = GetLowermostRec(outRec1, outRec2); + + if (!JoinPoints(join, outRec1, outRec2)) continue; + + if (outRec1 == outRec2) + { + //instead of joining two polygons, we've just created a new one by + //splitting one polygon into two. + outRec1.Pts = join.OutPt1; + outRec1.BottomPt = null; + outRec2 = CreateOutRec(); + outRec2.Pts = join.OutPt2; + + //update all OutRec2.Pts Idx's ... + UpdateOutPtIdxs(outRec2); + + if (Poly2ContainsPoly1(outRec2.Pts, outRec1.Pts)) + { + //outRec1 contains outRec2 ... + outRec2.IsHole = !outRec1.IsHole; + outRec2.FirstLeft = outRec1; + + if (m_UsingPolyTree) FixupFirstLefts2(outRec2, outRec1); + + if ((outRec2.IsHole ^ ReverseSolution) == (Area(outRec2) > 0)) + ReversePolyPtLinks(outRec2.Pts); + } + else if (Poly2ContainsPoly1(outRec1.Pts, outRec2.Pts)) + { + //outRec2 contains outRec1 ... + outRec2.IsHole = outRec1.IsHole; + outRec1.IsHole = !outRec2.IsHole; + outRec2.FirstLeft = outRec1.FirstLeft; + outRec1.FirstLeft = outRec2; + + if (m_UsingPolyTree) FixupFirstLefts2(outRec1, outRec2); + + if ((outRec1.IsHole ^ ReverseSolution) == (Area(outRec1) > 0)) + ReversePolyPtLinks(outRec1.Pts); + } + else + { + //the 2 polygons are completely separate ... + outRec2.IsHole = outRec1.IsHole; + outRec2.FirstLeft = outRec1.FirstLeft; + + //fixup FirstLeft pointers that may need reassigning to OutRec2 + if (m_UsingPolyTree) FixupFirstLefts1(outRec1, outRec2); + } + } + else + { + //joined 2 polygons together ... + + outRec2.Pts = null; + outRec2.BottomPt = null; + outRec2.Idx = outRec1.Idx; + + outRec1.IsHole = holeStateRec.IsHole; + if (holeStateRec == outRec2) + outRec1.FirstLeft = outRec2.FirstLeft; + outRec2.FirstLeft = outRec1; + + //fixup FirstLeft pointers that may need reassigning to OutRec1 + if (m_UsingPolyTree) FixupFirstLefts3(outRec2, outRec1); + } + } + } + + //------------------------------------------------------------------------------ + + private void UpdateOutPtIdxs(OutRec outrec) + { + OutPt op = outrec.Pts; + do + { + op.Idx = outrec.Idx; + op = op.Prev; + } + while (op != outrec.Pts); + } + + //------------------------------------------------------------------------------ + + private void DoSimplePolygons() + { + int i = 0; + while (i < m_PolyOuts.Count) + { + OutRec outrec = m_PolyOuts[i++]; + OutPt op = outrec.Pts; + if (op == null || outrec.IsOpen) continue; + do //for each Pt in Polygon until duplicate found do ... + { + OutPt op2 = op.Next; + while (op2 != outrec.Pts) + { + if ((op.Pt == op2.Pt) && op2.Next != op && op2.Prev != op) + { + //split the polygon into two ... + OutPt op3 = op.Prev; + OutPt op4 = op2.Prev; + op.Prev = op4; + op4.Next = op; + op2.Prev = op3; + op3.Next = op2; + + outrec.Pts = op; + OutRec outrec2 = CreateOutRec(); + outrec2.Pts = op2; + UpdateOutPtIdxs(outrec2); + if (Poly2ContainsPoly1(outrec2.Pts, outrec.Pts)) + { + //OutRec2 is contained by OutRec1 ... + outrec2.IsHole = !outrec.IsHole; + outrec2.FirstLeft = outrec; + if (m_UsingPolyTree) FixupFirstLefts2(outrec2, outrec); + } + else if (Poly2ContainsPoly1(outrec.Pts, outrec2.Pts)) + { + //OutRec1 is contained by OutRec2 ... + outrec2.IsHole = outrec.IsHole; + outrec.IsHole = !outrec2.IsHole; + outrec2.FirstLeft = outrec.FirstLeft; + outrec.FirstLeft = outrec2; + if (m_UsingPolyTree) FixupFirstLefts2(outrec, outrec2); + } + else + { + //the 2 polygons are separate ... + outrec2.IsHole = outrec.IsHole; + outrec2.FirstLeft = outrec.FirstLeft; + if (m_UsingPolyTree) FixupFirstLefts1(outrec, outrec2); + } + op2 = op; //ie get ready for the next iteration + } + op2 = op2.Next; + } + op = op.Next; + } + while (op != outrec.Pts); + } + } + + //------------------------------------------------------------------------------ + + public static double Area(Path poly) + { + int cnt = (int)poly.Count; + if (cnt < 3) return 0; + double a = 0; + for (int i = 0, j = cnt - 1; i < cnt; ++i) + { + a += ((double)poly[j].X + poly[i].X) * ((double)poly[j].Y - poly[i].Y); + j = i; + } + return -a * 0.5; + } + + //------------------------------------------------------------------------------ + + internal double Area(OutRec outRec) + { + return Area(outRec.Pts); + } + + //------------------------------------------------------------------------------ + + internal double Area(OutPt op) + { + OutPt opFirst = op; + if (op == null) return 0; + double a = 0; + do + { + a = a + (double)(op.Prev.Pt.X + op.Pt.X) * (double)(op.Prev.Pt.Y - op.Pt.Y); + op = op.Next; + } + while (op != opFirst); + return a * 0.5; + } + + //------------------------------------------------------------------------------ + // SimplifyPolygon functions ... + // Convert self-intersecting polygons into simple polygons + //------------------------------------------------------------------------------ + + public static Paths SimplifyPolygon(Path poly, + PolyFillType fillType = PolyFillType.pftEvenOdd) + { + Paths result = new Paths(); + Clipper c = new Clipper(); + c.StrictlySimple = true; + c.AddPath(poly, PolyType.ptSubject, true); + c.Execute(ClipType.ctUnion, result, fillType, fillType); + return result; + } + + //------------------------------------------------------------------------------ + + public static Paths SimplifyPolygons(Paths polys, + PolyFillType fillType = PolyFillType.pftEvenOdd) + { + Paths result = new Paths(); + Clipper c = new Clipper(); + c.StrictlySimple = true; + c.AddPaths(polys, PolyType.ptSubject, true); + c.Execute(ClipType.ctUnion, result, fillType, fillType); + return result; + } + + //------------------------------------------------------------------------------ + + private static double DistanceSqrd(IntPoint pt1, IntPoint pt2) + { + double dx = ((double)pt1.X - pt2.X); + double dy = ((double)pt1.Y - pt2.Y); + return (dx * dx + dy * dy); + } + + //------------------------------------------------------------------------------ + + private static double DistanceFromLineSqrd(IntPoint pt, IntPoint ln1, IntPoint ln2) + { + //The equation of a line in general form (Ax + By + C = 0) + //given 2 points (x¹,y¹) & (x²,y²) is ... + //(y¹ - y²)x + (x² - x¹)y + (y² - y¹)x¹ - (x² - x¹)y¹ = 0 + //A = (y¹ - y²); B = (x² - x¹); C = (y² - y¹)x¹ - (x² - x¹)y¹ + //perpendicular distance of point (x³,y³) = (Ax³ + By³ + C)/Sqrt(A² + B²) + //see http://en.wikipedia.org/wiki/Perpendicular_distance + double A = ln1.Y - ln2.Y; + double B = ln2.X - ln1.X; + double C = A * ln1.X + B * ln1.Y; + C = A * pt.X + B * pt.Y - C; + return (C * C) / (A * A + B * B); + } + + //--------------------------------------------------------------------------- + + private static bool SlopesNearCollinear(IntPoint pt1, + IntPoint pt2, IntPoint pt3, double distSqrd) + { + //this function is more accurate when the point that's GEOMETRICALLY + //between the other 2 points is the one that's tested for distance. + //nb: with 'spikes', either pt1 or pt3 is geometrically between the other pts + if (Math.Abs(pt1.X - pt2.X) > Math.Abs(pt1.Y - pt2.Y)) + { + if ((pt1.X > pt2.X) == (pt1.X < pt3.X)) + return DistanceFromLineSqrd(pt1, pt2, pt3) < distSqrd; + else if ((pt2.X > pt1.X) == (pt2.X < pt3.X)) + return DistanceFromLineSqrd(pt2, pt1, pt3) < distSqrd; + else + return DistanceFromLineSqrd(pt3, pt1, pt2) < distSqrd; + } + else + { + if ((pt1.Y > pt2.Y) == (pt1.Y < pt3.Y)) + return DistanceFromLineSqrd(pt1, pt2, pt3) < distSqrd; + else if ((pt2.Y > pt1.Y) == (pt2.Y < pt3.Y)) + return DistanceFromLineSqrd(pt2, pt1, pt3) < distSqrd; + else + return DistanceFromLineSqrd(pt3, pt1, pt2) < distSqrd; + } + } + + //------------------------------------------------------------------------------ + + private static bool PointsAreClose(IntPoint pt1, IntPoint pt2, double distSqrd) + { + double dx = (double)pt1.X - pt2.X; + double dy = (double)pt1.Y - pt2.Y; + return ((dx * dx) + (dy * dy) <= distSqrd); + } + + //------------------------------------------------------------------------------ + + private static OutPt ExcludeOp(OutPt op) + { + OutPt result = op.Prev; + result.Next = op.Next; + op.Next.Prev = result; + result.Idx = 0; + return result; + } + + //------------------------------------------------------------------------------ + + public static Path CleanPolygon(Path path, double distance = 1.415) + { + //distance = proximity in units/pixels below which vertices will be stripped. + //Default ~= sqrt(2) so when adjacent vertices or semi-adjacent vertices have + //both x & y coords within 1 unit, then the second vertex will be stripped. + + int cnt = path.Count; + + if (cnt == 0) return new Path(); + + OutPt[] outPts = new OutPt[cnt]; + for (int i = 0; i < cnt; ++i) outPts[i] = new OutPt(); + + for (int i = 0; i < cnt; ++i) + { + outPts[i].Pt = path[i]; + outPts[i].Next = outPts[(i + 1) % cnt]; + outPts[i].Next.Prev = outPts[i]; + outPts[i].Idx = 0; + } + + double distSqrd = distance * distance; + OutPt op = outPts[0]; + while (op.Idx == 0 && op.Next != op.Prev) + { + if (PointsAreClose(op.Pt, op.Prev.Pt, distSqrd)) + { + op = ExcludeOp(op); + cnt--; + } + else if (PointsAreClose(op.Prev.Pt, op.Next.Pt, distSqrd)) + { + ExcludeOp(op.Next); + op = ExcludeOp(op); + cnt -= 2; + } + else if (SlopesNearCollinear(op.Prev.Pt, op.Pt, op.Next.Pt, distSqrd)) + { + op = ExcludeOp(op); + cnt--; + } + else + { + op.Idx = 1; + op = op.Next; + } + } + + if (cnt < 3) cnt = 0; + Path result = new Path(cnt); + for (int i = 0; i < cnt; ++i) + { + result.Add(op.Pt); + op = op.Next; + } + outPts = null; + return result; + } + + //------------------------------------------------------------------------------ + + public static Paths CleanPolygons(Paths polys, + double distance = 1.415) + { + Paths result = new Paths(polys.Count); + for (int i = 0; i < polys.Count; i++) + result.Add(CleanPolygon(polys[i], distance)); + return result; + } + + //------------------------------------------------------------------------------ + + internal static Paths Minkowski(Path pattern, Path path, bool IsSum, bool IsClosed) + { + int delta = (IsClosed ? 1 : 0); + int polyCnt = pattern.Count; + int pathCnt = path.Count; + Paths result = new Paths(pathCnt); + if (IsSum) + for (int i = 0; i < pathCnt; i++) + { + Path p = new Path(polyCnt); + foreach (IntPoint ip in pattern) + p.Add(new IntPoint(path[i].X + ip.X, path[i].Y + ip.Y)); + result.Add(p); + } + else + for (int i = 0; i < pathCnt; i++) + { + Path p = new Path(polyCnt); + foreach (IntPoint ip in pattern) + p.Add(new IntPoint(path[i].X - ip.X, path[i].Y - ip.Y)); + result.Add(p); + } + + Paths quads = new Paths((pathCnt + delta) * (polyCnt + 1)); + for (int i = 0; i < pathCnt - 1 + delta; i++) + for (int j = 0; j < polyCnt; j++) + { + Path quad = new Path(4); + quad.Add(result[i % pathCnt][j % polyCnt]); + quad.Add(result[(i + 1) % pathCnt][j % polyCnt]); + quad.Add(result[(i + 1) % pathCnt][(j + 1) % polyCnt]); + quad.Add(result[i % pathCnt][(j + 1) % polyCnt]); + if (!Orientation(quad)) quad.Reverse(); + quads.Add(quad); + } + return quads; + } + + //------------------------------------------------------------------------------ + + public static Paths MinkowskiSum(Path pattern, Path path, bool pathIsClosed) + { + Paths paths = Minkowski(pattern, path, true, pathIsClosed); + Clipper c = new Clipper(); + c.AddPaths(paths, PolyType.ptSubject, true); + c.Execute(ClipType.ctUnion, paths, PolyFillType.pftNonZero, PolyFillType.pftNonZero); + return paths; + } + + //------------------------------------------------------------------------------ + + private static Path TranslatePath(Path path, IntPoint delta) + { + Path outPath = new Path(path.Count); + for (int i = 0; i < path.Count; i++) + outPath.Add(new IntPoint(path[i].X + delta.X, path[i].Y + delta.Y)); + return outPath; + } + + //------------------------------------------------------------------------------ + + public static Paths MinkowskiSum(Path pattern, Paths paths, bool pathIsClosed) + { + Paths solution = new Paths(); + Clipper c = new Clipper(); + for (int i = 0; i < paths.Count; ++i) + { + Paths tmp = Minkowski(pattern, paths[i], true, pathIsClosed); + c.AddPaths(tmp, PolyType.ptSubject, true); + if (pathIsClosed) + { + Path path = TranslatePath(paths[i], pattern[0]); + c.AddPath(path, PolyType.ptClip, true); + } + } + c.Execute(ClipType.ctUnion, solution, + PolyFillType.pftNonZero, PolyFillType.pftNonZero); + return solution; + } + + //------------------------------------------------------------------------------ + + public static Paths MinkowskiDiff(Path poly1, Path poly2) + { + Paths paths = Minkowski(poly1, poly2, false, true); + Clipper c = new Clipper(); + c.AddPaths(paths, PolyType.ptSubject, true); + c.Execute(ClipType.ctUnion, paths, PolyFillType.pftNonZero, PolyFillType.pftNonZero); + return paths; + } + + //------------------------------------------------------------------------------ + + internal enum NodeType { ntAny, ntOpen, ntClosed }; + + public static Paths PolyTreeToPaths(PolyTree polytree) + { + Paths result = new Paths(); + result.Capacity = polytree.Total; + AddPolyNodeToPaths(polytree, NodeType.ntAny, result); + return result; + } + + //------------------------------------------------------------------------------ + + internal static void AddPolyNodeToPaths(PolyNode polynode, NodeType nt, Paths paths) + { + bool match = true; + switch (nt) + { + case NodeType.ntOpen: return; + case NodeType.ntClosed: match = !polynode.IsOpen; break; + default: break; + } + + if (polynode.m_polygon.Count > 0 && match) + paths.Add(polynode.m_polygon); + foreach (PolyNode pn in polynode.Childs) + AddPolyNodeToPaths(pn, nt, paths); + } + + //------------------------------------------------------------------------------ + + public static Paths OpenPathsFromPolyTree(PolyTree polytree) + { + Paths result = new Paths(); + result.Capacity = polytree.ChildCount; + for (int i = 0; i < polytree.ChildCount; i++) + if (polytree.Childs[i].IsOpen) + result.Add(polytree.Childs[i].m_polygon); + return result; + } + + //------------------------------------------------------------------------------ + + public static Paths ClosedPathsFromPolyTree(PolyTree polytree) + { + Paths result = new Paths(); + result.Capacity = polytree.Total; + AddPolyNodeToPaths(polytree, NodeType.ntClosed, result); + return result; + } + + //------------------------------------------------------------------------------ + } //end Clipper + + public class ClipperOffset + { + private Paths m_destPolys; + private Path m_srcPoly; + private Path m_destPoly; + private List m_normals = new List(); + private double m_delta, m_sinA, m_sin, m_cos; + private double m_miterLim, m_StepsPerRad; + + private IntPoint m_lowest; + private PolyNode m_polyNodes = new PolyNode(); + + public double ArcTolerance { get; set; } + public double MiterLimit { get; set; } + + private const double two_pi = Math.PI * 2; + private const double def_arc_tolerance = 0.25; + + public ClipperOffset( + double miterLimit = 2.0, double arcTolerance = def_arc_tolerance) + { + MiterLimit = miterLimit; + ArcTolerance = arcTolerance; + m_lowest.X = -1; + } + + //------------------------------------------------------------------------------ + + public void Clear() + { + m_polyNodes.Childs.Clear(); + m_lowest.X = -1; + } + + //------------------------------------------------------------------------------ + + internal static cInt Round(double value) + { + return value < 0 ? (cInt)(value - 0.5) : (cInt)(value + 0.5); + } + + //------------------------------------------------------------------------------ + + public void AddPath(Path path, JoinType joinType, EndType endType) + { + int highI = path.Count - 1; + if (highI < 0) return; + PolyNode newNode = new PolyNode(); + newNode.m_jointype = joinType; + newNode.m_endtype = endType; + + //strip duplicate points from path and also get index to the lowest point ... + if (endType == EndType.etClosedLine || endType == EndType.etClosedPolygon) + while (highI > 0 && path[0] == path[highI]) highI--; + newNode.m_polygon.Capacity = highI + 1; + newNode.m_polygon.Add(path[0]); + int j = 0, k = 0; + for (int i = 1; i <= highI; i++) + if (newNode.m_polygon[j] != path[i]) + { + j++; + newNode.m_polygon.Add(path[i]); + if (path[i].Y > newNode.m_polygon[k].Y || + (path[i].Y == newNode.m_polygon[k].Y && + path[i].X < newNode.m_polygon[k].X)) k = j; + } + if (endType == EndType.etClosedPolygon && j < 2) return; + + m_polyNodes.AddChild(newNode); + + //if this path's lowest pt is lower than all the others then update m_lowest + if (endType != EndType.etClosedPolygon) return; + if (m_lowest.X < 0) + m_lowest = new IntPoint(m_polyNodes.ChildCount - 1, k); + else + { + IntPoint ip = m_polyNodes.Childs[(int)m_lowest.X].m_polygon[(int)m_lowest.Y]; + if (newNode.m_polygon[k].Y > ip.Y || + (newNode.m_polygon[k].Y == ip.Y && + newNode.m_polygon[k].X < ip.X)) + m_lowest = new IntPoint(m_polyNodes.ChildCount - 1, k); + } + } + + //------------------------------------------------------------------------------ + + public void AddPaths(Paths paths, JoinType joinType, EndType endType) + { + foreach (Path p in paths) + AddPath(p, joinType, endType); + } + + //------------------------------------------------------------------------------ + + private void FixOrientations() + { + //fixup orientations of all closed paths if the orientation of the + //closed path with the lowermost vertex is wrong ... + if (m_lowest.X >= 0 && + !Clipper.Orientation(m_polyNodes.Childs[(int)m_lowest.X].m_polygon)) + { + for (int i = 0; i < m_polyNodes.ChildCount; i++) + { + PolyNode node = m_polyNodes.Childs[i]; + if (node.m_endtype == EndType.etClosedPolygon || + (node.m_endtype == EndType.etClosedLine && + Clipper.Orientation(node.m_polygon))) + node.m_polygon.Reverse(); + } + } + else + { + for (int i = 0; i < m_polyNodes.ChildCount; i++) + { + PolyNode node = m_polyNodes.Childs[i]; + if (node.m_endtype == EndType.etClosedLine && + !Clipper.Orientation(node.m_polygon)) + node.m_polygon.Reverse(); + } + } + } + + //------------------------------------------------------------------------------ + + internal static DoublePoint GetUnitNormal(IntPoint pt1, IntPoint pt2) + { + double dx = (pt2.X - pt1.X); + double dy = (pt2.Y - pt1.Y); + if ((dx == 0) && (dy == 0)) return new DoublePoint(); + + double f = 1 * 1.0 / Math.Sqrt(dx * dx + dy * dy); + dx *= f; + dy *= f; + + return new DoublePoint(dy, -dx); + } + + //------------------------------------------------------------------------------ + + private void DoOffset(double delta) + { + m_destPolys = new Paths(); + m_delta = delta; + + //if Zero offset, just copy any CLOSED polygons to m_p and return ... + if (ClipperBase.near_zero(delta)) + { + m_destPolys.Capacity = m_polyNodes.ChildCount; + for (int i = 0; i < m_polyNodes.ChildCount; i++) + { + PolyNode node = m_polyNodes.Childs[i]; + if (node.m_endtype == EndType.etClosedPolygon) + m_destPolys.Add(node.m_polygon); + } + return; + } + + //see offset_triginometry3.svg in the documentation folder ... + if (MiterLimit > 2) m_miterLim = 2 / (MiterLimit * MiterLimit); + else m_miterLim = 0.5; + + double y; + if (ArcTolerance <= 0.0) + y = def_arc_tolerance; + else if (ArcTolerance > Math.Abs(delta) * def_arc_tolerance) + y = Math.Abs(delta) * def_arc_tolerance; + else + y = ArcTolerance; + //see offset_triginometry2.svg in the documentation folder ... + double steps = Math.PI / Math.Acos(1 - y / Math.Abs(delta)); + m_sin = Math.Sin(two_pi / steps); + m_cos = Math.Cos(two_pi / steps); + m_StepsPerRad = steps / two_pi; + if (delta < 0.0) m_sin = -m_sin; + + m_destPolys.Capacity = m_polyNodes.ChildCount * 2; + for (int i = 0; i < m_polyNodes.ChildCount; i++) + { + PolyNode node = m_polyNodes.Childs[i]; + m_srcPoly = node.m_polygon; + + int len = m_srcPoly.Count; + + if (len == 0 || (delta <= 0 && (len < 3 || + node.m_endtype != EndType.etClosedPolygon))) + continue; + + m_destPoly = new Path(); + + if (len == 1) + { + if (node.m_jointype == JoinType.jtRound) + { + double X = 1.0, Y = 0.0; + for (int j = 1; j <= steps; j++) + { + m_destPoly.Add(new IntPoint( + Round(m_srcPoly[0].X + X * delta), + Round(m_srcPoly[0].Y + Y * delta))); + double X2 = X; + X = X * m_cos - m_sin * Y; + Y = X2 * m_sin + Y * m_cos; + } + } + else + { + double X = -1.0, Y = -1.0; + for (int j = 0; j < 4; ++j) + { + m_destPoly.Add(new IntPoint( + Round(m_srcPoly[0].X + X * delta), + Round(m_srcPoly[0].Y + Y * delta))); + if (X < 0) X = 1; + else if (Y < 0) Y = 1; + else X = -1; + } + } + m_destPolys.Add(m_destPoly); + continue; + } + + //build m_normals ... + m_normals.Clear(); + m_normals.Capacity = len; + for (int j = 0; j < len - 1; j++) + m_normals.Add(GetUnitNormal(m_srcPoly[j], m_srcPoly[j + 1])); + if (node.m_endtype == EndType.etClosedLine || + node.m_endtype == EndType.etClosedPolygon) + m_normals.Add(GetUnitNormal(m_srcPoly[len - 1], m_srcPoly[0])); + else + m_normals.Add(new DoublePoint(m_normals[len - 2])); + + if (node.m_endtype == EndType.etClosedPolygon) + { + int k = len - 1; + for (int j = 0; j < len; j++) + OffsetPoint(j, ref k, node.m_jointype); + m_destPolys.Add(m_destPoly); + } + else if (node.m_endtype == EndType.etClosedLine) + { + int k = len - 1; + for (int j = 0; j < len; j++) + OffsetPoint(j, ref k, node.m_jointype); + m_destPolys.Add(m_destPoly); + m_destPoly = new Path(); + //re-build m_normals ... + DoublePoint n = m_normals[len - 1]; + for (int j = len - 1; j > 0; j--) + m_normals[j] = new DoublePoint(-m_normals[j - 1].X, -m_normals[j - 1].Y); + m_normals[0] = new DoublePoint(-n.X, -n.Y); + k = 0; + for (int j = len - 1; j >= 0; j--) + OffsetPoint(j, ref k, node.m_jointype); + m_destPolys.Add(m_destPoly); + } + else + { + int k = 0; + for (int j = 1; j < len - 1; ++j) + OffsetPoint(j, ref k, node.m_jointype); + + IntPoint pt1; + if (node.m_endtype == EndType.etOpenButt) + { + int j = len - 1; + pt1 = new IntPoint((cInt)Round(m_srcPoly[j].X + m_normals[j].X * + delta), (cInt)Round(m_srcPoly[j].Y + m_normals[j].Y * delta)); + m_destPoly.Add(pt1); + pt1 = new IntPoint((cInt)Round(m_srcPoly[j].X - m_normals[j].X * + delta), (cInt)Round(m_srcPoly[j].Y - m_normals[j].Y * delta)); + m_destPoly.Add(pt1); + } + else + { + int j = len - 1; + k = len - 2; + m_sinA = 0; + m_normals[j] = new DoublePoint(-m_normals[j].X, -m_normals[j].Y); + if (node.m_endtype == EndType.etOpenSquare) + DoSquare(j, k); + else + DoRound(j, k); + } + + //re-build m_normals ... + for (int j = len - 1; j > 0; j--) + m_normals[j] = new DoublePoint(-m_normals[j - 1].X, -m_normals[j - 1].Y); + + m_normals[0] = new DoublePoint(-m_normals[1].X, -m_normals[1].Y); + + k = len - 1; + for (int j = k - 1; j > 0; --j) + OffsetPoint(j, ref k, node.m_jointype); + + if (node.m_endtype == EndType.etOpenButt) + { + pt1 = new IntPoint((cInt)Round(m_srcPoly[0].X - m_normals[0].X * delta), + (cInt)Round(m_srcPoly[0].Y - m_normals[0].Y * delta)); + m_destPoly.Add(pt1); + pt1 = new IntPoint((cInt)Round(m_srcPoly[0].X + m_normals[0].X * delta), + (cInt)Round(m_srcPoly[0].Y + m_normals[0].Y * delta)); + m_destPoly.Add(pt1); + } + else + { + k = 1; + m_sinA = 0; + if (node.m_endtype == EndType.etOpenSquare) + DoSquare(0, 1); + else + DoRound(0, 1); + } + m_destPolys.Add(m_destPoly); + } + } + } + + //------------------------------------------------------------------------------ + + public void Execute(ref Paths solution, double delta) + { + solution.Clear(); + FixOrientations(); + DoOffset(delta); + //now clean up 'corners' ... + Clipper clpr = new Clipper(); + clpr.AddPaths(m_destPolys, PolyType.ptSubject, true); + if (delta > 0) + { + clpr.Execute(ClipType.ctUnion, solution, + PolyFillType.pftPositive, PolyFillType.pftPositive); + } + else + { + IntRect r = Clipper.GetBounds(m_destPolys); + Path outer = new Path(4); + + outer.Add(new IntPoint(r.left - 10, r.bottom + 10)); + outer.Add(new IntPoint(r.right + 10, r.bottom + 10)); + outer.Add(new IntPoint(r.right + 10, r.top - 10)); + outer.Add(new IntPoint(r.left - 10, r.top - 10)); + + clpr.AddPath(outer, PolyType.ptSubject, true); + clpr.ReverseSolution = true; + clpr.Execute(ClipType.ctUnion, solution, PolyFillType.pftNegative, PolyFillType.pftNegative); + if (solution.Count > 0) solution.RemoveAt(0); + } + } + + //------------------------------------------------------------------------------ + + public void Execute(ref PolyTree solution, double delta) + { + solution.Clear(); + FixOrientations(); + DoOffset(delta); + + //now clean up 'corners' ... + Clipper clpr = new Clipper(); + clpr.AddPaths(m_destPolys, PolyType.ptSubject, true); + if (delta > 0) + { + clpr.Execute(ClipType.ctUnion, solution, + PolyFillType.pftPositive, PolyFillType.pftPositive); + } + else + { + IntRect r = Clipper.GetBounds(m_destPolys); + Path outer = new Path(4); + + outer.Add(new IntPoint(r.left - 10, r.bottom + 10)); + outer.Add(new IntPoint(r.right + 10, r.bottom + 10)); + outer.Add(new IntPoint(r.right + 10, r.top - 10)); + outer.Add(new IntPoint(r.left - 10, r.top - 10)); + + clpr.AddPath(outer, PolyType.ptSubject, true); + clpr.ReverseSolution = true; + clpr.Execute(ClipType.ctUnion, solution, PolyFillType.pftNegative, PolyFillType.pftNegative); + //remove the outer PolyNode rectangle ... + if (solution.ChildCount == 1 && solution.Childs[0].ChildCount > 0) + { + PolyNode outerNode = solution.Childs[0]; + solution.Childs.Capacity = outerNode.ChildCount; + solution.Childs[0] = outerNode.Childs[0]; + solution.Childs[0].m_Parent = solution; + for (int i = 1; i < outerNode.ChildCount; i++) + solution.AddChild(outerNode.Childs[i]); + } + else + solution.Clear(); + } + } + + //------------------------------------------------------------------------------ + + void OffsetPoint(int j, ref int k, JoinType jointype) + { + //cross product ... + m_sinA = (m_normals[k].X * m_normals[j].Y - m_normals[j].X * m_normals[k].Y); + + if (Math.Abs(m_sinA * m_delta) < 1.0) + { + //dot product ... + double cosA = (m_normals[k].X * m_normals[j].X + m_normals[j].Y * m_normals[k].Y); + if (cosA > 0) // angle ==> 0 degrees + { + m_destPoly.Add(new IntPoint(Round(m_srcPoly[j].X + m_normals[k].X * m_delta), + Round(m_srcPoly[j].Y + m_normals[k].Y * m_delta))); + return; + } + //else angle ==> 180 degrees + } + else if (m_sinA > 1.0) m_sinA = 1.0; + else if (m_sinA < -1.0) m_sinA = -1.0; + + if (m_sinA * m_delta < 0) + { + m_destPoly.Add(new IntPoint(Round(m_srcPoly[j].X + m_normals[k].X * m_delta), + Round(m_srcPoly[j].Y + m_normals[k].Y * m_delta))); + m_destPoly.Add(m_srcPoly[j]); + m_destPoly.Add(new IntPoint(Round(m_srcPoly[j].X + m_normals[j].X * m_delta), + Round(m_srcPoly[j].Y + m_normals[j].Y * m_delta))); + } + else + switch (jointype) + { + case JoinType.jtMiter: + { + double r = 1 + (m_normals[j].X * m_normals[k].X + + m_normals[j].Y * m_normals[k].Y); + if (r >= m_miterLim) DoMiter(j, k, r); else DoSquare(j, k); + break; + } + case JoinType.jtSquare: DoSquare(j, k); break; + case JoinType.jtRound: DoRound(j, k); break; + } + k = j; + } + + //------------------------------------------------------------------------------ + + internal void DoSquare(int j, int k) + { + double dx = Math.Tan(Math.Atan2(m_sinA, + m_normals[k].X * m_normals[j].X + m_normals[k].Y * m_normals[j].Y) / 4); + m_destPoly.Add(new IntPoint( + Round(m_srcPoly[j].X + m_delta * (m_normals[k].X - m_normals[k].Y * dx)), + Round(m_srcPoly[j].Y + m_delta * (m_normals[k].Y + m_normals[k].X * dx)))); + m_destPoly.Add(new IntPoint( + Round(m_srcPoly[j].X + m_delta * (m_normals[j].X + m_normals[j].Y * dx)), + Round(m_srcPoly[j].Y + m_delta * (m_normals[j].Y - m_normals[j].X * dx)))); + } + + //------------------------------------------------------------------------------ + + internal void DoMiter(int j, int k, double r) + { + double q = m_delta / r; + m_destPoly.Add(new IntPoint(Round(m_srcPoly[j].X + (m_normals[k].X + m_normals[j].X) * q), + Round(m_srcPoly[j].Y + (m_normals[k].Y + m_normals[j].Y) * q))); + } + + //------------------------------------------------------------------------------ + + internal void DoRound(int j, int k) + { + double a = Math.Atan2(m_sinA, + m_normals[k].X * m_normals[j].X + m_normals[k].Y * m_normals[j].Y); + int steps = Math.Max((int)Round(m_StepsPerRad * Math.Abs(a)), 1); + + double X = m_normals[k].X, Y = m_normals[k].Y, X2; + for (int i = 0; i < steps; ++i) + { + m_destPoly.Add(new IntPoint( + Round(m_srcPoly[j].X + X * m_delta), + Round(m_srcPoly[j].Y + Y * m_delta))); + X2 = X; + X = X * m_cos - m_sin * Y; + Y = X2 * m_sin + Y * m_cos; + } + m_destPoly.Add(new IntPoint( + Round(m_srcPoly[j].X + m_normals[j].X * m_delta), + Round(m_srcPoly[j].Y + m_normals[j].Y * m_delta))); + } + + //------------------------------------------------------------------------------ + } + + class ClipperException : Exception + { + public ClipperException(string description) : base(description) {} + } + //------------------------------------------------------------------------------ +} //end ClipperLib namespace diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/Clipper.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/Clipper.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..3c9384eb6a4cc66a0ceffe9fefdfbaa3ed4fd212 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/Clipper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: cc4c383146400014d810176d3a637934 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/ConformingSpline.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/ConformingSpline.cs new file mode 100644 index 0000000000000000000000000000000000000000..acfda7abf73092224fc001c7bc3c71fe37bad048 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/ConformingSpline.cs @@ -0,0 +1,58 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.U2D; + +#if UNITY_EDITOR +using UnityEditor; +#endif + +// Demo Script Usage: +// When you want multiple SpriteShapes to share a common Spline, +// attach this script to the secondary objects you would like to +// copy the Spline and set the ParentObject to the original object +// you are copying from. + +[ExecuteInEditMode] +public class ConformingSpline : MonoBehaviour +{ + + public GameObject m_ParentObject; + private int hashCode; + + // Use this for initialization + void Start() + { + + } + + // Update is called once per frame + void Update() + { + if (m_ParentObject != null) + { + hashCode = CopySpline(m_ParentObject, gameObject, hashCode); + } + } + + private static int CopySpline(GameObject src, GameObject dst, int hashCode) + { +#if UNITY_EDITOR + var parentSpriteShapeController = src.GetComponent(); + var mirrorSpriteShapeController = dst.GetComponent(); + + if (parentSpriteShapeController != null && mirrorSpriteShapeController != null && parentSpriteShapeController.spline.GetHashCode() != hashCode) + { + SerializedObject srcController = new SerializedObject(parentSpriteShapeController); + SerializedObject dstController = new SerializedObject(mirrorSpriteShapeController); + SerializedProperty srcSpline = srcController.FindProperty("m_Spline"); + dstController.CopyFromSerializedProperty(srcSpline); + dstController.ApplyModifiedProperties(); + EditorUtility.SetDirty(mirrorSpriteShapeController); + return parentSpriteShapeController.spline.GetHashCode(); + } +#endif + return hashCode; + } + +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/ConformingSpline.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/ConformingSpline.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..133519a7d854a954ab33ace23a0602f01905ea47 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/ConformingSpline.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: db6f6067a1e6dd34ca4e2c4b7145e79b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/GenerateSpriteShapes.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/GenerateSpriteShapes.cs new file mode 100644 index 0000000000000000000000000000000000000000..ef868bdb99ffb1362c66a17595814e9fb2c056c2 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/GenerateSpriteShapes.cs @@ -0,0 +1,43 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.Rendering; +using UnityEngine.U2D; + +// Please add this Component to Camera or some top level object on each loadable scene. +public class GenerateSpriteShapes : MonoBehaviour +{ + + // Once all SpriteShapes are rendered, remove this Component if On or remove it from elsewhere. + public bool destroyOnCompletion = true; + + void OnGUI() + { + + // Loop all invisible SpriteShapeRenderers and generate geometry. + SpriteShapeRenderer[] spriteShapeRenderers = (SpriteShapeRenderer[]) GameObject.FindObjectsOfType (typeof(SpriteShapeRenderer)); + CommandBuffer rc = new CommandBuffer(); + rc.GetTemporaryRT(0, 256, 256, 0); + rc.SetRenderTarget(0); + foreach (var spriteShapeRenderer in spriteShapeRenderers) + { + var spriteShapeController = spriteShapeRenderer.gameObject.GetComponent(); + if (spriteShapeRenderer != null && spriteShapeController != null) + { + if (!spriteShapeRenderer.isVisible) + { + spriteShapeController.BakeMesh(); + rc.DrawRenderer(spriteShapeRenderer, spriteShapeRenderer.sharedMaterial); + // Debug.Log("generating shape for " + spriteShapeRenderer.gameObject.name); + } + } + } + rc.ReleaseTemporaryRT(0); + Graphics.ExecuteCommandBuffer(rc); + + // SpriteShape Renderers are generated. This component is no longer needed. Delete this [or] remove this Component from elsewhere. + if (destroyOnCompletion) + Destroy(this); + + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/GenerateSpriteShapes.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/GenerateSpriteShapes.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..6982b54ff67232416f8aabeb7ab6f04200517bfa --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/GenerateSpriteShapes.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fccb8cf469e193a4ea6c24362f061c12 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/GeometryCollider.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/GeometryCollider.cs new file mode 100644 index 0000000000000000000000000000000000000000..ca540902940046fb5113fda0027511ebb6d096c8 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/GeometryCollider.cs @@ -0,0 +1,171 @@ +using System.Collections; +using System.Collections.Generic; +using Unity.Collections; +using UnityEngine; +using UnityEngine.Experimental.U2D; +using UnityEngine.U2D; + +#if UNITY_EDITOR +using UnityEditor; +#endif + +[ExecuteAlways] +public class GeometryCollider : MonoBehaviour +{ + [SerializeField] + bool m_UpdateCollider = false; + + int m_HashCode = 0; + + void Start() + { + + } + + // Update is called once per frame + void Update() + { + if (m_UpdateCollider) + Bake(gameObject, false); + } + + static public void Bake(GameObject go, bool forced) + { + var spriteShapeController = go.GetComponent(); + var spriteShapeRenderer = go.GetComponent(); + var polyCollider = go.GetComponent(); + var geometryCollider = go.GetComponent(); + + if (spriteShapeController != null && polyCollider != null) + { + var spline = spriteShapeController.spline; + if (geometryCollider != null) + { + int splineHashCode = spline.GetHashCode(); + if (splineHashCode == geometryCollider.m_HashCode && !forced) + return; + geometryCollider.m_HashCode = splineHashCode; + } + NativeArray indexArray; + NativeSlice posArray; + NativeSlice uv0Array; + NativeArray geomArray; + spriteShapeRenderer.GetChannels(65536, out indexArray, out posArray, out uv0Array); + geomArray = spriteShapeRenderer.GetSegments(spline.GetPointCount() * 8); + + NativeArray indexArrayLocal = new NativeArray(indexArray.Length, Allocator.Temp); + + List points = new List(); + int indexCount = 0, vertexCount = 0, counter = 0; + for (int u = 0; u < geomArray.Length; ++u) + { + if (geomArray[u].indexCount > 0) + { + for (int i = 0; i < geomArray[u].indexCount; ++i) + { + indexArrayLocal[counter] = (ushort)(indexArray[counter] + vertexCount); + counter++; + } + vertexCount += geomArray[u].vertexCount; + indexCount += geomArray[u].indexCount; + } + } + Debug.Log(go.name + " : " + counter); + OuterEdges(polyCollider, indexArrayLocal, posArray, indexCount); + } + } + + // Generate the outer edges from the Renderer mesh. Based on code from www.h3xed.com + static void OuterEdges(PolygonCollider2D polygonCollider, NativeArray triangles, NativeSlice vertices, int triangleCount) + { + // Get just the outer edges from the mesh's triangles (ignore or remove any shared edges) + Dictionary> edges = new Dictionary>(); + for (int i = 0; i < triangleCount; i += 3) + { + for (int e = 0; e < 3; e++) + { + int vert1 = triangles[i + e]; + int vert2 = triangles[i + e + 1 > i + 2 ? i : i + e + 1]; + string edge = Mathf.Min(vert1, vert2) + ":" + Mathf.Max(vert1, vert2); + if (edges.ContainsKey(edge)) + { + edges.Remove(edge); + } + else + { + edges.Add(edge, new KeyValuePair(vert1, vert2)); + } + } + } + + // Create edge lookup (Key is first vertex, Value is second vertex, of each edge) + Dictionary lookup = new Dictionary(); + foreach (KeyValuePair edge in edges.Values) + { + if (lookup.ContainsKey(edge.Key) == false) + { + lookup.Add(edge.Key, edge.Value); + } + } + + // Create empty polygon collider + polygonCollider.pathCount = 0; + + // Loop through edge vertices in order + int startVert = 0; + int nextVert = startVert; + int highestVert = startVert; + List colliderPath = new List(); + while (true) + { + + // Add vertex to collider path + colliderPath.Add(vertices[nextVert]); + + // Get next vertex + nextVert = lookup[nextVert]; + + // Store highest vertex (to know what shape to move to next) + if (nextVert > highestVert) + { + highestVert = nextVert; + } + + // Shape complete + if (nextVert == startVert) + { + + // Add path to polygon collider + polygonCollider.pathCount++; + polygonCollider.SetPath(polygonCollider.pathCount - 1, colliderPath.ToArray()); + colliderPath.Clear(); + + // Go to next shape if one exists + if (lookup.ContainsKey(highestVert + 1)) + { + + // Set starting and next vertices + startVert = highestVert + 1; + nextVert = startVert; + + // Continue to next loop + continue; + } + + // No more verts + break; + } + } + } + +#if UNITY_EDITOR + + [MenuItem("SpriteShape/Generate Geometry Collider", false, 358)] + public static void BakeGeometryCollider() + { + if (Selection.activeGameObject != null) + GeometryCollider.Bake(Selection.activeGameObject, true); + } + +#endif +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/GeometryCollider.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/GeometryCollider.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..075e3285d0c8f4476641119e545bb0b87b773619 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/GeometryCollider.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e0ecd6fe4dd55d640bd7ef3235e0e425 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/LegacyCollider.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/LegacyCollider.cs new file mode 100644 index 0000000000000000000000000000000000000000..dae8235fadc0a6d2985bda98c0cf5c1eb2f56610 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/LegacyCollider.cs @@ -0,0 +1,159 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.U2D; +using ExtrasClipperLib; + +#if UNITY_EDITOR + using UnityEditor; +#endif + +public enum ColliderCornerType +{ + Square, + Round, + Sharp +} + +[ExecuteAlways] +public class LegacyCollider : MonoBehaviour +{ + [SerializeField] + ColliderCornerType m_ColliderCornerType = ColliderCornerType.Square; + [SerializeField] + float m_ColliderOffset = 1.0f; + [SerializeField] + bool m_UpdateCollider = false; + + const float s_ClipperScale = 100000.0f; + int m_HashCode = 0; + + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + if (m_UpdateCollider) + Bake(gameObject, false); + } + + static void SampleCurve(float colliderDetail, Vector3 startPoint, Vector3 startTangent, Vector3 endPoint, Vector3 endTangent, ref List path) + { + + if (startTangent.sqrMagnitude > 0f || endTangent.sqrMagnitude > 0f) + { + for (int j = 0; j <= colliderDetail; ++j) + { + float t = j / (float)colliderDetail; + Vector3 newPoint = BezierUtility.BezierPoint(startPoint, startTangent + startPoint, endTangent + endPoint, endPoint, t) * s_ClipperScale; + + path.Add(new IntPoint((System.Int64)newPoint.x, (System.Int64)newPoint.y)); + } + } + else + { + Vector3 newPoint = startPoint * s_ClipperScale; + path.Add(new IntPoint((System.Int64)newPoint.x, (System.Int64)newPoint.y)); + + newPoint = endPoint * s_ClipperScale; + path.Add(new IntPoint((System.Int64)newPoint.x, (System.Int64)newPoint.y)); + } + } + + public static void Bake(GameObject go, bool forced) + { + var sc = go.GetComponent(); + var lc = go.GetComponent(); + + if (sc != null) + { + List path = new List(); + int splinePointCount = sc.spline.GetPointCount(); + int pathPointCount = splinePointCount; + + ColliderCornerType cct = ColliderCornerType.Square; + float co = 1.0f; + + if (lc != null) + { + int hashCode = sc.spline.GetHashCode() + lc.m_ColliderCornerType.GetHashCode() + lc.m_ColliderOffset.GetHashCode(); + if (lc.m_HashCode == hashCode && !forced) + return; + + lc.m_HashCode = hashCode; + cct = lc.m_ColliderCornerType; + co = lc.m_ColliderOffset; + } + + if (sc.spline.isOpenEnded) + pathPointCount--; + + for (int i = 0; i < pathPointCount; ++i) + { + int nextIndex = SplineUtility.NextIndex(i, splinePointCount); + SampleCurve(sc.colliderDetail, sc.spline.GetPosition(i), sc.spline.GetRightTangent(i), sc.spline.GetPosition(nextIndex), sc.spline.GetLeftTangent(nextIndex), ref path); + } + + if (co != 0f) + { + List> solution = new List>(); + ClipperOffset clipOffset = new ClipperOffset(); + + EndType endType = EndType.etClosedPolygon; + + if (sc.spline.isOpenEnded) + { + endType = EndType.etOpenSquare; + + if (cct == ColliderCornerType.Round) + endType = EndType.etOpenRound; + } + + clipOffset.ArcTolerance = 200f / sc.colliderDetail; + clipOffset.AddPath(path, (ExtrasClipperLib.JoinType)cct, endType); + clipOffset.Execute(ref solution, s_ClipperScale * co); + + if (solution.Count > 0) + path = solution[0]; + } + + List pathPoints = new List(path.Count); + for (int i = 0; i < path.Count; ++i) + { + IntPoint ip = path[i]; + pathPoints.Add(new Vector2(ip.X / s_ClipperScale, ip.Y / s_ClipperScale)); + } + + var pc = go.GetComponent(); + if (pc) + { + pc.pathCount = 0; + pc.SetPath(0, pathPoints.ToArray()); + } + + var ec = go.GetComponent(); + if (ec) + { + if (co > 0f || co < 0f && !sc.spline.isOpenEnded) + pathPoints.Add(pathPoints[0]); + ec.points = pathPoints.ToArray(); + } + } + } + +#if UNITY_EDITOR + + [MenuItem("SpriteShape/Generate Legacy Collider", false, 358)] + public static void BakeLegacyCollider() + { + if (Selection.activeGameObject != null) + LegacyCollider.Bake(Selection.activeGameObject, true); + } + +#endif +} + diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/LegacyCollider.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/LegacyCollider.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..dd6fe01a53d80a4f7f8930e07e87612e43f3c725 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/LegacyCollider.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6a8e65bafadf93f41a17da25163f2f51 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/SimpleDraw.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/SimpleDraw.cs new file mode 100644 index 0000000000000000000000000000000000000000..ca04c87e39e4fb83d307db5c41e8f112c5f36b04 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/SimpleDraw.cs @@ -0,0 +1,59 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.U2D; + +// Dynamic modification of spline to follow the path of mouse movement. +// This script is just a simplified demo to demonstrate the idea. + +public class SimpleDraw : MonoBehaviour +{ + public float minimumDistance = 1.0f; + private Vector3 lastPosition; + + // Use this for initialization + void Start() + { + + } + + private void Smoothen(SpriteShapeController sc, int pointIndex) + { + Vector3 position = sc.spline.GetPosition(pointIndex); + Vector3 positionNext = sc.spline.GetPosition(SplineUtility.NextIndex(pointIndex, sc.spline.GetPointCount())); + Vector3 positionPrev = sc.spline.GetPosition(SplineUtility.PreviousIndex(pointIndex, sc.spline.GetPointCount())); + Vector3 forward = gameObject.transform.forward; + + float scale = Mathf.Min((positionNext - position).magnitude, (positionPrev - position).magnitude) * 0.33f; + + Vector3 leftTangent = (positionPrev - position).normalized * scale; + Vector3 rightTangent = (positionNext - position).normalized * scale; + + sc.spline.SetTangentMode(pointIndex, ShapeTangentMode.Continuous); + SplineUtility.CalculateTangents(position, positionPrev, positionNext, forward, scale, out rightTangent, out leftTangent); + + sc.spline.SetLeftTangent(pointIndex, leftTangent); + sc.spline.SetRightTangent(pointIndex, rightTangent); + } + + // Update is called once per frame + void Update() + { + var mp = Input.mousePosition; + mp.z = 10.0f; + mp = Camera.main.ScreenToWorldPoint(mp); + var dt = Mathf.Abs((mp - lastPosition).magnitude); + var md = (minimumDistance > 1.0f) ? minimumDistance : 1.0f; + if (Input.GetMouseButton(0) && dt > md) + { + var spriteShapeController = gameObject.GetComponent(); + var spline = spriteShapeController.spline; + spline.InsertPointAt(spline.GetPointCount(), mp); + var newPointIndex = spline.GetPointCount() - 1; + Smoothen(spriteShapeController, newPointIndex - 1); + + spline.SetHeight(newPointIndex, UnityEngine.Random.Range(0.1f, 2.0f)); + lastPosition = mp; + } + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/SimpleDraw.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/SimpleDraw.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..8eeecb805539cba6cd50bdddc6cf1324b6341e17 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/SimpleDraw.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 922bb1bbfeaeb9a4c9204b7d0bc3d8c8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/Sprinkler.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/Sprinkler.cs new file mode 100644 index 0000000000000000000000000000000000000000..d7914156aac10fe7e032ad6fc1ba57a4331b490d --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/Sprinkler.cs @@ -0,0 +1,53 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.U2D; + +public class Sprinkler : MonoBehaviour +{ + + public GameObject m_Prefab; + public float m_RandomFactor = 10.0f; + public bool m_UseNormals = false; + + float Angle(Vector3 a, Vector3 b) + { + float dot = Vector3.Dot(a, b); + float det = (a.x * b.y) - (b.x * a.y); + return Mathf.Atan2(det, dot) * Mathf.Rad2Deg; + } + + // Use this for initialization. Plant the Prefabs on Startup + void Start () + { + SpriteShapeController ssc = GetComponent(); + Spline spl = ssc.spline; + + for (int i = 1; i < spl.GetPointCount() - 1; ++i) + { + if (Random.Range(0, 100) > (100 - m_RandomFactor) ) + { + var go = GameObject.Instantiate(m_Prefab); + go.transform.position = spl.GetPosition(i); + + if (m_UseNormals) + { + Vector3 lt = Vector3.Normalize(spl.GetPosition(i - 1) - spl.GetPosition(i)); + Vector3 rt = Vector3.Normalize(spl.GetPosition(i + 1) - spl.GetPosition(i)); + float a = Angle(Vector3.up, lt); + float b = Angle(lt, rt); + float c = a + (b * 0.5f); + if (b > 0) + c = (180 + c); + go.transform.rotation = Quaternion.Euler(0, 0, c); + } + } + } + } + + // Update is called once per frame + void Update () + { + + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/Sprinkler.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/Sprinkler.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..023e9c9573fce751dcdf4a770f04c5c8b26bc3d6 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Scripts/Sprinkler.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1c3eb1d33a6f9114bb5b51099948d2ce +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Branch.asset b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Branch.asset new file mode 100644 index 0000000000000000000000000000000000000000..c4f0c2d912486079430fd8f1417391db9f423b90 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Branch.asset @@ -0,0 +1,48 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: af7181f404f1447c0a7a17b3070b952b, type: 3} + m_Name: Branch + m_EditorClassIdentifier: + m_Angles: + - m_Start: -180 + m_End: 180 + m_Order: 0 + m_Sprites: + - {fileID: 21300000, guid: e205c552afc6743cb9c52e5ff6504efc, type: 3} + m_FillTexture: {fileID: 0} + m_CornerSprites: + - m_CornerType: 0 + m_Sprites: + - {fileID: 0} + - m_CornerType: 1 + m_Sprites: + - {fileID: 0} + - m_CornerType: 2 + m_Sprites: + - {fileID: 0} + - m_CornerType: 3 + m_Sprites: + - {fileID: 0} + - m_CornerType: 4 + m_Sprites: + - {fileID: 0} + - m_CornerType: 5 + m_Sprites: + - {fileID: 0} + - m_CornerType: 6 + m_Sprites: + - {fileID: 0} + - m_CornerType: 7 + m_Sprites: + - {fileID: 0} + m_FillOffset: 0 + m_UseSpriteBorders: 1 diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Branch.asset.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Branch.asset.meta new file mode 100644 index 0000000000000000000000000000000000000000..a5024842bc74274cdf6e83d66e70743c35e18ab1 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Branch.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 67e0d7ab8806749199e5b764729aa46a +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Castle Wall.asset b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Castle Wall.asset new file mode 100644 index 0000000000000000000000000000000000000000..df92ba1c93d1bb1cc30c44a330ec4b0ceb11b46d --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Castle Wall.asset @@ -0,0 +1,64 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: af7181f404f1447c0a7a17b3070b952b, type: 3} + m_Name: Castle Wall + m_EditorClassIdentifier: + m_Angles: + - m_Start: -64 + m_End: 61 + m_Order: 7 + m_Sprites: + - {fileID: 21300002, guid: 3bc0f8978d0114d568eb440fca26e64b, type: 3} + - {fileID: 21300012, guid: a8321f6fae34f034787010a903e29648, type: 3} + - m_Start: 61 + m_End: 127 + m_Order: 4 + m_Sprites: + - {fileID: 21300014, guid: 3bc0f8978d0114d568eb440fca26e64b, type: 3} + - m_Start: 127 + m_End: 233 + m_Order: 8 + m_Sprites: + - {fileID: 21300010, guid: 3bc0f8978d0114d568eb440fca26e64b, type: 3} + - m_Start: -127 + m_End: -64 + m_Order: 3 + m_Sprites: + - {fileID: 21300006, guid: 3bc0f8978d0114d568eb440fca26e64b, type: 3} + m_FillTexture: {fileID: 2800000, guid: 7d8cda48c729c46329cd9d3c69a3a4e6, type: 3} + m_CornerSprites: + - m_CornerType: 0 + m_Sprites: + - {fileID: 21300000, guid: 3bc0f8978d0114d568eb440fca26e64b, type: 3} + - m_CornerType: 1 + m_Sprites: + - {fileID: 21300004, guid: 3bc0f8978d0114d568eb440fca26e64b, type: 3} + - m_CornerType: 2 + m_Sprites: + - {fileID: 21300012, guid: 3bc0f8978d0114d568eb440fca26e64b, type: 3} + - m_CornerType: 3 + m_Sprites: + - {fileID: 21300008, guid: 3bc0f8978d0114d568eb440fca26e64b, type: 3} + - m_CornerType: 4 + m_Sprites: + - {fileID: 0} + - m_CornerType: 5 + m_Sprites: + - {fileID: 0} + - m_CornerType: 6 + m_Sprites: + - {fileID: 21300012, guid: 3bc0f8978d0114d568eb440fca26e64b, type: 3} + - m_CornerType: 7 + m_Sprites: + - {fileID: 21300008, guid: 3bc0f8978d0114d568eb440fca26e64b, type: 3} + m_FillOffset: 0 + m_UseSpriteBorders: 1 diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Castle Wall.asset.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Castle Wall.asset.meta new file mode 100644 index 0000000000000000000000000000000000000000..a31245d21c2dc9efd94cce925cfd6bd64c587545 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Castle Wall.asset.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: a710fe91ca336478e999261a86254e9f +timeCreated: 1507533165 +licenseType: Pro +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Simple1.asset b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Simple1.asset new file mode 100644 index 0000000000000000000000000000000000000000..dc94871a1633b31acf44ef54fb020982eff9af7e --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Simple1.asset @@ -0,0 +1,48 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: af7181f404f1447c0a7a17b3070b952b, type: 3} + m_Name: Simple1 + m_EditorClassIdentifier: + m_Angles: + - m_Start: -180 + m_End: 180 + m_Order: 0 + m_Sprites: + - {fileID: 21300000, guid: e74b518a65bc45f4cace9a2fef6af29d, type: 3} + m_FillTexture: {fileID: 0} + m_CornerSprites: + - m_CornerType: 0 + m_Sprites: + - {fileID: 0} + - m_CornerType: 1 + m_Sprites: + - {fileID: 0} + - m_CornerType: 2 + m_Sprites: + - {fileID: 0} + - m_CornerType: 3 + m_Sprites: + - {fileID: 0} + - m_CornerType: 4 + m_Sprites: + - {fileID: 0} + - m_CornerType: 5 + m_Sprites: + - {fileID: 0} + - m_CornerType: 6 + m_Sprites: + - {fileID: 0} + - m_CornerType: 7 + m_Sprites: + - {fileID: 0} + m_FillOffset: 0 + m_UseSpriteBorders: 1 diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Simple1.asset.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Simple1.asset.meta new file mode 100644 index 0000000000000000000000000000000000000000..4fb38540d168c47e733c2a1b76c48e85f6f52d24 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Simple1.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 541c57e7ddb8adc46b7ca9573818a619 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Simple2.asset b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Simple2.asset new file mode 100644 index 0000000000000000000000000000000000000000..844c48560449525d2972558350130b024656576a --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Simple2.asset @@ -0,0 +1,49 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: af7181f404f1447c0a7a17b3070b952b, type: 3} + m_Name: Simple2 + m_EditorClassIdentifier: + m_Angles: + - m_Start: -180 + m_End: 180 + m_Order: 0 + m_Sprites: + - {fileID: 21300000, guid: 418ab5c27d3054eb89959d9c715e00c9, type: 3} + - {fileID: 21300000, guid: e74b518a65bc45f4cace9a2fef6af29d, type: 3} + m_FillTexture: {fileID: 0} + m_CornerSprites: + - m_CornerType: 0 + m_Sprites: + - {fileID: 0} + - m_CornerType: 1 + m_Sprites: + - {fileID: 0} + - m_CornerType: 2 + m_Sprites: + - {fileID: 0} + - m_CornerType: 3 + m_Sprites: + - {fileID: 0} + - m_CornerType: 4 + m_Sprites: + - {fileID: 0} + - m_CornerType: 5 + m_Sprites: + - {fileID: 0} + - m_CornerType: 6 + m_Sprites: + - {fileID: 0} + - m_CornerType: 7 + m_Sprites: + - {fileID: 0} + m_FillOffset: 0 + m_UseSpriteBorders: 1 diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Simple2.asset.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Simple2.asset.meta new file mode 100644 index 0000000000000000000000000000000000000000..9fa1d5111605d2b8a143370de2f2838d21d990b2 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Simple2.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e03579ec9d1b6c54ea364bd8ee0bcfd8 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Simple3.asset b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Simple3.asset new file mode 100644 index 0000000000000000000000000000000000000000..d33b86ecab467f729c2b24da675fd4cf417cea2a --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Simple3.asset @@ -0,0 +1,48 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: af7181f404f1447c0a7a17b3070b952b, type: 3} + m_Name: Simple3 + m_EditorClassIdentifier: + m_Angles: + - m_Start: -180 + m_End: 180 + m_Order: 0 + m_Sprites: + - {fileID: 21300000, guid: c6dabd295b8ab514fa47b5d4e2b0266e, type: 3} + m_FillTexture: {fileID: 0} + m_CornerSprites: + - m_CornerType: 0 + m_Sprites: + - {fileID: 0} + - m_CornerType: 1 + m_Sprites: + - {fileID: 0} + - m_CornerType: 2 + m_Sprites: + - {fileID: 0} + - m_CornerType: 3 + m_Sprites: + - {fileID: 0} + - m_CornerType: 4 + m_Sprites: + - {fileID: 0} + - m_CornerType: 5 + m_Sprites: + - {fileID: 0} + - m_CornerType: 6 + m_Sprites: + - {fileID: 0} + - m_CornerType: 7 + m_Sprites: + - {fileID: 0} + m_FillOffset: 0 + m_UseSpriteBorders: 1 diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Simple3.asset.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Simple3.asset.meta new file mode 100644 index 0000000000000000000000000000000000000000..f3861970754651a715c1e5dc17227ea6a36a243f --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Simple3.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 19b9cf308de41834c9968d12bec673b1 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Tree A.asset b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Tree A.asset new file mode 100644 index 0000000000000000000000000000000000000000..123e0fc9833e644cdc1d586b64617cb29df34b26 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Tree A.asset @@ -0,0 +1,43 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: af7181f404f1447c0a7a17b3070b952b, type: 3} + m_Name: Tree A + m_EditorClassIdentifier: + m_Angles: [] + m_FillTexture: {fileID: 2800000, guid: a94adaf94669646788de8f639270804a, type: 3} + m_CornerSprites: + - m_CornerType: 0 + m_Sprites: + - {fileID: 0} + - m_CornerType: 1 + m_Sprites: + - {fileID: 0} + - m_CornerType: 2 + m_Sprites: + - {fileID: 0} + - m_CornerType: 3 + m_Sprites: + - {fileID: 0} + - m_CornerType: 4 + m_Sprites: + - {fileID: 0} + - m_CornerType: 5 + m_Sprites: + - {fileID: 0} + - m_CornerType: 6 + m_Sprites: + - {fileID: 0} + - m_CornerType: 7 + m_Sprites: + - {fileID: 0} + m_FillOffset: 0 + m_UseSpriteBorders: 1 diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Tree A.asset.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Tree A.asset.meta new file mode 100644 index 0000000000000000000000000000000000000000..90f7ad5ca0defb32f055b9321f161dcfb3fa1144 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprite Shape Profiles/Tree A.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8e3fa9c7ff3ad4112a30689e933384ed +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprites/CastleWall.psd.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprites/CastleWall.psd.meta new file mode 100644 index 0000000000000000000000000000000000000000..271a0565e932e9264666c20f0b2913126efe551d --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprites/CastleWall.psd.meta @@ -0,0 +1,479 @@ +fileFormatVersion: 2 +guid: 3bc0f8978d0114d568eb440fca26e64b +TextureImporter: + internalIDToNameTable: + - first: + 213: 21300000 + second: CWall_TopLeft + - first: + 213: 21300002 + second: CWall_Top + - first: + 213: 21300004 + second: CWall_TopRight + - first: + 213: 21300006 + second: CWall_Right + - first: + 213: 21300008 + second: CWall_BottomRight + - first: + 213: 21300010 + second: CWall_Bottom + - first: + 213: 21300012 + second: CWall_BottomLeft + - first: + 213: 21300014 + second: CWall_Left + - first: + 213: 21300016 + second: CastleWall_0 + - first: + 213: 21300018 + second: CastleBlock01 + - first: + 213: 21300020 + second: CastleWall_Stand + externalObjects: {} + serializedVersion: 10 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: -1 + mipBias: -100 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 2 + spriteExtrude: 1 + spriteMeshType: 0 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 64 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + - serializedVersion: 3 + buildTarget: iPhone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + - serializedVersion: 3 + buildTarget: tvOS + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + - serializedVersion: 3 + buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + spriteSheet: + serializedVersion: 2 + sprites: + - serializedVersion: 2 + name: CWall_TopLeft + rect: + serializedVersion: 2 + x: 0 + y: 447 + width: 64 + height: 64 + alignment: 0 + pivot: {x: 0.5, y: 0.5} + border: {x: 0, y: 0, z: 0, w: 0} + outline: + - - {x: -32, y: 32} + - {x: -32, y: -32} + - {x: 32, y: -32} + - {x: 32, y: 32} + physicsShape: + - - {x: -32, y: 32} + - {x: -32, y: -32} + - {x: 32, y: -32} + - {x: 32, y: 32} + tessellationDetail: 0 + bones: [] + spriteID: 85bb4a12799104aea82ffd023631f5eb + internalID: 21300000 + vertices: [] + indices: + edges: [] + weights: [] + - serializedVersion: 2 + name: CWall_Top + rect: + serializedVersion: 2 + x: 65 + y: 447 + width: 191 + height: 64 + alignment: 0 + pivot: {x: 0.5, y: 0.5} + border: {x: 0, y: 0, z: 0, w: 0} + outline: + - - {x: -95.5, y: 32} + - {x: -95.5, y: -32} + - {x: 95.5, y: -32} + - {x: 95.5, y: 32} + physicsShape: + - - {x: -95.5, y: 32} + - {x: -95.5, y: -32} + - {x: 95.5, y: -32} + - {x: 95.5, y: 32} + tessellationDetail: 0 + bones: [] + spriteID: c0d4dbb40862b42719bed0178fc33863 + internalID: 21300002 + vertices: [] + indices: + edges: [] + weights: [] + - serializedVersion: 2 + name: CWall_TopRight + rect: + serializedVersion: 2 + x: 256 + y: 447 + width: 64 + height: 64 + alignment: 0 + pivot: {x: 0.5, y: 0.5} + border: {x: 0, y: 0, z: 0, w: 0} + outline: + - - {x: -32, y: 32} + - {x: -32, y: -32} + - {x: 32, y: -32} + - {x: 32, y: 32} + physicsShape: + - - {x: -32, y: 32} + - {x: -32, y: -32} + - {x: 32, y: -32} + - {x: 32, y: 32} + tessellationDetail: 0 + bones: [] + spriteID: e691435be8e234c8ba6bbd44cf93bf9f + internalID: 21300004 + vertices: [] + indices: + edges: [] + weights: [] + - serializedVersion: 2 + name: CWall_Right + rect: + serializedVersion: 2 + x: 193 + y: 383 + width: 192 + height: 64 + alignment: 0 + pivot: {x: 0.5, y: 0.5} + border: {x: 0, y: 0, z: 0, w: 0} + outline: + - - {x: -96, y: 32} + - {x: -96, y: -32} + - {x: 96, y: -32} + - {x: 96, y: 32} + physicsShape: + - - {x: -96, y: 32} + - {x: -96, y: -32} + - {x: 96, y: -32} + - {x: 96, y: 32} + tessellationDetail: 0 + bones: [] + spriteID: e8d31f3d729f846cf901c9b695c0a286 + internalID: 21300006 + vertices: [] + indices: + edges: [] + weights: [] + - serializedVersion: 2 + name: CWall_BottomRight + rect: + serializedVersion: 2 + x: 385 + y: 447 + width: 64 + height: 64 + alignment: 0 + pivot: {x: 0.5, y: 0.5} + border: {x: 0, y: 0, z: 0, w: 0} + outline: + - - {x: -32, y: 32} + - {x: -32, y: -32} + - {x: 32, y: -32} + - {x: 32, y: 32} + physicsShape: + - - {x: -32, y: 32} + - {x: -32, y: -32} + - {x: 32, y: -32} + - {x: 32, y: 32} + tessellationDetail: 0 + bones: [] + spriteID: b5f6cd57c80af465b9d7279b93edc0bd + internalID: 21300008 + vertices: [] + indices: + edges: [] + weights: [] + - serializedVersion: 2 + name: CWall_Bottom + rect: + serializedVersion: 2 + x: 1 + y: 319 + width: 192 + height: 64 + alignment: 0 + pivot: {x: 0.5, y: 0.5} + border: {x: 0, y: 0, z: 0, w: 0} + outline: + - - {x: -96, y: 32} + - {x: -96, y: -32} + - {x: 96, y: -32} + - {x: 96, y: 32} + physicsShape: + - - {x: -96, y: 32} + - {x: -96, y: -32} + - {x: 96, y: -32} + - {x: 96, y: 32} + tessellationDetail: 0 + bones: [] + spriteID: 940402297287e479a98329d757431010 + internalID: 21300010 + vertices: [] + indices: + edges: [] + weights: [] + - serializedVersion: 2 + name: CWall_BottomLeft + rect: + serializedVersion: 2 + x: 321 + y: 447 + width: 64 + height: 64 + alignment: 0 + pivot: {x: 0.5, y: 0.5} + border: {x: 0, y: 0, z: 0, w: 0} + outline: + - - {x: -32, y: 32} + - {x: -32, y: -32} + - {x: 32, y: -32} + - {x: 32, y: 32} + physicsShape: + - - {x: -32, y: 32} + - {x: -32, y: -32} + - {x: 32, y: -32} + - {x: 32, y: 32} + tessellationDetail: 0 + bones: [] + spriteID: 5196786b599a246edb4ade9ef6e46b5f + internalID: 21300012 + vertices: [] + indices: + edges: [] + weights: [] + - serializedVersion: 2 + name: CWall_Left + rect: + serializedVersion: 2 + x: 1 + y: 383 + width: 192 + height: 64 + alignment: 0 + pivot: {x: 0.5, y: 0.5} + border: {x: 0, y: 0, z: 0, w: 0} + outline: + - - {x: -96, y: 32} + - {x: -96, y: -32} + - {x: 96, y: -32} + - {x: 96, y: 32} + physicsShape: + - - {x: -96, y: 32} + - {x: -96, y: -32} + - {x: 96, y: -32} + - {x: 96, y: 32} + tessellationDetail: 0 + bones: [] + spriteID: 6f193a5bf4ad94d5280067f257f134f8 + internalID: 21300014 + vertices: [] + indices: + edges: [] + weights: [] + - serializedVersion: 2 + name: CastleBlock01 + rect: + serializedVersion: 2 + x: 0 + y: 127 + width: 257 + height: 128 + alignment: 0 + pivot: {x: 0.5, y: 0.5} + border: {x: 65, y: 0, z: 64, w: 0} + outline: + - - {x: -66.5, y: 64} + - {x: -128.5, y: 2} + - {x: -128.5, y: -64} + - {x: 67.5, y: -64} + - {x: 128.5, y: -6} + - {x: 128.5, y: 64} + physicsShape: + - - {x: -67.5, y: 64} + - {x: -128.5, y: 2} + - {x: -128.5, y: -64} + - {x: 67.5, y: -64} + - {x: 128.5, y: -2} + - {x: 128.5, y: 64} + tessellationDetail: 0 + bones: [] + spriteID: 9adb64494e8944defbfc84a91967bc6b + internalID: 21300018 + vertices: [] + indices: + edges: [] + weights: [] + - serializedVersion: 2 + name: CastleWall_0 + rect: + serializedVersion: 2 + x: 261 + y: 160 + width: 160 + height: 156 + alignment: 0 + pivot: {x: 0.5, y: 0.5} + border: {x: 0, y: 0, z: 0, w: 0} + outline: + - - {x: -21, y: 75} + - {x: -69, y: 73} + - {x: -71, y: 71} + - {x: -74, y: 52} + - {x: -73, y: 33} + - {x: -80, y: 24} + - {x: -80, y: -14} + - {x: -70, y: -78} + - {x: 36, y: -78} + - {x: 59, y: -74} + - {x: 80, y: -11} + - {x: 80, y: 75} + physicsShape: + - - {x: 71.5, y: 63.5} + - {x: -77.5, y: 35.5} + - {x: -77.5, y: 9.5} + - {x: -66.5, y: -63.5} + - {x: 34.5, y: -63.5} + - {x: 61.5, y: -33.5} + - {x: 77.5, y: 47.5} + - {x: 77.5, y: 63.5} + tessellationDetail: 0 + bones: [] + spriteID: bbf07de53ae6044018a1edfbc9640bcb + internalID: 21300016 + vertices: [] + indices: + edges: [] + weights: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 720371aceba864ae092233b0f03d0d69 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 1 + pSDShowRemoveMatteOption: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprites/IceSprite.png.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprites/IceSprite.png.meta new file mode 100644 index 0000000000000000000000000000000000000000..b8a833095561fe87fa87fca2c339211505b21646 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprites/IceSprite.png.meta @@ -0,0 +1,152 @@ +fileFormatVersion: 2 +guid: e74b518a65bc45f4cace9a2fef6af29d +TextureImporter: + internalIDToNameTable: + - first: + 213: 21300000 + second: IceSprite_0 + externalObjects: {} + serializedVersion: 10 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: 1 + mipBias: -100 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 2 + spriteExtrude: 1 + spriteMeshType: 0 + alignment: 2 + spritePivot: {x: 0.5, y: 1} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 1024 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 1024 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + - serializedVersion: 3 + buildTarget: iPhone + maxTextureSize: 1024 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + - serializedVersion: 3 + buildTarget: Windows Store Apps + maxTextureSize: 1024 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + spriteSheet: + serializedVersion: 2 + sprites: + - serializedVersion: 2 + name: IceSprite_0 + rect: + serializedVersion: 2 + x: 42 + y: 105 + width: 170 + height: 40 + alignment: 7 + pivot: {x: 0.5, y: 0} + border: {x: 0, y: 0, z: 0, w: 0} + outline: [] + physicsShape: [] + tessellationDetail: 0 + bones: [] + spriteID: 90ea334be9f96ef4bb890e2fc7bcf3de + internalID: 21300000 + vertices: [] + indices: + edges: [] + weights: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 79445debcbead99418b13722644a8ad2 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprites/PlankSprite.png.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprites/PlankSprite.png.meta new file mode 100644 index 0000000000000000000000000000000000000000..78c2770c548bc4569c2d04c8e23abc54bff346ea --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprites/PlankSprite.png.meta @@ -0,0 +1,128 @@ +fileFormatVersion: 2 +guid: 418ab5c27d3054eb89959d9c715e00c9 +TextureImporter: + internalIDToNameTable: + - first: + 213: 21300000 + second: PlankSprite_0 + externalObjects: {} + serializedVersion: 10 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: 1 + mipBias: -100 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 2 + spriteExtrude: 1 + spriteMeshType: 0 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 1024 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 1024 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + spriteSheet: + serializedVersion: 2 + sprites: + - serializedVersion: 2 + name: PlankSprite_0 + rect: + serializedVersion: 2 + x: 47 + y: 112 + width: 166 + height: 40 + alignment: 2 + pivot: {x: 0.5, y: 1} + border: {x: 0, y: 0, z: 0, w: 0} + outline: [] + physicsShape: [] + tessellationDetail: -1 + bones: [] + spriteID: 2830d711a22d0714a8ce4c5de8b159d7 + internalID: 21300000 + vertices: [] + indices: + edges: [] + weights: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: f36163a69805f48408e07f7f014bf3aa + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprites/RoadSprite.png.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprites/RoadSprite.png.meta new file mode 100644 index 0000000000000000000000000000000000000000..aef309bd35c85a0e63da30e4df637d033aa6b1dd --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprites/RoadSprite.png.meta @@ -0,0 +1,164 @@ +fileFormatVersion: 2 +guid: c6dabd295b8ab514fa47b5d4e2b0266e +TextureImporter: + internalIDToNameTable: + - first: + 213: 21300000 + second: RoadSprite_0 + externalObjects: {} + serializedVersion: 10 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: 1 + wrapV: 1 + wrapW: -1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 2 + spriteExtrude: 1 + spriteMeshType: 0 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 1, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + - serializedVersion: 3 + buildTarget: iPhone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + - serializedVersion: 3 + buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + - serializedVersion: 3 + buildTarget: Windows Store Apps + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + spriteSheet: + serializedVersion: 2 + sprites: + - serializedVersion: 2 + name: RoadSprite_0 + rect: + serializedVersion: 2 + x: 0 + y: 8 + width: 63 + height: 48 + alignment: 0 + pivot: {x: 0, y: 0} + border: {x: 0, y: 0, z: 0, w: 0} + outline: [] + physicsShape: [] + tessellationDetail: 0 + bones: [] + spriteID: ed6607adfdf684d4da85b7999d1f5202 + internalID: 21300000 + vertices: [] + indices: + edges: [] + weights: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: b468cefc15307564da2e53ce4a456f36 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprites/Tree Fill A.png.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprites/Tree Fill A.png.meta new file mode 100644 index 0000000000000000000000000000000000000000..e5544b6843afcd3f0d3bc6136bbcb3d08a49e57e --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprites/Tree Fill A.png.meta @@ -0,0 +1,116 @@ +fileFormatVersion: 2 +guid: a94adaf94669646788de8f639270804a +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 10 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 0 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + - serializedVersion: 3 + buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: e160e2ebf6044493bbf686cbdbdfa624 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprites/TreeSprite.png.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprites/TreeSprite.png.meta new file mode 100644 index 0000000000000000000000000000000000000000..3f2ea076f4dc2ca92b4abdc15c02106c9883eadb --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprites/TreeSprite.png.meta @@ -0,0 +1,128 @@ +fileFormatVersion: 2 +guid: 029f005d8b06f834fa06df50fc4e7dba +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 10 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: 1 + wrapV: 1 + wrapW: -1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 7 + spritePivot: {x: 0.5, y: 0} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + - serializedVersion: 3 + buildTarget: iPhone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + - serializedVersion: 3 + buildTarget: Windows Store Apps + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 962e294447b82444d861c1dac41c399a + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprites/TreeTrunk01.png.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprites/TreeTrunk01.png.meta new file mode 100644 index 0000000000000000000000000000000000000000..1662304dd5610a94134df97016bae5892c8e7506 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Sprites/TreeTrunk01.png.meta @@ -0,0 +1,104 @@ +fileFormatVersion: 2 +guid: e205c552afc6743cb9c52e5ff6504efc +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 10 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 0 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 347, y: 0, z: 261, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: e12b09d0e25b640d5979fab44e0b92b8 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Textures/CastleWallFill.psd.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Textures/CastleWallFill.psd.meta new file mode 100644 index 0000000000000000000000000000000000000000..d4fe3b480df08b94dfbc1e558f3cc060e133ee51 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.spriteshape@5.1.1/Samples~/Extras/Textures/CastleWallFill.psd.meta @@ -0,0 +1,116 @@ +fileFormatVersion: 2 +guid: 7d8cda48c729c46329cd9d3c69a3a4e6 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 10 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + - serializedVersion: 3 + buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 1 + pSDShowRemoveMatteOption: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Documentation~/TextMeshPro.md b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Documentation~/TextMeshPro.md new file mode 100644 index 0000000000000000000000000000000000000000..8f8c09260fff39d097f546f8685648d5f6685e26 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Documentation~/TextMeshPro.md @@ -0,0 +1,35 @@ +# **_TextMesh Pro User Guide_** + +#### **Overview** +This User Guide was designed to provide first time users of TextMesh Pro with a basic overview of the features and functionality of the tool. + +#### **Installation** +The TextMesh Pro UPM package is already included with the Unity Editor and as such does not require installation. TextMesh Pro "TMP" does however require adding resources to your project which are essential for using TextMesh Pro. + +To import the "*TMP Essential Resources*", please use the "*Window -> TextMeshPro -> Import TMP Essential Resources*" menu option. These resources will be added at the root of your project in the "*TextMesh Pro*" folder. + +The TextMesh Pro package also includes additional resources and examples that will make discovering and learning about TextMesh Pro's powerful features easier. It is strongly recommended that first time users import these additional resources. + +To import the "*TMP Examples & Extras*", please use the "*Window -> TextMeshPro -> Import TMP Examples & Extras*" menu option. These resources will also be added in the same "*TextMesh Pro*" folder inside your project. + + +#### **Quick Start** +There are two TextMesh Pro components available. The first TMP text component is of type <TextMeshPro> and designed to work with the MeshRenderer. This component is an ideal replacement for the legacy TextMesh component. + +To add a new <TextMeshPro> text object, go to: “*GameObject->3D Object->TextMeshPro Text*”. + +The second TMP text component is of type <TextMeshProUGUI> and designed to work with the CanvasRenderer and Canvas system. This component is an ideal replacement for the UI.Text component. + +To add a new <TextMeshProUGUI> text object, go to: “*GameObject->UI->TextMeshPro Text*”. + +You may also wish to watch this [Getting Started](https://youtu.be/olnxlo-Wri4) short video which covers this topic. + +We strongly recommend that you also watch the [Font Asset Creation](https://youtu.be/qzJNIGCFFtY) video as well as the [Working with Material Presets](https://youtu.be/d2MARbDNeaA) as these two topics is also key to working and getting the most out of TextMesh Pro. + +As mentionned in the Installation section of this guide, it is recommended that you import the "*TMP Examples & Extras*" and take the time to explore each of the examples as they provide a great overview of the functionality of the tool and the many text layout and [rich text tags](http://digitalnativestudios.com/textmeshpro/docs/rich-text/) available in TextMesh Pro. + +#### **Support & API Documentation** +Should you have questions or require assistance, please visit the [Unity UI & TextMesh Pro](https://forum.unity.com/forums/unity-ui-textmesh-pro.60/) section of the Unity forum as well as the [TextMesh Pro User Forum](http://digitalnativestudios.com/forum/index.php) where you will find additional information, [Video Tutorials](http://digitalnativestudios.com/forum/index.php?board=4.0) and [FAQ](http://digitalnativestudios.com/forum/index.php?topic=890.0). In the event you are unable to find the information you seek, always feel free to post on the [Unity UI & TextMesh Pro](https://forum.unity.com/forums/unity-ui-textmesh-pro.60/) section user forum. + +[Online Documentation](http://digitalnativestudios.com/textmeshpro/docs/) is also available on TextMesh Pro including Rich Text tags, Shaders, Scripting API and more. + diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Documentation~/TextMeshPro.md.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Documentation~/TextMeshPro.md.meta new file mode 100644 index 0000000000000000000000000000000000000000..8c72f725584c84d05172be1292fa9cba7066f006 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Documentation~/TextMeshPro.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: ca77d26d10b9455ca5a4b22c93be2a31 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Editor Resources/Gizmos.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Editor Resources/Gizmos.meta new file mode 100644 index 0000000000000000000000000000000000000000..f2596c789ed19b773124bf37a109e8a38a63bfd7 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Editor Resources/Gizmos.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e93ec7eb6de342aabd156833e253f838 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Editor Resources/Shaders.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Editor Resources/Shaders.meta new file mode 100644 index 0000000000000000000000000000000000000000..95efe2ba9a8506a1a77a37beac403932c2b4681e --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Editor Resources/Shaders.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2da27f5fe80a3a549ac7331d9f52f5f0 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Editor Resources/Textures.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Editor Resources/Textures.meta new file mode 100644 index 0000000000000000000000000000000000000000..d6754b05dc2ffa15b75c1d4d8a521e9c1d517275 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Editor Resources/Textures.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f8e6a2d47aba4c6c9b3c5a72d9f48da5 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Package Resources/TMP Essential Resources.unitypackage.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Package Resources/TMP Essential Resources.unitypackage.meta new file mode 100644 index 0000000000000000000000000000000000000000..bc49ab305d547db63e9add43995d7b88bf0a5a92 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Package Resources/TMP Essential Resources.unitypackage.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: ce4ff17ca867d2b48b5c8a4181611901 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Package Resources/TMP Examples & Extras.unitypackage.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Package Resources/TMP Examples & Extras.unitypackage.meta new file mode 100644 index 0000000000000000000000000000000000000000..aaf21f78b8aa4cbc973af27d83ce46a3b9a5ec57 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Package Resources/TMP Examples & Extras.unitypackage.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: bc00e25696e4132499f56528d3fed2e3 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Scripts/Editor.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Scripts/Editor.meta new file mode 100644 index 0000000000000000000000000000000000000000..af509a3a7dcb9a28a355b1af4fc1d3df204d05b4 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Scripts/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b5d6c28ed7b94775be9e2560f300247c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Scripts/Runtime.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Scripts/Runtime.meta new file mode 100644 index 0000000000000000000000000000000000000000..4b244150b1d81e6a042ec7d2056d03210e1a4eb5 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Scripts/Runtime.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5fc988a1d5b04aee9a5222502b201a45 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Tests/Editor.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Tests/Editor.meta new file mode 100644 index 0000000000000000000000000000000000000000..670a097d94a725b8f5871bcc9c14211d80edd348 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Tests/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2ddb9c7e83a272341992e289cb625a29 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Tests/Editor/TMP_EditorTests.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Tests/Editor/TMP_EditorTests.cs new file mode 100644 index 0000000000000000000000000000000000000000..a31a640a2821a98ace3f6f98719f7afaf7d81295 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Tests/Editor/TMP_EditorTests.cs @@ -0,0 +1,209 @@ +using UnityEngine; +using UnityEditor; +using UnityEngine.TestTools; +using NUnit.Framework; +using System.IO; +using System.Collections; + + +namespace TMPro +{ + [Category("Text Parsing & Layout")] + class TMP_EditorTests + { + private TextMeshPro m_TextComponent; + + // Characters: 22 Spaces: 4 Words: 5 Lines: + private const string m_TextBlock_00 = "A simple line of text."; + + // Characters: 104 Spaces: 14 Words: 15 Lines: + private const string m_TextBlock_01 = "Unity 2017 introduces new features that help teams of artists and developers build experiences together."; + + // Characters: 1500 Spaces: 228 Words: 241 + private const string m_TextBlock_02 = "The European languages are members of the same family. Their separate existence is a myth. For science, music, sport, etc, Europe uses the same vocabulary. The languages only differ in their grammar, their pronunciation and their most common words." + + "Everyone realizes why a new common language would be desirable: one could refuse to pay expensive translators.To achieve this, it would be necessary to have uniform grammar, pronunciation and more common words.If several languages coalesce, the grammar of the resulting language is more simple and regular than that of the individual languages." + + "The new common language will be more simple and regular than the existing European languages.It will be as simple as Occidental; in fact, it will be Occidental.To an English person, it will seem like simplified English, as a skeptical Cambridge friend of mine told me what Occidental is. The European languages are members of the same family." + + "Their separate existence is a myth. For science, music, sport, etc, Europe uses the same vocabulary.The languages only differ in their grammar, their pronunciation and their most common words.Everyone realizes why a new common language would be desirable: one could refuse to pay expensive translators.To achieve this, it would be necessary to" + + "have uniform grammar, pronunciation and more common words.If several languages coalesce, the grammar of the resulting language is more simple and regular than that of the individual languages.The new common language will be"; + + // Characters: 2500 Spaces: 343 Words: 370 + private const string m_TextBlock_03 = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. " + + "Nullam dictum felis eu pede mollis pretium.Integer tincidunt.Cras dapibus.Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim.Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus.Phasellus viverra nulla ut metus varius laoreet.Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue.Curabitur ullamcorper ultricies nisi. " + + "Nam eget dui.Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum.Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem.Maecenas nec odio et ante tincidunt tempus.Donec vitae sapien ut libero venenatis faucibus.Nullam quis ante.Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. " + + "Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc, quis gravida magna mi a libero. Fusce vulputate eleifend sapien. Vestibulum purus quam, scelerisque ut, mollis sed, nonummy id, metus.Nullam accumsan lorem in dui.Cras ultricies mi eu turpis hendrerit fringilla.Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In ac dui quis mi consectetuer lacinia. Nam pretium turpis et arcu. " + + "Duis arcu tortor, suscipit eget, imperdiet nec, imperdiet iaculis, ipsum. Sed aliquam ultrices mauris.Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris.Praesent adipiscing. Phasellus ullamcorper ipsum rutrum nunc.Nunc nonummy metus.Vestibulum volutpat pretium libero. Cras id dui.Aenean ut eros et nisl sagittis vestibulum.Nullam nulla eros, ultricies sit amet, nonummy id, imperdiet feugiat, pede.Sed lectus. Donec mollis hendrerit risus. Phasellus nec sem in justo pellentesque facilisis. " + + "Etiam imperdiet imperdiet orci. Nunc nec neque.Phasellus leo dolor, tempus non, auctor et, hendrerit quis, nisi.Curabitur ligula sapien, tincidunt non, euismod vitae, posuere imperdiet, leo.Maecenas malesuada. Praesent nan. The end of this of this long block of text."; + + // Characters: 3423 Spaces: 453 Words: 500 + private const string m_TextBlock_04 = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.Aenean commodo ligula eget dolor.Aenean massa.Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem.Nulla consequat massa quis enim.Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu.In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.Nullam dictum felis eu pede mollis pretium.Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus." + + "Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim.Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus.Phasellus viverra nulla ut metus varius laoreet.Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue.Curabitur ullamcorper ultricies nisi. Nam eget dui.Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum.Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem.Maecenas nec odio et ante tincidunt tempus.Donec vitae sapien ut libero venenatis faucibus.Nullam quis ante." + + "Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc, quis gravida magna mi a libero. Fusce vulputate eleifend sapien. Vestibulum purus quam, scelerisque ut, mollis sed, nonummy id, metus.Nullam accumsan lorem in dui.Cras ultricies mi eu turpis hendrerit fringilla.Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In ac dui quis mi consectetuer lacinia.Nam pretium turpis et arcu." + + "Duis arcu tortor, suscipit eget, imperdiet nec, imperdiet iaculis, ipsum. Sed aliquam ultrices mauris.Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris.Praesent adipiscing. Phasellus ullamcorper ipsum rutrum nunc.Nunc nonummy metus.Vestibulum volutpat pretium libero. Cras id dui.Aenean ut eros et nisl sagittis vestibulum.Nullam nulla eros, ultricies sit amet, nonummy id, imperdiet feugiat, pede.Sed lectus. Donec mollis hendrerit risus. Phasellus nec sem in justo pellentesque facilisis.Etiam imperdiet imperdiet orci. Nunc nec neque." + + "Phasellus leo dolor, tempus non, auctor et, hendrerit quis, nisi.Curabitur ligula sapien, tincidunt non, euismod vitae, posuere imperdiet, leo.Maecenas malesuada. Praesent congue erat at massa.Sed cursus turpis vitae tortor.Donec posuere vulputate arcu. Phasellus accumsan cursus velit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed aliquam, nisi quis porttitor congue, elit erat euismod orci, ac placerat dolor lectus quis orci.Phasellus consectetuer vestibulum elit.Aenean tellus metus, bibendum sed, posuere ac, mattis non, nunc.Vestibulum fringilla pede sit amet augue." + + "In turpis. Pellentesque posuere. Praesent turpis. Aenean posuere, tortor sed cursus feugiat, nunc augue blandit nunc, eu sollicitudin urna dolor sagittis lacus. Donec elit libero, sodales nec, volutpat a, suscipit non, turpis.Nullam sagittis. Suspendisse pulvinar, augue ac venenatis condimentum, sem libero volutpat nibh, nec pellentesque velit pede quis nunc. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce id purus.Ut varius tincidunt libero.Phasellus dolor.Maecenas vestibulum mollis"; + + // + private const string m_TextBlock_05 = "This block of text contains bold and italicized characters."; + + private const string m_TextBlock_06 = "<#ffffff>Multiple<#80f0ff> Alignment per text object\n" + + " The <<#ffffa0>align> tag in TextMesh<#40a0ff>Pro provides the ability to control the alignment of lines and paragraphs which is essential when working with text.\n" + + " You may want some block of text to be<#80f0ff>left aligned <<#ffffa0>align=<#80f0ff>left> which is sort of the standard.\n" + + "<#ffffa0>\"Using <#80f0ff>Center Alignment <<#ffffa0>align=<#80f0ff>center> for a title or displaying a quote is another good example of text alignment.\"\n" + + "<#80f0ff>Right Alignment <<#ffffa0>align=<#80f0ff>right> can be useful to create contrast between lines and paragraphs of text.\n" + + "<#80f0ff>Justified Alignment <<#ffffa0>align=<#80f0ff>justified> results in text that is flush on both the left and right margins. Used well, justified type can look clean and classy.\n" + + "<#ffffa0>\"Text formatting and alignment has a huge impact on how people will read and perceive your text.\"\n" + + " -Stephan Bouchard"; + + private readonly string[] testStrings = new string[] { m_TextBlock_00, m_TextBlock_01, m_TextBlock_02, m_TextBlock_03, m_TextBlock_04, m_TextBlock_05, m_TextBlock_06 }; + + + [OneTimeSetUp] + public void Setup() + { + if (Directory.Exists(Path.GetFullPath("Assets/TextMesh Pro")) || Directory.Exists(Path.GetFullPath("Packages/com.unity.textmeshpro.tests/TextMesh Pro"))) + { + GameObject textObject = new GameObject("Text Object"); + m_TextComponent = textObject.AddComponent(); + + m_TextComponent.fontSize = 18; + } + else + { + Debug.Log("Skipping over Editor tests as TMP Essential Resources are missing from the current test project."); + Assert.Ignore(); + + return; + } + } + + + [Test] + [TestCase("/Package Resources/TMP Essential Resources.unitypackage", "ce4ff17ca867d2b48b5c8a4181611901")] + [TestCase("/Package Resources/TMP Examples & Extras.unitypackage", "bc00e25696e4132499f56528d3fed2e3")] + [TestCase("/PackageConversionData.json", "05f5bfd584002f948982a1498890f9a9")] + public void InternalResourceCheck(string filePath, string guid) + { + string packageRelativePath = EditorUtilities.TMP_EditorUtility.packageRelativePath; + string packageFullPath = EditorUtilities.TMP_EditorUtility.packageFullPath; + + Assert.AreEqual(AssetDatabase.AssetPathToGUID(packageRelativePath + filePath), guid); + Assert.IsTrue(System.IO.File.Exists(packageFullPath + filePath)); + + } + + + [Test] + [TestCase(4, 3423, 453, 500, 1)] + [TestCase(3, 2500, 343, 370, 1)] + [TestCase(2, 1500, 228, 241, 1)] + [TestCase(1, 104, 14, 15, 1)] + [TestCase(0, 22, 4, 5, 1)] + public void TextParsing_TextInfoTest_WordWrappingDisabled(int sourceTextIndex, int characterCount, int spaceCount, int wordCount, int lineCount) + { + m_TextComponent.text = testStrings[sourceTextIndex]; + m_TextComponent.enableWordWrapping = false; + m_TextComponent.alignment = TextAlignmentOptions.TopLeft; + + // Size the RectTransform + m_TextComponent.rectTransform.sizeDelta = new Vector2(50, 5); + + // Force text generation to populate the TextInfo data structure. + m_TextComponent.ForceMeshUpdate(); + + Assert.AreEqual(m_TextComponent.textInfo.characterCount, characterCount); + Assert.AreEqual(m_TextComponent.textInfo.spaceCount, spaceCount); + Assert.AreEqual(m_TextComponent.textInfo.wordCount, wordCount); + Assert.AreEqual(m_TextComponent.textInfo.lineCount, lineCount); + } + + + [Test] + [TestCase(4, 3423, 453, 500, 29)] + [TestCase(3, 2500, 343, 370, 21)] + [TestCase(2, 1500, 228, 241, 13)] + [TestCase(1, 104, 14, 15, 1)] + [TestCase(0, 22, 4, 5, 1)] + public void TextParsing_TextInfoTest_WordWrappingEnabled(int sourceTextIndex, int characterCount, int spaceCount, int wordCount, int lineCount) + { + m_TextComponent.text = testStrings[sourceTextIndex]; + m_TextComponent.enableWordWrapping = true; + m_TextComponent.alignment = TextAlignmentOptions.TopLeft; + + // Size the RectTransform + m_TextComponent.rectTransform.sizeDelta = new Vector2(100, 50); + + // Force text generation to populate the TextInfo data structure. + m_TextComponent.ForceMeshUpdate(); + + Assert.AreEqual(m_TextComponent.textInfo.characterCount, characterCount); + Assert.AreEqual(m_TextComponent.textInfo.spaceCount, spaceCount); + Assert.AreEqual(m_TextComponent.textInfo.wordCount, wordCount); + Assert.AreEqual(m_TextComponent.textInfo.lineCount, lineCount); + } + + + [Test] + [TestCase(4, 3423, 453, 500, 27)] + [TestCase(3, 2500, 343, 370, 20)] + [TestCase(2, 1500, 228, 241, 13)] + public void TextParsing_TextInfoTest_TopJustifiedAlignment(int sourceTextIndex, int characterCount, int spaceCount, int wordCount, int lineCount) + { + m_TextComponent.text = testStrings[sourceTextIndex]; + m_TextComponent.enableWordWrapping = true; + m_TextComponent.alignment = TextAlignmentOptions.TopJustified; + + // Size the RectTransform + m_TextComponent.rectTransform.sizeDelta = new Vector2(100, 50); + + // Force text generation to populate the TextInfo data structure. + m_TextComponent.ForceMeshUpdate(); + + Assert.AreEqual(m_TextComponent.textInfo.characterCount, characterCount); + Assert.AreEqual(m_TextComponent.textInfo.spaceCount, spaceCount); + Assert.AreEqual(m_TextComponent.textInfo.wordCount, wordCount); + Assert.AreEqual(m_TextComponent.textInfo.lineCount, lineCount); + } + + + [Test] + [TestCase(6, 768, 124, 126, 14)] + [TestCase(5, 59, 8, 9, 1)] + public void TextParsing_TextInfoTest_RichText(int sourceTextIndex, int characterCount, int spaceCount, int wordCount, int lineCount) + { + m_TextComponent.text = testStrings[sourceTextIndex]; + m_TextComponent.enableWordWrapping = true; + m_TextComponent.alignment = TextAlignmentOptions.TopLeft; + + // Size the RectTransform + m_TextComponent.rectTransform.sizeDelta = new Vector2(70, 35); + + // Force text generation to populate the TextInfo data structure. + m_TextComponent.ForceMeshUpdate(); + + Assert.AreEqual(m_TextComponent.textInfo.characterCount, characterCount); + Assert.AreEqual(m_TextComponent.textInfo.spaceCount, spaceCount); + Assert.AreEqual(m_TextComponent.textInfo.wordCount, wordCount); + Assert.AreEqual(m_TextComponent.textInfo.lineCount, lineCount); + } + + + // Add tests that check position of individual characters in a complex block of text. + // These test also use the data contained inside the TMP_TextInfo class. + + + //[OneTimeTearDown] + //public void Cleanup() + //{ + // // Remove TMP Essential Resources if they were imported in the project as a result of running tests. + // if (TMPro_EventManager.temporaryResourcesImported == true) + // { + // if (Directory.Exists(Path.GetFullPath("Assets/TextMesh Pro"))) + // { + // AssetDatabase.DeleteAsset("Assets/TextMesh Pro"); + // TMPro_EventManager.temporaryResourcesImported = false; + // } + // } + //} + + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Tests/Editor/TMP_EditorTests.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Tests/Editor/TMP_EditorTests.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..99b09c856748e79736583250fd7d0395fcd76728 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Tests/Editor/TMP_EditorTests.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 592f7288ed0df2c4b884e2cd9baac023 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Tests/Editor/Unity.TextMeshPro.Editor.Tests.asmdef b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Tests/Editor/Unity.TextMeshPro.Editor.Tests.asmdef new file mode 100644 index 0000000000000000000000000000000000000000..adb75e25545a21fb0c6fbed371473771874791f2 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Tests/Editor/Unity.TextMeshPro.Editor.Tests.asmdef @@ -0,0 +1,17 @@ +{ + "name": "Unity.TextMeshPro.Editor.Tests", + "references": [ + "Unity.TextMeshPro", + "Unity.TextMeshPro.Editor" + ], + "optionalUnityReferences": [ + "TestAssemblies" + ], + "defineConstraints": [ + "UNITY_INCLUDE_TESTS" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [] +} \ No newline at end of file diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Tests/Editor/Unity.TextMeshPro.Editor.Tests.asmdef.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Tests/Editor/Unity.TextMeshPro.Editor.Tests.asmdef.meta new file mode 100644 index 0000000000000000000000000000000000000000..ddfe991f56762feb1a881f97a278ec02449b8daa --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Tests/Editor/Unity.TextMeshPro.Editor.Tests.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 656e461844099ae43a609ff6109b0877 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Tests/Runtime.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Tests/Runtime.meta new file mode 100644 index 0000000000000000000000000000000000000000..15d57899fdb26339f315a26e433b739704c045b3 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Tests/Runtime.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 114ee901710203147bd1e6b8555e3887 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Tests/Runtime/TMP_RuntimeTests.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Tests/Runtime/TMP_RuntimeTests.cs new file mode 100644 index 0000000000000000000000000000000000000000..7b1834d2c9f72cd1b9171e955d37474d89afa988 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Tests/Runtime/TMP_RuntimeTests.cs @@ -0,0 +1,207 @@ +using UnityEngine; +using UnityEngine.TestTools; +using NUnit.Framework; +using System.IO; +using System.Collections; +using System.Collections.Generic; + +namespace TMPro +{ + [Category("Text Parsing & Layout")] + class TMP_RuntimeTests + { + private TextMeshPro m_TextComponent; + + // Characters: 22 Spaces: 4 Words: 5 Lines: + private const string m_TextBlock_00 = "A simple line of text."; + + // Characters: 104 Spaces: 14 Words: 15 Lines: + private const string m_TextBlock_01 = "Unity 2017 introduces new features that help teams of artists and developers build experiences together."; + + // Characters: 1500 Spaces: 228 Words: 241 + private const string m_TextBlock_02 = "The European languages are members of the same family. Their separate existence is a myth. For science, music, sport, etc, Europe uses the same vocabulary. The languages only differ in their grammar, their pronunciation and their most common words." + + "Everyone realizes why a new common language would be desirable: one could refuse to pay expensive translators.To achieve this, it would be necessary to have uniform grammar, pronunciation and more common words.If several languages coalesce, the grammar of the resulting language is more simple and regular than that of the individual languages." + + "The new common language will be more simple and regular than the existing European languages.It will be as simple as Occidental; in fact, it will be Occidental.To an English person, it will seem like simplified English, as a skeptical Cambridge friend of mine told me what Occidental is. The European languages are members of the same family." + + "Their separate existence is a myth. For science, music, sport, etc, Europe uses the same vocabulary.The languages only differ in their grammar, their pronunciation and their most common words.Everyone realizes why a new common language would be desirable: one could refuse to pay expensive translators.To achieve this, it would be necessary to" + + "have uniform grammar, pronunciation and more common words.If several languages coalesce, the grammar of the resulting language is more simple and regular than that of the individual languages.The new common language will be"; + + // Characters: 2500 Spaces: 343 Words: 370 + private const string m_TextBlock_03 = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. " + + "Nullam dictum felis eu pede mollis pretium.Integer tincidunt.Cras dapibus.Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim.Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus.Phasellus viverra nulla ut metus varius laoreet.Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue.Curabitur ullamcorper ultricies nisi. " + + "Nam eget dui.Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum.Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem.Maecenas nec odio et ante tincidunt tempus.Donec vitae sapien ut libero venenatis faucibus.Nullam quis ante.Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. " + + "Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc, quis gravida magna mi a libero. Fusce vulputate eleifend sapien. Vestibulum purus quam, scelerisque ut, mollis sed, nonummy id, metus.Nullam accumsan lorem in dui.Cras ultricies mi eu turpis hendrerit fringilla.Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In ac dui quis mi consectetuer lacinia. Nam pretium turpis et arcu. " + + "Duis arcu tortor, suscipit eget, imperdiet nec, imperdiet iaculis, ipsum. Sed aliquam ultrices mauris.Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris.Praesent adipiscing. Phasellus ullamcorper ipsum rutrum nunc.Nunc nonummy metus.Vestibulum volutpat pretium libero. Cras id dui.Aenean ut eros et nisl sagittis vestibulum.Nullam nulla eros, ultricies sit amet, nonummy id, imperdiet feugiat, pede.Sed lectus. Donec mollis hendrerit risus. Phasellus nec sem in justo pellentesque facilisis. " + + "Etiam imperdiet imperdiet orci. Nunc nec neque.Phasellus leo dolor, tempus non, auctor et, hendrerit quis, nisi.Curabitur ligula sapien, tincidunt non, euismod vitae, posuere imperdiet, leo.Maecenas malesuada. Praesent nan. The end of this of this long block of text."; + + // Characters: 3423 Spaces: 453 Words: 500 + private const string m_TextBlock_04 = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.Aenean commodo ligula eget dolor.Aenean massa.Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem.Nulla consequat massa quis enim.Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu.In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.Nullam dictum felis eu pede mollis pretium.Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus." + + "Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim.Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus.Phasellus viverra nulla ut metus varius laoreet.Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue.Curabitur ullamcorper ultricies nisi. Nam eget dui.Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum.Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem.Maecenas nec odio et ante tincidunt tempus.Donec vitae sapien ut libero venenatis faucibus.Nullam quis ante." + + "Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc, quis gravida magna mi a libero. Fusce vulputate eleifend sapien. Vestibulum purus quam, scelerisque ut, mollis sed, nonummy id, metus.Nullam accumsan lorem in dui.Cras ultricies mi eu turpis hendrerit fringilla.Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In ac dui quis mi consectetuer lacinia.Nam pretium turpis et arcu." + + "Duis arcu tortor, suscipit eget, imperdiet nec, imperdiet iaculis, ipsum. Sed aliquam ultrices mauris.Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris.Praesent adipiscing. Phasellus ullamcorper ipsum rutrum nunc.Nunc nonummy metus.Vestibulum volutpat pretium libero. Cras id dui.Aenean ut eros et nisl sagittis vestibulum.Nullam nulla eros, ultricies sit amet, nonummy id, imperdiet feugiat, pede.Sed lectus. Donec mollis hendrerit risus. Phasellus nec sem in justo pellentesque facilisis.Etiam imperdiet imperdiet orci. Nunc nec neque." + + "Phasellus leo dolor, tempus non, auctor et, hendrerit quis, nisi.Curabitur ligula sapien, tincidunt non, euismod vitae, posuere imperdiet, leo.Maecenas malesuada. Praesent congue erat at massa.Sed cursus turpis vitae tortor.Donec posuere vulputate arcu. Phasellus accumsan cursus velit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed aliquam, nisi quis porttitor congue, elit erat euismod orci, ac placerat dolor lectus quis orci.Phasellus consectetuer vestibulum elit.Aenean tellus metus, bibendum sed, posuere ac, mattis non, nunc.Vestibulum fringilla pede sit amet augue." + + "In turpis. Pellentesque posuere. Praesent turpis. Aenean posuere, tortor sed cursus feugiat, nunc augue blandit nunc, eu sollicitudin urna dolor sagittis lacus. Donec elit libero, sodales nec, volutpat a, suscipit non, turpis.Nullam sagittis. Suspendisse pulvinar, augue ac venenatis condimentum, sem libero volutpat nibh, nec pellentesque velit pede quis nunc. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce id purus.Ut varius tincidunt libero.Phasellus dolor.Maecenas vestibulum mollis"; + + // + private const string m_TextBlock_05 = "This block of text contains bold and italicized characters."; + + private const string m_TextBlock_06 = "<#ffffff>Multiple<#80f0ff> Alignment per text object\n" + + " The <<#ffffa0>align> tag in TextMesh<#40a0ff>Pro provides the ability to control the alignment of lines and paragraphs which is essential when working with text.\n" + + " You may want some block of text to be<#80f0ff>left aligned <<#ffffa0>align=<#80f0ff>left> which is sort of the standard.\n" + + "<#ffffa0>\"Using <#80f0ff>Center Alignment <<#ffffa0>align=<#80f0ff>center> for a title or displaying a quote is another good example of text alignment.\"\n" + + "<#80f0ff>Right Alignment <<#ffffa0>align=<#80f0ff>right> can be useful to create contrast between lines and paragraphs of text.\n" + + "<#80f0ff>Justified Alignment <<#ffffa0>align=<#80f0ff>justified> results in text that is flush on both the left and right margins. Used well, justified type can look clean and classy.\n" + + "<#ffffa0>\"Text formatting and alignment has a huge impact on how people will read and perceive your text.\"\n" + + " -Stephan Bouchard"; + + private readonly string[] testStrings = new string[] { m_TextBlock_00, m_TextBlock_01, m_TextBlock_02, m_TextBlock_03, m_TextBlock_04, m_TextBlock_05, m_TextBlock_06 }; + + [OneTimeSetUp] + public void Setup() + { + if (Directory.Exists(Path.GetFullPath("Assets/TextMesh Pro")) || Directory.Exists(Path.GetFullPath("Packages/com.unity.textmeshpro.tests/TextMesh Pro"))) + { + GameObject textObject = new GameObject("Text Object"); + m_TextComponent = textObject.AddComponent(); + + m_TextComponent.fontSize = 18; + } + else + { + Debug.Log("Skipping over Editor tests as TMP Essential Resources are missing from the current test project."); + Assert.Ignore(); + + return; + } + } + + public static IEnumerable TestCases_Parsing_TextInfo_WordWrapDisabled() + { + yield return new object[] { 0, 22, 4, 5, 1 }; + yield return new object[] { 1, 104, 14, 15, 1 }; + yield return new object[] { 2, 1500, 228, 241, 1 }; + yield return new object[] { 3, 2500, 343, 370, 1 }; + yield return new object[] { 4, 3423, 453, 500, 1 }; + } + + [Test, TestCaseSource("TestCases_Parsing_TextInfo_WordWrapDisabled")] + public void Parsing_TextInfo_WordWrapDisabled(int sourceTextIndex, int characterCount, int spaceCount, int wordCount, int lineCount) + { + m_TextComponent.text = testStrings[sourceTextIndex]; + m_TextComponent.enableWordWrapping = false; + m_TextComponent.alignment = TextAlignmentOptions.TopLeft; + + // Size the RectTransform + m_TextComponent.rectTransform.sizeDelta = new Vector2(50, 5); + + // Force text generation to populate the TextInfo data structure. + m_TextComponent.ForceMeshUpdate(); + + Assert.AreEqual(m_TextComponent.textInfo.characterCount, characterCount); + Assert.AreEqual(m_TextComponent.textInfo.spaceCount, spaceCount); + Assert.AreEqual(m_TextComponent.textInfo.wordCount, wordCount); + Assert.AreEqual(m_TextComponent.textInfo.lineCount, lineCount); + } + + + public static IEnumerable TestCases_Parsing_TextInfo_WordWrapEnabled() + { + yield return new object[] { 0, 22, 4, 5, 1 }; + yield return new object[] { 1, 104, 14, 15, 1 }; + yield return new object[] { 2, 1500, 228, 241, 13 }; + yield return new object[] { 3, 2500, 343, 370, 21 }; + yield return new object[] { 4, 3423, 453, 500, 29 }; + } + + [Test, TestCaseSource("TestCases_Parsing_TextInfo_WordWrapEnabled")] + public void Parsing_TextInfo_WordWrapEnabled(int sourceTextIndex, int characterCount, int spaceCount, int wordCount, int lineCount) + { + m_TextComponent.text = testStrings[sourceTextIndex]; + m_TextComponent.enableWordWrapping = true; + m_TextComponent.alignment = TextAlignmentOptions.TopLeft; + + // Size the RectTransform + m_TextComponent.rectTransform.sizeDelta = new Vector2(100, 50); + + // Force text generation to populate the TextInfo data structure. + m_TextComponent.ForceMeshUpdate(); + + Assert.AreEqual(m_TextComponent.textInfo.characterCount, characterCount); + Assert.AreEqual(m_TextComponent.textInfo.spaceCount, spaceCount); + Assert.AreEqual(m_TextComponent.textInfo.wordCount, wordCount); + Assert.AreEqual(m_TextComponent.textInfo.lineCount, lineCount); + } + + + public static IEnumerable TestCases_Parsing_TextInfo_AlignmentTopJustified() + { + yield return new object[] { 2, 1500, 228, 241, 13 }; + yield return new object[] { 3, 2500, 343, 370, 20 }; + yield return new object[] { 4, 3423, 453, 500, 27 }; + } + + [Test, TestCaseSource("TestCases_Parsing_TextInfo_AlignmentTopJustified")] + public void Parsing_TextInfo_AlignmentTopJustified(int sourceTextIndex, int characterCount, int spaceCount, int wordCount, int lineCount) + { + m_TextComponent.text = testStrings[sourceTextIndex]; + m_TextComponent.enableWordWrapping = true; + m_TextComponent.alignment = TextAlignmentOptions.TopJustified; + + // Size the RectTransform + m_TextComponent.rectTransform.sizeDelta = new Vector2(100, 50); + + // Force text generation to populate the TextInfo data structure. + m_TextComponent.ForceMeshUpdate(); + + Assert.AreEqual(m_TextComponent.textInfo.characterCount, characterCount); + Assert.AreEqual(m_TextComponent.textInfo.spaceCount, spaceCount); + Assert.AreEqual(m_TextComponent.textInfo.wordCount, wordCount); + Assert.AreEqual(m_TextComponent.textInfo.lineCount, lineCount); + } + + + public static IEnumerable TestCases_Parsing_TextInfo_RichText() + { + yield return new object[] { 5, 59, 8, 9, 1 }; + yield return new object[] { 6, 768, 124, 126, 14 }; + } + + [Test, TestCaseSource("TestCases_Parsing_TextInfo_RichText")] + public void Parsing_TextInfo_RichText(int sourceTextIndex, int characterCount, int spaceCount, int wordCount, int lineCount) + { + m_TextComponent.text = testStrings[sourceTextIndex]; + m_TextComponent.enableWordWrapping = true; + m_TextComponent.alignment = TextAlignmentOptions.TopLeft; + + // Size the RectTransform + m_TextComponent.rectTransform.sizeDelta = new Vector2(70, 35); + + // Force text generation to populate the TextInfo data structure. + m_TextComponent.ForceMeshUpdate(); + + Assert.AreEqual(m_TextComponent.textInfo.characterCount, characterCount); + Assert.AreEqual(m_TextComponent.textInfo.spaceCount, spaceCount); + Assert.AreEqual(m_TextComponent.textInfo.wordCount, wordCount); + Assert.AreEqual(m_TextComponent.textInfo.lineCount, lineCount); + } + + + //[OneTimeTearDown] + //public void Cleanup() + //{ + // // Remove TMP Essential Resources if they were imported in the project as a result of running tests. + // if (TMPro_EventManager.temporaryResourcesImported == true) + // { + // string testResourceFolderPath = Path.GetFullPath("Assets/TextMesh Pro"); + + // if (Directory.Exists(testResourceFolderPath)) + // { + // Directory.Delete(testResourceFolderPath); + // File.Delete(Path.GetFullPath("Assets/TextMesh Pro.meta")); + // } + + // TMPro_EventManager.temporaryResourcesImported = false; + // } + //} + + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Tests/Runtime/TMP_RuntimeTests.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Tests/Runtime/TMP_RuntimeTests.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..e004fed6722cae1c0fb3add293e4cbdcf52b9dd5 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.textmeshpro@3.0.1/Tests/Runtime/TMP_RuntimeTests.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9de24983a2c6cbe4f925c3e98a79b804 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Actions/Menus/MenuItemActionBase.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Actions/Menus/MenuItemActionBase.cs new file mode 100644 index 0000000000000000000000000000000000000000..2c0365a8461362cb663f754c6b5db172b887752e --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Actions/Menus/MenuItemActionBase.cs @@ -0,0 +1,36 @@ +namespace UnityEditor.Timeline.Actions +{ + /// + /// Indicates the validity of an action for a given data set. + /// + public enum ActionValidity + { + /// + /// Action is valid in the provided context. + /// If the action is linked to a menu item, the menu item will be visible. + /// + Valid, + /// + /// Action is not applicable in the current context. + /// If the action is linked to a menu item, the menu item will not be shown. + /// + NotApplicable, + /// + /// Action is not valid in the current context. + /// If the action is linked to a menu item, the menu item will be shown but grayed out. + /// + Invalid + } + + struct MenuActionItem + { + public string category; + public string entryName; + public string shortCut; + public int priority; + public bool isActiveInMode; + public ActionValidity state; + public bool isChecked; + public GenericMenu.MenuFunction callback; + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Actions/Menus/MenuItemActionBase.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Actions/Menus/MenuItemActionBase.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..045ed68756fee2eb2a24f4ce53c99f721ee51c8b --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Actions/Menus/MenuItemActionBase.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5882d0e4313310143acb11d1a66c597f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Actions/Menus/TimelineContextMenu.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Actions/Menus/TimelineContextMenu.cs new file mode 100644 index 0000000000000000000000000000000000000000..c17ec78de8af230ffcde976f63648d54ce52eaac --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Actions/Menus/TimelineContextMenu.cs @@ -0,0 +1,425 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEditor.Timeline.Actions; +using UnityEngine; +using UnityEngine.Playables; +using UnityEngine.Timeline; +using Object = UnityEngine.Object; + +namespace UnityEditor.Timeline +{ + static class SequencerContextMenu + { + static class Styles + { + public static readonly string addItemFromAssetTemplate = L10n.Tr("Add {0} From {1}"); + public static readonly string addSingleItemFromAssetTemplate = L10n.Tr("Add From {1}"); + public static readonly string addItemTemplate = L10n.Tr("Add {0}"); + public static readonly string typeSelectorTemplate = L10n.Tr("Select {0}"); + public static readonly string trackGroup = L10n.Tr("Track Group"); + public static readonly string trackSubGroup = L10n.Tr("Track Sub-Group"); + public static readonly string addTrackLayer = L10n.Tr("Add Layer"); + public static readonly string layerName = L10n.Tr("Layer {0}"); + } + + public static void ShowMarkerHeaderContextMenu(Vector2? mousePosition, WindowState state) + { + var menu = new GenericMenu(); + List items = new List(100); + BuildMarkerHeaderContextMenu(items, mousePosition, state); + ActionManager.BuildMenu(menu, items); + menu.ShowAsContext(); + } + + public static void ShowNewTracksContextMenu(ICollection tracks, WindowState state) + { + var menu = new GenericMenu(); + List items = new List(100); + BuildNewTracksContextMenu(items, tracks, state); + ActionManager.BuildMenu(menu, items); + menu.ShowAsContext(); + } + + public static void ShowNewTracksContextMenu(ICollection tracks, WindowState state, Rect rect) + { + var menu = new GenericMenu(); + List items = new List(100); + BuildNewTracksContextMenu(items, tracks, state); + ActionManager.BuildMenu(menu, items); + menu.DropDown(rect); + } + + public static void ShowTrackContextMenu(Vector2? mousePosition) + { + var items = new List(); + var menu = new GenericMenu(); + BuildTrackContextMenu(items, mousePosition); + ActionManager.BuildMenu(menu, items); + menu.ShowAsContext(); + } + + public static void ShowItemContextMenu(Vector2 mousePosition) + { + var menu = new GenericMenu(); + var items = new List(); + BuildItemContextMenu(items, mousePosition); + ActionManager.BuildMenu(menu, items); + menu.ShowAsContext(); + } + + public static void BuildItemContextMenu(List items, Vector2 mousePosition) + { + ActionManager.GetMenuEntries(ActionManager.TimelineActions, mousePosition, items); + ActionManager.GetMenuEntries(ActionManager.ClipActions, items); + ActionManager.GetMenuEntries(ActionManager.MarkerActions, items); + + var clips = TimelineEditor.selectedClips; + if (clips.Length > 0) + AddMarkerMenuCommands(items, clips.Select(c => c.parentTrack).Distinct().ToList(), TimelineHelpers.GetCandidateTime(mousePosition)); + } + + public static void BuildNewTracksContextMenu(List menuItems, ICollection parentTracks, WindowState state, string format = null) + { + if (parentTracks == null) + parentTracks = new TrackAsset[0]; + + if (string.IsNullOrEmpty(format)) + format = "{0}"; + + // Add Group or SubGroup + var title = string.Format(format, parentTracks.Any(t => t != null) ? Styles.trackSubGroup : Styles.trackGroup); + var menuState = ActionValidity.Valid; + if (state.editSequence.isReadOnly) + menuState = ActionValidity.Invalid; + if (parentTracks.Any() && parentTracks.Any(t => t != null && t.lockedInHierarchy)) + menuState = ActionValidity.Invalid; + + GenericMenu.MenuFunction command = () => + { + SelectionManager.Clear(); + if (parentTracks.Count == 0) + Selection.Add(TimelineHelpers.CreateTrack(null, title)); + + foreach (var parentTrack in parentTracks) + Selection.Add(TimelineHelpers.CreateTrack(parentTrack, title)); + + TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved); + }; + + menuItems.Add( + new MenuActionItem() + { + category = string.Empty, + entryName = title, + isActiveInMode = true, + priority = MenuPriority.AddItem.addGroup, + state = menuState, + isChecked = false, + callback = command + } + ); + + + var allTypes = TypeUtility.AllTrackTypes().Where(x => x != typeof(GroupTrack) && !TypeUtility.IsHiddenInMenu(x)).ToList(); + + int builtInPriority = MenuPriority.AddItem.addTrack; + int customPriority = MenuPriority.AddItem.addCustomTrack; + foreach (var trackType in allTypes) + { + var trackItemType = trackType; + + command = () => + { + SelectionManager.Clear(); + + if (parentTracks.Count == 0) + SelectionManager.Add(TimelineHelpers.CreateTrack((Type)trackItemType, null)); + + foreach (var parentTrack in parentTracks) + SelectionManager.Add(TimelineHelpers.CreateTrack((Type)trackItemType, parentTrack)); + }; + + menuItems.Add( + new MenuActionItem() + { + category = TimelineHelpers.GetTrackCategoryName(trackType), + entryName = string.Format(format, TimelineHelpers.GetTrackMenuName(trackItemType)), + isActiveInMode = true, + priority = TypeUtility.IsBuiltIn(trackType) ? builtInPriority++ : customPriority++, + state = menuState, + callback = command + } + ); + } + } + + public static void BuildMarkerHeaderContextMenu(List menu, Vector2? mousePosition, WindowState state) + { + ActionManager.GetMenuEntries(ActionManager.TimelineActions, null, menu, MenuFilter.MarkerHeader); + + var timeline = state.editSequence.asset; + var time = TimelineHelpers.GetCandidateTime(mousePosition); + var enabled = timeline.markerTrack == null || !timeline.markerTrack.lockedInHierarchy; + + var addMarkerCommand = new Action + ( + (type, obj) => AddSingleMarkerCallback(type, time, timeline, state.editSequence.director, obj) + ); + + AddMarkerMenuCommands(menu, new TrackAsset[] {timeline.markerTrack}, addMarkerCommand, enabled); + } + + public static void BuildTrackContextMenu(List items, Vector2? mousePosition) + { + var tracks = SelectionManager.SelectedTracks().ToArray(); + if (tracks.Length == 0) + return; + + ActionManager.GetMenuEntries(ActionManager.TimelineActions, mousePosition, items); + ActionManager.GetMenuEntries(ActionManager.TrackActions, items); + AddLayeredTrackCommands(items, tracks); + + var first = tracks.First().GetType(); + var allTheSame = tracks.All(t => t.GetType() == first); + if (allTheSame) + { + if (first != typeof(GroupTrack)) + { + var candidateTime = TimelineHelpers.GetCandidateTime(mousePosition, tracks); + AddClipMenuCommands(items, tracks, candidateTime); + AddMarkerMenuCommands(items, tracks, candidateTime); + } + else + { + BuildNewTracksContextMenu(items, tracks, TimelineWindow.instance.state, Styles.addItemTemplate); + } + } + } + + static void AddLayeredTrackCommands(List menuItems, ICollection tracks) + { + if (tracks.Count == 0) + return; + + var layeredType = tracks.First().GetType(); + // animation tracks have a special menu. + if (layeredType == typeof(AnimationTrack)) + return; + + // must implement ILayerable + if (!typeof(UnityEngine.Timeline.ILayerable).IsAssignableFrom(layeredType)) + return; + + if (tracks.Any(t => t.GetType() != layeredType)) + return; + + // only supported on the master track no nesting. + if (tracks.Any(t => t.isSubTrack)) + return; + + var enabled = tracks.All(t => t != null && !t.lockedInHierarchy) && !TimelineWindow.instance.state.editSequence.isReadOnly; + int priority = MenuPriority.AddTrackMenu.addLayerTrack; + GenericMenu.MenuFunction menuCallback = () => + { + foreach (var track in tracks) + TimelineHelpers.CreateTrack(layeredType, track, string.Format(Styles.layerName, track.GetChildTracks().Count() + 1)); + }; + + var entryName = Styles.addTrackLayer; + menuItems.Add( + new MenuActionItem() + { + category = string.Empty, + entryName = entryName, + isActiveInMode = true, + priority = priority++, + state = enabled ? ActionValidity.Valid : ActionValidity.Invalid, + callback = menuCallback + } + ); + } + + static void AddClipMenuCommands(List menuItems, ICollection tracks, double candidateTime) + { + if (!tracks.Any()) + return; + + var trackAsset = tracks.First(); + var trackType = trackAsset.GetType(); + if (tracks.Any(t => t.GetType() != trackType)) + return; + + var enabled = tracks.All(t => t != null && !t.lockedInHierarchy) && !TimelineWindow.instance.state.editSequence.isReadOnly; + var assetTypes = TypeUtility.GetPlayableAssetsHandledByTrack(trackType); + var visibleAssetTypes = TypeUtility.GetVisiblePlayableAssetsHandledByTrack(trackType); + + // skips the name if there is only a single type + var commandNameTemplate = assetTypes.Count() == 1 ? Styles.addSingleItemFromAssetTemplate : Styles.addItemFromAssetTemplate; + int builtInPriority = MenuPriority.AddItem.addClip; + int customPriority = MenuPriority.AddItem.addCustomClip; + foreach (var assetType in assetTypes) + { + var assetItemType = assetType; + var category = TimelineHelpers.GetItemCategoryName(assetType); + Action onObjectChanged = obj => + { + if (obj != null) + { + foreach (var t in tracks) + { + TimelineHelpers.CreateClipOnTrack(assetItemType, obj, t, candidateTime); + } + } + }; + + foreach (var objectReference in TypeUtility.ObjectReferencesForType(assetType)) + { + var isSceneReference = objectReference.isSceneReference; + var dataType = objectReference.type; + GenericMenu.MenuFunction menuCallback = () => + { + ObjectSelector.get.Show(null, dataType, null, isSceneReference, null, (obj) => onObjectChanged(obj), null); + ObjectSelector.get.titleContent = EditorGUIUtility.TrTextContent(string.Format(Styles.typeSelectorTemplate, TypeUtility.GetDisplayName(dataType))); + }; + + menuItems.Add( + new MenuActionItem() + { + category = category, + entryName = string.Format(commandNameTemplate, TypeUtility.GetDisplayName(assetType), TypeUtility.GetDisplayName(objectReference.type)), + isActiveInMode = true, + priority = TypeUtility.IsBuiltIn(assetType) ? builtInPriority++ : customPriority++, + state = enabled ? ActionValidity.Valid : ActionValidity.Invalid, + callback = menuCallback + } + ); + } + } + + foreach (var assetType in visibleAssetTypes) + { + var assetItemType = assetType; + var category = TimelineHelpers.GetItemCategoryName(assetType); + var commandName = string.Format(Styles.addItemTemplate, TypeUtility.GetDisplayName(assetType)); + GenericMenu.MenuFunction command = () => + { + foreach (var t in tracks) + { + TimelineHelpers.CreateClipOnTrack(assetItemType, t, candidateTime); + } + }; + + menuItems.Add( + new MenuActionItem() + { + category = category, + entryName = commandName, + isActiveInMode = true, + priority = TypeUtility.IsBuiltIn(assetItemType) ? builtInPriority++ : customPriority++, + state = enabled ? ActionValidity.Valid : ActionValidity.Invalid, + callback = command + } + ); + } + } + + static void AddMarkerMenuCommands(List menu, IEnumerable markerTypes, Action addMarkerCommand, bool enabled) + { + int builtInPriority = MenuPriority.AddItem.addMarker; + int customPriority = MenuPriority.AddItem.addCustomMarker; + foreach (var markerType in markerTypes) + { + var markerItemType = markerType; + string category = TimelineHelpers.GetItemCategoryName(markerItemType); + menu.Add( + new MenuActionItem() + { + category = category, + entryName = string.Format(Styles.addItemTemplate, TypeUtility.GetDisplayName(markerType)), + isActiveInMode = true, + priority = TypeUtility.IsBuiltIn(markerType) ? builtInPriority++ : customPriority++, + state = enabled ? ActionValidity.Valid : ActionValidity.Invalid, + callback = () => addMarkerCommand(markerItemType, null) + } + ); + + foreach (var objectReference in TypeUtility.ObjectReferencesForType(markerType)) + { + var isSceneReference = objectReference.isSceneReference; + GenericMenu.MenuFunction menuCallback = () => + { + Type assetDataType = objectReference.type; + ObjectSelector.get.titleContent = EditorGUIUtility.TrTextContent(string.Format(Styles.typeSelectorTemplate, TypeUtility.GetDisplayName(assetDataType))); + ObjectSelector.get.Show(null, assetDataType, null, isSceneReference, null, obj => + { + if (obj != null) + addMarkerCommand(markerItemType, obj); + }, null); + }; + + menu.Add( + new MenuActionItem + { + category = TimelineHelpers.GetItemCategoryName(markerItemType), + entryName = string.Format(Styles.addItemFromAssetTemplate, TypeUtility.GetDisplayName(markerType), TypeUtility.GetDisplayName(objectReference.type)), + isActiveInMode = true, + priority = TypeUtility.IsBuiltIn(markerType) ? builtInPriority++ : customPriority++, + state = enabled ? ActionValidity.Valid : ActionValidity.Invalid, + callback = menuCallback + } + ); + } + } + } + + static void AddMarkerMenuCommands(List menuItems, ICollection tracks, double candidateTime) + { + if (tracks.Count == 0) + return; + + var enabled = tracks.All(t => !t.lockedInHierarchy) && !TimelineWindow.instance.state.editSequence.isReadOnly; + var addMarkerCommand = new Action((type, obj) => AddMarkersCallback(tracks, type, candidateTime, obj)); + + AddMarkerMenuCommands(menuItems, tracks, addMarkerCommand, enabled); + } + + static void AddMarkerMenuCommands(List menuItems, ICollection tracks, Action command, bool enabled) + { + var markerTypes = TypeUtility.GetBuiltInMarkerTypes().Union(TypeUtility.GetUserMarkerTypes()); + if (tracks != null) + markerTypes = markerTypes.Where(x => tracks.All(track => (track == null) || TypeUtility.DoesTrackSupportMarkerType(track, x))); // null track indicates marker track to be created + + AddMarkerMenuCommands(menuItems, markerTypes, command, enabled); + } + + static void AddMarkersCallback(ICollection targets, Type markerType, double time, Object obj) + { + SelectionManager.Clear(); + foreach (var target in targets) + { + var marker = TimelineHelpers.CreateMarkerOnTrack(markerType, obj, target, time); + SelectionManager.Add(marker); + } + TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved); + } + + static void AddSingleMarkerCallback(Type markerType, double time, TimelineAsset timeline, PlayableDirector director, Object assignableObject) + { + timeline.CreateMarkerTrack(); + var markerTrack = timeline.markerTrack; + + SelectionManager.Clear(); + var marker = TimelineHelpers.CreateMarkerOnTrack(markerType, assignableObject, markerTrack, time); + SelectionManager.Add(marker); + + if (typeof(INotification).IsAssignableFrom(markerType) && director != null) + { + if (director != null && director.GetGenericBinding(markerTrack) == null) + director.SetGenericBinding(markerTrack, director.gameObject); + } + + TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved); + } + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Actions/Menus/TimelineContextMenu.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Actions/Menus/TimelineContextMenu.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..adfa86d8a285c7361bbd573fb4bf000cbcb45584 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Actions/Menus/TimelineContextMenu.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: de86b4ed8106fd84a8bc2f5d69798d53 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/AddDelete/IAddDeleteItemMode.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/AddDelete/IAddDeleteItemMode.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..1296e1fceea522907fb3c0b4fbf15c380b0f1a2d --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/AddDelete/IAddDeleteItemMode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4db13e1060deaae48b30246ed63b7c9b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Cursors/TimelineCursors.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Cursors/TimelineCursors.cs new file mode 100644 index 0000000000000000000000000000000000000000..4935cabce67d8f09031212474d23b924863b8352 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Cursors/TimelineCursors.cs @@ -0,0 +1,95 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace UnityEditor.Timeline +{ + class TimelineCursors + { + public enum CursorType + { + MixBoth, + MixLeft, + MixRight, + Replace, + Ripple, + + Pan + } + + class CursorInfo + { + public readonly string assetPath; + public readonly Vector2 hotSpot; + public readonly MouseCursor mouseCursorType; + + public CursorInfo(string assetPath, Vector2 hotSpot, MouseCursor mouseCursorType) + { + this.assetPath = assetPath; + this.hotSpot = hotSpot; + this.mouseCursorType = mouseCursorType; + } + } + + const string k_CursorAssetRoot = "Cursors/"; + const string k_CursorAssetsNamespace = "Timeline."; + const string k_CursorAssetExtension = ".png"; + + const string k_MixBothCursorAssetName = k_CursorAssetsNamespace + "MixBoth" + k_CursorAssetExtension; + const string k_MixLeftCursorAssetName = k_CursorAssetsNamespace + "MixLeft" + k_CursorAssetExtension; + const string k_MixRightCursorAssetName = k_CursorAssetsNamespace + "MixRight" + k_CursorAssetExtension; + const string k_ReplaceCursorAssetName = k_CursorAssetsNamespace + "Replace" + k_CursorAssetExtension; + const string k_RippleCursorAssetName = k_CursorAssetsNamespace + "Ripple" + k_CursorAssetExtension; + + static readonly string s_PlatformPath = (Application.platform == RuntimePlatform.WindowsEditor) ? "Windows/" : "macOS/"; + static readonly string s_CursorAssetDirectory = k_CursorAssetRoot + s_PlatformPath; + + static readonly Dictionary s_CursorInfoLookup = new Dictionary + { + {CursorType.MixBoth, new CursorInfo(s_CursorAssetDirectory + k_MixBothCursorAssetName, new Vector2(16, 18), MouseCursor.CustomCursor)}, + {CursorType.MixLeft, new CursorInfo(s_CursorAssetDirectory + k_MixLeftCursorAssetName, new Vector2(7, 18), MouseCursor.CustomCursor)}, + {CursorType.MixRight, new CursorInfo(s_CursorAssetDirectory + k_MixRightCursorAssetName, new Vector2(25, 18), MouseCursor.CustomCursor)}, + {CursorType.Replace, new CursorInfo(s_CursorAssetDirectory + k_ReplaceCursorAssetName, new Vector2(16, 28), MouseCursor.CustomCursor)}, + {CursorType.Ripple, new CursorInfo(s_CursorAssetDirectory + k_RippleCursorAssetName, new Vector2(26, 19), MouseCursor.CustomCursor)}, + {CursorType.Pan, new CursorInfo(null, Vector2.zero, MouseCursor.Pan)} + }; + + static readonly Dictionary s_CursorAssetCache = new Dictionary(); + + static CursorType? s_CurrentCursor; + + public static void SetCursor(CursorType cursorType) + { + if (s_CurrentCursor.HasValue && s_CurrentCursor.Value == cursorType) return; + + s_CurrentCursor = cursorType; + var cursorInfo = s_CursorInfoLookup[cursorType]; + + Texture2D cursorAsset = null; + + if (cursorInfo.mouseCursorType == MouseCursor.CustomCursor) + { + cursorAsset = LoadCursorAsset(cursorInfo.assetPath); + } + + EditorGUIUtility.SetCurrentViewCursor(cursorAsset, cursorInfo.hotSpot, cursorInfo.mouseCursorType); + } + + public static void ClearCursor() + { + if (!s_CurrentCursor.HasValue) return; + + EditorGUIUtility.ClearCurrentViewCursor(); + s_CurrentCursor = null; + } + + static Texture2D LoadCursorAsset(string assetPath) + { + if (!s_CursorAssetCache.ContainsKey(assetPath)) + { + s_CursorAssetCache.Add(assetPath, (Texture2D)EditorGUIUtility.Load(assetPath)); + } + + return s_CursorAssetCache[assetPath]; + } + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Cursors/TimelineCursors.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Cursors/TimelineCursors.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..0e017d08e2f12f4d1e5dbc15a9e5df7a284b9bbf --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Cursors/TimelineCursors.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f16e09785c984c445a0467e30f845636 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/IMoveItemMode.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/IMoveItemMode.cs new file mode 100644 index 0000000000000000000000000000000000000000..ac459cadc40f4909192addc76dff398cb7a11a9a --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/IMoveItemMode.cs @@ -0,0 +1,28 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace UnityEditor.Timeline +{ + interface IMoveItemMode + { + void OnTrackDetach(IEnumerable itemsGroups); + void HandleTrackSwitch(IEnumerable itemsGroups); + bool AllowTrackSwitch(); + + double AdjustStartTime(WindowState state, ItemsPerTrack itemsGroup, double time); + + void OnModeClutchEnter(IEnumerable itemsGroups); + void OnModeClutchExit(IEnumerable itemsGroups); + + void BeginMove(IEnumerable itemsGroups); + void UpdateMove(IEnumerable itemsGroups); + void FinishMove(IEnumerable itemsGroups); + + bool ValidateMove(ItemsPerTrack itemsGroup); + } + + interface IMoveItemDrawer + { + void DrawGUI(WindowState state, IEnumerable movingItems, Color color); + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/IMoveItemMode.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/IMoveItemMode.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..619723e56ed1aece151fd4e660d86922a18719ab --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/IMoveItemMode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3ff3d24ea34f9f74cb138e435f5f491e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/MoveItemHandler.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/MoveItemHandler.cs new file mode 100644 index 0000000000000000000000000000000000000000..974950fa1208b3f40540a0fe6323d3d960dd1a17 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/MoveItemHandler.cs @@ -0,0 +1,311 @@ +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using UnityEngine.Timeline; + +namespace UnityEditor.Timeline +{ + class MoveItemHandler : IAttractable, IAttractionHandler + { + bool m_Grabbing; + + MovingItems m_LeftMostMovingItems; + MovingItems m_RightMostMovingItems; + + HashSet m_ItemGUIs; + ItemsGroup m_ItemsGroup; + + public TrackAsset targetTrack { get; private set; } + + public bool allowTrackSwitch { get; private set; } + + int m_GrabbedModalUndoGroup = -1; + + readonly WindowState m_State; + + public MovingItems[] movingItems { get; private set; } + + public MoveItemHandler(WindowState state) + { + m_State = state; + } + + public void Grab(IEnumerable items, TrackAsset referenceTrack) + { + Grab(items, referenceTrack, Vector2.zero); + } + + public void Grab(IEnumerable items, TrackAsset referenceTrack, Vector2 mousePosition) + { + if (items == null) return; + + items = items.ToArray(); // Cache enumeration result + + if (!items.Any()) return; + + m_GrabbedModalUndoGroup = Undo.GetCurrentGroup(); + + var trackItems = items.GroupBy(c => c.parentTrack).ToArray(); + var trackItemsCount = trackItems.Length; + var tracks = items.Select(c => c.parentTrack).Where(x => x != null).Distinct(); + + movingItems = new MovingItems[trackItemsCount]; + + allowTrackSwitch = trackItemsCount == 1 && !trackItems.SelectMany(x => x).Any(x => x is MarkerItem); // For now, track switch is only supported when all items are on the same track and there are no items + + // one push per track handles all the clips on the track + UndoExtensions.RegisterTracks(tracks, "Move Items"); + foreach (var sourceTrack in tracks) + { + // push all markers on the track because of ripple + UndoExtensions.RegisterMarkers(sourceTrack.GetMarkers(), "Move Items"); + } + + for (var i = 0; i < trackItemsCount; ++i) + { + var track = trackItems[i].Key; + var grabbedItems = new MovingItems(m_State, track, trackItems[i].ToArray(), referenceTrack, mousePosition, allowTrackSwitch); + movingItems[i] = grabbedItems; + } + + m_LeftMostMovingItems = null; + m_RightMostMovingItems = null; + + foreach (var grabbedTrackItems in movingItems) + { + if (m_LeftMostMovingItems == null || m_LeftMostMovingItems.start > grabbedTrackItems.start) + m_LeftMostMovingItems = grabbedTrackItems; + + if (m_RightMostMovingItems == null || m_RightMostMovingItems.end < grabbedTrackItems.end) + m_RightMostMovingItems = grabbedTrackItems; + } + + m_ItemGUIs = new HashSet(); + m_ItemsGroup = new ItemsGroup(items); + + foreach (var item in items) + m_ItemGUIs.Add(item.gui); + + targetTrack = referenceTrack; + + EditMode.BeginMove(this); + m_Grabbing = true; + } + + public void Drop() + { + if (IsValidDrop()) + { + foreach (var grabbedItems in movingItems) + { + var track = grabbedItems.targetTrack; + UndoExtensions.RegisterTrack(track, "Move Items"); + + if (EditModeUtils.IsInfiniteTrack(track) && grabbedItems.clips.Any()) + ((AnimationTrack)track).ConvertToClipMode(); + } + + EditMode.FinishMove(); + + Done(); + } + else + { + Cancel(); + } + + EditMode.ClearEditMode(); + } + + bool IsValidDrop() + { + return movingItems.All(g => g.canDrop); + } + + void Cancel() + { + if (!m_Grabbing) + return; + + // TODO fix undo reselection persistency + // identify the clips by their playable asset, since that reference will survive the undo + // This is a workaround, until a more persistent fix for selection of clips across Undo can be found + var assets = movingItems.SelectMany(x => x.clips).Select(x => x.asset); + + Undo.RevertAllDownToGroup(m_GrabbedModalUndoGroup); + + // reselect the clips from the original clip + var clipsToSelect = movingItems.Select(x => x.originalTrack).SelectMany(x => x.GetClips()).Where(x => assets.Contains(x.asset)).ToArray(); + SelectionManager.RemoveTimelineSelection(); + + foreach (var c in clipsToSelect) + SelectionManager.Add(c); + + Done(); + } + + void Done() + { + foreach (var movingItem in movingItems) + { + foreach (var item in movingItem.items) + { + if (item.gui != null) + item.gui.isInvalid = false; + } + } + + movingItems = null; + m_LeftMostMovingItems = null; + m_RightMostMovingItems = null; + m_Grabbing = false; + + m_State.Refresh(); + } + + public double start { get { return m_ItemsGroup.start; } } + + public double end { get { return m_ItemsGroup.end; } } + + public bool ShouldSnapTo(ISnappable snappable) + { + var itemGUI = snappable as TimelineItemGUI; + return itemGUI != null && !m_ItemGUIs.Contains(itemGUI); + } + + public void UpdateTrackTarget(TrackAsset track) + { + if (!EditMode.AllowTrackSwitch()) + return; + + targetTrack = track; + + var targetTracksChanged = false; + + foreach (var grabbedItem in movingItems) + { + var prevTrackGUI = grabbedItem.targetTrack; + + grabbedItem.SetReferenceTrack(track); + + targetTracksChanged = grabbedItem.targetTrack != prevTrackGUI; + } + + if (targetTracksChanged) + EditMode.HandleTrackSwitch(movingItems); + + RefreshPreviewItems(); + + m_State.rebuildGraph |= targetTracksChanged; + } + + public void OnGUI(Event evt) + { + if (!m_Grabbing) + return; + + if (evt.type != EventType.Repaint) + return; + + var isValid = IsValidDrop(); + + using (new GUIViewportScope(m_State.GetWindow().sequenceContentRect)) + { + foreach (var grabbedClip in movingItems) + { + grabbedClip.RefreshBounds(m_State, evt.mousePosition); + + if (!grabbedClip.HasAnyDetachedParents()) + continue; + + grabbedClip.Draw(isValid); + } + + if (isValid) + { + EditMode.DrawMoveGUI(m_State, movingItems); + } + else + { + TimelineCursors.ClearCursor(); + } + } + } + + public void OnAttractedEdge(IAttractable attractable, ManipulateEdges manipulateEdges, AttractedEdge edge, double time) + { + double offset; + + if (edge == AttractedEdge.Right) + { + var duration = end - start; + var startTime = time - duration; + startTime = EditMode.AdjustStartTime(m_State, m_RightMostMovingItems, startTime); + + offset = startTime + duration - end; + } + else + { + if (edge == AttractedEdge.Left) + time = EditMode.AdjustStartTime(m_State, m_LeftMostMovingItems, time); + + offset = time - start; + } + + if (start + offset < 0.0) + offset = -start; + + if (!offset.Equals(0.0)) + { + foreach (var grabbedClips in movingItems) + grabbedClips.start += offset; + + EditMode.UpdateMove(); + + RefreshPreviewItems(); + } + } + + public void RefreshPreviewItems() + { + foreach (var movingItemsGroup in movingItems) + { + // Check validity + var valid = ValidateItemDrag(movingItemsGroup); + + foreach (var item in movingItemsGroup.items) + { + if (item.gui != null) + item.gui.isInvalid = !valid; + } + + movingItemsGroup.canDrop = valid; + } + } + + static bool ValidateItemDrag(ItemsPerTrack itemsGroup) + { + //TODO-marker: this is to prevent the drag operation from being canceled when moving only markers + if (itemsGroup.clips.Any()) + { + if (itemsGroup.targetTrack == null) + return false; + + if (itemsGroup.targetTrack.lockedInHierarchy) + return false; + + if (itemsGroup.items.Any(i => !i.IsCompatibleWithTrack(itemsGroup.targetTrack))) + return false; + + return EditMode.ValidateDrag(itemsGroup); + } + + return true; + } + + public void OnTrackDetach() + { + EditMode.OnTrackDetach(movingItems); + } + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/MoveItemHandler.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/MoveItemHandler.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..43dce6ad1d156643631cceb715642bf4b55e1030 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/MoveItemHandler.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f6bd368ab00d75c459e2582e017191e6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/MoveItemModeMix.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/MoveItemModeMix.cs new file mode 100644 index 0000000000000000000000000000000000000000..21822027bc9d5c6d712f6d9b2433f4bf8552e1a4 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/MoveItemModeMix.cs @@ -0,0 +1,136 @@ +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using UnityEngine.Timeline; + +namespace UnityEditor.Timeline +{ + class MoveItemModeMix : IMoveItemMode, IMoveItemDrawer + { + public void OnTrackDetach(IEnumerable itemsGroups) + { + // Nothing + } + + public void HandleTrackSwitch(IEnumerable itemsGroups) + { + foreach (var itemsGroup in itemsGroups) + { + var targetTrack = itemsGroup.targetTrack; + if (targetTrack != null && itemsGroup.items.Any()) + { + var compatible = itemsGroup.items.First().IsCompatibleWithTrack(targetTrack) && + !EditModeUtils.IsInfiniteTrack(targetTrack); + var track = compatible ? targetTrack : null; + + UndoExtensions.RegisterTrack(track, "Move Items"); + EditModeUtils.SetParentTrack(itemsGroup.items, track); + } + else + { + EditModeUtils.SetParentTrack(itemsGroup.items, null); + } + } + } + + public bool AllowTrackSwitch() + { + return true; + } + + public double AdjustStartTime(WindowState state, ItemsPerTrack itemsGroup, double time) + { + return time; + } + + public void OnModeClutchEnter(IEnumerable itemsGroups) + { + // Nothing + } + + public void OnModeClutchExit(IEnumerable itemsGroups) + { + // Nothing + } + + public void BeginMove(IEnumerable itemsGroups) + { + // Nothing + } + + public void UpdateMove(IEnumerable itemsGroups) + { + // Nothing + } + + public void FinishMove(IEnumerable itemsGroups) + { + // Nothing + } + + public bool ValidateMove(ItemsPerTrack itemsGroup) + { + var track = itemsGroup.targetTrack; + var items = itemsGroup.items; + + if (EditModeUtils.IsInfiniteTrack(track)) + { + double startTime; + double stopTime; + EditModeUtils.GetInfiniteClipBoundaries(track, out startTime, out stopTime); + + return items.All(item => + !EditModeUtils.IsItemWithinRange(item, startTime, stopTime) && + !EditModeUtils.IsRangeWithinItem(startTime, stopTime, item)); + } + + var siblings = ItemsUtils.GetItemsExcept(itemsGroup.targetTrack, items); + return items.All(item => EditModeMixUtils.GetPlacementValidity(item, siblings) == PlacementValidity.Valid); + } + + public void DrawGUI(WindowState state, IEnumerable movingItems, Color color) + { + var selectionHasAnyBlendIn = false; + var selectionHasAnyBlendOut = false; + + foreach (var grabbedItems in movingItems) + { + var bounds = grabbedItems.onTrackItemsBounds; + + var counter = 0; + foreach (var item in grabbedItems.items.OfType()) + { + if (item.hasLeftBlend) + { + EditModeGUIUtils.DrawBoundsEdge(bounds[counter], color, TrimEdge.Start); + selectionHasAnyBlendIn = true; + } + + if (item.hasRightBlend) + { + EditModeGUIUtils.DrawBoundsEdge(bounds[counter], color, TrimEdge.End); + selectionHasAnyBlendOut = true; + } + counter++; + } + } + + if (selectionHasAnyBlendIn && selectionHasAnyBlendOut) + { + TimelineCursors.SetCursor(TimelineCursors.CursorType.MixBoth); + } + else if (selectionHasAnyBlendIn) + { + TimelineCursors.SetCursor(TimelineCursors.CursorType.MixLeft); + } + else if (selectionHasAnyBlendOut) + { + TimelineCursors.SetCursor(TimelineCursors.CursorType.MixRight); + } + else + { + TimelineCursors.ClearCursor(); + } + } + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/MoveItemModeMix.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/MoveItemModeMix.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..966ebfab325fdd840db10116cc99dfeb9d7af0e5 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/MoveItemModeMix.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a2a8aecb05814e644abbb070fbd91156 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/MoveItemModeReplace.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/MoveItemModeReplace.cs new file mode 100644 index 0000000000000000000000000000000000000000..4d558208e7cf49a46c2d3e61fe8340a1a58bac7c --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/MoveItemModeReplace.cs @@ -0,0 +1,99 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace UnityEditor.Timeline +{ + class MoveItemModeReplace : IMoveItemMode, IMoveItemDrawer + { + public void OnTrackDetach(IEnumerable itemsGroups) + { + // Nothing + } + + public void HandleTrackSwitch(IEnumerable itemsGroups) + { + // Nothing + } + + public bool AllowTrackSwitch() + { + return true; + } + + public double AdjustStartTime(WindowState state, ItemsPerTrack itemsGroup, double time) + { + return time; + } + + public void OnModeClutchEnter(IEnumerable itemsGroups) + { + // TODO + } + + public void OnModeClutchExit(IEnumerable itemsGroups) + { + // TODO + } + + public void BeginMove(IEnumerable itemsGroups) + { + foreach (var itemsGroup in itemsGroups) + { + EditModeUtils.SetParentTrack(itemsGroup.items, null); + } + } + + public void UpdateMove(IEnumerable itemsGroups) + { + // Nothing + } + + public void FinishMove(IEnumerable itemsGroups) + { + EditModeReplaceUtils.Insert(itemsGroups); + } + + public bool ValidateMove(ItemsPerTrack itemsGroup) + { + return true; + } + + public void DrawGUI(WindowState state, IEnumerable movingItems, Color color) + { + var operationWillReplace = false; + + foreach (var itemsPerTrack in movingItems) + { + var bounds = itemsPerTrack.onTrackItemsBounds; + + var counter = 0; + foreach (var item in itemsPerTrack.items) + { + if (EditModeUtils.GetFirstIntersectedItem(itemsPerTrack.items, item.start) != null) + { + EditModeGUIUtils.DrawBoundsEdge(bounds[counter], color, TrimEdge.Start); + operationWillReplace = true; + } + + if (EditModeUtils.GetFirstIntersectedItem(itemsPerTrack.items, item.end) != null) + { + EditModeGUIUtils.DrawBoundsEdge(bounds[counter], color, TrimEdge.End); + operationWillReplace = true; + } + + counter++; + // TODO Display swallowed clips? + } + } + + if (operationWillReplace) + { + TimelineCursors.SetCursor(TimelineCursors.CursorType.Replace); + } + else + { + TimelineCursors.ClearCursor(); + } + } + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/MoveItemModeReplace.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/MoveItemModeReplace.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..abcc2f39a2a2c539ee66eabdd2bf66ec35e26a17 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/MoveItemModeReplace.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ea5e2240e8a7d9046a651557deec40b2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/MoveItemModeRipple.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/MoveItemModeRipple.cs new file mode 100644 index 0000000000000000000000000000000000000000..aadf5f7bad97040dc2359eb229c5924fbaa1c025 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/MoveItemModeRipple.cs @@ -0,0 +1,271 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using Object = UnityEngine.Object; + +namespace UnityEditor.Timeline +{ + class MoveItemModeRipple : IMoveItemMode, IMoveItemDrawer + { + const float k_SnapToEdgeDistance = 30.0f; + + class PrevItemInfo + { + public ITimelineItem item; + public ITimelineItem firstSelectedItem; + public bool blending; + + public PrevItemInfo(ITimelineItem item, ITimelineItem firstSelectedItem) + { + this.item = item; + this.firstSelectedItem = firstSelectedItem; + blending = item != null && item.end > firstSelectedItem.start; + } + } + + readonly Dictionary> m_NextItems = new Dictionary>(); + readonly Dictionary m_PreviousItem = new Dictionary(); + double m_PreviousEnd; + + bool m_TrackLocked; + bool m_Detached; + + public void OnTrackDetach(IEnumerable itemsGroups) + { + if (m_TrackLocked) + return; + + if (m_Detached) + return; + + if (itemsGroups.Any(x => x.markers.Any())) + return; + + // Ripple can either remove or not clips when detaching them from their track. + // Keep it off for now. TODO: add clutch key to toggle this feature? + //EditModeRippleUtils.Remove(manipulatedClipsList); + + StartDetachMode(itemsGroups); + } + + public void HandleTrackSwitch(IEnumerable itemsGroups) + { + // Nothing + } + + public bool AllowTrackSwitch() + { + return !m_TrackLocked; + } + + public double AdjustStartTime(WindowState state, ItemsPerTrack itemsGroup, double time) + { + var track = itemsGroup.targetTrack; + if (track == null) + return time; + + double start; + double end; + + if (EditModeUtils.IsInfiniteTrack(track)) + { + EditModeUtils.GetInfiniteClipBoundaries(track, out start, out end); + } + else + { + var siblings = ItemsUtils.GetItemsExcept(track, itemsGroup.items); + var firstIntersectedItem = EditModeUtils.GetFirstIntersectedItem(siblings, time); + + if (firstIntersectedItem == null) + return time; + + start = firstIntersectedItem.start; + end = firstIntersectedItem.end; + } + + var closestTime = Math.Abs(time - start) < Math.Abs(time - end) ? start : end; + + var pixelTime = state.TimeToPixel(time); + var pixelClosestTime = state.TimeToPixel(closestTime); + + if (Math.Abs(pixelTime - pixelClosestTime) < k_SnapToEdgeDistance) + return closestTime; + + return time; + } + + void StartDetachMode(IEnumerable itemsGroups) + { + m_Detached = true; + + foreach (var itemsGroup in itemsGroups) + EditModeUtils.SetParentTrack(itemsGroup.items, null); + } + + public void OnModeClutchEnter(IEnumerable itemsGroups) + { + StartDetachMode(itemsGroups); + m_TrackLocked = false; + } + + public void OnModeClutchExit(IEnumerable itemsGroups) + { + m_Detached = false; + m_TrackLocked = false; + } + + public void BeginMove(IEnumerable itemsGroups) + { + m_NextItems.Clear(); + m_PreviousItem.Clear(); + var itemTypes = ItemsUtils.GetItemTypes(itemsGroups).ToList(); + + foreach (var itemsGroup in itemsGroups) + { + //can only ripple items of the same type as those selected + var sortedSelectedItems = itemsGroup.items.OrderBy(i => i.start).ToList(); + var siblings = itemsGroup.targetTrack.GetItemsExcept(itemsGroup.items); + var sortedSiblingsToRipple = siblings.Where(i => itemTypes.Contains(i.GetType())).OrderBy(i => i.start).ToList(); + var start = sortedSelectedItems.First().start; + + m_NextItems.Add(itemsGroup.targetTrack, sortedSiblingsToRipple.Where(i => i.start > start).ToList()); + m_PreviousItem.Add(itemsGroup.targetTrack, CalculatePrevItemInfo(sortedSelectedItems, sortedSiblingsToRipple, itemTypes)); + } + + m_PreviousEnd = itemsGroups.Max(m => m.items.Max(c => c.end)); + } + + public void UpdateMove(IEnumerable itemsGroups) + { + if (m_Detached) + return; + + m_TrackLocked = true; + + var overlap = 0.0; + foreach (var itemsGroup in itemsGroups) + { + var track = itemsGroup.targetTrack; + if (track == null) continue; + + var prevItemInfo = m_PreviousItem[track]; + if (prevItemInfo.item != null) + { + var prevItem = prevItemInfo.item; + var firstItem = prevItemInfo.firstSelectedItem; + + if (prevItemInfo.blending) + prevItemInfo.blending = prevItem.end > firstItem.start; + + if (prevItemInfo.blending) + { + var b = EditModeUtils.BlendDuration(firstItem, TrimEdge.End); + overlap = Math.Max(overlap, Math.Max(prevItem.start, prevItem.end - firstItem.end + firstItem.start + b) - firstItem.start); + } + else + { + overlap = Math.Max(overlap, prevItem.end - firstItem.start); + } + } + } + + if (overlap > 0) + { + foreach (var itemsGroup in itemsGroups) + { + foreach (var item in itemsGroup.items) + item.start += overlap; + } + } + + var newEnd = itemsGroups.Max(m => m.items.Max(c => c.end)); + + var offset = newEnd - m_PreviousEnd; + m_PreviousEnd = newEnd; + + foreach (var itemsGroup in itemsGroups) + { + foreach (var item in m_NextItems[itemsGroup.targetTrack]) + item.start += offset; + } + } + + static PrevItemInfo CalculatePrevItemInfo(List orderedSelection, List orderedSiblings, IEnumerable itemTypes) + { + ITimelineItem previousItem = null; + ITimelineItem firstSelectedItem = null; + var gap = double.PositiveInfinity; + + foreach (var type in itemTypes) + { + var firstSelectedItemOfType = orderedSelection.FirstOrDefault(i => i.GetType() == type); + if (firstSelectedItemOfType == null) continue; + + var previousItemOfType = orderedSiblings.LastOrDefault(i => i.GetType() == type && i.start < firstSelectedItemOfType.start); + if (previousItemOfType == null) continue; + + var currentGap = firstSelectedItemOfType.start - previousItemOfType.end; + if (currentGap < gap) + { + gap = currentGap; + firstSelectedItem = firstSelectedItemOfType; + previousItem = previousItemOfType; + } + } + + return new PrevItemInfo(previousItem, firstSelectedItem); + } + + public bool ValidateMove(ItemsPerTrack itemsGroup) + { + return true; + } + + public void FinishMove(IEnumerable itemsGroups) + { + if (m_Detached) + EditModeRippleUtils.Insert(itemsGroups); + + m_Detached = false; + m_TrackLocked = false; + } + + public void DrawGUI(WindowState state, IEnumerable movingItems, Color color) + { + if (m_Detached) + { + var xMin = float.MaxValue; + var xMax = float.MinValue; + + foreach (var grabbedItems in movingItems) + { + xMin = Math.Min(xMin, grabbedItems.onTrackItemsBounds.Min(b => b.xMin)); // TODO Cache this? + xMax = Math.Max(xMax, grabbedItems.onTrackItemsBounds.Max(b => b.xMax)); + } + + foreach (var grabbedItems in movingItems) + { + var bounds = Rect.MinMaxRect(xMin, grabbedItems.onTrackItemsBounds[0].yMin, + xMax, grabbedItems.onTrackItemsBounds[0].yMax); + + EditModeGUIUtils.DrawOverlayRect(bounds, new Color(1.0f, 1.0f, 1.0f, 0.5f)); + + EditModeGUIUtils.DrawBoundsEdge(bounds, color, TrimEdge.Start); + } + } + else + { + foreach (var grabbedItems in movingItems) + { + var bounds = Rect.MinMaxRect(grabbedItems.onTrackItemsBounds.Min(b => b.xMin), grabbedItems.onTrackItemsBounds[0].yMin, + grabbedItems.onTrackItemsBounds.Max(b => b.xMax), grabbedItems.onTrackItemsBounds[0].yMax); + + EditModeGUIUtils.DrawBoundsEdge(bounds, color, TrimEdge.Start); + } + } + + TimelineCursors.SetCursor(TimelineCursors.CursorType.Ripple); + } + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/MoveItemModeRipple.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/MoveItemModeRipple.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..890c3edbdee2b3eb9992aeb17ccec11024207ea2 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/MoveItemModeRipple.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: eebde5009793ce948bf5d4c4435b89b9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/MovingItems.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/MovingItems.cs new file mode 100644 index 0000000000000000000000000000000000000000..1620269d2d25deceb7e41772ddb8c85f5d87c4a8 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/MovingItems.cs @@ -0,0 +1,137 @@ +using System; +using System.Linq; +using UnityEngine; +using UnityEngine.Timeline; + +namespace UnityEditor.Timeline +{ + class MovingItems : ItemsPerTrack + { + TrackAsset m_ReferenceTrack; + readonly bool m_AllowTrackSwitch; + + readonly Rect[] m_ItemsBoundsOnTrack; + readonly Vector2[] m_ItemsMouseOffsets; + + static readonly Rect s_InvisibleBounds = new Rect(float.MaxValue, float.MaxValue, 0.0f, 0.0f); + + public TrackAsset originalTrack { get; } + + public override TrackAsset targetTrack + { + get + { + if (m_AllowTrackSwitch) + return m_ReferenceTrack; + + return originalTrack; + } + } + + public bool canDrop; + + public double start + { + get { return m_ItemsGroup.start; } + set { m_ItemsGroup.start = value; } + } + + public double end + { + get { return m_ItemsGroup.end; } + } + + public Rect[] onTrackItemsBounds + { + get { return m_ItemsBoundsOnTrack; } + } + + public MovingItems(WindowState state, TrackAsset parentTrack, ITimelineItem[] items, TrackAsset referenceTrack, Vector2 mousePosition, bool allowTrackSwitch) + : base(parentTrack, items) + { + originalTrack = parentTrack; + m_ReferenceTrack = referenceTrack; + m_AllowTrackSwitch = allowTrackSwitch; + + m_ItemsBoundsOnTrack = new Rect[items.Length]; + m_ItemsMouseOffsets = new Vector2[items.Length]; + + for (int i = 0; i < items.Length; ++i) + { + var itemGUi = items[i].gui; + + if (itemGUi != null) + { + m_ItemsBoundsOnTrack[i] = itemGUi.rect; + m_ItemsMouseOffsets[i] = mousePosition - m_ItemsBoundsOnTrack[i].position; + } + } + + canDrop = true; + } + + public void SetReferenceTrack(TrackAsset track) + { + m_ReferenceTrack = track; + } + + public bool HasAnyDetachedParents() + { + return m_ItemsGroup.items.Any(x => x.parentTrack == null); + } + + public void RefreshBounds(WindowState state, Vector2 mousePosition) + { + for (int i = 0; i < m_ItemsGroup.items.Length; ++i) + { + var item = m_ItemsGroup.items[i]; + var itemGUI = item.gui; + + if (item.parentTrack != null) + { + m_ItemsBoundsOnTrack[i] = itemGUI.visible ? itemGUI.rect : s_InvisibleBounds; + } + else + { + if (targetTrack != null) + { + var trackGUI = (TimelineTrackGUI)TimelineWindow.instance.allTracks.FirstOrDefault(t => t.track == targetTrack); + if (trackGUI == null) return; + var trackRect = trackGUI.boundingRect; + m_ItemsBoundsOnTrack[i] = itemGUI.RectToTimeline(trackRect, state); + } + else + { + m_ItemsBoundsOnTrack[i].position = mousePosition - m_ItemsMouseOffsets[i]; + } + } + } + } + + public void Draw(bool isValid) + { + for (int i = 0; i < m_ItemsBoundsOnTrack.Length; ++i) + { + var rect = m_ItemsBoundsOnTrack[i]; + DrawItemInternal(m_ItemsGroup.items[i], rect, isValid); + } + } + + static void DrawItemInternal(ITimelineItem item, Rect rect, bool isValid) + { + var clipGUI = item.gui as TimelineClipGUI; + + if (clipGUI != null) + { + if (isValid) + { + clipGUI.DrawGhostClip(rect); + } + else + { + clipGUI.DrawInvalidClip(rect); + } + } + } + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/MovingItems.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/MovingItems.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..f3c7fdb4bec44ce49d2b3b1cb2c589711ece1323 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Move/MovingItems.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 81a142c61a4e14d46bb21b02548ad24d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/EaseClip.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/EaseClip.cs new file mode 100644 index 0000000000000000000000000000000000000000..80b41e6798be7e8560987b9d9ad602f6ebbdeee4 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/EaseClip.cs @@ -0,0 +1,151 @@ +using System; +using System.Text; +using UnityEngine; +using UnityEngine.Timeline; + +namespace UnityEditor.Timeline +{ + class EaseClip : Manipulator + { + bool m_IsCaptured; + bool m_UndoSaved; + TimelineClipHandle m_EaseClipHandler; + ManipulateEdges m_Edges; + TimelineClip m_Clip; + StringBuilder m_OverlayText = new StringBuilder(""); + double m_OriginalValue; + + public static readonly string EaseInClipText = L10n.Tr("Ease In Clip"); + public static readonly string EaseOutClipText = L10n.Tr("Ease Out Clip"); + public static readonly string EaseInText = L10n.Tr("Ease In"); + public static readonly string EaseOutText = L10n.Tr("Ease Out"); + public static readonly string DurationFrameText = L10n.Tr(" Duration {0:0.00;-0.00} frames "); + public static readonly string DurationSecText = L10n.Tr(" Duration {0:0.00;-0.00} s "); + public static readonly string DeltaFrameText = L10n.Tr("({0:+0.00;-0.00} frames)"); + public static readonly string DeltaSecText = L10n.Tr("({0:+0.00;-0.00} s)"); + + protected override bool MouseDown(Event evt, WindowState state) + { + if (evt.modifiers != ManipulatorsUtils.actionModifier) + return false; + return MouseDownInternal(evt, state, PickerUtils.TopmostPickedItem() as TimelineClipHandle); + } + + protected bool MouseDownInternal(Event evt, WindowState state, TimelineClipHandle handle) + { + if (handle == null) + return false; + + if (handle.clipGUI.clip != null && !handle.clipGUI.clip.clipCaps.HasAny(ClipCaps.Blending)) + return false; + + m_Edges = ManipulateEdges.Right; + if (handle.trimDirection == TrimEdge.Start) + m_Edges = ManipulateEdges.Left; + + if (m_Edges == ManipulateEdges.Left && handle.clipGUI.clip.hasBlendIn || m_Edges == ManipulateEdges.Right && handle.clipGUI.clip.hasBlendOut) + return false; + + m_IsCaptured = true; + m_UndoSaved = false; + + m_EaseClipHandler = handle; + m_Clip = handle.clipGUI.clip; + m_OriginalValue = m_Edges == ManipulateEdges.Left ? m_Clip.easeInDuration : m_Clip.easeOutDuration; + + + // Change cursor only when OnGUI Process (not in test) + if (GUIUtility.guiDepth > 0) + TimelineCursors.SetCursor(m_Edges == ManipulateEdges.Left ? TimelineCursors.CursorType.MixRight : TimelineCursors.CursorType.MixLeft); + + state.AddCaptured(this); + return true; + } + + protected override bool MouseUp(Event evt, WindowState state) + { + if (!m_IsCaptured) + return false; + m_IsCaptured = false; + m_UndoSaved = false; + state.captured.Clear(); + + // Clear cursor only when OnGUI Process (not in test) + if (GUIUtility.guiDepth > 0) + TimelineCursors.ClearCursor(); + + return true; + } + + protected override bool MouseDrag(Event evt, WindowState state) + { + if (!m_IsCaptured) + return false; + if (!m_UndoSaved) + { + var uiClip = m_EaseClipHandler.clipGUI; + string undoName = m_Edges == ManipulateEdges.Left ? EaseInClipText : EaseOutClipText; + UndoExtensions.RegisterClip(uiClip.clip, undoName); + m_UndoSaved = true; + } + + double d = state.PixelDeltaToDeltaTime(evt.delta.x); + + var duration = m_Clip.duration; + var easeInDurationLimit = duration - m_Clip.easeOutDuration; + var easeOutDurationLimit = duration - m_Clip.easeInDuration; + + if (m_Edges == ManipulateEdges.Left) + { + m_Clip.easeInDuration = Math.Min(easeInDurationLimit, Math.Max(0, m_Clip.easeInDuration + d)); + } + else if (m_Edges == ManipulateEdges.Right) + { + m_Clip.easeOutDuration = Math.Min(easeOutDurationLimit, Math.Max(0, m_Clip.easeOutDuration - d)); + } + RefreshOverlayStrings(m_EaseClipHandler, state); + return true; + } + + public override void Overlay(Event evt, WindowState state) + { + if (!m_IsCaptured) + return; + if (m_OverlayText.Length > 0) + { + int stringLength = m_OverlayText.Length; + var r = new Rect(evt.mousePosition.x - (stringLength / 2.0f), + m_EaseClipHandler.clipGUI.rect.yMax, + stringLength, 20); + GUI.Label(r, m_OverlayText.ToString(), TimelineWindow.styles.tinyFont); + } + } + + void RefreshOverlayStrings(TimelineClipHandle handle, WindowState state) + { + m_OverlayText.Length = 0; + m_OverlayText.Append(m_Edges == ManipulateEdges.Left ? EaseInText : EaseOutText); + double easeDuration = m_Edges == ManipulateEdges.Left ? m_Clip.easeInDuration : m_Clip.easeOutDuration; + double deltaDuration = easeDuration - m_OriginalValue; + bool hasDurationDelta = Math.Abs(deltaDuration) > double.Epsilon; + if (state.timeInFrames) + { + easeDuration *= state.editSequence.frameRate; + deltaDuration *= state.editSequence.frameRate; + m_OverlayText.AppendFormat(DurationFrameText, easeDuration); + if (hasDurationDelta) + { + m_OverlayText.AppendFormat(DeltaFrameText, deltaDuration); + } + } + else + { + m_OverlayText.AppendFormat(DurationSecText, easeDuration); + if (hasDurationDelta) + { + m_OverlayText.AppendFormat(DeltaSecText, deltaDuration); + } + } + } + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/EaseClip.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/EaseClip.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..a161d2fd9adbb78776d03add47c30242e71c456d --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/EaseClip.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b7cabea05434bb9479aee1e121b0d103 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/Jog.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/Jog.cs new file mode 100644 index 0000000000000000000000000000000000000000..b470b5862a06df2b0bfb53b101664b6a9b6ff9da --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/Jog.cs @@ -0,0 +1,61 @@ +using UnityEditor.ShortcutManagement; +using UnityEngine; +using UnityEngine.Timeline; + +namespace UnityEditor.Timeline +{ + class Jog : Manipulator + { + Vector2 m_MouseDownOrigin = Vector2.zero; + + [ClutchShortcut("Timeline/Jog", typeof(TimelineWindow), KeyCode.J)] + static void JogShortcut(ShortcutArguments args) + { + if (args.stage == ShortcutStage.Begin) + { + (args.context as TimelineWindow).state.isJogging = true; + } + else if (args.stage == ShortcutStage.End) + { + (args.context as TimelineWindow).state.isJogging = false; + } + } + + protected override bool MouseDown(Event evt, WindowState state) + { + if (!state.isJogging) + return false; + + m_MouseDownOrigin = evt.mousePosition; + state.playbackSpeed = 0.0f; + state.Play(); + + return true; + } + + protected override bool MouseUp(Event evt, WindowState state) + { + if (!state.isJogging) + { + return false; + } + + m_MouseDownOrigin = evt.mousePosition; + state.playbackSpeed = 0.0f; + state.Play(); + return false; + } + + protected override bool MouseDrag(Event evt, WindowState state) + { + if (!state.isJogging) + return false; + + var distance = evt.mousePosition - m_MouseDownOrigin; + + state.playbackSpeed = distance.x * 0.002f; + state.Play(); + return true; + } + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/Jog.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/Jog.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..9f266504e09b228ccc4cdadb27ebc6083017c542 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/Jog.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 949b7e126b3f27940885a6808a15458e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/MarkerHeaderContextMenu.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/MarkerHeaderContextMenu.cs new file mode 100644 index 0000000000000000000000000000000000000000..a6b7c871c58dabc84a8c075d98e90928a4b561b8 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/MarkerHeaderContextMenu.cs @@ -0,0 +1,24 @@ +using System; +using UnityEngine; +using UnityEngine.Playables; +using UnityEngine.Timeline; +using Object = UnityEngine.Object; + +namespace UnityEditor.Timeline +{ + class TimelineMarkerHeaderContextMenu : Manipulator + { + protected override bool ContextClick(Event evt, WindowState state) + { + if (!state.showMarkerHeader) + return false; + + if (!(state.GetWindow().markerHeaderRect.Contains(evt.mousePosition) + || state.GetWindow().markerContentRect.Contains(evt.mousePosition))) + return false; + + SequencerContextMenu.ShowMarkerHeaderContextMenu(evt.mousePosition, state); + return true; + } + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/MarkerHeaderContextMenu.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/MarkerHeaderContextMenu.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..6f6012a7fb96643b10ed7e5491fd5d411b02c772 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/MarkerHeaderContextMenu.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e74ddf4132f3401409c824bed60280ee +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/RectangleSelect.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/RectangleSelect.cs new file mode 100644 index 0000000000000000000000000000000000000000..17342ef5c449107f0f7a024788bf2e8a6e059b27 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/RectangleSelect.cs @@ -0,0 +1,36 @@ +using System.Linq; +using UnityEngine; + +namespace UnityEditor.Timeline +{ + class RectangleSelect : RectangleTool + { + protected override bool enableAutoPan { get { return false; } } + + protected override bool CanStartRectangle(Event evt, Vector2 mousePosition, WindowState state) + { + if (evt.button != 0 || evt.alt) + return false; + + return PickerUtils.pickedElements.All(e => e is IRowGUI); + } + + protected override bool OnFinish(Event evt, WindowState state, Rect rect) + { + var selectables = state.spacePartitioner.GetItemsInArea(rect).ToList(); + + if (!selectables.Any()) + return false; + + if (ItemSelection.CanClearSelection(evt)) + SelectionManager.Clear(); + + foreach (var selectable in selectables) + { + ItemSelection.HandleItemSelection(evt, selectable); + } + + return true; + } + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/RectangleSelect.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/RectangleSelect.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..ddff16effd996d4bf57833881bfa33c5c59f0318 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/RectangleSelect.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: edd4f4b395430604d935bcf0b14c7d42 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/RectangleTool.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/RectangleTool.cs new file mode 100644 index 0000000000000000000000000000000000000000..5de1eb69cf7d16f0d86f400570c1cc638fef16ef --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/RectangleTool.cs @@ -0,0 +1,169 @@ +using System; +using UnityEngine; + +namespace UnityEditor.Timeline +{ + abstract class RectangleTool + { + struct TimelinePoint + { + readonly double m_Time; + readonly float m_YPos; + readonly float m_YScrollPos; + + readonly WindowState m_State; + readonly TimelineTreeViewGUI m_TreeViewGUI; + + public TimelinePoint(WindowState state, Vector2 mousePosition) + { + m_State = state; + m_TreeViewGUI = state.GetWindow().treeView; + + m_Time = m_State.PixelToTime(mousePosition.x); + m_YPos = mousePosition.y; + m_YScrollPos = m_TreeViewGUI.scrollPosition.y; + } + + public Vector2 ToPixel() + { + return new Vector2(m_State.TimeToPixel(m_Time), m_YPos - (m_TreeViewGUI.scrollPosition.y - m_YScrollPos)); + } + } + + TimeAreaAutoPanner m_TimeAreaAutoPanner; + + TimelinePoint m_StartPoint; + Vector2 m_EndPixel = Vector2.zero; + + Rect m_ActiveRect; + + protected abstract bool enableAutoPan { get; } + protected abstract bool CanStartRectangle(Event evt, Vector2 mousePosition, WindowState state); + protected abstract bool OnFinish(Event evt, WindowState state, Rect rect); + + int m_Id; + + public void OnGUI(WindowState state, EventType rawType, Vector2 mousePosition) + { + if (m_Id == 0) + m_Id = GUIUtility.GetPermanentControlID(); + + if (state == null || state.GetWindow().treeView == null) + return; + + var evt = Event.current; + + if (rawType == EventType.MouseDown || evt.type == EventType.MouseDown) + { + if (state.IsCurrentEditingASequencerTextField()) + return; + + m_ActiveRect = TimelineWindow.instance.sequenceContentRect; + + if (!m_ActiveRect.Contains(mousePosition)) + return; + + if (!CanStartRectangle(evt, mousePosition, state)) + return; + + if (enableAutoPan) + m_TimeAreaAutoPanner = new TimeAreaAutoPanner(state); + + m_StartPoint = new TimelinePoint(state, mousePosition); + m_EndPixel = mousePosition; + + GUIUtility.hotControl = m_Id; //HACK: Because the treeView eats all the events, steal the hotControl if necessary... + evt.Use(); + + return; + } + + switch (evt.GetTypeForControl(m_Id)) + { + case EventType.KeyDown: + { + if (GUIUtility.hotControl == m_Id) + { + if (evt.keyCode == KeyCode.Escape) + { + m_TimeAreaAutoPanner = null; + + GUIUtility.hotControl = 0; + evt.Use(); + } + } + + return; + } + + case EventType.MouseDrag: + { + if (GUIUtility.hotControl != m_Id) + return; + + m_EndPixel = mousePosition; + evt.Use(); + + return; + } + + case EventType.MouseUp: + { + if (GUIUtility.hotControl != m_Id) + return; + + m_TimeAreaAutoPanner = null; + + var rect = CurrentRectangle(); + + if (IsValidRect(rect)) + OnFinish(evt, state, rect); + + GUIUtility.hotControl = 0; + evt.Use(); + + return; + } + } + + if (GUIUtility.hotControl == m_Id) + { + if (evt.type == EventType.Repaint) + { + var r = CurrentRectangle(); + + if (IsValidRect(r)) + { + using (new GUIViewportScope(m_ActiveRect)) + { + DrawRectangle(r); + } + } + } + + if (m_TimeAreaAutoPanner != null) + m_TimeAreaAutoPanner.OnGUI(evt); + } + } + + protected virtual void DrawRectangle(Rect rect) + { + EditorStyles.selectionRect.Draw(rect, GUIContent.none, false, false, false, false); + } + + static bool IsValidRect(Rect rect) + { + return rect.width >= 1.0f && rect.height >= 1.0f; + } + + Rect CurrentRectangle() + { + var startPixel = m_StartPoint.ToPixel(); + return Rect.MinMaxRect( + Math.Min(startPixel.x, m_EndPixel.x), + Math.Min(startPixel.y, m_EndPixel.y), + Math.Max(startPixel.x, m_EndPixel.x), + Math.Max(startPixel.y, m_EndPixel.y)); + } + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/RectangleTool.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/RectangleTool.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..3a0d71a5afade0a550ac78c0070b27bae4d82d82 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/RectangleTool.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 24a7ce8b48db53747a4e8abbda77eac4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/RectangleZoom.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/RectangleZoom.cs new file mode 100644 index 0000000000000000000000000000000000000000..0a2d45f994f4e84f0991a51844e134297bfc96cd --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/RectangleZoom.cs @@ -0,0 +1,23 @@ +using UnityEngine; + +namespace UnityEditor.Timeline +{ + class RectangleZoom : RectangleTool + { + protected override bool enableAutoPan { get { return true; } } + + protected override bool CanStartRectangle(Event evt, Vector2 mousePosition, WindowState state) + { + return evt.button == 1 && evt.modifiers == (EventModifiers.Alt | EventModifiers.Shift); + } + + protected override bool OnFinish(Event evt, WindowState state, Rect rect) + { + var x = state.PixelToTime(rect.xMin); + var y = state.PixelToTime(rect.xMax); + state.SetTimeAreaShownRange(x, y); + + return true; + } + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/RectangleZoom.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/RectangleZoom.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..e32aad555d8d9157b6ebe9b54bb9b915fcd22695 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/RectangleZoom.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5aa8f57287fc17149bcd798be813180b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/SelectAndMoveItem.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/SelectAndMoveItem.cs new file mode 100644 index 0000000000000000000000000000000000000000..4f65edbb9f30fb0a676b74d720cd2c6cdaf1c9e6 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/SelectAndMoveItem.cs @@ -0,0 +1,298 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using UnityEngine.Timeline; + +namespace UnityEditor.Timeline +{ + class ClearSelection : Manipulator + { + protected override bool MouseDown(Event evt, WindowState state) + { + // If we hit this point this means no one used the mouse down events. We can safely clear the selection if needed + if (evt.button != 0) + return false; + + var window = state.GetWindow(); + + if (!window.sequenceRect.Contains(evt.mousePosition)) + return false; + + if (ItemSelection.CanClearSelection(evt)) + { + SelectionManager.Clear(); + return true; + } + + return false; + } + } + + static class ItemSelection + { + public static bool CanClearSelection(Event evt) + { + return !evt.control && !evt.command && !evt.shift; + } + + public static void RangeSelectItems(ITimelineItem lastItemToSelect) + { + var selectSorted = SelectionManager.SelectedItems().ToList(); + var firstSelect = selectSorted.FirstOrDefault(); + if (firstSelect == null) + { + SelectionManager.Add(lastItemToSelect); + return; + } + + var allTracks = TimelineEditor.inspectedAsset.flattenedTracks; + var allItems = allTracks.SelectMany(ItemsUtils.GetItems).ToList(); + TimelineHelpers.RangeSelect(allItems, selectSorted, lastItemToSelect, SelectionManager.Add, SelectionManager.Remove); + } + + public static ISelectable HandleSingleSelection(Event evt) + { + var item = PickerUtils.TopmostPickedItemOfType(i => i.CanSelect()); + + if (item != null) + { + var selected = item.IsSelected(); + if (!selected && CanClearSelection(evt)) + SelectionManager.Clear(); + + if (evt.modifiers == EventModifiers.Shift) + { + if (!selected) + RangeSelectItems((item as TimelineItemGUI)?.item); + } + else + { + HandleItemSelection(evt, item); + } + } + + return item; + } + + public static void HandleItemSelection(Event evt, ISelectable item) + { + if (evt.modifiers == ManipulatorsUtils.actionModifier) + { + if (item.IsSelected()) + item.Deselect(); + else + item.Select(); + } + else + { + if (!item.IsSelected()) + item.Select(); + } + } + } + + class SelectAndMoveItem : Manipulator + { + bool m_Dragged; + SnapEngine m_SnapEngine; + TimeAreaAutoPanner m_TimeAreaAutoPanner; + Vector2 m_MouseDownPosition; + + bool m_HorizontalMovementDone; + bool m_VerticalMovementDone; + + MoveItemHandler m_MoveItemHandler; + bool m_CycleMarkersPending; + + protected override bool MouseDown(Event evt, WindowState state) + { + if (evt.alt || evt.button != 0) + return false; + + m_Dragged = false; + + // Cycling markers and selection are mutually exclusive operations + if (!HandleMarkerCycle() && !HandleSingleSelection(evt)) + return false; + + m_MouseDownPosition = evt.mousePosition; + m_VerticalMovementDone = false; + m_HorizontalMovementDone = false; + + return true; + } + + protected override bool MouseUp(Event evt, WindowState state) + { + if (!m_Dragged) + { + var item = PickerUtils.TopmostPickedItem() as ISelectable; + + if (item == null) + return false; + + if (!item.IsSelected()) + return false; + + // Re-selecting an item part of a multi-selection should only keep this item selected. + if (SelectionManager.Count() > 1 && ItemSelection.CanClearSelection(evt)) + { + SelectionManager.Clear(); + item.Select(); + return true; + } + + if (m_CycleMarkersPending) + { + m_CycleMarkersPending = false; + TimelineMarkerClusterGUI.CycleMarkers(); + return true; + } + + return false; + } + + m_TimeAreaAutoPanner = null; + + DropItems(); + + m_SnapEngine = null; + m_MoveItemHandler = null; + + state.Evaluate(); + state.RemoveCaptured(this); + m_Dragged = false; + TimelineCursors.ClearCursor(); + + return true; + } + + protected override bool DoubleClick(Event evt, WindowState state) + { + return MouseDown(evt, state) && MouseUp(evt, state); + } + + protected override bool MouseDrag(Event evt, WindowState state) + { + if (state.editSequence.isReadOnly) + return false; + + // case 1099285 - ctrl-click can cause no clips to be selected + var selectedItemsGUI = SelectionManager.SelectedItems(); + if (!selectedItemsGUI.Any()) + { + m_Dragged = false; + return false; + } + + const float hDeadZone = 5.0f; + const float vDeadZone = 5.0f; + + bool vDone = m_VerticalMovementDone || Math.Abs(evt.mousePosition.y - m_MouseDownPosition.y) > vDeadZone; + bool hDone = m_HorizontalMovementDone || Math.Abs(evt.mousePosition.x - m_MouseDownPosition.x) > hDeadZone; + + m_CycleMarkersPending = false; + + if (!m_Dragged) + { + var canStartMove = vDone || hDone; + + if (canStartMove) + { + state.AddCaptured(this); + m_Dragged = true; + + var referenceTrack = GetTrackDropTargetAt(state, m_MouseDownPosition); + + foreach (var item in selectedItemsGUI) + item.gui.StartDrag(); + + m_MoveItemHandler = new MoveItemHandler(state); + + m_MoveItemHandler.Grab(selectedItemsGUI, referenceTrack, m_MouseDownPosition); + + m_SnapEngine = new SnapEngine(m_MoveItemHandler, m_MoveItemHandler, ManipulateEdges.Both, + state, m_MouseDownPosition); + + m_TimeAreaAutoPanner = new TimeAreaAutoPanner(state); + } + } + + if (!m_VerticalMovementDone) + { + m_VerticalMovementDone = vDone; + + if (m_VerticalMovementDone) + m_MoveItemHandler.OnTrackDetach(); + } + + if (!m_HorizontalMovementDone) + { + m_HorizontalMovementDone = hDone; + } + + if (m_Dragged) + { + if (m_HorizontalMovementDone) + m_SnapEngine.Snap(evt.mousePosition, evt.modifiers); + + if (m_VerticalMovementDone) + { + var track = GetTrackDropTargetAt(state, evt.mousePosition); + m_MoveItemHandler.UpdateTrackTarget(track); + } + + state.Evaluate(); + } + + return true; + } + + public override void Overlay(Event evt, WindowState state) + { + if (!m_Dragged) + return; + + if (m_TimeAreaAutoPanner != null) + m_TimeAreaAutoPanner.OnGUI(evt); + + m_MoveItemHandler.OnGUI(evt); + + if (!m_MoveItemHandler.allowTrackSwitch || m_MoveItemHandler.targetTrack != null) + { + TimeIndicator.Draw(state, m_MoveItemHandler.start, m_MoveItemHandler.end); + m_SnapEngine.OnGUI(); + } + } + + bool HandleMarkerCycle() + { + m_CycleMarkersPending = TimelineMarkerClusterGUI.CanCycleMarkers(); + return m_CycleMarkersPending; + } + + static bool HandleSingleSelection(Event evt) + { + return ItemSelection.HandleSingleSelection(evt) != null; + } + + void DropItems() + { + // Order matters here: m_MoveItemHandler.movingItems is destroyed during call to Drop() + foreach (var movingItem in m_MoveItemHandler.movingItems) + { + foreach (var item in movingItem.items) + item.gui.StopDrag(); + } + + m_MoveItemHandler.Drop(); + } + + static TrackAsset GetTrackDropTargetAt(WindowState state, Vector2 point) + { + var track = state.spacePartitioner.GetItemsAtPosition(point).FirstOrDefault(); + return track != null ? track.asset : null; + } + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/SelectAndMoveItem.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/SelectAndMoveItem.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..16f015275b984401142fd8e70e554677ef836be3 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/SelectAndMoveItem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f4f988528bbbb0846a4cb50efb4587a5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/TrackZoom.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/TrackZoom.cs new file mode 100644 index 0000000000000000000000000000000000000000..fc167f4d7319f8e1f8fb7590b83e33b8ad49cc70 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/TrackZoom.cs @@ -0,0 +1,20 @@ +using UnityEngine; +using UnityEngine.Timeline; + +namespace UnityEditor.Timeline +{ + class TrackZoom : Manipulator + { + // only handles 'vertical' zoom. horizontal is handled in timelineGUI + protected override bool MouseWheel(Event evt, WindowState state) + { + if (EditorGUI.actionKey) + { + state.trackScale = Mathf.Min(Mathf.Max(state.trackScale + (evt.delta.y * 0.1f), 1.0f), 100.0f); + return true; + } + + return false; + } + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/TrackZoom.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/TrackZoom.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..a13fea681155cdf13157c0b99821e029ab647200 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/TrackZoom.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6e7c80eefe2def5459e0b486b3ab96e2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/TrimClip.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/TrimClip.cs new file mode 100644 index 0000000000000000000000000000000000000000..9bcb089c9d76f25e3ac87b959bf3a930bf654894 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/TrimClip.cs @@ -0,0 +1,246 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using UnityEngine.Timeline; + +namespace UnityEditor.Timeline +{ + class TrimClip : Manipulator + { + class TrimClipAttractionHandler : IAttractionHandler + { + public void OnAttractedEdge(IAttractable attractable, ManipulateEdges manipulateEdges, AttractedEdge edge, double time) + { + var clipGUI = attractable as TimelineClipGUI; + if (clipGUI == null) + return; + + var clipItem = ItemsUtils.ToItem(clipGUI.clip); + if (manipulateEdges == ManipulateEdges.Right) + { + bool affectTimeScale = IsAffectingTimeScale(clipGUI.clip); + EditMode.TrimEnd(clipItem, time, affectTimeScale); + } + else if (manipulateEdges == ManipulateEdges.Left) + { + bool affectTimeScale = IsAffectingTimeScale(clipGUI.clip); + EditMode.TrimStart(clipItem, time, affectTimeScale); + } + } + + private bool IsAffectingTimeScale(TimelineClip clip) + { + bool autoScale = (clip.clipCaps & ClipCaps.AutoScale) == ClipCaps.AutoScale; + + // TODO Do not use Event.current from here. + bool affectTimeScale = (autoScale && (Event.current.modifiers != EventModifiers.Shift)) + || (!autoScale && (Event.current.modifiers == EventModifiers.Shift)); + return affectTimeScale; + } + } + + bool m_IsCaptured; + TimelineClipHandle m_TrimClipHandler; + + double m_OriginalDuration; + double m_OriginalTimeScale; + double m_OriginalEaseInDuration; + double m_OriginalEaseOutDuration; + + bool m_UndoSaved; + SnapEngine m_SnapEngine; + + readonly StringBuilder m_OverlayText = new StringBuilder(); + readonly List m_OverlayStrings = new List(); + + static readonly double kEpsilon = 0.0000001; + + protected override bool MouseDown(Event evt, WindowState state) + { + var handle = PickerUtils.TopmostPickedItem() as TimelineClipHandle; + if (handle == null) + return false; + + if (handle.clipGUI.clip.parentTrack != null && handle.clipGUI.clip.parentTrack.lockedInHierarchy) + return false; + + m_TrimClipHandler = handle; + + m_IsCaptured = true; + state.AddCaptured(this); + + m_UndoSaved = false; + + var clip = m_TrimClipHandler.clipGUI.clip; + + m_OriginalDuration = clip.duration; + m_OriginalTimeScale = clip.timeScale; + m_OriginalEaseInDuration = clip.easeInDuration; + m_OriginalEaseOutDuration = clip.easeOutDuration; + + RefreshOverlayStrings(m_TrimClipHandler, state); + + // in ripple trim, the right edge moves and needs to snap + var edges = ManipulateEdges.Right; + if (EditMode.editType != EditMode.EditType.Ripple && m_TrimClipHandler.trimDirection == TrimEdge.Start) + edges = ManipulateEdges.Left; + m_SnapEngine = new SnapEngine(m_TrimClipHandler.clipGUI, new TrimClipAttractionHandler(), edges, state, + evt.mousePosition); + + EditMode.BeginTrim(ItemsUtils.ToItem(clip), m_TrimClipHandler.trimDirection); + + return true; + } + + protected override bool MouseUp(Event evt, WindowState state) + { + if (!m_IsCaptured) + return false; + + m_IsCaptured = false; + m_TrimClipHandler = null; + m_UndoSaved = false; + m_SnapEngine = null; + EditMode.FinishTrim(); + + state.captured.Clear(); + + return true; + } + + protected override bool MouseDrag(Event evt, WindowState state) + { + if (state.editSequence.isReadOnly) + return false; + + if (!m_IsCaptured) + return false; + + var uiClip = m_TrimClipHandler.clipGUI; + if (!m_UndoSaved) + { + UndoExtensions.RegisterClip(uiClip.clip, "Trim Clip"); + if (TimelineUtility.IsRecordableAnimationClip(uiClip.clip)) + { + TimelineUndo.PushUndo(uiClip.clip.animationClip, "Trim Clip"); + } + + m_UndoSaved = true; + } + + //Reset to original ease values. The trim operation will calculate the proper blend values. + uiClip.clip.easeInDuration = m_OriginalEaseInDuration; + uiClip.clip.easeOutDuration = m_OriginalEaseOutDuration; + + if (m_SnapEngine != null) + m_SnapEngine.Snap(evt.mousePosition, evt.modifiers); + + RefreshOverlayStrings(m_TrimClipHandler, state); + + if (Selection.activeObject != null) + EditorUtility.SetDirty(Selection.activeObject); + + // updates the duration of the graph without rebuilding + state.UpdateRootPlayableDuration(state.editSequence.duration); + + return true; + } + + public override void Overlay(Event evt, WindowState state) + { + if (!m_IsCaptured) + return; + + EditMode.DrawTrimGUI(state, m_TrimClipHandler.clipGUI, m_TrimClipHandler.trimDirection); + + bool trimStart = m_TrimClipHandler.trimDirection == TrimEdge.Start; + + TimeIndicator.Draw(state, trimStart ? m_TrimClipHandler.clipGUI.start : m_TrimClipHandler.clipGUI.end); + + if (m_SnapEngine != null) + m_SnapEngine.OnGUI(trimStart, !trimStart); + + if (m_OverlayStrings.Count > 0) + { + const float padding = 4.0f; + var labelStyle = TimelineWindow.styles.tinyFont; + var longestLine = labelStyle.CalcSize( + new GUIContent(m_OverlayStrings.Aggregate("", (max, cur) => max.Length > cur.Length ? max : cur))); + var stringLength = longestLine.x + padding; + var lineHeight = longestLine.y + padding; + + var r = new Rect(evt.mousePosition.x - (stringLength / 2.0f), + m_TrimClipHandler.clipGUI.rect.yMax, + stringLength, lineHeight); + + foreach (var s in m_OverlayStrings) + { + GUI.Label(r, s, labelStyle); + r.y += lineHeight; + } + } + } + + void RefreshOverlayStrings(TimelineClipHandle handle, WindowState state) + { + m_OverlayStrings.Clear(); + + m_OverlayText.Length = 0; + + var differenceDuration = handle.clipGUI.clip.duration - m_OriginalDuration; + bool hasDurationDelta = Math.Abs(differenceDuration) > kEpsilon; + + if (state.timeInFrames) + { + var durationInFrame = handle.clipGUI.clip.duration * state.referenceSequence.frameRate; + m_OverlayText.Append("duration: ").Append(durationInFrame.ToString("f2")).Append(" frames"); + + if (hasDurationDelta) + { + m_OverlayText.Append(" ("); + + if (differenceDuration > 0.0) + m_OverlayText.Append("+"); + + var valueInFrame = differenceDuration * state.referenceSequence.frameRate; + m_OverlayText.Append(valueInFrame.ToString("f2")).Append(" frames)"); + } + } + else + { + m_OverlayText.Append("duration: ").Append(handle.clipGUI.clip.duration.ToString("f2")).Append("s"); + + if (hasDurationDelta) + { + m_OverlayText.Append(" ("); + + if (differenceDuration > 0.0) + m_OverlayText.Append("+"); + + m_OverlayText.Append(differenceDuration.ToString("f2")).Append("s)"); + } + } + + m_OverlayStrings.Add(m_OverlayText.ToString()); + + m_OverlayText.Length = 0; + + var differenceSpeed = m_OriginalTimeScale - handle.clipGUI.clip.timeScale; + if (Math.Abs(differenceSpeed) > kEpsilon) + { + m_OverlayText.Append("speed: ").Append(handle.clipGUI.clip.timeScale.ToString("p2")); + + m_OverlayText.Append(" ("); + + if (differenceSpeed > 0.0) + m_OverlayText.Append("+"); + + m_OverlayText.Append(differenceSpeed.ToString("p2")).Append(")"); + + m_OverlayStrings.Add(m_OverlayText.ToString()); + } + } + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/TrimClip.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/TrimClip.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..063a1c69a98155858587db85285f0751f4def657 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Sequence/TrimClip.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 511aa760b8728a940a41c29837945292 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Trim/ITrimItemMode.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Trim/ITrimItemMode.cs new file mode 100644 index 0000000000000000000000000000000000000000..d99beb83a243fd92c7781058abe87441312ae866 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Trim/ITrimItemMode.cs @@ -0,0 +1,23 @@ +using UnityEngine; + +namespace UnityEditor.Timeline +{ + enum TrimEdge + { + Start, + End + } + + interface ITrimItemMode + { + void OnBeforeTrim(ITrimmable item, TrimEdge trimDirection); + + void TrimStart(ITrimmable item, double time, bool affectTimeScale); + void TrimEnd(ITrimmable item, double time, bool affectTimeScale); + } + + interface ITrimItemDrawer + { + void DrawGUI(WindowState state, Rect bounds, Color color, TrimEdge edge); + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Utils/PlacementValidity.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Utils/PlacementValidity.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..571f365b25bdbb597be5881b3489f4d1fa749538 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/Manipulators/Utils/PlacementValidity.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 335020228a0fe124897f51f25f6350ee +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/inspectors/ClipInspector/ClipInspector.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/inspectors/ClipInspector/ClipInspector.cs new file mode 100644 index 0000000000000000000000000000000000000000..9045be36e3fe1644908c17b10bba7c5e45cf8eee --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/inspectors/ClipInspector/ClipInspector.cs @@ -0,0 +1,818 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEditorInternal; +using UnityEngine; +using UnityEngine.Timeline; +using UnityObject = UnityEngine.Object; + +namespace UnityEditor.Timeline +{ + [CustomEditor(typeof(EditorClip)), CanEditMultipleObjects] + class ClipInspector : Editor + { + internal static class Styles + { + public static readonly GUIContent StartName = EditorGUIUtility.TrTextContent("Start", "The start time of the clip"); + public static readonly GUIContent DurationName = EditorGUIUtility.TrTextContent("Duration", "The length of the clip"); + public static readonly GUIContent EndName = EditorGUIUtility.TrTextContent("End", "The end time of the clip"); + public static readonly GUIContent EaseInDurationName = EditorGUIUtility.TrTextContent("Ease In Duration", "The length of the ease in"); + public static readonly GUIContent BlendInDurationName = EditorGUIUtility.TrTextContent("Blend In Duration", "The length of the blend in"); + public static readonly GUIContent EaseOutDurationName = EditorGUIUtility.TrTextContent("Ease Out Duration", "The length of the ease out"); + public static readonly GUIContent BlendOutDurationName = EditorGUIUtility.TrTextContent("Blend Out Duration", "The length of the blend out"); + public static readonly GUIContent ClipInName = EditorGUIUtility.TrTextContent("Clip In", "Start the clip at this local time"); + public static readonly GUIContent TimeScaleName = EditorGUIUtility.TrTextContent("Speed Multiplier", "Time scale of the playback speed"); + public static readonly GUIContent PreExtrapolateLabel = EditorGUIUtility.TrTextContent("Pre-Extrapolate", "Extrapolation used prior to the first clip"); + public static readonly GUIContent PostExtrapolateLabel = EditorGUIUtility.TrTextContent("Post-Extrapolate", "Extrapolation used after a clip ends"); + public static readonly GUIContent BlendInCurveName = EditorGUIUtility.TrTextContent("In", "Blend In Curve"); + public static readonly GUIContent BlendOutCurveName = EditorGUIUtility.TrTextContent("Out", "Blend Out Curve"); + public static readonly GUIContent PreviewTitle = EditorGUIUtility.TrTextContent("Curve Editor"); + public static readonly GUIContent ClipTimingTitle = EditorGUIUtility.TrTextContent("Clip Timing"); + public static readonly GUIContent AnimationExtrapolationTitle = EditorGUIUtility.TrTextContent("Animation Extrapolation"); + public static readonly GUIContent BlendCurvesTitle = EditorGUIUtility.TrTextContent("Blend Curves"); + public static readonly GUIContent GroupTimingTitle = EditorGUIUtility.TrTextContent("Multiple Clip Timing"); + public static readonly GUIContent MultipleClipsSelectedIncompatibleCapabilitiesWarning = EditorGUIUtility.TrTextContent("Multiple clips selected. Only common properties are shown."); + public static readonly GUIContent MultipleSelectionTitle = EditorGUIUtility.TrTextContent("Timeline Clips"); + public static readonly GUIContent MultipleClipStartName = EditorGUIUtility.TrTextContent("Start", "The start time of the clip group"); + public static readonly GUIContent MultipleClipEndName = EditorGUIUtility.TrTextContent("End", "The end time of the clip group"); + public static readonly GUIContent TimelineClipFG = DirectorStyles.IconContent("TimelineClipFG"); + public static readonly GUIContent TimelineClipBG = DirectorStyles.IconContent("TimelineClipBG"); + } + + class EditorClipSelection : ICurvesOwnerInspectorWrapper + { + public EditorClip editorClip { get; } + + public TimelineClip clip + { + get { return editorClip == null ? null : editorClip.clip; } + } + + public SerializedObject serializedPlayableAsset { get; } + + public ICurvesOwner curvesOwner + { + get { return clip; } + } + + public int lastCurveVersion { get; set; } + public double lastEvalTime { get; set; } + + public EditorClipSelection(EditorClip anEditorClip) + { + editorClip = anEditorClip; + lastCurveVersion = -1; + lastEvalTime = -1; + + var so = new SerializedObject(editorClip); + var playableAssetProperty = so.FindProperty("m_Clip.m_Asset"); + if (playableAssetProperty != null) + { + var asset = playableAssetProperty.objectReferenceValue as UnityEngine.Playables.PlayableAsset; + if (asset != null) + serializedPlayableAsset = new SerializedObject(asset); + } + } + + public double ToLocalTime(double time) + { + return clip == null ? time : clip.ToLocalTime(time); + } + } + + enum PreviewCurveState + { + None = 0, + MixIn = 1, + MixOut = 2 + } + + + SerializedProperty m_DisplayNameProperty; + SerializedProperty m_BlendInDurationProperty; + SerializedProperty m_BlendOutDurationProperty; + SerializedProperty m_EaseInDurationProperty; + SerializedProperty m_EaseOutDurationProperty; + SerializedProperty m_ClipInProperty; + SerializedProperty m_TimeScaleProperty; + SerializedProperty m_PostExtrapolationModeProperty; + SerializedProperty m_PreExtrapolationModeProperty; + SerializedProperty m_PostExtrapolationTimeProperty; + SerializedProperty m_PreExtrapolationTimeProperty; + SerializedProperty m_MixInCurveProperty; + SerializedProperty m_MixOutCurveProperty; + SerializedProperty m_BlendInCurveModeProperty; + SerializedProperty m_BlendOutCurveModeProperty; + + void InitializeProperties() + { + m_DisplayNameProperty = serializedObject.FindProperty("m_Clip.m_DisplayName"); + m_BlendInDurationProperty = serializedObject.FindProperty("m_Clip.m_BlendInDuration"); + m_BlendOutDurationProperty = serializedObject.FindProperty("m_Clip.m_BlendOutDuration"); + m_EaseInDurationProperty = serializedObject.FindProperty("m_Clip.m_EaseInDuration"); + m_EaseOutDurationProperty = serializedObject.FindProperty("m_Clip.m_EaseOutDuration"); + m_ClipInProperty = serializedObject.FindProperty("m_Clip.m_ClipIn"); + m_TimeScaleProperty = serializedObject.FindProperty("m_Clip.m_TimeScale"); + m_PostExtrapolationModeProperty = serializedObject.FindProperty("m_Clip.m_PostExtrapolationMode"); + m_PreExtrapolationModeProperty = serializedObject.FindProperty("m_Clip.m_PreExtrapolationMode"); + m_PostExtrapolationTimeProperty = serializedObject.FindProperty("m_Clip.m_PostExtrapolationTime"); + m_PreExtrapolationTimeProperty = serializedObject.FindProperty("m_Clip.m_PreExtrapolationTime"); + m_MixInCurveProperty = serializedObject.FindProperty("m_Clip.m_MixInCurve"); + m_MixOutCurveProperty = serializedObject.FindProperty("m_Clip.m_MixOutCurve"); + m_BlendInCurveModeProperty = serializedObject.FindProperty("m_Clip.m_BlendInCurveMode"); + m_BlendOutCurveModeProperty = serializedObject.FindProperty("m_Clip.m_BlendOutCurveMode"); + } + + TimelineAsset m_TimelineAsset; + + List m_SelectionCache; + Editor m_SelectedPlayableAssetsInspector; + + ClipInspectorCurveEditor m_ClipCurveEditor; + CurvePresetLibrary m_CurvePresets; + + bool m_IsClipAssetInspectorExpanded = true; + GUIContent m_ClipAssetTitle = new GUIContent(); + string m_MultiselectionHeaderTitle; + + ClipInspectorSelectionInfo m_SelectionInfo; + + // the state of the mixin curve preview + PreviewCurveState m_PreviewCurveState; + + const double k_TimeScaleSensitivity = 0.003; + + + + bool hasMultipleSelection + { + get { return targets.Length > 1; } + } + + float currentFrameRate + { + get { return m_TimelineAsset != null ? m_TimelineAsset.editorSettings.fps : TimelineAsset.EditorSettings.kDefaultFps; } + } + + bool selectionHasIncompatibleCapabilities + { + get + { + return !(m_SelectionInfo.supportsBlending + && m_SelectionInfo.supportsClipIn + && m_SelectionInfo.supportsExtrapolation + && m_SelectionInfo.supportsSpeedMultiplier); + } + } + + public override bool RequiresConstantRepaint() + { + return base.RequiresConstantRepaint() || (m_SelectedPlayableAssetsInspector != null && m_SelectedPlayableAssetsInspector.RequiresConstantRepaint()); + } + + internal override void OnHeaderTitleGUI(Rect titleRect, string header) + { + if (hasMultipleSelection) + { + base.OnHeaderTitleGUI(titleRect, m_MultiselectionHeaderTitle); + return; + } + + if (m_DisplayNameProperty != null) + { + using (new EditorGUI.DisabledScope(!IsEnabled())) + { + serializedObject.Update(); + if (IsLocked()) + { + base.OnHeaderTitleGUI(titleRect, m_DisplayNameProperty.stringValue); + } + else + { + EditorGUI.BeginChangeCheck(); + EditorGUI.DelayedTextField(titleRect, m_DisplayNameProperty, GUIContent.none); + if (EditorGUI.EndChangeCheck()) + { + ApplyModifiedProperties(); + TimelineWindow.RepaintIfEditingTimelineAsset(m_TimelineAsset); + } + } + } + } + } + + internal override Rect DrawHeaderHelpAndSettingsGUI(Rect r) + { + using (new EditorGUI.DisabledScope(IsLocked())) + { + var helpSize = EditorStyles.iconButton.CalcSize(EditorGUI.GUIContents.helpIcon); + const int kTopMargin = 5; + // Show Editor Header Items. + return EditorGUIUtility.DrawEditorHeaderItems(new Rect(r.xMax - helpSize.x, r.y + kTopMargin, helpSize.x, helpSize.y), targets); + } + } + + internal override void OnHeaderIconGUI(Rect iconRect) + { + using (new EditorGUI.DisabledScope(IsLocked())) + { + var bgColor = Color.white; + if (!EditorGUIUtility.isProSkin) + bgColor.a = 0.55f; + using (new GUIColorOverride(bgColor)) + { + GUI.Label(iconRect, Styles.TimelineClipBG); + } + + var fgColor = Color.white; + if (m_SelectionInfo != null && m_SelectionInfo.uniqueParentTracks.Count == 1) + fgColor = TrackResourceCache.GetTrackColor(m_SelectionInfo.uniqueParentTracks.First()); + + using (new GUIColorOverride(fgColor)) + { + GUI.Label(iconRect, Styles.TimelineClipFG); + } + } + } + + public void OnEnable() + { + Undo.undoRedoPerformed += OnUndoRedoPerformed; + + m_ClipCurveEditor = new ClipInspectorCurveEditor(); + + m_SelectionCache = new List(); + var selectedClips = new List(); + foreach (var editorClipObject in targets) + { + var editorClip = editorClipObject as EditorClip; + if (editorClip != null) + { + //all selected clips should have the same TimelineAsset + if (!IsTimelineAssetValidForEditorClip(editorClip)) + { + m_SelectionCache.Clear(); + return; + } + m_SelectionCache.Add(new EditorClipSelection(editorClip)); + selectedClips.Add(editorClip.clip); + } + } + + InitializeProperties(); + m_SelectionInfo = new ClipInspectorSelectionInfo(selectedClips); + + if (m_SelectionInfo.selectedAssetTypesAreHomogeneous) + { + var selectedAssets = m_SelectionCache.Select(e => e.clip.asset).ToArray(); + m_SelectedPlayableAssetsInspector = TimelineInspectorUtility.GetInspectorForObjects(selectedAssets); + } + + m_MultiselectionHeaderTitle = m_SelectionCache.Count + " " + Styles.MultipleSelectionTitle.text; + m_ClipAssetTitle.text = PlayableAssetSectionTitle(); + } + + void OnDisable() + { + Undo.undoRedoPerformed -= OnUndoRedoPerformed; + } + + void DrawClipProperties() + { + var dirtyEditorClipSelection = m_SelectionCache.Where(s => s.editorClip.GetHashCode() != s.editorClip.lastHash); + UnselectCurves(); + + EditorGUI.BeginChangeCheck(); + + //Group Selection + if (hasMultipleSelection) + { + GUILayout.Label(Styles.GroupTimingTitle); + EditorGUI.indentLevel++; + DrawGroupSelectionProperties(); + EditorGUI.indentLevel--; + EditorGUILayout.Space(); + } + + //Draw clip timing + GUILayout.Label(Styles.ClipTimingTitle); + + if (hasMultipleSelection && selectionHasIncompatibleCapabilities) + { + GUILayout.Label(Styles.MultipleClipsSelectedIncompatibleCapabilitiesWarning, EditorStyles.helpBox); + } + + EditorGUI.indentLevel++; + + if (!m_SelectionInfo.containsAtLeastTwoClipsOnTheSameTrack) + { + DrawStartTimeField(); + DrawEndTimeField(); + } + + if (!hasMultipleSelection) + { + DrawDurationProperty(); + } + + if (m_SelectionInfo.supportsBlending) + { + EditorGUILayout.Space(); + DrawBlendingProperties(); + } + + if (m_SelectionInfo.supportsClipIn) + { + EditorGUILayout.Space(); + DrawClipInProperty(); + } + + if (!hasMultipleSelection && m_SelectionInfo.supportsSpeedMultiplier) + { + EditorGUILayout.Space(); + DrawTimeScale(); + } + + EditorGUI.indentLevel--; + + bool hasDirtyEditorClips = false; + foreach (var editorClipSelection in dirtyEditorClipSelection) + { + EditorUtility.SetDirty(editorClipSelection.editorClip); + hasDirtyEditorClips = true; + } + + //Re-evaluate the graph in case of a change in properties + bool propertiesHaveChanged = false; + if (EditorGUI.EndChangeCheck() || hasDirtyEditorClips) + { + if (TimelineWindow.IsEditingTimelineAsset(m_TimelineAsset) && TimelineWindow.instance.state != null) + { + TimelineWindow.instance.state.Evaluate(); + TimelineWindow.instance.Repaint(); + } + propertiesHaveChanged = true; + } + + //Draw Animation Extrapolation + if (m_SelectionInfo.supportsExtrapolation) + { + EditorGUILayout.Space(); + GUILayout.Label(Styles.AnimationExtrapolationTitle); + EditorGUI.indentLevel++; + DrawExtrapolationOptions(); + EditorGUI.indentLevel--; + } + + //Blend curves + if (m_SelectionInfo.supportsBlending) + { + EditorGUILayout.Space(); + GUILayout.Label(Styles.BlendCurvesTitle); + EditorGUI.indentLevel++; + DrawBlendOptions(); + EditorGUI.indentLevel--; + } + + EditorGUILayout.Space(); + + if (CanShowPlayableAssetInspector()) + { + DrawClipAssetGui(); + } + + if (propertiesHaveChanged) + { + foreach (var item in m_SelectionCache) + item.editorClip.lastHash = item.editorClip.GetHashCode(); + m_SelectionInfo.Update(); + } + } + + public override void OnInspectorGUI() + { + if (TimelineWindow.instance == null || m_TimelineAsset == null) + return; + + using (new EditorGUI.DisabledScope(IsLocked())) + { + EditMode.HandleModeClutch(); + + serializedObject.Update(); + DrawClipProperties(); + ApplyModifiedProperties(); + } + } + + internal override bool IsEnabled() + { + if (!TimelineUtility.IsCurrentSequenceValid() || IsCurrentSequenceReadOnly()) + return false; + + if (m_TimelineAsset != TimelineWindow.instance.state.editSequence.asset) + return false; + return base.IsEnabled(); + } + + void DrawTimeScale() + { + var inputEvent = InputEvent.None; + var newEndTime = m_SelectionInfo.end; + var oldTimeScale = m_TimeScaleProperty.doubleValue; + + EditorGUI.BeginChangeCheck(); + var newTimeScale = TimelineInspectorUtility.DelayedAndDraggableDoubleField(Styles.TimeScaleName, oldTimeScale, ref inputEvent, k_TimeScaleSensitivity); + + if (EditorGUI.EndChangeCheck()) + { + newTimeScale = newTimeScale.Clamp(TimelineClip.kTimeScaleMin, TimelineClip.kTimeScaleMax); + newEndTime = m_SelectionInfo.start + (m_SelectionInfo.duration * oldTimeScale / newTimeScale); + } + EditMode.inputHandler.ProcessTrim(inputEvent, newEndTime, true); + } + + void DrawStartTimeField() + { + var inputEvent = InputEvent.None; + var newStart = TimelineInspectorUtility.TimeFieldUsingTimeReference(Styles.StartName, m_SelectionInfo.multipleClipStart, false, m_SelectionInfo.hasMultipleStartValues, currentFrameRate, 0.0, TimelineClip.kMaxTimeValue, ref inputEvent); + + if (inputEvent.InputHasBegun() && m_SelectionInfo.hasMultipleStartValues) + { + var items = ItemsUtils.ToItems(m_SelectionInfo.clips); + EditMode.inputHandler.SetValueForEdge(items, AttractedEdge.Left, newStart); //if the field has multiple values, set the same start on all selected clips + m_SelectionInfo.Update(); //clips could have moved relative to each other, recalculate + } + + EditMode.inputHandler.ProcessMove(inputEvent, newStart); + } + + void DrawEndTimeField() + { + var inputEvent = InputEvent.None; + var newEndTime = TimelineInspectorUtility.TimeFieldUsingTimeReference(Styles.EndName, m_SelectionInfo.multipleClipEnd, false, m_SelectionInfo.hasMultipleEndValues, currentFrameRate, 0, TimelineClip.kMaxTimeValue, ref inputEvent); + + if (inputEvent.InputHasBegun() && m_SelectionInfo.hasMultipleEndValues) + { + var items = ItemsUtils.ToItems(m_SelectionInfo.clips); + EditMode.inputHandler.SetValueForEdge(items, AttractedEdge.Right, newEndTime); //if the field has multiple value, set the same end on all selected clips + m_SelectionInfo.Update(); //clips could have moved relative to each other, recalculate + } + + var newStartValue = m_SelectionInfo.multipleClipStart + (newEndTime - m_SelectionInfo.multipleClipEnd); + EditMode.inputHandler.ProcessMove(inputEvent, newStartValue); + } + + void DrawClipAssetGui() + { + const float labelIndent = 34; + if (m_SelectedPlayableAssetsInspector == null) + return; + + var rect = GUILayoutUtility.GetRect(GUIContent.none, EditorStyles.inspectorTitlebar); + var oldWidth = EditorGUIUtility.labelWidth; + EditorGUIUtility.labelWidth = rect.width - labelIndent; + m_IsClipAssetInspectorExpanded = EditorGUI.FoldoutTitlebar(rect, m_ClipAssetTitle, m_IsClipAssetInspectorExpanded, false); + EditorGUIUtility.labelWidth = oldWidth; + if (m_IsClipAssetInspectorExpanded) + { + EditorGUILayout.Space(); + EditorGUI.indentLevel++; + ShowPlayableAssetInspector(); + EditorGUI.indentLevel--; + } + } + + void DrawExtrapolationOptions() + { + // PreExtrapolation + var preExtrapolationTime = m_PreExtrapolationTimeProperty.doubleValue; + bool hasPreExtrap = preExtrapolationTime > 0.0; + if (hasPreExtrap) + { + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.PropertyField(m_PreExtrapolationModeProperty, Styles.PreExtrapolateLabel); + using (new GUIMixedValueScope(m_PreExtrapolationTimeProperty.hasMultipleDifferentValues)) + EditorGUILayout.DoubleField(preExtrapolationTime, EditorStyles.label); + EditorGUILayout.EndHorizontal(); + } + + // PostExtrapolation + { + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.PropertyField(m_PostExtrapolationModeProperty, Styles.PostExtrapolateLabel); + using (new GUIMixedValueScope(m_PostExtrapolationTimeProperty.hasMultipleDifferentValues)) + EditorGUILayout.DoubleField(m_PostExtrapolationTimeProperty.doubleValue, EditorStyles.label); + EditorGUILayout.EndHorizontal(); + } + } + + void OnDestroy() + { + DestroyImmediate(m_SelectedPlayableAssetsInspector); + } + + public override GUIContent GetPreviewTitle() + { + return Styles.PreviewTitle; + } + + public override bool HasPreviewGUI() + { + return m_PreviewCurveState != PreviewCurveState.None; + } + + public override void OnInteractivePreviewGUI(Rect r, GUIStyle background) + { + if (m_PreviewCurveState != PreviewCurveState.None && m_ClipCurveEditor != null) + { + SetCurveEditorTrackHead(); + m_ClipCurveEditor.OnGUI(r, m_CurvePresets); + } + } + + void SetCurveEditorTrackHead() + { + if (TimelineWindow.instance == null || TimelineWindow.instance.state == null) + return; + + if (hasMultipleSelection) + return; + + var editorClip = target as EditorClip; + if (editorClip == null) + return; + + var director = TimelineWindow.instance.state.editSequence.director; + + if (director == null) + return; + + m_ClipCurveEditor.trackTime = ClipInspectorCurveEditor.kDisableTrackTime; + } + + void UnselectCurves() + { + if (Event.current.type == EventType.MouseDown) + { + if (m_ClipCurveEditor != null) + m_ClipCurveEditor.SetUpdateCurveCallback(null); + m_PreviewCurveState = PreviewCurveState.None; + } + } + + // Callback when the mixin/mixout properties are clicked on + void OnMixCurveSelected(string title, CurvePresetLibrary library, SerializedProperty curveSelected, bool easeIn) + { + m_PreviewCurveState = easeIn ? PreviewCurveState.MixIn : PreviewCurveState.MixOut; + + m_CurvePresets = library; + var animationCurve = curveSelected.animationCurveValue; + m_ClipCurveEditor.headerString = title; + m_ClipCurveEditor.SetCurve(animationCurve); + m_ClipCurveEditor.SetSelected(animationCurve); + if (easeIn) + m_ClipCurveEditor.SetUpdateCurveCallback(MixInCurveUpdated); + else + m_ClipCurveEditor.SetUpdateCurveCallback(MixOutCurveUpdated); + Repaint(); + } + + // callback when the mix property is updated + void MixInCurveUpdated(AnimationCurve curve, EditorCurveBinding binding) + { + curve.keys = CurveEditUtility.SanitizeCurveKeys(curve.keys, true); + m_MixInCurveProperty.animationCurveValue = curve; + ApplyModifiedProperties(); + var editorClip = target as EditorClip; + if (editorClip != null) + editorClip.lastHash = editorClip.GetHashCode(); + RefreshCurves(); + } + + void MixOutCurveUpdated(AnimationCurve curve, EditorCurveBinding binding) + { + curve.keys = CurveEditUtility.SanitizeCurveKeys(curve.keys, false); + m_MixOutCurveProperty.animationCurveValue = curve; + ApplyModifiedProperties(); + var editorClip = target as EditorClip; + if (editorClip != null) + editorClip.lastHash = editorClip.GetHashCode(); + RefreshCurves(); + } + + void RefreshCurves() + { + AnimationCurvePreviewCache.ClearCache(); + TimelineWindow.RepaintIfEditingTimelineAsset(m_TimelineAsset); + Repaint(); + } + + void DrawBlendCurve(GUIContent title, SerializedProperty modeProperty, SerializedProperty curveProperty, Action onCurveClick) + { + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.PropertyField(modeProperty, title); + if (hasMultipleSelection) + { + GUILayout.FlexibleSpace(); + } + else + { + using (new EditorGUI.DisabledScope(modeProperty.intValue != (int)TimelineClip.BlendCurveMode.Manual)) + { + ClipInspectorCurveEditor.CurveField(GUIContent.none, curveProperty, onCurveClick); + } + } + + EditorGUILayout.EndHorizontal(); + } + + void ShowPlayableAssetInspector() + { + if (!m_SelectionInfo.selectedAssetTypesAreHomogeneous) + return; + + if (m_SelectedPlayableAssetsInspector != null) + { + foreach (var selectedItem in m_SelectionCache) + CurvesOwnerInspectorHelper.PreparePlayableAsset(selectedItem); + + EditorGUI.BeginChangeCheck(); + using (new EditorGUI.DisabledScope(IsLocked())) + { + m_SelectedPlayableAssetsInspector.OnInspectorGUI(); + } + if (EditorGUI.EndChangeCheck()) + { + MarkClipsDirty(); + if (TimelineWindow.IsEditingTimelineAsset(m_TimelineAsset) && TimelineWindow.instance.state != null) + { + var basicInspector = m_SelectedPlayableAssetsInspector as BasicAssetInspector; + if (basicInspector != null) + basicInspector.ApplyChanges(); + else + TimelineEditor.Refresh(RefreshReason.ContentsModified); + } + } + } + } + + void ApplyModifiedProperties() + { + // case 926861 - we need to force the track to be dirty since modifying the clip does not + // automatically mark the track asset as dirty + if (serializedObject.ApplyModifiedProperties()) + { + foreach (var obj in serializedObject.targetObjects) + { + var editorClip = obj as EditorClip; + if (editorClip != null && editorClip.clip != null && editorClip.clip.parentTrack != null) + { + editorClip.clip.MarkDirty(); + EditorUtility.SetDirty(editorClip.clip.parentTrack); + } + } + } + } + + void MarkClipsDirty() + { + foreach (var obj in targets) + { + var editorClip = obj as EditorClip; + if (editorClip != null && editorClip.clip != null) + { + editorClip.clip.MarkDirty(); + } + } + } + + string PlayableAssetSectionTitle() + { + var firstSelectedClipAsset = m_SelectionCache.Any() ? m_SelectionCache.First().clip.asset : null; + return firstSelectedClipAsset != null + ? ObjectNames.NicifyVariableName(firstSelectedClipAsset.GetType().Name) + : string.Empty; + } + + bool IsTimelineAssetValidForEditorClip(EditorClip editorClip) + { + var trackAsset = editorClip.clip.parentTrack; + if (trackAsset == null) + return false; + + var clipTimelineAsset = trackAsset.timelineAsset; + if (m_TimelineAsset == null) + m_TimelineAsset = clipTimelineAsset; + else if (clipTimelineAsset != m_TimelineAsset) + { + m_TimelineAsset = null; + return false; + } + return true; + } + + bool CanShowPlayableAssetInspector() + { + if (hasMultipleSelection) + return m_SelectedPlayableAssetsInspector != null && + m_SelectedPlayableAssetsInspector.canEditMultipleObjects && + m_SelectionInfo.selectedAssetTypesAreHomogeneous; + else + return true; + } + + void DrawDurationProperty() + { + var minDuration = 1.0 / 30.0; + if (currentFrameRate > float.Epsilon) + { + minDuration = 1.0 / currentFrameRate; + } + + var inputEvent = InputEvent.None; + var newDuration = TimelineInspectorUtility.DurationFieldUsingTimeReference( + Styles.DurationName, m_SelectionInfo.start, m_SelectionInfo.end, false, m_SelectionInfo.hasMultipleDurationValues, currentFrameRate, minDuration, TimelineClip.kMaxTimeValue, ref inputEvent); + EditMode.inputHandler.ProcessTrim(inputEvent, m_SelectionInfo.start + newDuration, false); + } + + void DrawBlendingProperties() + { + const double mixMinimum = 0.0; + var useBlendIn = m_SelectionInfo.hasBlendIn; + var useBlendOut = m_SelectionInfo.hasBlendOut; + + var currentMixInProperty = useBlendIn ? m_BlendInDurationProperty : m_EaseInDurationProperty; + var currentMixOutProperty = useBlendOut ? m_BlendOutDurationProperty : m_EaseOutDurationProperty; + + var maxEaseIn = Math.Max(mixMinimum, m_SelectionInfo.maxMixIn); + var maxEaseOut = Math.Max(mixMinimum, m_SelectionInfo.maxMixOut); + + var inputEvent = InputEvent.None; + + var blendMax = useBlendIn ? TimelineClip.kMaxTimeValue : maxEaseIn; + var label = useBlendIn ? Styles.BlendInDurationName : Styles.EaseInDurationName; + TimelineInspectorUtility.TimeField(currentMixInProperty, label, useBlendIn, currentFrameRate, mixMinimum, blendMax, ref inputEvent); + + blendMax = useBlendOut ? TimelineClip.kMaxTimeValue : maxEaseOut; + label = useBlendOut ? Styles.BlendOutDurationName : Styles.EaseOutDurationName; + TimelineInspectorUtility.TimeField(currentMixOutProperty, label, useBlendOut, currentFrameRate, mixMinimum, blendMax, ref inputEvent); + } + + void DrawClipInProperty() + { + var action = InputEvent.None; + TimelineInspectorUtility.TimeField(m_ClipInProperty, Styles.ClipInName, false, currentFrameRate, 0, TimelineClip.kMaxTimeValue, ref action); + } + + void DrawBlendOptions() + { + EditorGUI.BeginChangeCheck(); + + DrawBlendCurve(Styles.BlendInCurveName, m_BlendInCurveModeProperty, m_MixInCurveProperty, x => OnMixCurveSelected("Blend In", BuiltInPresets.blendInPresets, x, true)); + DrawBlendCurve(Styles.BlendOutCurveName, m_BlendOutCurveModeProperty, m_MixOutCurveProperty, x => OnMixCurveSelected("Blend Out", BuiltInPresets.blendOutPresets, x, false)); + + if (EditorGUI.EndChangeCheck()) + TimelineWindow.RepaintIfEditingTimelineAsset(m_TimelineAsset); + } + + void DrawGroupSelectionProperties() + { + var inputEvent = InputEvent.None; + var newStartTime = TimelineInspectorUtility.TimeField(Styles.MultipleClipStartName, m_SelectionInfo.multipleClipStart, false, false, currentFrameRate, 0, TimelineClip.kMaxTimeValue, ref inputEvent); + EditMode.inputHandler.ProcessMove(inputEvent, newStartTime); + + inputEvent = InputEvent.None; + var newEndTime = TimelineInspectorUtility.TimeField(Styles.MultipleClipEndName, m_SelectionInfo.multipleClipEnd, false, false, currentFrameRate, 0, TimelineClip.kMaxTimeValue, ref inputEvent); + var newStartValue = newStartTime + (newEndTime - m_SelectionInfo.multipleClipEnd); + EditMode.inputHandler.ProcessMove(inputEvent, newStartValue); + } + + bool IsLocked() + { + if (!TimelineUtility.IsCurrentSequenceValid() || IsCurrentSequenceReadOnly()) + return true; + + return targets.OfType().Any(t => t.clip.parentTrack != null && t.clip.parentTrack.lockedInHierarchy); + } + + static bool IsCurrentSequenceReadOnly() + { + return TimelineWindow.instance.state.editSequence.isReadOnly; + } + + void OnUndoRedoPerformed() + { + if (m_PreviewCurveState == PreviewCurveState.None) + return; + + // if an undo is performed the curves need to be updated in the curve editor, as the reference to them is no longer valid + // case 978673 + if (m_ClipCurveEditor != null) + { + serializedObject.Update(); + m_ClipCurveEditor.SetCurve(m_PreviewCurveState == PreviewCurveState.MixIn ? m_MixInCurveProperty.animationCurveValue : m_MixOutCurveProperty.animationCurveValue); + } + } + + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/inspectors/ClipInspector/ClipInspector.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/inspectors/ClipInspector/ClipInspector.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..165a3ea0df28e5f713c6a1d36cd8175a78bcac50 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/inspectors/ClipInspector/ClipInspector.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dff73c4907c95264c8fc095a81f9d51e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/inspectors/ClipInspector/ClipInspectorCurveEditor.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/inspectors/ClipInspector/ClipInspectorCurveEditor.cs new file mode 100644 index 0000000000000000000000000000000000000000..67d5ca1fbab92db8668a241013730fa1634da9c6 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/inspectors/ClipInspector/ClipInspectorCurveEditor.cs @@ -0,0 +1,353 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEditorInternal; +using UnityEngine; + +namespace UnityEditor.Timeline +{ + class ClipInspectorCurveEditor + { + CurveEditor m_CurveEditor; + CurveWrapper[] m_CurveWrappers; + + const float k_HeaderHeight = 30; + const float k_PresetHeight = 30; + + Action m_CurveUpdatedCallback; + GUIContent m_TextContent = new GUIContent(); + + GUIStyle m_LabelStyle; + GUIStyle m_LegendStyle; + + // Track time. controls the position of the track head + public static readonly double kDisableTrackTime = double.NaN; + double m_trackTime = kDisableTrackTime; + public double trackTime { get { return m_trackTime; } set { m_trackTime = value; } } + + public string headerString { get; set; } + + public ClipInspectorCurveEditor() + { + var curveEditorSettings = new CurveEditorSettings + { + allowDeleteLastKeyInCurve = false, + allowDraggingCurvesAndRegions = true, + hTickLabelOffset = 0.1f, + showAxisLabels = true, + useFocusColors = false, + wrapColor = new EditorGUIUtility.SkinnedColor(Color.black), + hSlider = false, + hRangeMin = 0.0f, + vRangeMin = 0.0F, + vRangeMax = 1.0f, + hRangeMax = 1.0F, + vSlider = false, + hRangeLocked = false, + vRangeLocked = false, + undoRedoSelection = true, + + + hTickStyle = new TickStyle + { + tickColor = new EditorGUIUtility.SkinnedColor(new Color(0.0f, 0.0f, 0.0f, 0.2f)), + distLabel = 30, + stubs = false, + centerLabel = true + }, + + vTickStyle = new TickStyle + { + tickColor = new EditorGUIUtility.SkinnedColor(new Color(1.0f, 0.0f, 0.0f, 0.2f)), + distLabel = 20, + stubs = false, + centerLabel = true + } + }; + + m_CurveEditor = new CurveEditor(new Rect(0, 0, 1000, 100), new CurveWrapper[0], true) + { + settings = curveEditorSettings, + ignoreScrollWheelUntilClicked = true + }; + } + + internal bool InitStyles() + { + if (EditorStyles.s_Current == null) + return false; + + if (m_LabelStyle == null) + { + m_LabelStyle = new GUIStyle(EditorStyles.whiteLargeLabel); + m_LegendStyle = new GUIStyle(EditorStyles.miniBoldLabel); + + m_LabelStyle.alignment = TextAnchor.MiddleCenter; + m_LegendStyle.alignment = TextAnchor.MiddleCenter; + } + return true; + } + + internal void OnGUI(Rect clientRect, CurvePresetLibrary presets) + { + const float presetPad = 30.0f; + + if (!InitStyles()) + return; + + if (m_CurveWrappers == null || m_CurveWrappers.Length == 0) + return; + + // regions + var headerRect = new Rect(clientRect.x, clientRect.y, clientRect.width, k_HeaderHeight); + var curveRect = new Rect(clientRect.x, clientRect.y + headerRect.height, clientRect.width, clientRect.height - k_HeaderHeight - k_PresetHeight); + var presetRect = new Rect(clientRect.x + presetPad, clientRect.y + curveRect.height + k_HeaderHeight, clientRect.width - presetPad, k_PresetHeight); + + GUI.Box(headerRect, headerString, m_LabelStyle); + + //Case 1201474 : Force to update only when Repaint event is called as the new rect provided on other event create a wrong curve editor computation. + if (Event.current.type == EventType.Repaint) + { + m_CurveEditor.rect = curveRect; + m_CurveEditor.shownAreaInsideMargins = new Rect(0, 0, 1, 1); + } + m_CurveEditor.animationCurves = m_CurveWrappers; + UpdateSelectionColors(); + + DrawTrackHead(curveRect); + + EditorGUI.BeginChangeCheck(); + + m_CurveEditor.OnGUI(); + DrawPresets(presetRect, presets); + + bool hasChanged = EditorGUI.EndChangeCheck(); + + if (presets == null) + DrawLegend(presetRect); + + if (hasChanged) + ProcessUpdates(); + + ConsumeMouseEvents(clientRect); + } + + static void ConsumeMouseEvents(Rect rect) + { + var isMouseEvent = Event.current.type == EventType.MouseUp || Event.current.type == EventType.MouseDown; + if (isMouseEvent && rect.Contains(Event.current.mousePosition)) + Event.current.Use(); + } + + void DrawPresets(Rect position, PresetLibrary curveLibrary) + { + if (curveLibrary == null || curveLibrary.Count() == 0) + return; + + const int maxNumPresets = 9; + int numPresets = curveLibrary.Count(); + int showNumPresets = Mathf.Min(numPresets, maxNumPresets); + + const float swatchWidth = 30; + const float swatchHeight = 15; + const float spaceBetweenSwatches = 10; + float presetButtonsWidth = showNumPresets * swatchWidth + (showNumPresets - 1) * spaceBetweenSwatches; + float flexWidth = (position.width - presetButtonsWidth) * 0.5f; + + // Preset swatch area + float curY = (position.height - swatchHeight) * 0.5f; + float curX = 3.0f; + if (flexWidth > 0) + curX = flexWidth; + + GUI.BeginGroup(position); + + for (int i = 0; i < showNumPresets; i++) + { + if (i > 0) + curX += spaceBetweenSwatches; + + var swatchRect = new Rect(curX, curY, swatchWidth, swatchHeight); + m_TextContent.tooltip = curveLibrary.GetName(i); + if (GUI.Button(swatchRect, m_TextContent, GUIStyle.none)) + { + // if there is only 1, no need to specify + IEnumerable wrappers = m_CurveWrappers; + if (m_CurveWrappers.Length > 1) + wrappers = m_CurveWrappers.Where(x => x.selected == CurveWrapper.SelectionMode.Selected); + + foreach (var wrapper in wrappers) + { + var presetCurve = (AnimationCurve)curveLibrary.GetPreset(i); + wrapper.curve.keys = (Keyframe[])presetCurve.keys.Clone(); + wrapper.changed = true; + } + + // case 1259902 - flushes internal selection caches preventing index out of range exceptions + m_CurveEditor.SelectNone(); + foreach (var wrapper in wrappers) + wrapper.selected = CurveWrapper.SelectionMode.Selected; + } + + if (Event.current.type == EventType.Repaint) + curveLibrary.Draw(swatchRect, i); + + curX += swatchWidth; + } + + GUI.EndGroup(); + } + + // draw a line representing where in the current clip we are + void DrawTrackHead(Rect clientRect) + { + DirectorStyles styles = TimelineWindow.styles; + if (styles == null) + return; + + if (!double.IsNaN(m_trackTime)) + { + float x = m_CurveEditor.TimeToPixel((float)m_trackTime, clientRect); + x = Mathf.Clamp(x, clientRect.xMin, clientRect.xMax); + var p1 = new Vector2(x, clientRect.yMin); + var p2 = new Vector2(x, clientRect.yMax); + Graphics.DrawLine(p1, p2, DirectorStyles.Instance.customSkin.colorPlayhead); + } + } + + // Draws a legend for the displayed curves + void DrawLegend(Rect r) + { + if (m_CurveWrappers == null || m_CurveWrappers.Length == 0) + return; + + Color c = GUI.color; + float boxWidth = r.width / m_CurveWrappers.Length; + for (int i = 0; i < m_CurveWrappers.Length; i++) + { + CurveWrapper cw = m_CurveWrappers[i]; + if (cw != null) + { + var pos = new Rect(r.x + i * boxWidth, r.y, boxWidth, r.height); + var textColor = cw.color; + textColor.a = 1; + GUI.color = textColor; + string name = LabelName(cw.binding.propertyName); + EditorGUI.LabelField(pos, name, m_LegendStyle); + } + } + GUI.color = c; + } + + // Helper for making label name appropriately small + static char[] s_LabelMarkers = { '_' }; + + static string LabelName(string propertyName) + { + propertyName = AnimationWindowUtility.GetPropertyDisplayName(propertyName); + int index = propertyName.LastIndexOfAny(s_LabelMarkers); + if (index >= 0) + propertyName = propertyName.Substring(index); + return propertyName; + } + + public void SetCurve(AnimationCurve curve) + { + if (m_CurveWrappers == null || m_CurveWrappers.Length != 1) + { + m_CurveWrappers = new CurveWrapper[1]; + var cw = new CurveWrapper + { + renderer = new NormalCurveRenderer(curve), + readOnly = false, + color = EditorGUI.kCurveColor, + id = 0xFEED, + hidden = false, + regionId = -1 + }; + + cw.renderer.SetWrap(WrapMode.Clamp, WrapMode.Clamp); + cw.renderer.SetCustomRange(0, 1); + m_CurveWrappers[0] = cw; + + UpdateSelectionColors(); + m_CurveEditor.animationCurves = m_CurveWrappers; + } + else + { + m_CurveWrappers[0].renderer = new NormalCurveRenderer(curve); + } + } + + internal void SetUpdateCurveCallback(Action callback) + { + m_CurveUpdatedCallback = callback; + } + + void ProcessUpdates() + { + foreach (var cw in m_CurveWrappers) + { + if (cw.changed) + { + cw.changed = false; + + if (m_CurveUpdatedCallback != null) + m_CurveUpdatedCallback(cw.curve, cw.binding); + } + } + } + + public void SetSelected(AnimationCurve curve) + { + m_CurveEditor.SelectNone(); + if (m_CurveWrappers != null && m_CurveWrappers.Length > 0) + { + if (m_CurveWrappers[0].renderer.GetCurve() == curve) + { + m_CurveWrappers[0].selected = CurveWrapper.SelectionMode.Selected; + m_CurveEditor.AddSelection(new CurveSelection(m_CurveWrappers[0].id, 0)); + } + } + UpdateSelectionColors(); + } + + void UpdateSelectionColors() + { + if (m_CurveWrappers == null) + return; + + // manually manage selection colors + foreach (var cw in m_CurveWrappers) + { + Color c = cw.color; + if (cw.readOnly) + c.a = 0.75f; + else if (cw.selected != CurveWrapper.SelectionMode.None) + c.a = 1.0f; + else + c.a = 0.5f; + cw.color = c; + } + } + + public static void CurveField(GUIContent title, SerializedProperty property, Action onClick) + { + Rect controlRect = EditorGUILayout.GetControlRect(GUILayout.MinWidth(20)); + EditorGUI.BeginProperty(controlRect, title, property); + DrawCurve(controlRect, property, onClick, EditorGUI.kCurveColor, EditorGUI.kCurveBGColor); + EditorGUI.EndProperty(); + } + + static Rect DrawCurve(Rect controlRect, SerializedProperty property, Action onClick, Color fgColor, Color bgColor) + { + if (GUI.Button(controlRect, GUIContent.none)) + { + if (onClick != null) + onClick(property); + } + EditorGUIUtility.DrawCurveSwatch(controlRect, null, property, fgColor, bgColor); + return controlRect; + } + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/inspectors/ClipInspector/ClipInspectorCurveEditor.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/inspectors/ClipInspector/ClipInspectorCurveEditor.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..1d1657674ec8d7b59fe4fc4c2110ca2b25fad882 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/inspectors/ClipInspector/ClipInspectorCurveEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d3d14fa8f6934e14d92e37279e40e89b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/inspectors/ClipInspector/ClipInspectorSelectionInfo.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/inspectors/ClipInspector/ClipInspectorSelectionInfo.cs new file mode 100644 index 0000000000000000000000000000000000000000..bfd149c5683ddc899bd350ec4577ee562330ea8a --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/inspectors/ClipInspector/ClipInspectorSelectionInfo.cs @@ -0,0 +1,146 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using UnityEngine.Timeline; + +namespace UnityEditor.Timeline +{ + class ClipInspectorSelectionInfo + { + public double start, end, duration; + public double multipleClipStart, multipleClipEnd; + public double smallestDuration; + + public bool hasMultipleStartValues, hasMultipleEndValues, hasMultipleDurationValues; + public bool supportsExtrapolation, supportsClipIn, supportsSpeedMultiplier, supportsBlending; + public bool hasBlendIn, hasBlendOut; + public double maxMixIn, maxMixOut; + public bool selectedAssetTypesAreHomogeneous; + public bool containsAtLeastTwoClipsOnTheSameTrack; + + public HashSet uniqueParentTracks = new HashSet(); + public ICollection clips { get; private set; } + + public ClipInspectorSelectionInfo(ICollection selectedClips) + { + supportsBlending = supportsClipIn = supportsExtrapolation = supportsSpeedMultiplier = true; + hasBlendIn = hasBlendOut = true; + maxMixIn = maxMixOut = TimelineClip.kMaxTimeValue; + selectedAssetTypesAreHomogeneous = true; + smallestDuration = TimelineClip.kMaxTimeValue; + start = end = duration = 0; + multipleClipStart = multipleClipEnd = 0; + hasMultipleStartValues = hasMultipleEndValues = hasMultipleDurationValues = false; + containsAtLeastTwoClipsOnTheSameTrack = false; + + clips = selectedClips; + Build(); + } + + void Build() + { + if (!clips.Any()) return; + + var firstSelectedClip = clips.First(); + if (firstSelectedClip == null) return; + + var firstSelectedClipAssetType = firstSelectedClip.asset != null ? firstSelectedClip.asset.GetType() : null; + + smallestDuration = TimelineClip.kMaxTimeValue; + InitSelectionBounds(firstSelectedClip); + InitMultipleClipBounds(firstSelectedClip); + + foreach (var clip in clips) + { + if (clip == null) continue; + + uniqueParentTracks.Add(clip.parentTrack); + selectedAssetTypesAreHomogeneous &= clip.asset.GetType() == firstSelectedClipAssetType; + + UpdateClipCaps(clip); + UpdateBlends(clip); + UpdateMixMaximums(clip); + UpdateSmallestDuration(clip); + UpdateMultipleValues(clip); + UpdateMultipleValues(clip); + } + containsAtLeastTwoClipsOnTheSameTrack = uniqueParentTracks.Count != clips.Count; + } + + public void Update() + { + var firstSelectedClip = clips.First(); + if (firstSelectedClip == null) return; + + hasBlendIn = hasBlendOut = true; + maxMixIn = maxMixOut = TimelineClip.kMaxTimeValue; + hasMultipleStartValues = hasMultipleDurationValues = hasMultipleEndValues = false; + smallestDuration = TimelineClip.kMaxTimeValue; + InitSelectionBounds(firstSelectedClip); + InitMultipleClipBounds(firstSelectedClip); + + foreach (var clip in clips) + { + if (clip == null) continue; + + UpdateBlends(clip); + UpdateMixMaximums(clip); + UpdateSmallestDuration(clip); + UpdateMultipleValues(clip); + } + } + + void InitSelectionBounds(TimelineClip clip) + { + start = clip.start; + duration = clip.duration; + end = clip.start + clip.duration; + } + + void InitMultipleClipBounds(TimelineClip firstSelectedClip) + { + multipleClipStart = firstSelectedClip.start; + multipleClipEnd = end; + } + + void UpdateSmallestDuration(TimelineClip clip) + { + smallestDuration = Math.Min(smallestDuration, clip.duration); + } + + void UpdateClipCaps(TimelineClip clip) + { + supportsBlending &= clip.SupportsBlending(); + supportsClipIn &= clip.SupportsClipIn(); + supportsExtrapolation &= clip.SupportsExtrapolation(); + supportsSpeedMultiplier &= clip.SupportsSpeedMultiplier(); + } + + void UpdateMultipleValues(TimelineClip clip) + { + hasMultipleStartValues |= !Mathf.Approximately((float)clip.start, (float)start); + hasMultipleDurationValues |= !Mathf.Approximately((float)clip.duration, (float)duration); + var clipEnd = clip.start + clip.duration; + hasMultipleEndValues |= !Mathf.Approximately((float)clipEnd, (float)end); + + multipleClipStart = Math.Min(multipleClipStart, clip.start); + multipleClipEnd = Math.Max(multipleClipEnd, clip.end); + } + + void UpdateBlends(TimelineClip clip) + { + hasBlendIn &= clip.hasBlendIn; + hasBlendOut &= clip.hasBlendOut; + } + + void UpdateMixMaximums(TimelineClip clip) + { + var clipMaxMixIn = Math.Max(0.0, clip.duration - clip.mixOutDuration); + var clipMaxMixOut = Math.Max(0.0, clip.duration - clip.mixInDuration); + + maxMixIn = Math.Min(maxMixIn, clipMaxMixIn); + maxMixOut = Math.Min(maxMixOut, clipMaxMixOut); + } + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/inspectors/ClipInspector/ClipInspectorSelectionInfo.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/inspectors/ClipInspector/ClipInspectorSelectionInfo.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..bd8f85e1b9082d2c7e9e274b1387588aef2ff28f --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/inspectors/ClipInspector/ClipInspectorSelectionInfo.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 57a39be2178cca94ab21e15c082e3ab6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/inspectors/CurvesOwner/CurvesOwnerInspectorHelper.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/inspectors/CurvesOwner/CurvesOwnerInspectorHelper.cs new file mode 100644 index 0000000000000000000000000000000000000000..c5c44054ccf68fe29d393a294f124eb1740ef7ef --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/inspectors/CurvesOwner/CurvesOwnerInspectorHelper.cs @@ -0,0 +1,109 @@ +using System; +using UnityEngine; +using UnityEngine.Timeline; + +namespace UnityEditor.Timeline +{ + static class CurvesOwnerInspectorHelper + { + // Because what is animated is not the asset, but the instanced playable, + // we apply the animation clip here to preview what is being shown + // This could be improved doing something more inline with animation mode, + // and reverting values that aren't be recorded later to avoid dirtying the asset + public static void PreparePlayableAsset(ICurvesOwnerInspectorWrapper wrapper) + { + if (Event.current.type != EventType.Repaint) + return; + + if (wrapper.serializedPlayableAsset == null) + return; + + var curvesOwner = wrapper.curvesOwner; + if (curvesOwner == null || curvesOwner.curves == null) + return; + + var timelineWindow = TimelineWindow.instance; + if (timelineWindow == null || timelineWindow.state == null) + return; + + // requires preview mode. reset the eval time so previous value is correct value is displayed while toggling + if (!timelineWindow.state.previewMode) + { + wrapper.lastEvalTime = -1; + return; + } + + var time = wrapper.ToLocalTime(timelineWindow.state.editSequence.time); + + // detect if the time has changed, or if the curves have changed + if (Math.Abs(wrapper.lastEvalTime - time) < TimeUtility.kTimeEpsilon) + { + int curveVersion = AnimationClipCurveCache.Instance.GetCurveInfo(curvesOwner.curves).version; + if (curveVersion == wrapper.lastCurveVersion) + return; + + wrapper.lastCurveVersion = curveVersion; + } + + wrapper.lastEvalTime = time; + + var clipInfo = AnimationClipCurveCache.Instance.GetCurveInfo(curvesOwner.curves); + int count = clipInfo.bindings.Length; + if (count == 0) + return; + + wrapper.serializedPlayableAsset.Update(); + + var prop = wrapper.serializedPlayableAsset.GetIterator(); + while (prop.NextVisible(true)) + { + if (curvesOwner.IsParameterAnimated(prop.propertyPath)) + { + var curve = curvesOwner.GetAnimatedParameter(prop.propertyPath); + switch (prop.propertyType) + { + case SerializedPropertyType.Boolean: + prop.boolValue = curve.Evaluate((float)time) > 0; + break; + case SerializedPropertyType.Float: + prop.floatValue = curve.Evaluate((float)time); + break; + case SerializedPropertyType.Integer: + prop.intValue = Mathf.FloorToInt(curve.Evaluate((float)time)); + break; + case SerializedPropertyType.Color: + SetAnimatedValue(curvesOwner, prop, "r", time); + SetAnimatedValue(curvesOwner, prop, "g", time); + SetAnimatedValue(curvesOwner, prop, "b", time); + SetAnimatedValue(curvesOwner, prop, "a", time); + break; + case SerializedPropertyType.Quaternion: + case SerializedPropertyType.Vector4: + SetAnimatedValue(curvesOwner, prop, "w", time); + goto case SerializedPropertyType.Vector3; + case SerializedPropertyType.Vector3: + SetAnimatedValue(curvesOwner, prop, "z", time); + goto case SerializedPropertyType.Vector2; + case SerializedPropertyType.Vector2: + SetAnimatedValue(curvesOwner, prop, "x", time); + SetAnimatedValue(curvesOwner, prop, "y", time); + break; + } + } + } + + wrapper.serializedPlayableAsset.ApplyModifiedPropertiesWithoutUndo(); + } + + static void SetAnimatedValue(ICurvesOwner clip, SerializedProperty property, string path, double localTime) + { + var prop = property.FindPropertyRelative(path); + if (prop != null) + { + var curve = clip.GetAnimatedParameter(prop.propertyPath); + if (curve != null) + prop.floatValue = curve.Evaluate((float)localTime); + } + } + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/inspectors/CurvesOwner/CurvesOwnerInspectorHelper.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/inspectors/CurvesOwner/CurvesOwnerInspectorHelper.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..17e8bb3583e24b0a44584cfee9279a5c8b21c683 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/inspectors/CurvesOwner/CurvesOwnerInspectorHelper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9a371bcbba2084dd0a8ebc6826aa8794 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/inspectors/CurvesOwner/ICurvesOwnerInspectorWrapper.cs b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/inspectors/CurvesOwner/ICurvesOwnerInspectorWrapper.cs new file mode 100644 index 0000000000000000000000000000000000000000..0ce6f58f56b25ec320c7998e75a8628aae03b149 --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/inspectors/CurvesOwner/ICurvesOwnerInspectorWrapper.cs @@ -0,0 +1,14 @@ +using UnityEngine.Timeline; + +namespace UnityEditor.Timeline +{ + interface ICurvesOwnerInspectorWrapper + { + ICurvesOwner curvesOwner { get; } + SerializedObject serializedPlayableAsset { get; } + int lastCurveVersion { get; set; } + double lastEvalTime { get; set; } + + double ToLocalTime(double time); + } +} diff --git a/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/inspectors/CurvesOwner/ICurvesOwnerInspectorWrapper.cs.meta b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/inspectors/CurvesOwner/ICurvesOwnerInspectorWrapper.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..746e9706bad34c6dcac6345b074e8b15a51ebd9f --- /dev/null +++ b/benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.timeline@1.4.6/Editor/inspectors/CurvesOwner/ICurvesOwnerInspectorWrapper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 926a61ff0dec44a5aab649acb411e9ad +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: