├── .gitignore ├── Assets ├── Resources.meta ├── Resources │ ├── BillingMode.json │ └── BillingMode.json.meta ├── TriangleNet.meta └── TriangleNet │ ├── LICENSE.md │ ├── LICENSE.md.meta │ ├── Runtime.meta │ ├── Runtime │ ├── Scripts.meta │ ├── Scripts │ │ ├── Source.meta │ │ ├── Source │ │ │ ├── Behavior.cs │ │ │ ├── Behavior.cs.meta │ │ │ ├── Configuration.cs │ │ │ ├── Configuration.cs.meta │ │ │ ├── Enums.cs │ │ │ ├── Enums.cs.meta │ │ │ ├── Geometry.meta │ │ │ ├── Geometry │ │ │ │ ├── Contour.cs │ │ │ │ ├── Contour.cs.meta │ │ │ │ ├── Edge.cs │ │ │ │ ├── Edge.cs.meta │ │ │ │ ├── ExtensionMethods.cs │ │ │ │ ├── ExtensionMethods.cs.meta │ │ │ │ ├── IEdge.cs │ │ │ │ ├── IEdge.cs.meta │ │ │ │ ├── IPolygon.cs │ │ │ │ ├── IPolygon.cs.meta │ │ │ │ ├── ISegment.cs │ │ │ │ ├── ISegment.cs.meta │ │ │ │ ├── ITriangle.cs │ │ │ │ ├── ITriangle.cs.meta │ │ │ │ ├── Point.cs │ │ │ │ ├── Point.cs.meta │ │ │ │ ├── Polygon.cs │ │ │ │ ├── Polygon.cs.meta │ │ │ │ ├── Rectangle.cs │ │ │ │ ├── Rectangle.cs.meta │ │ │ │ ├── RegionPointer.cs │ │ │ │ ├── RegionPointer.cs.meta │ │ │ │ ├── Segment.cs │ │ │ │ ├── Segment.cs.meta │ │ │ │ ├── Vertex.cs │ │ │ │ └── Vertex.cs.meta │ │ │ ├── IO.meta │ │ │ ├── IO │ │ │ │ ├── DebugWriter.cs │ │ │ │ ├── DebugWriter.cs.meta │ │ │ │ ├── FileProcessor.cs │ │ │ │ ├── FileProcessor.cs.meta │ │ │ │ ├── IFileFormat.cs │ │ │ │ ├── IFileFormat.cs.meta │ │ │ │ ├── IMeshFormat.cs │ │ │ │ ├── IMeshFormat.cs.meta │ │ │ │ ├── IPolygonFormat.cs │ │ │ │ ├── IPolygonFormat.cs.meta │ │ │ │ ├── InputTriangle.cs │ │ │ │ ├── InputTriangle.cs.meta │ │ │ │ ├── TriangleFormat.cs │ │ │ │ ├── TriangleFormat.cs.meta │ │ │ │ ├── TriangleReader.cs │ │ │ │ ├── TriangleReader.cs.meta │ │ │ │ ├── TriangleWriter.cs │ │ │ │ └── TriangleWriter.cs.meta │ │ │ ├── IPredicates.cs │ │ │ ├── IPredicates.cs.meta │ │ │ ├── Log.cs │ │ │ ├── Log.cs.meta │ │ │ ├── Logging.meta │ │ │ ├── Logging │ │ │ │ ├── ILog.cs │ │ │ │ ├── ILog.cs.meta │ │ │ │ ├── ILogItem.cs │ │ │ │ ├── ILogItem.cs.meta │ │ │ │ ├── LogItem.cs │ │ │ │ └── LogItem.cs.meta │ │ │ ├── MeshValidator.cs │ │ │ ├── MeshValidator.cs.meta │ │ │ ├── Meshing.meta │ │ │ ├── Meshing │ │ │ │ ├── Algorithm.meta │ │ │ │ ├── Algorithm │ │ │ │ │ ├── Dwyer.cs │ │ │ │ │ ├── Dwyer.cs.meta │ │ │ │ │ ├── Incremental.cs │ │ │ │ │ ├── Incremental.cs.meta │ │ │ │ │ ├── SweepLine.cs │ │ │ │ │ └── SweepLine.cs.meta │ │ │ │ ├── ConstraintMesher.cs │ │ │ │ ├── ConstraintMesher.cs.meta │ │ │ │ ├── ConstraintOptions.cs │ │ │ │ ├── ConstraintOptions.cs.meta │ │ │ │ ├── Converter.cs │ │ │ │ ├── Converter.cs.meta │ │ │ │ ├── Data.meta │ │ │ │ ├── Data │ │ │ │ │ ├── BadSubseg.cs │ │ │ │ │ ├── BadSubseg.cs.meta │ │ │ │ │ ├── BadTriQueue.cs │ │ │ │ │ ├── BadTriQueue.cs.meta │ │ │ │ │ ├── BadTriangle.cs │ │ │ │ │ └── BadTriangle.cs.meta │ │ │ │ ├── GenericMesher.cs │ │ │ │ ├── GenericMesher.cs.meta │ │ │ │ ├── IConstraintMesher.cs │ │ │ │ ├── IConstraintMesher.cs.meta │ │ │ │ ├── IMesh.cs │ │ │ │ ├── IMesh.cs.meta │ │ │ │ ├── IQualityMesher.cs │ │ │ │ ├── IQualityMesher.cs.meta │ │ │ │ ├── ITriangulator.cs │ │ │ │ ├── ITriangulator.cs.meta │ │ │ │ ├── Iterators.meta │ │ │ │ ├── Iterators │ │ │ │ │ ├── EdgeIterator.cs │ │ │ │ │ ├── EdgeIterator.cs.meta │ │ │ │ │ ├── RegionIterator.cs │ │ │ │ │ ├── RegionIterator.cs.meta │ │ │ │ │ ├── VertexCirculator.cs │ │ │ │ │ └── VertexCirculator.cs.meta │ │ │ │ ├── QualityMesher.cs │ │ │ │ ├── QualityMesher.cs.meta │ │ │ │ ├── QualityOptions.cs │ │ │ │ └── QualityOptions.cs.meta │ │ │ ├── NewLocation.cs │ │ │ ├── NewLocation.cs.meta │ │ │ ├── RobustPredicates.cs │ │ │ ├── RobustPredicates.cs.meta │ │ │ ├── Smoothing.meta │ │ │ ├── Smoothing │ │ │ │ ├── ISmoother.cs │ │ │ │ ├── ISmoother.cs.meta │ │ │ │ ├── SimpleSmoother.cs │ │ │ │ ├── SimpleSmoother.cs.meta │ │ │ │ ├── VoronoiFactory.cs │ │ │ │ └── VoronoiFactory.cs.meta │ │ │ ├── Tools.meta │ │ │ ├── Tools │ │ │ │ ├── AdjacencyMatrix.cs │ │ │ │ ├── AdjacencyMatrix.cs.meta │ │ │ │ ├── CuthillMcKee.cs │ │ │ │ ├── CuthillMcKee.cs.meta │ │ │ │ ├── Interpolation.cs │ │ │ │ ├── Interpolation.cs.meta │ │ │ │ ├── IntersectionHelper.cs │ │ │ │ ├── IntersectionHelper.cs.meta │ │ │ │ ├── PolygonValidator.cs │ │ │ │ ├── PolygonValidator.cs.meta │ │ │ │ ├── QualityMeasure.cs │ │ │ │ ├── QualityMeasure.cs.meta │ │ │ │ ├── Statistic.cs │ │ │ │ ├── Statistic.cs.meta │ │ │ │ ├── TriangleQuadTree.cs │ │ │ │ ├── TriangleQuadTree.cs.meta │ │ │ │ ├── VertexSorter.cs │ │ │ │ └── VertexSorter.cs.meta │ │ │ ├── Topology.meta │ │ │ ├── Topology │ │ │ │ ├── DCEL.meta │ │ │ │ ├── DCEL │ │ │ │ │ ├── DcelMesh.cs │ │ │ │ │ ├── DcelMesh.cs.meta │ │ │ │ │ ├── Face.cs │ │ │ │ │ ├── Face.cs.meta │ │ │ │ │ ├── HalfEdge.cs │ │ │ │ │ ├── HalfEdge.cs.meta │ │ │ │ │ ├── Vertex.cs │ │ │ │ │ └── Vertex.cs.meta │ │ │ │ ├── Osub.cs │ │ │ │ ├── Osub.cs.meta │ │ │ │ ├── Otri.cs │ │ │ │ ├── Otri.cs.meta │ │ │ │ ├── SubSegment.cs │ │ │ │ ├── SubSegment.cs.meta │ │ │ │ ├── Triangle.cs │ │ │ │ └── Triangle.cs.meta │ │ │ ├── TriangleLocator.cs │ │ │ ├── TriangleLocator.cs.meta │ │ │ ├── TriangleNetMesh.cs │ │ │ ├── TriangleNetMesh.cs.meta │ │ │ ├── TrianglePool.cs │ │ │ ├── TrianglePool.cs.meta │ │ │ ├── TriangleSampler.cs │ │ │ ├── TriangleSampler.cs.meta │ │ │ ├── Voronoi.meta │ │ │ └── Voronoi │ │ │ │ ├── BoundedVoronoi.cs │ │ │ │ ├── BoundedVoronoi.cs.meta │ │ │ │ ├── DefaultVoronoiFactory.cs │ │ │ │ ├── DefaultVoronoiFactory.cs.meta │ │ │ │ ├── IVoronoiFactory.cs │ │ │ │ ├── IVoronoiFactory.cs.meta │ │ │ │ ├── Legacy.meta │ │ │ │ ├── Legacy │ │ │ │ ├── BoundedVoronoiLegacy.cs │ │ │ │ ├── BoundedVoronoiLegacy.cs.meta │ │ │ │ ├── IVoronoi.cs │ │ │ │ ├── IVoronoi.cs.meta │ │ │ │ ├── SimpleVoronoi.cs │ │ │ │ ├── SimpleVoronoi.cs.meta │ │ │ │ ├── VoronoiRegion.cs │ │ │ │ └── VoronoiRegion.cs.meta │ │ │ │ ├── StandardVoronoi.cs │ │ │ │ ├── StandardVoronoi.cs.meta │ │ │ │ ├── VoronoiBase.cs │ │ │ │ └── VoronoiBase.cs.meta │ │ ├── UnityExtentions.cs │ │ └── UnityExtentions.cs.meta │ ├── nox7atra.triangle.net.asmdef │ └── nox7atra.triangle.net.asmdef.meta │ ├── Tests.meta │ ├── Tests │ ├── Resources.meta │ ├── Resources │ │ ├── MeshDrawer.meta │ │ └── MeshDrawer │ │ │ ├── ContourMaterial.mat │ │ │ ├── ContourMaterial.mat.meta │ │ │ ├── DemoMat.mat │ │ │ ├── DemoMat.mat.meta │ │ │ ├── HoleMat.mat │ │ │ ├── HoleMat.mat.meta │ │ │ ├── TexturesCom_Brick_Modern_512_albedo.tif │ │ │ └── TexturesCom_Brick_Modern_512_albedo.tif.meta │ ├── Scenes.meta │ ├── Scenes │ │ ├── MeshDrawer.unity │ │ └── MeshDrawer.unity.meta │ ├── Scripts.meta │ ├── Scripts │ │ ├── MathUtils.cs │ │ ├── MathUtils.cs.meta │ │ ├── MeshDrawer.meta │ │ ├── MeshDrawer │ │ │ ├── MeshDrawer.cs │ │ │ └── MeshDrawer.cs.meta │ │ ├── TriangulationTest.cs │ │ └── TriangulationTest.cs.meta │ ├── nox7atra.triangle.net.Tests.asmdef │ └── nox7atra.triangle.net.Tests.asmdef.meta │ ├── package.json │ └── package.json.meta ├── Logs └── ApiUpdaterCheck.txt ├── Packages ├── manifest.json └── packages-lock.json ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NetworkManager.asset ├── PackageManagerSettings.asset ├── Physics2DSettings.asset ├── PresetManager.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset ├── UnityConnectSettings.asset ├── VFXManager.asset └── VersionControlSettings.asset ├── README.md └── UserSettings └── EditorUserSettings.asset /.gitignore: -------------------------------------------------------------------------------- 1 | /[Ll]ibrary/ 2 | /[Tt]emp/ 3 | /[Oo]bj/ 4 | /[Bb]uild/ 5 | /[Bb]uilds/ 6 | 7 | # Exclude 3rd party libraries installed from the assets store 8 | [Aa]ssets/Asset Store Resources/ 9 | 10 | # Some asset tools can't be moved so need to explicitly 11 | /Assets/TextMesh Pro* 12 | 13 | # Exclude rider idea data 14 | .idea 15 | 16 | # Autogenerated VS/MD/Consulo solution and project files 17 | ExportedObj/ 18 | .consulo/ 19 | *.csproj 20 | *.unityproj 21 | *.sln 22 | *.suo 23 | *.tmp 24 | *.user 25 | *.userprefs 26 | *.pidb 27 | *.booproj 28 | *.svd 29 | *.pdb 30 | 31 | 32 | # Unity3D generated meta files 33 | *.pidb.meta 34 | 35 | # Unity3D Generated File On Crash Reports 36 | sysinfo.txt 37 | 38 | # Builds 39 | *.apk 40 | *.unitypackage 41 | *.gif 42 | Assets/AssetStoreTools* 43 | -------------------------------------------------------------------------------- /Assets/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5a5d4654212007f4fb369d74ca69ab4e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Resources/BillingMode.json: -------------------------------------------------------------------------------- 1 | {"androidStore":"GooglePlay"} -------------------------------------------------------------------------------- /Assets/Resources/BillingMode.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f7895fb4fbdae684ba835f2d7f1f29a7 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/TriangleNet.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a29fc23b148c3db4a8f4292dbf9f340e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangleNet/LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Grygory Dyadichenko 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Assets/TriangleNet/LICENSE.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 75c27f0c9fec78e4091b7e6caa3c14bd 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a32a0ad438fd569418ab91130f423b41 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 240bd5cc3d2fa794d9a163411d2d4339 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7cc5c306aa897904da9e59d155d605c5 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Behavior.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b5ba34055b8bd56409486bda75a016db 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Configuration.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace TriangleNet 8 | { 9 | using System; 10 | using TriangleNet.Meshing; 11 | using TriangleNet.Meshing.Algorithm; 12 | 13 | /// 14 | /// Configure advanced aspects of the library. 15 | /// 16 | public class Configuration 17 | { 18 | public Configuration() 19 | : this(() => RobustPredicates.Default, () => new TrianglePool()) 20 | { 21 | } 22 | 23 | public Configuration(Func predicates) 24 | : this(predicates, () => new TrianglePool()) 25 | { 26 | } 27 | 28 | public Configuration(Func predicates, Func trianglePool) 29 | { 30 | Predicates = predicates; 31 | TrianglePool = trianglePool; 32 | } 33 | 34 | /// 35 | /// Gets or sets the factory method for the implementation. 36 | /// 37 | public Func Predicates { get; set; } 38 | 39 | /// 40 | /// Gets or sets the factory method for the . 41 | /// 42 | public Func TrianglePool { get; set; } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Configuration.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d28fee55d1ed60d42b22fc97f2a44c97 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Enums.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Original Triangle code by Jonathan Richard Shewchuk, http://www.cs.cmu.edu/~quake/triangle.html 4 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | namespace TriangleNet 9 | { 10 | /// 11 | /// The type of the mesh vertex. 12 | /// 13 | public enum VertexType { InputVertex, SegmentVertex, FreeVertex, DeadVertex, UndeadVertex }; 14 | 15 | /// 16 | /// Node renumbering algorithms. 17 | /// 18 | public enum NodeNumbering { None, Linear, CuthillMcKee }; 19 | 20 | /// 21 | /// Labels that signify the result of point location. 22 | /// 23 | /// The result of a search indicates that the point falls in the 24 | /// interior of a triangle, on an edge, on a vertex, or outside the mesh. 25 | /// 26 | public enum LocateResult { InTriangle, OnEdge, OnVertex, Outside }; 27 | 28 | /// 29 | /// Labels that signify the result of vertex insertion. 30 | /// 31 | /// The result indicates that the vertex was inserted with complete 32 | /// success, was inserted but encroaches upon a subsegment, was not inserted 33 | /// because it lies on a segment, or was not inserted because another vertex 34 | /// occupies the same location. 35 | /// 36 | enum InsertVertexResult { Successful, Encroaching, Violating, Duplicate }; 37 | 38 | /// 39 | /// Labels that signify the result of direction finding. 40 | /// 41 | /// The result indicates that a segment connecting the two query 42 | /// points falls within the direction triangle, along the left edge of the 43 | /// direction triangle, or along the right edge of the direction triangle. 44 | /// 45 | enum FindDirectionResult { Within, Leftcollinear, Rightcollinear }; 46 | } 47 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Enums.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 73e0d05da73e0ed478dfb2090d8ce6ec 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Geometry.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7bd8f64ee18078f4987e3f59c57cab3d 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Geometry/Contour.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 39d5f0ea53da9394bbdcac0ae727ccba 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Geometry/Edge.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace TriangleNet.Geometry 8 | { 9 | /// 10 | /// Represents a straight line segment in 2D space. 11 | /// 12 | public class Edge : IEdge 13 | { 14 | /// 15 | /// Gets the first endpoints index. 16 | /// 17 | public int P0 18 | { 19 | get; 20 | private set; 21 | } 22 | 23 | /// 24 | /// Gets the second endpoints index. 25 | /// 26 | public int P1 27 | { 28 | get; 29 | private set; 30 | } 31 | 32 | /// 33 | /// Gets the segments boundary mark. 34 | /// 35 | public int Label 36 | { 37 | get; 38 | private set; 39 | } 40 | 41 | /// 42 | /// Initializes a new instance of the class. 43 | /// 44 | public Edge(int p0, int p1) 45 | : this(p0, p1, 0) 46 | { } 47 | 48 | /// 49 | /// Initializes a new instance of the class. 50 | /// 51 | public Edge(int p0, int p1, int label) 52 | { 53 | this.P0 = p0; 54 | this.P1 = p1; 55 | this.Label = label; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Geometry/Edge.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 89b903145d9b3ef4e95fd61b2d7acd71 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Geometry/ExtensionMethods.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace TriangleNet.Geometry 3 | { 4 | using System; 5 | using TriangleNet.Meshing; 6 | 7 | public static class ExtensionMethods 8 | { 9 | #region IPolygon extensions 10 | 11 | /// 12 | /// Triangulates a polygon. 13 | /// 14 | public static IMesh Triangulate(this IPolygon polygon) 15 | { 16 | return (new GenericMesher()).Triangulate(polygon, null, null); 17 | } 18 | 19 | /// 20 | /// Triangulates a polygon, applying constraint options. 21 | /// 22 | /// Constraint options. 23 | public static IMesh Triangulate(this IPolygon polygon, ConstraintOptions options) 24 | { 25 | return (new GenericMesher()).Triangulate(polygon, options, null); 26 | } 27 | 28 | /// 29 | /// Triangulates a polygon, applying quality options. 30 | /// 31 | /// Quality options. 32 | public static IMesh Triangulate(this IPolygon polygon, QualityOptions quality) 33 | { 34 | return (new GenericMesher()).Triangulate(polygon, null, quality); 35 | } 36 | 37 | /// 38 | /// Triangulates a polygon, applying quality and constraint options. 39 | /// 40 | /// Constraint options. 41 | /// Quality options. 42 | public static IMesh Triangulate(this IPolygon polygon, ConstraintOptions options, QualityOptions quality) 43 | { 44 | return (new GenericMesher()).Triangulate(polygon, options, quality); 45 | } 46 | 47 | /// 48 | /// Triangulates a polygon, applying quality and constraint options. 49 | /// 50 | /// Constraint options. 51 | /// Quality options. 52 | /// The triangulation algorithm. 53 | public static IMesh Triangulate(this IPolygon polygon, ConstraintOptions options, QualityOptions quality, 54 | ITriangulator triangulator) 55 | { 56 | return (new GenericMesher(triangulator)).Triangulate(polygon, options, quality); 57 | } 58 | 59 | #endregion 60 | 61 | #region Rectangle extensions 62 | 63 | #endregion 64 | 65 | #region ITriangle extensions 66 | 67 | /// 68 | /// Test whether a given point lies inside a triangle or not. 69 | /// 70 | /// Point to locate. 71 | /// True, if point is inside or on the edge of this triangle. 72 | public static bool Contains(this ITriangle triangle, Point p) 73 | { 74 | return Contains(triangle, p.X, p.Y); 75 | } 76 | 77 | /// 78 | /// Test whether a given point lies inside a triangle or not. 79 | /// 80 | /// Point to locate. 81 | /// Point to locate. 82 | /// True, if point is inside or on the edge of this triangle. 83 | public static bool Contains(this ITriangle triangle, float x, float y) 84 | { 85 | var t0 = triangle.GetVertex(0); 86 | var t1 = triangle.GetVertex(1); 87 | var t2 = triangle.GetVertex(2); 88 | 89 | // TODO: no need to create new Point instances here 90 | Point d0 = new Point(t1.X - t0.X, t1.Y - t0.Y); 91 | Point d1 = new Point(t2.X - t0.X, t2.Y - t0.Y); 92 | Point d2 = new Point(x - t0.X, y - t0.Y); 93 | 94 | // crossproduct of (0, 0, 1) and d0 95 | Point c0 = new Point(-d0.Y, d0.X); 96 | 97 | // crossproduct of (0, 0, 1) and d1 98 | Point c1 = new Point(-d1.Y, d1.X); 99 | 100 | // Linear combination d2 = s * d0 + v * d1. 101 | // 102 | // Multiply both sides of the equation with c0 and c1 103 | // and solve for s and v respectively 104 | // 105 | // s = d2 * c1 / d0 * c1 106 | // v = d2 * c0 / d1 * c0 107 | 108 | float s = DotProduct(d2, c1) / DotProduct(d0, c1); 109 | float v = DotProduct(d2, c0) / DotProduct(d1, c0); 110 | 111 | if (s >= 0 && v >= 0 && ((s + v) <= 1)) 112 | { 113 | // Point is inside or on the edge of this triangle. 114 | return true; 115 | } 116 | 117 | return false; 118 | } 119 | 120 | public static Rectangle Bounds(this ITriangle triangle) 121 | { 122 | var bounds = new Rectangle(); 123 | 124 | for (int i = 0; i < 3; i++) 125 | { 126 | bounds.Expand(triangle.GetVertex(i)); 127 | } 128 | 129 | return bounds; 130 | } 131 | 132 | #endregion 133 | 134 | #region Helper methods 135 | 136 | internal static float DotProduct(Point p, Point q) 137 | { 138 | return p.X * q.X + p.Y * q.Y; 139 | } 140 | 141 | #endregion 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Geometry/ExtensionMethods.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 590c8d2df75488540b7dfbf1324b14e1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Geometry/IEdge.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace TriangleNet.Geometry 8 | { 9 | public interface IEdge 10 | { 11 | /// 12 | /// Gets the first endpoints index. 13 | /// 14 | int P0 { get; } 15 | 16 | /// 17 | /// Gets the second endpoints index. 18 | /// 19 | int P1 { get; } 20 | 21 | /// 22 | /// Gets or sets a general-purpose label. 23 | /// 24 | /// 25 | /// This is used for the segments boundary mark. 26 | /// 27 | int Label { get; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Geometry/IEdge.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 365cba7859cc82e4da5b6e81acf6747b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Geometry/IPolygon.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace TriangleNet.Geometry 8 | { 9 | using System; 10 | using System.Collections.Generic; 11 | 12 | /// 13 | /// Polygon interface. 14 | /// 15 | public interface IPolygon 16 | { 17 | /// 18 | /// Gets the vertices of the polygon. 19 | /// 20 | List Points { get; } 21 | 22 | /// 23 | /// Gets the segments of the polygon. 24 | /// 25 | List Segments { get; } 26 | 27 | /// 28 | /// Gets a list of points defining the holes of the polygon. 29 | /// 30 | List Holes { get; } 31 | 32 | /// 33 | /// Gets a list of pointers defining the regions of the polygon. 34 | /// 35 | List Regions { get; } 36 | 37 | /// 38 | /// Gets or sets a value indicating whether the vertices have marks or not. 39 | /// 40 | bool HasPointMarkers { get; set; } 41 | 42 | /// 43 | /// Gets or sets a value indicating whether the segments have marks or not. 44 | /// 45 | bool HasSegmentMarkers { get; set; } 46 | 47 | [Obsolete("Use polygon.Add(contour) method instead.")] 48 | void AddContour(IEnumerable points, int marker, bool hole, bool convex); 49 | 50 | [Obsolete("Use polygon.Add(contour) method instead.")] 51 | void AddContour(IEnumerable points, int marker, Point hole); 52 | 53 | /// 54 | /// Compute the bounds of the polygon. 55 | /// 56 | /// Rectangle defining an axis-aligned bounding box. 57 | Rectangle Bounds(); 58 | 59 | /// 60 | /// Add a vertex to the polygon. 61 | /// 62 | /// The vertex to insert. 63 | void Add(Vertex vertex); 64 | 65 | /// 66 | /// Add a segment to the polygon. 67 | /// 68 | /// The segment to insert. 69 | /// If true, both endpoints will be added to the points list. 70 | void Add(ISegment segment, bool insert = false); 71 | 72 | /// 73 | /// Add a segment to the polygon. 74 | /// 75 | /// The segment to insert. 76 | /// The index of the segment endpoint to add to the points list (must be 0 or 1). 77 | void Add(ISegment segment, int index); 78 | 79 | /// 80 | /// Add a contour to the polygon. 81 | /// 82 | /// The contour to insert. 83 | /// Treat contour as a hole. 84 | void Add(Contour contour, bool hole = false); 85 | 86 | /// 87 | /// Add a contour to the polygon. 88 | /// 89 | /// The contour to insert. 90 | /// Point inside the contour, making it a hole. 91 | void Add(Contour contour, Point hole); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Geometry/IPolygon.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d77db4c2de882ff4d9f3ccebfab89fb0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Geometry/ISegment.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace TriangleNet.Geometry 8 | { 9 | /// 10 | /// Interface for segment geometry. 11 | /// 12 | public interface ISegment : IEdge 13 | { 14 | /// 15 | /// Gets the vertex at given index. 16 | /// 17 | /// The local index (0 or 1). 18 | Vertex GetVertex(int index); 19 | 20 | /// 21 | /// Gets an adjoining triangle. 22 | /// 23 | /// The triangle index (0 or 1). 24 | ITriangle GetTriangle(int index); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Geometry/ISegment.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 43b41c01a75ff1f449e2fdef57accb5b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Geometry/ITriangle.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace TriangleNet.Geometry 8 | { 9 | using TriangleNet.Topology; 10 | 11 | /// 12 | /// Triangle interface. 13 | /// 14 | public interface ITriangle 15 | { 16 | /// 17 | /// Gets or sets the triangle ID. 18 | /// 19 | int ID { get; set; } 20 | 21 | /// 22 | /// Gets or sets a general-purpose label. 23 | /// 24 | /// 25 | /// This is used for region information. 26 | /// 27 | int Label { get; set; } 28 | 29 | /// 30 | /// Gets or sets the triangle area constraint. 31 | /// 32 | float Area { get; set; } 33 | 34 | /// 35 | /// Gets the vertex at given index. 36 | /// 37 | /// The local index (0, 1 or 2). 38 | /// The vertex. 39 | Vertex GetVertex(int index); 40 | 41 | /// 42 | /// Gets the ID of the vertex at given index. 43 | /// 44 | /// The local index (0, 1 or 2). 45 | /// The vertex ID. 46 | int GetVertexID(int index); 47 | 48 | /// 49 | /// Gets the neighbor triangle at given index. 50 | /// 51 | /// The local index (0, 1 or 2). 52 | /// The neighbor triangle. 53 | ITriangle GetNeighbor(int index); 54 | 55 | /// 56 | /// Gets the ID of the neighbor triangle at given index. 57 | /// 58 | /// The local index (0, 1 or 2). 59 | /// The neighbor triangle ID. 60 | int GetNeighborID(int index); 61 | 62 | /// 63 | /// Gets the segment at given index. 64 | /// 65 | /// The local index (0, 1 or 2). 66 | /// The segment. 67 | ISegment GetSegment(int index); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Geometry/ITriangle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: addbacaea19a128479e6708dbeae21d5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Geometry/Point.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | using UnityEngine; 8 | 9 | namespace TriangleNet.Geometry 10 | { 11 | using System; 12 | using System.Diagnostics; 13 | 14 | /// 15 | /// Represents a 2D point. 16 | /// 17 | #if USE_Z 18 | [DebuggerDisplay("ID {ID} [{X}, {Y}, {Z}]")] 19 | #else 20 | [DebuggerDisplay("ID {ID} [{X}, {Y}]")] 21 | #endif 22 | public class Point : IComparable, IEquatable 23 | { 24 | internal int id; 25 | internal int label; 26 | 27 | internal float x; 28 | internal float y; 29 | #if USE_Z 30 | internal float z; 31 | #endif 32 | 33 | public Point() 34 | : this(0.0f, 0.0f, 0) 35 | { 36 | } 37 | 38 | public Point(float x, float y) 39 | : this(x, y, 0) 40 | { 41 | } 42 | 43 | public Point(float x, float y, int label) 44 | { 45 | this.x = x; 46 | this.y = y; 47 | this.label = label; 48 | } 49 | 50 | #region Public properties 51 | 52 | /// 53 | /// Gets or sets the vertex id. 54 | /// 55 | public int ID 56 | { 57 | get { return this.id; } 58 | set { this.id = value; } 59 | } 60 | 61 | /// 62 | /// Gets or sets the vertex x coordinate. 63 | /// 64 | public float X 65 | { 66 | get { return this.x; } 67 | set { this.x = value; } 68 | } 69 | 70 | /// 71 | /// Gets or sets the vertex y coordinate. 72 | /// 73 | public float Y 74 | { 75 | get { return this.y; } 76 | set { this.y = value; } 77 | } 78 | 79 | #if USE_Z 80 | /// 81 | /// Gets or sets the vertex z coordinate. 82 | /// 83 | public float Z 84 | { 85 | get { return this.z; } 86 | set { this.z = value; } 87 | } 88 | #endif 89 | 90 | /// 91 | /// Gets or sets a general-purpose label. 92 | /// 93 | /// 94 | /// This is used for the vertex boundary mark. 95 | /// 96 | public int Label 97 | { 98 | get { return this.label; } 99 | set { this.label = value; } 100 | } 101 | 102 | #endregion 103 | 104 | #region Operator overloading / overriding Equals 105 | 106 | // Compare "Guidelines for Overriding Equals() and Operator ==" 107 | // http://msdn.microsoft.com/en-us/library/ms173147.aspx 108 | 109 | public static bool operator ==(Point a, Point b) 110 | { 111 | // If both are null, or both are same instance, return true. 112 | if (Object.ReferenceEquals(a, b)) 113 | { 114 | return true; 115 | } 116 | 117 | // If one is null, but not both, return false. 118 | if (((object)a == null) || ((object)b == null)) 119 | { 120 | return false; 121 | } 122 | 123 | return a.Equals(b); 124 | } 125 | 126 | public static bool operator !=(Point a, Point b) 127 | { 128 | return !(a == b); 129 | } 130 | 131 | public override bool Equals(object obj) 132 | { 133 | // If parameter is null return false. 134 | if (obj == null) 135 | { 136 | return false; 137 | } 138 | 139 | Point p = obj as Point; 140 | 141 | if ((object)p == null) 142 | { 143 | return false; 144 | } 145 | 146 | return (x == p.x) && (y == p.y); 147 | } 148 | 149 | public bool Equals(Point p) 150 | { 151 | // If vertex is null return false. 152 | if ((object)p == null) 153 | { 154 | return false; 155 | } 156 | 157 | // Return true if the fields match: 158 | return (x == p.x) && (y == p.y); 159 | } 160 | 161 | #endregion 162 | 163 | public int CompareTo(Point other) 164 | { 165 | if (x == other.x && y == other.y) 166 | { 167 | return 0; 168 | } 169 | 170 | return (x < other.x || (x == other.x && y < other.y)) ? -1 : 1; 171 | } 172 | 173 | public override int GetHashCode() 174 | { 175 | int hash = 19; 176 | hash = hash * 31 + x.GetHashCode(); 177 | hash = hash * 31 + y.GetHashCode(); 178 | 179 | return hash; 180 | } 181 | 182 | public static explicit operator Vector2(Point p) 183 | { 184 | return new Vector2(p.x, p.y); 185 | } 186 | public static explicit operator Vector3(Point p) 187 | { 188 | return new Vector3(p.x, p.y); 189 | } 190 | } 191 | } 192 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Geometry/Point.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 53076c53027b1e24bba4c47a39f222ce 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Geometry/Polygon.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5e452b77043913a45ad0586b357d254a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Geometry/Rectangle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9a2e53953ee3fcc44ac0d9b95f8c0dd1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Geometry/RegionPointer.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace TriangleNet.Geometry 8 | { 9 | using System; 10 | using System.Collections.Generic; 11 | 12 | /// 13 | /// Pointer to a region in the mesh geometry. A region is a well-defined 14 | /// subset of the geomerty (enclosed by subsegments). 15 | /// 16 | public class RegionPointer 17 | { 18 | internal Point point; 19 | internal int id; 20 | internal float area; 21 | 22 | /// 23 | /// Gets or sets a region area constraint. 24 | /// 25 | public float Area 26 | { 27 | get { return area; } 28 | set 29 | { 30 | if (value < 0.0f) 31 | { 32 | throw new ArgumentException("Area constraints must not be negative."); 33 | } 34 | area = value; 35 | } 36 | } 37 | 38 | /// 39 | /// Initializes a new instance of the class. 40 | /// 41 | /// X coordinate of the region. 42 | /// Y coordinate of the region. 43 | /// Region id. 44 | public RegionPointer(float x, float y, int id) 45 | : this(x, y, id, 0.0f) 46 | { 47 | } 48 | 49 | /// 50 | /// Initializes a new instance of the class. 51 | /// 52 | /// X coordinate of the region. 53 | /// Y coordinate of the region. 54 | /// Region id. 55 | /// Area constraint. 56 | public RegionPointer(float x, float y, int id, float area) 57 | { 58 | this.point = new Point(x, y); 59 | this.id = id; 60 | this.area = area; 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Geometry/RegionPointer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f8e28af8476432b4ca4534e34695eb9c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Geometry/Segment.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace TriangleNet.Geometry 8 | { 9 | using System; 10 | 11 | /// 12 | /// Represents a straight line segment in 2D space. 13 | /// 14 | public class Segment : ISegment 15 | { 16 | Vertex v0; 17 | Vertex v1; 18 | 19 | int label; 20 | 21 | /// 22 | /// Gets or sets the segments boundary mark. 23 | /// 24 | public int Label 25 | { 26 | get { return label; } 27 | set { label = value; } 28 | } 29 | /// 30 | /// Gets the first endpoints index. 31 | /// 32 | public int P0 33 | { 34 | get { return v0.id; } 35 | } 36 | 37 | /// 38 | /// Gets the second endpoints index. 39 | /// 40 | public int P1 41 | { 42 | get { return v1.id; } 43 | } 44 | 45 | /// 46 | /// Initializes a new instance of the class. 47 | /// 48 | public Segment(Vertex v0, Vertex v1) 49 | : this (v0, v1, 0) 50 | { 51 | } 52 | 53 | /// 54 | /// Initializes a new instance of the class. 55 | /// 56 | public Segment(Vertex v0, Vertex v1, int label) 57 | { 58 | this.v0 = v0; 59 | this.v1 = v1; 60 | 61 | this.label = label; 62 | } 63 | 64 | /// 65 | /// Gets the specified segment endpoint. 66 | /// 67 | /// The endpoint index (0 or 1). 68 | /// 69 | public Vertex GetVertex(int index) 70 | { 71 | if (index == 0) 72 | { 73 | return v0; 74 | } 75 | 76 | if (index == 1) 77 | { 78 | return v1; 79 | } 80 | 81 | throw new IndexOutOfRangeException(); 82 | } 83 | 84 | /// 85 | /// WARNING: not implemented. 86 | /// 87 | public ITriangle GetTriangle(int index) 88 | { 89 | throw new NotImplementedException(); 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Geometry/Segment.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c0cc3d9411c2cf0478eadf615249eaa5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Geometry/Vertex.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Original Triangle code by Jonathan Richard Shewchuk, http://www.cs.cmu.edu/~quake/triangle.html 4 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using System.Collections.Generic; 9 | using UnityEngine; 10 | 11 | namespace TriangleNet.Geometry 12 | { 13 | using System; 14 | using TriangleNet.Topology; 15 | 16 | /// 17 | /// The vertex data structure. 18 | /// 19 | public class Vertex : Point 20 | { 21 | // Hash for dictionary. Will be set by mesh instance. 22 | internal int hash; 23 | 24 | #if USE_ATTRIBS 25 | internal float[] attributes; 26 | #endif 27 | internal VertexType type; 28 | internal Otri tri; 29 | 30 | /// 31 | /// Initializes a new instance of the class. 32 | /// 33 | public Vertex() 34 | : this(0, 0, 0) 35 | { 36 | } 37 | 38 | /// 39 | /// Initializes a new instance of the class. 40 | /// 41 | /// The x coordinate of the vertex. 42 | /// The y coordinate of the vertex. 43 | public Vertex(float x, float y) 44 | : this(x, y, 0) 45 | { 46 | } 47 | 48 | /// 49 | /// Initializes a new instance of the class. 50 | /// 51 | /// The x coordinate of the vertex. 52 | /// The y coordinate of the vertex. 53 | /// The boundary mark. 54 | public Vertex(float x, float y, int mark) 55 | : base(x, y, mark) 56 | { 57 | this.type = VertexType.InputVertex; 58 | } 59 | 60 | #if USE_ATTRIBS 61 | /// 62 | /// Initializes a new instance of the class. 63 | /// 64 | /// The x coordinate of the vertex. 65 | /// The y coordinate of the vertex. 66 | /// The boundary mark. 67 | /// The number of point attributes. 68 | public Vertex(float x, float y, int mark, int attribs) 69 | : this(x, y, mark) 70 | { 71 | if (attribs > 0) 72 | { 73 | this.attributes = new float[attribs]; 74 | } 75 | } 76 | #endif 77 | 78 | #region Public properties 79 | 80 | #if USE_ATTRIBS 81 | /// 82 | /// Gets the vertex attributes (may be null). 83 | /// 84 | public float[] Attributes 85 | { 86 | get { return this.attributes; } 87 | } 88 | #endif 89 | 90 | /// 91 | /// Gets the vertex type. 92 | /// 93 | public VertexType Type 94 | { 95 | get { return this.type; } 96 | } 97 | 98 | /// 99 | /// Gets the specified coordinate of the vertex. 100 | /// 101 | /// Coordinate index. 102 | /// X coordinate, if index is 0, Y coordinate, if index is 1. 103 | public float this[int i] 104 | { 105 | get 106 | { 107 | if (i == 0) 108 | { 109 | return x; 110 | } 111 | 112 | if (i == 1) 113 | { 114 | return y; 115 | } 116 | 117 | throw new ArgumentOutOfRangeException("Index must be 0 or 1."); 118 | } 119 | } 120 | 121 | #endregion 122 | 123 | public override int GetHashCode() 124 | { 125 | return this.hash; 126 | } 127 | 128 | public static explicit operator Vector2(Vertex p) 129 | { 130 | return new Vector2(p.x, p.y); 131 | } 132 | public static explicit operator Vector3(Vertex p) 133 | { 134 | return new Vector3(p.x, p.y); 135 | } 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Geometry/Vertex.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a9a341e92d9e7ad41ab4b769a78710b9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/IO.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8590f746460b44945bed41c03a6742c3 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/IO/DebugWriter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d49a04308532d8c47b35cf9d39490284 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/IO/FileProcessor.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace TriangleNet.IO 8 | { 9 | using System; 10 | using System.Collections.Generic; 11 | using TriangleNet.Geometry; 12 | using TriangleNet.Meshing; 13 | 14 | public static class FileProcessor 15 | { 16 | static List formats; 17 | 18 | static FileProcessor() 19 | { 20 | formats = new List(); 21 | 22 | // Add Triangle file format as default. 23 | formats.Add(new TriangleFormat()); 24 | } 25 | 26 | public static void Add(IFileFormat format) 27 | { 28 | formats.Add(format); 29 | } 30 | 31 | public static bool IsSupported(string file) 32 | { 33 | foreach (var format in formats) 34 | { 35 | if (format.IsSupported(file)) 36 | { 37 | return true; 38 | } 39 | } 40 | 41 | return false; 42 | } 43 | 44 | #region Polygon read/write 45 | 46 | /// 47 | /// Read a file containing polygon geometry. 48 | /// 49 | /// The path of the file to read. 50 | /// An instance of the class. 51 | public static IPolygon Read(string filename) 52 | { 53 | foreach (IPolygonFormat format in formats) 54 | { 55 | if (format != null && format.IsSupported(filename)) 56 | { 57 | return format.Read(filename); 58 | } 59 | } 60 | 61 | throw new Exception("File format not supported."); 62 | } 63 | 64 | /// 65 | /// Save a polygon geometry to disk. 66 | /// 67 | /// An instance of the class. 68 | /// The path of the file to save. 69 | public static void Write(IPolygon polygon, string filename) 70 | { 71 | foreach (IPolygonFormat format in formats) 72 | { 73 | if (format != null && format.IsSupported(filename)) 74 | { 75 | format.Write(polygon, filename); 76 | return; 77 | } 78 | } 79 | 80 | throw new Exception("File format not supported."); 81 | } 82 | 83 | #endregion 84 | 85 | #region Mesh read/write 86 | 87 | /// 88 | /// Read a file containing a mesh. 89 | /// 90 | /// The path of the file to read. 91 | /// An instance of the interface. 92 | public static IMesh Import(string filename) 93 | { 94 | foreach (IMeshFormat format in formats) 95 | { 96 | if (format != null && format.IsSupported(filename)) 97 | { 98 | return format.Import(filename); 99 | } 100 | } 101 | 102 | throw new Exception("File format not supported."); 103 | } 104 | 105 | /// 106 | /// Save a mesh to disk. 107 | /// 108 | /// An instance of the interface. 109 | /// The path of the file to save. 110 | public static void Write(IMesh mesh, string filename) 111 | { 112 | foreach (IMeshFormat format in formats) 113 | { 114 | if (format != null && format.IsSupported(filename)) 115 | { 116 | format.Write(mesh, filename); 117 | return; 118 | } 119 | } 120 | 121 | throw new Exception("File format not supported."); 122 | } 123 | 124 | #endregion 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/IO/FileProcessor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3ea4211b9151b6c4eb40b4ca68e2f3cf 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/IO/IFileFormat.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace TriangleNet.IO 8 | { 9 | public interface IFileFormat 10 | { 11 | bool IsSupported(string file); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/IO/IFileFormat.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bc04d72ec2e070e448d4d7889e9bec72 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/IO/IMeshFormat.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace TriangleNet.IO 8 | { 9 | using System.IO; 10 | using TriangleNet.Meshing; 11 | 12 | /// 13 | /// Interface for mesh I/O. 14 | /// 15 | public interface IMeshFormat : IFileFormat 16 | { 17 | /// 18 | /// Read a file containing a mesh. 19 | /// 20 | /// The path of the file to read. 21 | /// An instance of the interface. 22 | IMesh Import(string filename); 23 | 24 | /// 25 | /// Save a mesh to disk. 26 | /// 27 | /// An instance of the interface. 28 | /// The path of the file to save. 29 | void Write(IMesh mesh, string filename); 30 | 31 | /// 32 | /// Save a mesh to a . 33 | /// 34 | /// An instance of the interface. 35 | /// The stream to save to. 36 | void Write(IMesh mesh, Stream stream); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/IO/IMeshFormat.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 572128b7c2f2888418d4652d822adc1b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/IO/IPolygonFormat.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace TriangleNet.IO 8 | { 9 | using System.IO; 10 | using TriangleNet.Geometry; 11 | 12 | /// 13 | /// Interface for geometry input. 14 | /// 15 | public interface IPolygonFormat : IFileFormat 16 | { 17 | /// 18 | /// Read a file containing polygon geometry. 19 | /// 20 | /// The path of the file to read. 21 | /// An instance of the class. 22 | IPolygon Read(string filename); 23 | 24 | /// 25 | /// Save a polygon geometry to disk. 26 | /// 27 | /// An instance of the class. 28 | /// The path of the file to save. 29 | void Write(IPolygon polygon, string filename); 30 | 31 | /// 32 | /// Save a polygon geometry to a . 33 | /// 34 | /// An instance of the class. 35 | /// The stream to save to. 36 | void Write(IPolygon polygon, Stream stream); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/IO/IPolygonFormat.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 82492ade37de50747b2bcb6a1d39c846 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/IO/InputTriangle.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace TriangleNet.IO 8 | { 9 | using TriangleNet.Topology; 10 | using TriangleNet.Geometry; 11 | 12 | /// 13 | /// Simple triangle class for input. 14 | /// 15 | public class InputTriangle : ITriangle 16 | { 17 | internal int[] vertices; 18 | internal int label; 19 | internal float area; 20 | 21 | public InputTriangle(int p0, int p1, int p2) 22 | { 23 | this.vertices = new int[] { p0, p1, p2 }; 24 | } 25 | 26 | #region Public properties 27 | 28 | /// 29 | /// Gets the triangle id. 30 | /// 31 | public int ID 32 | { 33 | get { return 0; } 34 | set { } 35 | } 36 | 37 | /// 38 | /// Region ID the triangle belongs to. 39 | /// 40 | public int Label 41 | { 42 | get { return label; } 43 | set { label = value; } 44 | } 45 | 46 | /// 47 | /// Gets the triangle area constraint. 48 | /// 49 | public float Area 50 | { 51 | get { return area; } 52 | set { area = value; } 53 | } 54 | 55 | /// 56 | /// Gets the specified corners vertex. 57 | /// 58 | public Vertex GetVertex(int index) 59 | { 60 | return null; // TODO: throw NotSupportedException? 61 | } 62 | 63 | public int GetVertexID(int index) 64 | { 65 | return vertices[index]; 66 | } 67 | 68 | public ITriangle GetNeighbor(int index) 69 | { 70 | return null; 71 | } 72 | 73 | public int GetNeighborID(int index) 74 | { 75 | return -1; 76 | } 77 | 78 | public ISegment GetSegment(int index) 79 | { 80 | return null; 81 | } 82 | 83 | #endregion 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/IO/InputTriangle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b9ca263b6038e7c4380e83be00019012 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/IO/TriangleFormat.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace TriangleNet.IO 8 | { 9 | using System; 10 | using System.Collections.Generic; 11 | using System.IO; 12 | using TriangleNet.Geometry; 13 | using TriangleNet.Meshing; 14 | 15 | /// 16 | /// Implements geometry and mesh file formats of the the original Triangle code. 17 | /// 18 | public class TriangleFormat : IPolygonFormat, IMeshFormat 19 | { 20 | public bool IsSupported(string file) 21 | { 22 | string ext = Path.GetExtension(file).ToLower(); 23 | 24 | if (ext == ".node" || ext == ".poly" || ext == ".ele") 25 | { 26 | return true; 27 | } 28 | 29 | return false; 30 | } 31 | 32 | public IMesh Import(string filename) 33 | { 34 | string ext = Path.GetExtension(filename); 35 | 36 | if (ext == ".node" || ext == ".poly" || ext == ".ele") 37 | { 38 | List triangles; 39 | Polygon geometry; 40 | 41 | (new TriangleReader()).Read(filename, out geometry, out triangles); 42 | 43 | if (geometry != null && triangles != null) 44 | { 45 | return Converter.ToMesh(geometry, triangles.ToArray()); 46 | } 47 | } 48 | 49 | throw new NotSupportedException("Could not load '" + filename + "' file."); 50 | } 51 | 52 | public void Write(IMesh mesh, string filename) 53 | { 54 | var writer = new TriangleWriter(); 55 | 56 | writer.WritePoly((TriangleNetMesh)mesh, Path.ChangeExtension(filename, ".poly")); 57 | writer.WriteElements((TriangleNetMesh)mesh, Path.ChangeExtension(filename, ".ele")); 58 | } 59 | 60 | public void Write(IMesh mesh, Stream stream) 61 | { 62 | throw new NotImplementedException(); 63 | } 64 | 65 | public IPolygon Read(string filename) 66 | { 67 | string ext = Path.GetExtension(filename); 68 | 69 | if (ext == ".node") 70 | { 71 | return (new TriangleReader()).ReadNodeFile(filename); 72 | } 73 | else if (ext == ".poly") 74 | { 75 | return (new TriangleReader()).ReadPolyFile(filename); 76 | } 77 | 78 | throw new NotSupportedException("File format '" + ext + "' not supported."); 79 | } 80 | 81 | 82 | public void Write(IPolygon polygon, string filename) 83 | { 84 | (new TriangleWriter()).WritePoly(polygon, filename); 85 | } 86 | 87 | public void Write(IPolygon polygon, Stream stream) 88 | { 89 | throw new NotImplementedException(); 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/IO/TriangleFormat.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 52396cdb5a7ffbf4280326928cef46d6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/IO/TriangleReader.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8611f9dd61b2124488d9e7c60a44b84b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/IO/TriangleWriter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9e29e9f9bf6de9548922d7f8eb233d85 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/IPredicates.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace TriangleNet 8 | { 9 | using TriangleNet.Geometry; 10 | 11 | public interface IPredicates 12 | { 13 | float CounterClockwise(Point a, Point b, Point c); 14 | 15 | float InCircle(Point a, Point b, Point c, Point p); 16 | 17 | Point FindCircumcenter(Point org, Point dest, Point apex, ref float xi, ref float eta); 18 | 19 | Point FindCircumcenter(Point org, Point dest, Point apex, ref float xi, ref float eta, 20 | float offconstant); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/IPredicates.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2dc186932d18b88489f2820a8e70d335 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Log.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace TriangleNet 8 | { 9 | using System.Collections.Generic; 10 | using TriangleNet.Logging; 11 | 12 | /// 13 | /// A simple logger, which logs messages to a List. 14 | /// 15 | /// Using singleton pattern as proposed by Jon Skeet. 16 | /// http://csharpindepth.com/Articles/General/Singleton.aspx 17 | /// 18 | public sealed class Log : ILog 19 | { 20 | /// 21 | /// Log detailed information. 22 | /// 23 | public static bool Verbose { get; set; } 24 | 25 | private List log = new List(); 26 | 27 | private LogLevel level = LogLevel.Info; 28 | 29 | #region Singleton pattern 30 | 31 | private static readonly Log instance = new Log(); 32 | 33 | // Explicit static constructor to tell C# compiler 34 | // not to mark type as beforefieldinit 35 | static Log() { } 36 | 37 | private Log() { } 38 | 39 | public static ILog Instance 40 | { 41 | get 42 | { 43 | return instance; 44 | } 45 | } 46 | 47 | #endregion 48 | 49 | public void Add(LogItem item) 50 | { 51 | log.Add(item); 52 | } 53 | 54 | public void Clear() 55 | { 56 | log.Clear(); 57 | } 58 | 59 | public void Info(string message) 60 | { 61 | log.Add(new LogItem(LogLevel.Info, message)); 62 | } 63 | 64 | public void Warning(string message, string location) 65 | { 66 | log.Add(new LogItem(LogLevel.Warning, message, location)); 67 | } 68 | 69 | public void Error(string message, string location) 70 | { 71 | log.Add(new LogItem(LogLevel.Error, message, location)); 72 | } 73 | 74 | public IList Data 75 | { 76 | get { return log; } 77 | } 78 | 79 | public LogLevel Level 80 | { 81 | get { return level; } 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Log.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dce71e5bf7c6d694eb0bcca08c366698 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Logging.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ea49d580a6d09384a88d072344fe892a 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Logging/ILog.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace TriangleNet.Logging 8 | { 9 | using System.Collections.Generic; 10 | 11 | public enum LogLevel 12 | { 13 | Info = 0, 14 | Warning = 1, 15 | Error = 2 16 | } 17 | 18 | /// 19 | /// A basic log interface. 20 | /// 21 | public interface ILog where T : ILogItem 22 | { 23 | void Add(T item); 24 | void Clear(); 25 | 26 | void Info(string message); 27 | void Error(string message, string info); 28 | void Warning(string message, string info); 29 | 30 | IList Data { get; } 31 | 32 | LogLevel Level { get; } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Logging/ILog.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 52d292e15b16969459815660885f52d0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Logging/ILogItem.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace TriangleNet.Logging 8 | { 9 | using System; 10 | 11 | /// 12 | /// A basic log item interface. 13 | /// 14 | public interface ILogItem 15 | { 16 | DateTime Time { get; } 17 | LogLevel Level { get; } 18 | string Message { get; } 19 | string Info { get; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Logging/ILogItem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ea9be4d2b8363c849a58795b2f954514 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Logging/LogItem.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace TriangleNet.Logging 8 | { 9 | using System; 10 | 11 | /// 12 | /// Represents an item stored in the log. 13 | /// 14 | public class LogItem : ILogItem 15 | { 16 | DateTime time; 17 | LogLevel level; 18 | string message; 19 | string info; 20 | 21 | public DateTime Time 22 | { 23 | get { return time; } 24 | } 25 | 26 | public LogLevel Level 27 | { 28 | get { return level; } 29 | } 30 | 31 | public string Message 32 | { 33 | get { return message; } 34 | } 35 | 36 | public string Info 37 | { 38 | get { return info; } 39 | } 40 | 41 | public LogItem(LogLevel level, string message) 42 | : this(level, message, "") 43 | { } 44 | 45 | public LogItem(LogLevel level, string message, string info) 46 | { 47 | this.time = DateTime.Now; 48 | this.level = level; 49 | this.message = message; 50 | this.info = info; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Logging/LogItem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0c330ea092eac7e4781d9fb8a001b8f3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/MeshValidator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b068cd9bff62a644c80c7f5946ca7714 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 458ea82b6f9e94e47b89321387f241cb 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/Algorithm.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 61b92884ff1472e4eab6c6f8b578e8cb 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/Algorithm/Dwyer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c5f026404f083c4eb73f68eefa79221 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/Algorithm/Incremental.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d38b62eaed049b04bac4638caa6e987a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/Algorithm/SweepLine.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 253d7a93887d90047ae045a4062899c9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/ConstraintMesher.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 19a62e034c3d03741bb4688bdcf5945e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/ConstraintOptions.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace TriangleNet.Meshing 3 | { 4 | /// 5 | /// Mesh constraint options for polygon triangulation. 6 | /// 7 | public class ConstraintOptions 8 | { 9 | // TODO: remove ConstraintOptions.UseRegions 10 | 11 | /// 12 | /// Gets or sets a value indicating whether to use regions. 13 | /// 14 | [System.Obsolete("Not used anywhere, will be removed in beta 4.")] 15 | public bool UseRegions { get; set; } 16 | 17 | /// 18 | /// Gets or sets a value indicating whether to create a Conforming 19 | /// Delaunay triangulation. 20 | /// 21 | public bool ConformingDelaunay { get; set; } 22 | 23 | /// 24 | /// Gets or sets a value indicating whether to enclose the convex 25 | /// hull with segments. 26 | /// 27 | public bool Convex { get; set; } 28 | 29 | /// 30 | /// Gets or sets a flag indicating whether to suppress boundary 31 | /// segment splitting. 32 | /// 33 | /// 34 | /// 0 = split segments (default) 35 | /// 1 = no new vertices on the boundary 36 | /// 2 = prevent all segment splitting, including internal boundaries 37 | /// 38 | public int SegmentSplitting { get; set; } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/ConstraintOptions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 99c7d622c177d394f81d58f545f9d6a9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/Converter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b53c642967a40aa48b95578acaab2058 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/Data.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 61cfee9c8c83ae8469eb8a5ad7fbec54 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/Data/BadSubseg.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Original Triangle code by Jonathan Richard Shewchuk, http://www.cs.cmu.edu/~quake/triangle.html 4 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | namespace TriangleNet.Meshing.Data 9 | { 10 | using System; 11 | using TriangleNet.Geometry; 12 | using TriangleNet.Topology; 13 | 14 | /// 15 | /// A queue used to store encroached subsegments. 16 | /// 17 | /// 18 | /// Each subsegment's vertices are stored so that we can check whether a 19 | /// subsegment is still the same. 20 | /// 21 | class BadSubseg 22 | { 23 | public Osub subseg; // An encroached subsegment. 24 | public Vertex org, dest; // Its two vertices. 25 | 26 | public override int GetHashCode() 27 | { 28 | return subseg.seg.hash; 29 | } 30 | 31 | public override string ToString() 32 | { 33 | return String.Format("B-SID {0}", subseg.seg.hash); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/Data/BadSubseg.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ff0cbe47d09ae1040861c63eb1ab07aa 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/Data/BadTriQueue.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f43417350e04ff1458c4e2ea20f439b7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/Data/BadTriangle.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Original Triangle code by Jonathan Richard Shewchuk, http://www.cs.cmu.edu/~quake/triangle.html 4 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | namespace TriangleNet.Meshing.Data 9 | { 10 | using System; 11 | using TriangleNet.Geometry; 12 | using TriangleNet.Topology; 13 | 14 | /// 15 | /// A queue used to store bad triangles. 16 | /// 17 | /// 18 | /// The key is the square of the cosine of the smallest angle of the triangle. 19 | /// Each triangle's vertices are stored so that one can check whether a 20 | /// triangle is still the same. 21 | /// 22 | class BadTriangle 23 | { 24 | public Otri poortri; // A skinny or too-large triangle. 25 | public float key; // cos^2 of smallest (apical) angle. 26 | public Vertex org, dest, apex; // Its three vertices. 27 | public BadTriangle next; // Pointer to next bad triangle. 28 | 29 | public override string ToString() 30 | { 31 | return String.Format("B-TID {0}", poortri.tri.hash); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/Data/BadTriangle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f6bce406f0cc0a74c97849854523c67d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/GenericMesher.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4eee59ced7d14cc458ac904d6f666856 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/IConstraintMesher.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace TriangleNet.Meshing 3 | { 4 | using TriangleNet.Geometry; 5 | 6 | /// 7 | /// Interface for polygon triangulation. 8 | /// 9 | public interface IConstraintMesher 10 | { 11 | /// 12 | /// Triangulates a polygon. 13 | /// 14 | /// The polygon. 15 | /// Mesh 16 | IMesh Triangulate(IPolygon polygon); 17 | 18 | /// 19 | /// Triangulates a polygon, applying constraint options. 20 | /// 21 | /// The polygon. 22 | /// Constraint options. 23 | /// Mesh 24 | IMesh Triangulate(IPolygon polygon, ConstraintOptions options); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/IConstraintMesher.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6904108d859bfed4e9bd80ba92efba82 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/IMesh.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace TriangleNet.Meshing 3 | { 4 | using System.Collections.Generic; 5 | using TriangleNet.Topology; 6 | using TriangleNet.Geometry; 7 | 8 | /// 9 | /// Mesh interface. 10 | /// 11 | public interface IMesh 12 | { 13 | /// 14 | /// Gets the vertices of the mesh. 15 | /// 16 | ICollection Vertices { get; } 17 | 18 | /// 19 | /// Gets the edges of the mesh. 20 | /// 21 | IEnumerable Edges { get; } 22 | 23 | /// 24 | /// Gets the segments (constraint edges) of the mesh. 25 | /// 26 | ICollection Segments { get; } 27 | 28 | /// 29 | /// Gets the triangles of the mesh. 30 | /// 31 | ICollection Triangles { get; } 32 | 33 | /// 34 | /// Gets the holes of the mesh. 35 | /// 36 | IList Holes { get; } 37 | 38 | /// 39 | /// Gets the bounds of the mesh. 40 | /// 41 | Rectangle Bounds { get; } 42 | 43 | /// 44 | /// Renumber mesh vertices and triangles. 45 | /// 46 | void Renumber(); 47 | 48 | /// 49 | /// Refine the mesh. 50 | /// 51 | /// The quality constraints. 52 | /// 53 | /// A value indicating, if the refined mesh should be Conforming Delaunay. 54 | /// 55 | void Refine(QualityOptions quality, bool delaunay); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/IMesh.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8fbab63e986975c4ba322aea216fe95e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/IQualityMesher.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace TriangleNet.Meshing 3 | { 4 | using TriangleNet.Geometry; 5 | 6 | /// 7 | /// Interface for polygon triangulation with quality constraints. 8 | /// 9 | public interface IQualityMesher 10 | { 11 | /// 12 | /// Triangulates a polygon, applying quality options. 13 | /// 14 | /// The polygon. 15 | /// Quality options. 16 | /// Mesh 17 | IMesh Triangulate(IPolygon polygon, QualityOptions quality); 18 | 19 | /// 20 | /// Triangulates a polygon, applying quality and constraint options. 21 | /// 22 | /// The polygon. 23 | /// Constraint options. 24 | /// Quality options. 25 | /// Mesh 26 | IMesh Triangulate(IPolygon polygon, ConstraintOptions options, QualityOptions quality); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/IQualityMesher.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0bd3e5619a67ed44aacde8015a77de2b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/ITriangulator.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace TriangleNet.Meshing 8 | { 9 | using System.Collections.Generic; 10 | using TriangleNet.Geometry; 11 | 12 | /// 13 | /// Interface for point set triangulation. 14 | /// 15 | public interface ITriangulator 16 | { 17 | /// 18 | /// Triangulates a point set. 19 | /// 20 | /// Collection of points. 21 | /// 22 | /// Mesh 23 | IMesh Triangulate(IList points, Configuration config); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/ITriangulator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8a8808f41b8e42c4a813e27b92141859 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/Iterators.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 99c6794d4b8408c40a7686f6933b2374 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/Iterators/EdgeIterator.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace TriangleNet.Meshing.Iterators 8 | { 9 | using System.Collections.Generic; 10 | using TriangleNet.Topology; 11 | using TriangleNet.Geometry; 12 | 13 | /// 14 | /// Enumerates the edges of a triangulation. 15 | /// 16 | public class EdgeIterator : IEnumerator 17 | { 18 | IEnumerator triangles; 19 | Otri tri = default(Otri); 20 | Otri neighbor = default(Otri); 21 | Osub sub = default(Osub); 22 | Edge current; 23 | Vertex p1, p2; 24 | 25 | /// 26 | /// Initializes a new instance of the class. 27 | /// 28 | public EdgeIterator(TriangleNetMesh triangleNetMesh) 29 | { 30 | triangles = triangleNetMesh.triangles.GetEnumerator(); 31 | triangles.MoveNext(); 32 | 33 | tri.tri = triangles.Current; 34 | tri.orient = 0; 35 | } 36 | 37 | public Edge Current 38 | { 39 | get { return current; } 40 | } 41 | 42 | public void Dispose() 43 | { 44 | this.triangles.Dispose(); 45 | } 46 | 47 | object System.Collections.IEnumerator.Current 48 | { 49 | get { return current; } 50 | } 51 | 52 | public bool MoveNext() 53 | { 54 | if (tri.tri == null) 55 | { 56 | return false; 57 | } 58 | 59 | current = null; 60 | 61 | while (current == null) 62 | { 63 | if (tri.orient == 3) 64 | { 65 | if (triangles.MoveNext()) 66 | { 67 | tri.tri = triangles.Current; 68 | tri.orient = 0; 69 | } 70 | else 71 | { 72 | // Finally no more triangles 73 | return false; 74 | } 75 | } 76 | 77 | tri.Sym(ref neighbor); 78 | 79 | if ((tri.tri.id < neighbor.tri.id) || (neighbor.tri.id == TriangleNetMesh.DUMMY)) 80 | { 81 | p1 = tri.Org(); 82 | p2 = tri.Dest(); 83 | 84 | tri.Pivot(ref sub); 85 | 86 | // Boundary mark of dummysub is 0, so we don't need to worry about that. 87 | current = new Edge(p1.id, p2.id, sub.seg.boundary); 88 | } 89 | 90 | tri.orient++; 91 | } 92 | 93 | return true; 94 | } 95 | 96 | public void Reset() 97 | { 98 | this.triangles.Reset(); 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/Iterators/EdgeIterator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8bbed786eca6d8f40bd63601f9bc597a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/Iterators/RegionIterator.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Original Matlab code by John Burkardt, Florida State University 4 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | namespace TriangleNet.Meshing.Iterators 9 | { 10 | using System; 11 | using System.Collections.Generic; 12 | using TriangleNet.Topology; 13 | 14 | /// 15 | /// Iterates the region a given triangle belongs to and applies an action 16 | /// to each connected trianlge in that region. 17 | /// 18 | /// 19 | /// The default action is to set the region id and area constraint. 20 | /// 21 | public class RegionIterator 22 | { 23 | List region; 24 | 25 | public RegionIterator(TriangleNetMesh triangleNetMesh) 26 | { 27 | this.region = new List(); 28 | } 29 | 30 | /// 31 | /// Set the region attribute of all trianlges connected to given triangle. 32 | /// 33 | /// The triangle seed. 34 | /// If non-zero, process all triangles of the 35 | /// region that is enclosed by segments with given boundary label. 36 | public void Process(Triangle triangle, int boundary = 0) 37 | { 38 | this.Process(triangle, (tri) => 39 | { 40 | // Set the region id and area constraint. 41 | tri.label = triangle.label; 42 | tri.area = triangle.area; 43 | }, boundary); 44 | } 45 | 46 | /// 47 | /// Process all trianlges connected to given triangle and apply given action. 48 | /// 49 | /// The seeding triangle. 50 | /// The action to apply to each triangle. 51 | /// If non-zero, process all triangles of the 52 | /// region that is enclosed by segments with given boundary label. 53 | public void Process(Triangle triangle, Action action, int boundary = 0) 54 | { 55 | // Make sure the triangle under consideration still exists. 56 | // It may have been eaten by the virus. 57 | if (triangle.id == TriangleNetMesh.DUMMY || Otri.IsDead(triangle)) 58 | { 59 | return; 60 | } 61 | 62 | // Add the seeding triangle to the region. 63 | region.Add(triangle); 64 | 65 | triangle.infected = true; 66 | 67 | if (boundary == 0) 68 | { 69 | // Stop at any subsegment. 70 | ProcessRegion(action, seg => seg.hash == TriangleNetMesh.DUMMY); 71 | } 72 | else 73 | { 74 | // Stop at segments that have the given boundary label. 75 | ProcessRegion(action, seg => seg.boundary != boundary); 76 | } 77 | 78 | // Free up memory (virus pool should be empty anyway). 79 | region.Clear(); 80 | } 81 | 82 | /// 83 | /// Apply given action to each triangle of selected region. 84 | /// 85 | /// 86 | /// 87 | void ProcessRegion(Action action, Func protector) 88 | { 89 | Otri testtri = default(Otri); 90 | Otri neighbor = default(Otri); 91 | Osub neighborsubseg = default(Osub); 92 | 93 | // Loop through all the infected triangles, spreading the attribute 94 | // and/or area constraint to their neighbors, then to their neighbors' 95 | // neighbors. 96 | for (int i = 0; i < region.Count; i++) 97 | { 98 | // WARNING: Don't use foreach, viri list gets modified. 99 | 100 | testtri.tri = region[i]; 101 | 102 | // Apply function. 103 | action(testtri.tri); 104 | 105 | // Check each of the triangle's three neighbors. 106 | for (testtri.orient = 0; testtri.orient < 3; testtri.orient++) 107 | { 108 | // Find the neighbor. 109 | testtri.Sym(ref neighbor); 110 | // Check for a subsegment between the triangle and its neighbor. 111 | testtri.Pivot(ref neighborsubseg); 112 | // Make sure the neighbor exists, is not already infected, and 113 | // isn't protected by a subsegment. 114 | if ((neighbor.tri.id != TriangleNetMesh.DUMMY) && !neighbor.IsInfected() 115 | && protector(neighborsubseg.seg)) 116 | { 117 | // Infect the neighbor. 118 | neighbor.Infect(); 119 | // Ensure that the neighbor's neighbors will be infected. 120 | region.Add(neighbor.tri); 121 | } 122 | } 123 | } 124 | 125 | // Uninfect all triangles. 126 | foreach (var virus in region) 127 | { 128 | virus.infected = false; 129 | } 130 | 131 | // Empty the virus pool. 132 | region.Clear(); 133 | } 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/Iterators/RegionIterator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 820f0a950a0508d4e9dcff82e07baa74 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/Iterators/VertexCirculator.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace TriangleNet.Meshing.Iterators 3 | { 4 | using System.Collections.Generic; 5 | using TriangleNet.Geometry; 6 | using TriangleNet.Topology; 7 | 8 | public class VertexCirculator 9 | { 10 | List cache = new List(); 11 | 12 | public VertexCirculator(TriangleNetMesh triangleNetMesh) 13 | { 14 | triangleNetMesh.MakeVertexMap(); 15 | } 16 | 17 | /// 18 | /// Enumerate all vertices adjacent to given vertex. 19 | /// 20 | /// The center vertex. 21 | /// 22 | public IEnumerable EnumerateVertices(Vertex vertex) 23 | { 24 | BuildCache(vertex, true); 25 | 26 | foreach (var item in cache) 27 | { 28 | yield return item.Dest(); 29 | } 30 | } 31 | 32 | /// 33 | /// Enumerate all triangles adjacent to given vertex. 34 | /// 35 | /// The center vertex. 36 | /// 37 | public IEnumerable EnumerateTriangles(Vertex vertex) 38 | { 39 | BuildCache(vertex, false); 40 | 41 | foreach (var item in cache) 42 | { 43 | yield return item.tri; 44 | } 45 | } 46 | 47 | private void BuildCache(Vertex vertex, bool vertices) 48 | { 49 | cache.Clear(); 50 | 51 | Otri init = vertex.tri; 52 | Otri next = default(Otri); 53 | Otri prev = default(Otri); 54 | 55 | init.Copy(ref next); 56 | 57 | // Move counter-clockwise around the vertex. 58 | while (next.tri.id != TriangleNetMesh.DUMMY) 59 | { 60 | cache.Add(next); 61 | 62 | next.Copy(ref prev); 63 | next.Onext(); 64 | 65 | if (next.Equals(init)) 66 | { 67 | break; 68 | } 69 | } 70 | 71 | if (next.tri.id == TriangleNetMesh.DUMMY) 72 | { 73 | // We reached the boundary. To get all adjacent triangles, start 74 | // again at init triangle and now move clockwise. 75 | init.Copy(ref next); 76 | 77 | if (vertices) 78 | { 79 | // Don't forget to add the vertex lying on the boundary. 80 | prev.Lnext(); 81 | cache.Add(prev); 82 | } 83 | 84 | next.Oprev(); 85 | 86 | while (next.tri.id != TriangleNetMesh.DUMMY) 87 | { 88 | cache.Insert(0, next); 89 | 90 | next.Oprev(); 91 | 92 | if (next.Equals(init)) 93 | { 94 | break; 95 | } 96 | } 97 | } 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/Iterators/VertexCirculator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2743877aeac798143b076cb701a947ec 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/QualityMesher.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a714ce4cf31570e48bfd3b56664bfbeb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/QualityOptions.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace TriangleNet.Meshing 3 | { 4 | using System; 5 | using TriangleNet.Geometry; 6 | 7 | /// 8 | /// Mesh constraint options for quality triangulation. 9 | /// 10 | public class QualityOptions 11 | { 12 | /// 13 | /// Gets or sets a maximum angle constraint. 14 | /// 15 | public float MaximumAngle { get; set; } 16 | 17 | /// 18 | /// Gets or sets a minimum angle constraint. 19 | /// 20 | public float MinimumAngle { get; set; } 21 | 22 | /// 23 | /// Gets or sets a maximum triangle area constraint. 24 | /// 25 | public float MaximumArea { get; set; } 26 | 27 | /// 28 | /// Gets or sets a user-defined triangle constraint. 29 | /// 30 | /// 31 | /// The test function will be called for each triangle in the mesh. The 32 | /// second argument is the area of the triangle tested. If the function 33 | /// returns true, the triangle is considered bad and will be refined. 34 | /// 35 | public Func UserTest { get; set; } 36 | 37 | /// 38 | /// Gets or sets an area constraint per triangle. 39 | /// 40 | /// 41 | /// If this flag is set to true, the value will 42 | /// be used to check if a triangle needs refinement. 43 | /// 44 | public bool VariableArea { get; set; } 45 | 46 | /// 47 | /// Gets or sets the maximum number of Steiner points to be inserted into the mesh. 48 | /// 49 | /// 50 | /// If the value is 0 (default), an unknown number of Steiner points may be inserted 51 | /// to meet the other quality constraints. 52 | /// 53 | public int SteinerPoints { get; set; } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Meshing/QualityOptions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 82453d55a0fa55247a6f3d15ec871d05 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/NewLocation.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 071efafbb8e737d42adb604ad5b61982 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/RobustPredicates.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b05f7881e78cd5e4ab2b7ca375aced06 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Smoothing.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3157e5c1636acca41a43b1b0cbcd7ddd 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Smoothing/ISmoother.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace TriangleNet.Smoothing 8 | { 9 | using TriangleNet.Meshing; 10 | 11 | /// 12 | /// Interface for mesh smoothers. 13 | /// 14 | public interface ISmoother 15 | { 16 | void Smooth(IMesh mesh); 17 | void Smooth(IMesh mesh, int limit); 18 | } 19 | } -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Smoothing/ISmoother.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1d8c5c2dd1fe5da4fb3c46118b0beb00 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Smoothing/SimpleSmoother.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c4affca1742e49e4e8011970575cbf44 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Smoothing/VoronoiFactory.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace TriangleNet.Smoothing 3 | { 4 | using System; 5 | using TriangleNet.Topology.DCEL; 6 | using TriangleNet.Voronoi; 7 | 8 | /// 9 | /// Factory which re-uses objects in the smoothing loop to enhance performance. 10 | /// 11 | /// 12 | /// See . 13 | /// 14 | class VoronoiFactory : IVoronoiFactory 15 | { 16 | ObjectPool vertices; 17 | ObjectPool edges; 18 | ObjectPool faces; 19 | 20 | public VoronoiFactory() 21 | { 22 | vertices = new ObjectPool(); 23 | edges = new ObjectPool(); 24 | faces = new ObjectPool(); 25 | } 26 | 27 | public void Initialize(int vertexCount, int edgeCount, int faceCount) 28 | { 29 | vertices.Capacity = vertexCount; 30 | edges.Capacity = edgeCount; 31 | faces.Capacity = faceCount; 32 | 33 | for (int i = vertices.Count; i < vertexCount; i++) 34 | { 35 | vertices.Put(new Vertex(0, 0)); 36 | } 37 | 38 | 39 | for (int i = edges.Count; i < edgeCount; i++) 40 | { 41 | edges.Put(new HalfEdge(null)); 42 | } 43 | 44 | for (int i = faces.Count; i < faceCount; i++) 45 | { 46 | faces.Put(new Face(null)); 47 | } 48 | 49 | Reset(); 50 | } 51 | 52 | public void Reset() 53 | { 54 | vertices.Release(); 55 | edges.Release(); 56 | faces.Release(); 57 | } 58 | 59 | public Vertex CreateVertex(float x, float y) 60 | { 61 | Vertex vertex; 62 | 63 | if (vertices.TryGet(out vertex)) 64 | { 65 | vertex.x = x; 66 | vertex.y = y; 67 | vertex.leaving = null; 68 | 69 | return vertex; 70 | } 71 | 72 | vertex = new Vertex(x, y); 73 | 74 | vertices.Put(vertex); 75 | 76 | return vertex; 77 | } 78 | 79 | public HalfEdge CreateHalfEdge(Vertex origin, Face face) 80 | { 81 | HalfEdge edge; 82 | 83 | if (edges.TryGet(out edge)) 84 | { 85 | edge.origin = origin; 86 | edge.face = face; 87 | edge.next = null; 88 | edge.twin = null; 89 | 90 | if (face != null && face.edge == null) 91 | { 92 | face.edge = edge; 93 | } 94 | 95 | return edge; 96 | } 97 | 98 | edge = new HalfEdge(origin, face); 99 | 100 | edges.Put(edge); 101 | 102 | return edge; 103 | } 104 | 105 | public Face CreateFace(Geometry.Vertex vertex) 106 | { 107 | Face face; 108 | 109 | if (faces.TryGet(out face)) 110 | { 111 | face.id = vertex.id; 112 | face.generator = vertex; 113 | face.edge = null; 114 | 115 | return face; 116 | } 117 | 118 | face = new Face(vertex); 119 | 120 | faces.Put(face); 121 | 122 | return face; 123 | } 124 | 125 | class ObjectPool where T : class 126 | { 127 | int index, count; 128 | 129 | T[] pool; 130 | 131 | public int Count 132 | { 133 | get { return count; } 134 | } 135 | 136 | 137 | public int Capacity 138 | { 139 | get { return this.pool.Length; } 140 | set { Resize(value); } 141 | } 142 | 143 | public ObjectPool(int capacity = 3) 144 | { 145 | this.index = 0; 146 | this.count = 0; 147 | 148 | this.pool = new T[capacity]; 149 | } 150 | 151 | public ObjectPool(T[] pool) 152 | { 153 | this.index = 0; 154 | this.count = 0; 155 | 156 | this.pool = pool; 157 | } 158 | 159 | public bool TryGet(out T obj) 160 | { 161 | if (this.index < this.count) 162 | { 163 | obj = this.pool[this.index++]; 164 | 165 | return true; 166 | } 167 | 168 | obj = null; 169 | 170 | return false; 171 | } 172 | 173 | public void Put(T obj) 174 | { 175 | var capacity = this.pool.Length; 176 | 177 | if (capacity <= this.count) 178 | { 179 | Resize(2 * capacity); 180 | } 181 | 182 | this.pool[this.count++] = obj; 183 | 184 | this.index++; 185 | } 186 | 187 | public void Release() 188 | { 189 | this.index = 0; 190 | } 191 | 192 | private void Resize(int size) 193 | { 194 | if (size > this.count) 195 | { 196 | Array.Resize(ref this.pool, size); 197 | } 198 | } 199 | } 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Smoothing/VoronoiFactory.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 04c29a75a773c1f4fb4cd3c8effab7c0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Tools.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 439d0acf46c09724d82f3286beee8eaa 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Tools/AdjacencyMatrix.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2c2d4becb00d3074187c2aec4f2d6a2a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Tools/CuthillMcKee.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8518c665931e6184fab68825020b80e2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Tools/Interpolation.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace TriangleNet.Tools 3 | { 4 | using TriangleNet.Geometry; 5 | 6 | public static class Interpolation 7 | { 8 | #if USE_ATTRIBS 9 | /// 10 | /// Linear interpolation of vertex attributes. 11 | /// 12 | /// The interpolation vertex. 13 | /// The triangle containing the vertex. 14 | /// The number of vertex attributes. 15 | /// 16 | /// The vertex is expected to lie inside the triangle. 17 | /// 18 | public static void InterpolateAttributes(Vertex vertex, ITriangle triangle, int n) 19 | { 20 | Vertex org = triangle.GetVertex(0); 21 | Vertex dest = triangle.GetVertex(1); 22 | Vertex apex = triangle.GetVertex(2); 23 | 24 | float xdo, ydo, xao, yao; 25 | float denominator; 26 | float dx, dy; 27 | float xi, eta; 28 | 29 | // Compute the circumcenter of the triangle. 30 | xdo = dest.x - org.x; 31 | ydo = dest.y - org.y; 32 | xao = apex.x - org.x; 33 | yao = apex.y - org.y; 34 | 35 | denominator = 0.5 / (xdo * yao - xao * ydo); 36 | 37 | //dx = (yao * dodist - ydo * aodist) * denominator; 38 | //dy = (xdo * aodist - xao * dodist) * denominator; 39 | 40 | dx = vertex.x - org.x; 41 | dy = vertex.y - org.y; 42 | 43 | // To interpolate vertex attributes for the new vertex, define a 44 | // coordinate system with a xi-axis directed from the triangle's 45 | // origin to its destination, and an eta-axis, directed from its 46 | // origin to its apex. 47 | xi = (yao * dx - xao * dy) * (2.0 * denominator); 48 | eta = (xdo * dy - ydo * dx) * (2.0 * denominator); 49 | 50 | for (int i = 0; i < n; i++) 51 | { 52 | // Interpolate the vertex attributes. 53 | vertex.attributes[i] = org.attributes[i] 54 | + xi * (dest.attributes[i] - org.attributes[i]) 55 | + eta * (apex.attributes[i] - org.attributes[i]); 56 | } 57 | } 58 | #endif 59 | 60 | #if USE_Z 61 | /// 62 | /// Linear interpolation of a scalar value. 63 | /// 64 | /// The interpolation point. 65 | /// The triangle containing the point. 66 | /// 67 | /// The point is expected to lie inside the triangle. 68 | /// 69 | public static void InterpolateZ(Point p, ITriangle triangle) 70 | { 71 | Vertex org = triangle.GetVertex(0); 72 | Vertex dest = triangle.GetVertex(1); 73 | Vertex apex = triangle.GetVertex(2); 74 | 75 | float xdo, ydo, xao, yao; 76 | float denominator; 77 | float dx, dy; 78 | float xi, eta; 79 | 80 | // Compute the circumcenter of the triangle. 81 | xdo = dest.x - org.x; 82 | ydo = dest.y - org.y; 83 | xao = apex.x - org.x; 84 | yao = apex.y - org.y; 85 | 86 | denominator = 0.5 / (xdo * yao - xao * ydo); 87 | 88 | //dx = (yao * dodist - ydo * aodist) * denominator; 89 | //dy = (xdo * aodist - xao * dodist) * denominator; 90 | 91 | dx = p.x - org.x; 92 | dy = p.y - org.y; 93 | 94 | // To interpolate z value for the given point inserted, define a 95 | // coordinate system with a xi-axis, directed from the triangle's 96 | // origin to its destination, and an eta-axis, directed from its 97 | // origin to its apex. 98 | xi = (yao * dx - xao * dy) * (2.0 * denominator); 99 | eta = (xdo * dy - ydo * dx) * (2.0 * denominator); 100 | 101 | p.z = org.z + xi * (dest.z - org.z) + eta * (apex.z - org.z); 102 | } 103 | #endif 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Tools/Interpolation.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 81d0029686bfff4418b7f22aeb39e553 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Tools/IntersectionHelper.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8d79c18332640474c895236cafec81d8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Tools/PolygonValidator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: acbe9fa799a0c7642942528a7ba296df 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Tools/QualityMeasure.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ab7101a9786c0cd44ab4545312fc076d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Tools/Statistic.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 039ac523d2d3e3a458554645735aa0ba 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Tools/TriangleQuadTree.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ad5f4243e7fa16d4a878622b966dc2b1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Tools/VertexSorter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: facac6efc14d3ee47b46690754808ecb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Topology.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 89fc5e6665737744e8999fdfc64f0c4b 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Topology/DCEL.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 79542a90a8862104096fb2b30a72286b 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Topology/DCEL/DcelMesh.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9513faddd433ad64fb29cb13698cbd54 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Topology/DCEL/Face.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace TriangleNet.Topology.DCEL 8 | { 9 | using System.Collections.Generic; 10 | using TriangleNet.Geometry; 11 | 12 | /// 13 | /// A face of DCEL mesh. 14 | /// 15 | public class Face 16 | { 17 | #region Static initialization of "Outer Space" face 18 | 19 | public static readonly Face Empty; 20 | 21 | static Face() 22 | { 23 | Empty = new Face(null); 24 | Empty.id = -1; 25 | } 26 | 27 | #endregion 28 | 29 | internal int id; 30 | internal int mark; 31 | 32 | internal Point generator; 33 | 34 | internal HalfEdge edge; 35 | internal bool bounded; 36 | 37 | /// 38 | /// Gets or sets the face id. 39 | /// 40 | public int ID 41 | { 42 | get { return id; } 43 | set { id = value; } 44 | } 45 | 46 | /// 47 | /// Gets or sets a half-edge connected to the face. 48 | /// 49 | public HalfEdge Edge 50 | { 51 | get { return edge; } 52 | set { edge = value; } 53 | } 54 | 55 | /// 56 | /// Gets or sets a value, indicating if the face is bounded (for Voronoi diagram). 57 | /// 58 | public bool Bounded 59 | { 60 | get { return bounded; } 61 | set { bounded = value; } 62 | } 63 | 64 | /// 65 | /// Initializes a new instance of the class. 66 | /// 67 | /// The generator of this face (for Voronoi diagram) 68 | public Face(Point generator) 69 | : this(generator, null) 70 | { 71 | } 72 | 73 | /// 74 | /// Initializes a new instance of the class. 75 | /// 76 | /// The generator of this face (for Voronoi diagram) 77 | /// The half-edge connected to this face. 78 | public Face(Point generator, HalfEdge edge) 79 | { 80 | this.generator = generator; 81 | this.edge = edge; 82 | this.bounded = true; 83 | 84 | if (generator != null) 85 | { 86 | this.id = generator.ID; 87 | } 88 | } 89 | 90 | /// 91 | /// Enumerates all half-edges of the face boundary. 92 | /// 93 | /// 94 | public IEnumerable EnumerateEdges() 95 | { 96 | var edge = this.Edge; 97 | int first = edge.ID; 98 | 99 | do 100 | { 101 | yield return edge; 102 | 103 | edge = edge.Next; 104 | } while (edge.ID != first); 105 | } 106 | 107 | public override string ToString() 108 | { 109 | return string.Format("F-ID {0}", id); 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Topology/DCEL/Face.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 878a2c47190ddf848966c9b83d5dcd31 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Topology/DCEL/HalfEdge.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace TriangleNet.Topology.DCEL 8 | { 9 | public class HalfEdge 10 | { 11 | internal int id; 12 | internal int mark; 13 | 14 | internal Vertex origin; 15 | internal Face face; 16 | internal HalfEdge twin; 17 | internal HalfEdge next; 18 | 19 | /// 20 | /// Gets or sets the half-edge id. 21 | /// 22 | public int ID 23 | { 24 | get { return id; } 25 | set { id = value; } 26 | } 27 | 28 | public int Boundary 29 | { 30 | get { return mark; } 31 | set { mark = value; } 32 | } 33 | 34 | /// 35 | /// Gets or sets the origin of the half-edge. 36 | /// 37 | public Vertex Origin 38 | { 39 | get { return origin; } 40 | set { origin = value; } 41 | } 42 | 43 | /// 44 | /// Gets or sets the face connected to the half-edge. 45 | /// 46 | public Face Face 47 | { 48 | get { return face; } 49 | set { face = value; } 50 | } 51 | 52 | /// 53 | /// Gets or sets the twin of the half-edge. 54 | /// 55 | public HalfEdge Twin 56 | { 57 | get { return twin; } 58 | set { twin = value; } 59 | } 60 | 61 | /// 62 | /// Gets or sets the next pointer of the half-edge. 63 | /// 64 | public HalfEdge Next 65 | { 66 | get { return next; } 67 | set { next = value; } 68 | } 69 | 70 | /// 71 | /// Initializes a new instance of the class. 72 | /// 73 | /// The origin of this half-edge. 74 | public HalfEdge(Vertex origin) 75 | { 76 | this.origin = origin; 77 | } 78 | 79 | /// 80 | /// Initializes a new instance of the class. 81 | /// 82 | /// The origin of this half-edge. 83 | /// The face connected to this half-edge. 84 | public HalfEdge(Vertex origin, Face face) 85 | { 86 | this.origin = origin; 87 | this.face = face; 88 | 89 | // IMPORTANT: do not remove the (face.edge == null) check! 90 | if (face != null && face.edge == null) 91 | { 92 | face.edge = this; 93 | } 94 | } 95 | 96 | public override string ToString() 97 | { 98 | return string.Format("HE-ID {0} (Origin = VID-{1})", id, origin.id); 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Topology/DCEL/HalfEdge.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d7645c59389213040be4e289de5c1f03 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Topology/DCEL/Vertex.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace TriangleNet.Topology.DCEL 8 | { 9 | using System.Collections.Generic; 10 | 11 | public class Vertex : TriangleNet.Geometry.Point 12 | { 13 | internal HalfEdge leaving; 14 | 15 | /// 16 | /// Gets or sets a half-edge leaving the vertex. 17 | /// 18 | public HalfEdge Leaving 19 | { 20 | get { return leaving; } 21 | set { leaving = value; } 22 | } 23 | 24 | /// 25 | /// Initializes a new instance of the class. 26 | /// 27 | /// The x coordinate. 28 | /// The y coordinate. 29 | public Vertex(float x, float y) 30 | : base(x, y) 31 | { 32 | } 33 | 34 | /// 35 | /// Initializes a new instance of the class. 36 | /// 37 | /// The x coordinate. 38 | /// The y coordinate. 39 | /// A half-edge leaving this vertex. 40 | public Vertex(float x, float y, HalfEdge leaving) 41 | : base(x, y) 42 | { 43 | this.leaving = leaving; 44 | } 45 | 46 | /// 47 | /// Enumerates all half-edges leaving this vertex. 48 | /// 49 | /// 50 | public IEnumerable EnumerateEdges() 51 | { 52 | var edge = this.Leaving; 53 | int first = edge.ID; 54 | 55 | do 56 | { 57 | yield return edge; 58 | 59 | edge = edge.Twin.Next; 60 | } while (edge.ID != first); 61 | } 62 | 63 | public override string ToString() 64 | { 65 | return string.Format("V-ID {0}", base.id); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Topology/DCEL/Vertex.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c9f08b20e9c1c4948a02fa47b6557908 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Topology/Osub.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cf07c66fdb92828489a1ae5fdf988768 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Topology/Otri.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f7f5b92b81f8e894ea8c5e8cafc8cb6e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Topology/SubSegment.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Original Triangle code by Jonathan Richard Shewchuk, http://www.cs.cmu.edu/~quake/triangle.html 4 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | namespace TriangleNet.Topology 9 | { 10 | using System; 11 | using TriangleNet.Geometry; 12 | 13 | /// 14 | /// The subsegment data structure. 15 | /// 16 | public class SubSegment : ISegment 17 | { 18 | // Hash for dictionary. Will be set by mesh instance. 19 | internal int hash; 20 | 21 | internal Osub[] subsegs; 22 | internal Vertex[] vertices; 23 | internal Otri[] triangles; 24 | internal int boundary; 25 | 26 | public SubSegment() 27 | { 28 | // Four NULL vertices. 29 | vertices = new Vertex[4]; 30 | 31 | // Set the boundary marker to zero. 32 | boundary = 0; 33 | 34 | // Initialize the two adjoining subsegments to be the omnipresent 35 | // subsegment. 36 | subsegs = new Osub[2]; 37 | 38 | // Initialize the two adjoining triangles to be "outer space." 39 | triangles = new Otri[2]; 40 | } 41 | 42 | #region Public properties 43 | 44 | /// 45 | /// Gets the first endpoints vertex id. 46 | /// 47 | public int P0 48 | { 49 | get { return this.vertices[0].id; } 50 | } 51 | 52 | /// 53 | /// Gets the seconds endpoints vertex id. 54 | /// 55 | public int P1 56 | { 57 | get { return this.vertices[1].id; } 58 | } 59 | 60 | /// 61 | /// Gets the segment boundary mark. 62 | /// 63 | public int Label 64 | { 65 | get { return this.boundary; } 66 | } 67 | 68 | #endregion 69 | 70 | /// 71 | /// Gets the segments endpoint. 72 | /// 73 | public Vertex GetVertex(int index) 74 | { 75 | return this.vertices[index]; // TODO: Check range? 76 | } 77 | 78 | /// 79 | /// Gets an adjoining triangle. 80 | /// 81 | public ITriangle GetTriangle(int index) 82 | { 83 | return triangles[index].tri.hash == TriangleNetMesh.DUMMY ? null : triangles[index].tri; 84 | } 85 | 86 | public override int GetHashCode() 87 | { 88 | return this.hash; 89 | } 90 | 91 | public override string ToString() 92 | { 93 | return String.Format("SID {0}", hash); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Topology/SubSegment.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9a66fcc858c78b34e8006dcb65e8388d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Topology/Triangle.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Original Triangle code by Jonathan Richard Shewchuk, http://www.cs.cmu.edu/~quake/triangle.html 4 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | namespace TriangleNet.Topology 9 | { 10 | using System; 11 | using TriangleNet.Geometry; 12 | 13 | /// 14 | /// The triangle data structure. 15 | /// 16 | public class Triangle : ITriangle 17 | { 18 | // Hash for dictionary. Will be set by mesh instance. 19 | internal int hash; 20 | 21 | // The ID is only used for mesh output. 22 | internal int id; 23 | 24 | internal Otri[] neighbors; 25 | internal Vertex[] vertices; 26 | internal Osub[] subsegs; 27 | internal int label; 28 | internal float area; 29 | internal bool infected; 30 | 31 | /// 32 | /// Initializes a new instance of the class. 33 | /// 34 | public Triangle() 35 | { 36 | // Three NULL vertices. 37 | vertices = new Vertex[3]; 38 | 39 | // Initialize the three adjoining subsegments to be the omnipresent subsegment. 40 | subsegs = new Osub[3]; 41 | 42 | // Initialize the three adjoining triangles to be "outer space". 43 | neighbors = new Otri[3]; 44 | 45 | // area = -1.0; 46 | } 47 | 48 | #region Public properties 49 | 50 | /// 51 | /// Gets or sets the triangle id. 52 | /// 53 | public int ID 54 | { 55 | get { return this.id; } 56 | set { this.id = value; } 57 | } 58 | 59 | /// 60 | /// Region ID the triangle belongs to. 61 | /// 62 | public int Label 63 | { 64 | get { return this.label; } 65 | set { this.label = value; } 66 | } 67 | 68 | /// 69 | /// Gets the triangle area constraint. 70 | /// 71 | public float Area 72 | { 73 | get { return this.area; } 74 | set { this.area = value; } 75 | } 76 | 77 | /// 78 | /// Gets the specified corners vertex. 79 | /// 80 | public Vertex GetVertex(int index) 81 | { 82 | return this.vertices[index]; // TODO: Check range? 83 | } 84 | 85 | public int GetVertexID(int index) 86 | { 87 | return this.vertices[index].id; 88 | } 89 | 90 | /// 91 | /// Gets a triangles' neighbor. 92 | /// 93 | /// The neighbor index (0, 1 or 2). 94 | /// The neigbbor opposite of vertex with given index. 95 | public ITriangle GetNeighbor(int index) 96 | { 97 | return neighbors[index].tri.hash == TriangleNetMesh.DUMMY ? null : neighbors[index].tri; 98 | } 99 | 100 | /// 101 | public int GetNeighborID(int index) 102 | { 103 | return neighbors[index].tri.hash == TriangleNetMesh.DUMMY ? -1 : neighbors[index].tri.id; 104 | } 105 | 106 | /// 107 | /// Gets a triangles segment. 108 | /// 109 | /// The vertex index (0, 1 or 2). 110 | /// The segment opposite of vertex with given index. 111 | public ISegment GetSegment(int index) 112 | { 113 | return subsegs[index].seg.hash == TriangleNetMesh.DUMMY ? null : subsegs[index].seg; 114 | } 115 | 116 | #endregion 117 | 118 | public override int GetHashCode() 119 | { 120 | return this.hash; 121 | } 122 | 123 | public override string ToString() 124 | { 125 | return String.Format("TID {0}", hash); 126 | } 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Topology/Triangle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6bd5482400e0d0d438e0286801cf99b3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/TriangleLocator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b318e2d620e818e4ea7087509b1bcdcd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/TriangleNetMesh.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 83492c33d2729054c85f142b46f2b6e5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/TrianglePool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a8d675b3f8a5fae4ba4de53093933eb3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/TriangleSampler.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Original Triangle code by Jonathan Richard Shewchuk, http://www.cs.cmu.edu/~quake/triangle.html 4 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | namespace TriangleNet 9 | { 10 | using System; 11 | using System.Collections.Generic; 12 | using TriangleNet.Topology; 13 | 14 | /// 15 | /// Used for triangle sampling in the class. 16 | /// 17 | class TriangleSampler : IEnumerable 18 | { 19 | private const int RANDOM_SEED = 110503; 20 | 21 | // Empirically chosen factor. 22 | private const int samplefactor = 11; 23 | 24 | private Random random; 25 | private TriangleNetMesh _TriangleNetMesh; 26 | 27 | // Number of random samples for point location (at least 1). 28 | private int samples = 1; 29 | 30 | // Number of triangles in mesh. 31 | private int triangleCount = 0; 32 | 33 | public TriangleSampler(TriangleNetMesh triangleNetMesh) 34 | : this(triangleNetMesh, new Random(RANDOM_SEED)) 35 | { 36 | } 37 | 38 | public TriangleSampler(TriangleNetMesh triangleNetMesh, Random random) 39 | { 40 | this._TriangleNetMesh = triangleNetMesh; 41 | this.random = random; 42 | } 43 | 44 | /// 45 | /// Reset the sampler. 46 | /// 47 | public void Reset() 48 | { 49 | this.samples = 1; 50 | this.triangleCount = 0; 51 | } 52 | 53 | /// 54 | /// Update sampling parameters if mesh changed. 55 | /// 56 | public void Update() 57 | { 58 | int count = _TriangleNetMesh.triangles.Count; 59 | 60 | if (triangleCount != count) 61 | { 62 | triangleCount = count; 63 | 64 | // The number of random samples taken is proportional to the cube root 65 | // of the number of triangles in the mesh. The next bit of code assumes 66 | // that the number of triangles increases monotonically (or at least 67 | // doesn't decrease enough to matter). 68 | while (samplefactor * samples * samples * samples < count) 69 | { 70 | samples++; 71 | } 72 | } 73 | } 74 | 75 | public IEnumerator GetEnumerator() 76 | { 77 | return _TriangleNetMesh.triangles.Sample(samples, random).GetEnumerator(); 78 | } 79 | 80 | System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() 81 | { 82 | return GetEnumerator(); 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/TriangleSampler.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8c279d255e4d8f547a8076e23582e3cb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Voronoi.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4d82459171ba04a4abcee28291912116 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Voronoi/BoundedVoronoi.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3c6908e0231e82a408c90a20728cff6b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Voronoi/DefaultVoronoiFactory.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace TriangleNet.Voronoi 3 | { 4 | using System; 5 | using TriangleNet.Topology.DCEL; 6 | 7 | /// 8 | /// Default factory for Voronoi / DCEL mesh objects. 9 | /// 10 | public class DefaultVoronoiFactory : IVoronoiFactory 11 | { 12 | public void Initialize(int vertexCount, int edgeCount, int faceCount) 13 | { 14 | } 15 | 16 | public void Reset() 17 | { 18 | } 19 | 20 | public Vertex CreateVertex(float x, float y) 21 | { 22 | return new Vertex(x, y); 23 | } 24 | 25 | public HalfEdge CreateHalfEdge(Vertex origin, Face face) 26 | { 27 | return new HalfEdge(origin, face); 28 | } 29 | 30 | public Face CreateFace(Geometry.Vertex vertex) 31 | { 32 | return new Face(vertex); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Voronoi/DefaultVoronoiFactory.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b5ac9d51dcd8036438ac2f6dc0d5f5c5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Voronoi/IVoronoiFactory.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace TriangleNet.Voronoi 3 | { 4 | using TriangleNet.Topology.DCEL; 5 | 6 | public interface IVoronoiFactory 7 | { 8 | void Initialize(int vertexCount, int edgeCount, int faceCount); 9 | 10 | void Reset(); 11 | 12 | Vertex CreateVertex(float x, float y); 13 | 14 | HalfEdge CreateHalfEdge(Vertex origin, Face face); 15 | 16 | Face CreateFace(Geometry.Vertex vertex); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Voronoi/IVoronoiFactory.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1c3517b53e00a8f48a2432466b5e1234 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Voronoi/Legacy.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 85802e0452b153842886c57601dff0dc 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Voronoi/Legacy/BoundedVoronoiLegacy.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 14145762b36477e45958c8b988c696e2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Voronoi/Legacy/IVoronoi.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace TriangleNet.Voronoi.Legacy 8 | { 9 | using System.Collections.Generic; 10 | using TriangleNet.Geometry; 11 | 12 | /// 13 | /// Voronoi diagram interface. 14 | /// 15 | public interface IVoronoi 16 | { 17 | /// 18 | /// Gets the list of Voronoi vertices. 19 | /// 20 | Point[] Points { get; } 21 | 22 | /// 23 | /// Gets the list of Voronoi regions. 24 | /// 25 | ICollection Regions { get; } 26 | 27 | /// 28 | /// Gets the list of edges. 29 | /// 30 | IEnumerable Edges { get; } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Voronoi/Legacy/IVoronoi.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bedbe62b80afb3b49b12dcd8027f2a6b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Voronoi/Legacy/SimpleVoronoi.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 09fbe007670d48c4ba41815f357a19aa 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Voronoi/Legacy/VoronoiRegion.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace TriangleNet.Voronoi.Legacy 8 | { 9 | using System; 10 | using System.Collections.Generic; 11 | using TriangleNet.Topology; 12 | using TriangleNet.Geometry; 13 | 14 | /// 15 | /// Represents a region in the Voronoi diagram. 16 | /// 17 | public class VoronoiRegion 18 | { 19 | int id; 20 | Point generator; 21 | List vertices; 22 | bool bounded; 23 | 24 | // A map (vertex id) -> (neighbor across adjacent edge) 25 | Dictionary neighbors; 26 | 27 | /// 28 | /// Gets the Voronoi region id (which is the same as the generators vertex id). 29 | /// 30 | public int ID 31 | { 32 | get { return id; } 33 | } 34 | 35 | /// 36 | /// Gets the Voronoi regions generator. 37 | /// 38 | public Point Generator 39 | { 40 | get { return generator; } 41 | } 42 | 43 | /// 44 | /// Gets the Voronoi vertices on the regions boundary. 45 | /// 46 | public ICollection Vertices 47 | { 48 | get { return vertices; } 49 | } 50 | 51 | /// 52 | /// Gets or sets whether the Voronoi region is bounded. 53 | /// 54 | public bool Bounded 55 | { 56 | get { return bounded; } 57 | set { bounded = value; } 58 | } 59 | 60 | public VoronoiRegion(Vertex generator) 61 | { 62 | this.id = generator.id; 63 | this.generator = generator; 64 | this.vertices = new List(); 65 | this.bounded = true; 66 | 67 | this.neighbors = new Dictionary(); 68 | } 69 | 70 | public void Add(Point point) 71 | { 72 | this.vertices.Add(point); 73 | } 74 | 75 | public void Add(List points) 76 | { 77 | this.vertices.AddRange(points); 78 | } 79 | 80 | /// 81 | /// Returns the neighbouring Voronoi region, that lies across the edge starting at 82 | /// given vertex. 83 | /// 84 | /// Vertex defining an edge of the region. 85 | /// Neighbouring Voronoi region 86 | /// 87 | /// The edge starting at p is well defined (vertices are ordered counterclockwise). 88 | /// 89 | public VoronoiRegion GetNeighbor(Point p) 90 | { 91 | VoronoiRegion neighbor; 92 | 93 | if (neighbors.TryGetValue(p.id, out neighbor)) 94 | { 95 | return neighbor; 96 | } 97 | 98 | return null; 99 | } 100 | 101 | internal void AddNeighbor(int id, VoronoiRegion neighbor) 102 | { 103 | this.neighbors.Add(id, neighbor); 104 | } 105 | 106 | public override string ToString() 107 | { 108 | return String.Format("R-ID {0}", id); 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Voronoi/Legacy/VoronoiRegion.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7033436d5c2a7754eb298e35409b9f30 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Voronoi/StandardVoronoi.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/ 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace TriangleNet.Voronoi 8 | { 9 | using System.Collections.Generic; 10 | using TriangleNet.Geometry; 11 | using TriangleNet.Tools; 12 | using TriangleNet.Topology.DCEL; 13 | 14 | public class StandardVoronoi : VoronoiBase 15 | { 16 | public StandardVoronoi(TriangleNetMesh triangleNetMesh) 17 | : this(triangleNetMesh, triangleNetMesh.bounds, new DefaultVoronoiFactory(), RobustPredicates.Default) 18 | { 19 | } 20 | 21 | public StandardVoronoi(TriangleNetMesh triangleNetMesh, Rectangle box) 22 | : this(triangleNetMesh, box, new DefaultVoronoiFactory(), RobustPredicates.Default) 23 | { 24 | } 25 | 26 | public StandardVoronoi(TriangleNetMesh triangleNetMesh, Rectangle box, IVoronoiFactory factory, IPredicates predicates) 27 | : base(triangleNetMesh, factory, predicates, true) 28 | { 29 | // We assume the box to be at least as large as the mesh. 30 | box.Expand(triangleNetMesh.bounds); 31 | 32 | // We explicitly told the base constructor to call the Generate method, so 33 | // at this point the basic Voronoi diagram is already created. 34 | PostProcess(box); 35 | } 36 | 37 | /// 38 | /// Compute edge intersections with bounding box. 39 | /// 40 | private void PostProcess(Rectangle box) 41 | { 42 | foreach (var edge in rays) 43 | { 44 | // The vertices of the infinite edge. 45 | var v1 = (Point)edge.origin; 46 | var v2 = (Point)edge.twin.origin; 47 | 48 | if (box.Contains(v1) || box.Contains(v2)) 49 | { 50 | // Move infinite vertex v2 onto the box boundary. 51 | IntersectionHelper.BoxRayIntersection(box, v1, v2, ref v2); 52 | } 53 | else 54 | { 55 | // There is actually no easy way to handle the second case. The two edges 56 | // leaving v1, pointing towards the mesh, don't have to intersect the box 57 | // (the could join with edges of other cells outside the box). 58 | 59 | // A general intersection algorithm (DCEL <-> Rectangle) is needed, which 60 | // computes intersections with all edges and discards objects outside the 61 | // box. 62 | } 63 | } 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Voronoi/StandardVoronoi.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ae5e45d01f3d7f34ca85c5de2e20d8d1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/Source/Voronoi/VoronoiBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 04deee94f6fc5224ca0dc8f5c383f8d1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/UnityExtentions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using TriangleNet.Geometry; 5 | using TriangleNet.Meshing; 6 | using UnityEngine; 7 | 8 | namespace TriangleNet 9 | { 10 | public static class UnityExtentions 11 | { 12 | public static void Add(this Polygon polygon, List contour, bool isHole = false) 13 | { 14 | polygon.Add(new Contour(contour.ToTriangleNetVertices()), isHole); 15 | } 16 | 17 | public static void Add(this Polygon polygon, Vector2 vertex) 18 | { 19 | polygon.Add(new Vertex(vertex.x, vertex.y)); 20 | } 21 | 22 | public static Mesh GenerateUnityMesh(this TriangleNetMesh triangleNetMesh, QualityOptions options = null) 23 | { 24 | if (options != null) 25 | { 26 | triangleNetMesh.Refine(options); 27 | } 28 | 29 | Mesh mesh = new Mesh(); 30 | var triangleNetVerts = triangleNetMesh.Vertices.ToList(); 31 | 32 | var triangles = triangleNetMesh.Triangles; 33 | 34 | Vector3[] verts = new Vector3[triangleNetVerts.Count]; 35 | int[] trisIndex = new int[triangles.Count * 3]; 36 | 37 | for (int i = 0; i < verts.Length; i++) 38 | { 39 | verts[i] = (Vector3) triangleNetVerts[i]; 40 | } 41 | 42 | int k = 0; 43 | 44 | foreach (var triangle in triangles) 45 | { 46 | for (int i = 2; i >= 0; i--) 47 | { 48 | trisIndex[k] = triangleNetVerts.IndexOf(triangle.GetVertex(i)); 49 | k++; 50 | } 51 | } 52 | 53 | mesh.vertices = verts; 54 | mesh.triangles = trisIndex; 55 | 56 | mesh.RecalculateBounds(); 57 | mesh.RecalculateNormals(); 58 | return mesh; 59 | } 60 | 61 | private static List ToTriangleNetVertices(this List points) 62 | { 63 | List vertices = new List(); 64 | foreach (var vec in points) 65 | { 66 | vertices.Add(new Vertex(vec.x, vec.y)); 67 | } 68 | 69 | return vertices; 70 | } 71 | 72 | public static void DrawGizmos(this TriangleNetMesh triangleNetMesh) 73 | { 74 | foreach (var triangle in triangleNetMesh.triangles) 75 | { 76 | var verts = triangle.vertices; 77 | Gizmos.DrawLine((Vector3) verts[0], (Vector3) verts[1]); 78 | Gizmos.DrawLine((Vector3) verts[1], (Vector3) verts[2]); 79 | Gizmos.DrawLine((Vector3) verts[2], (Vector3) verts[0]); 80 | } 81 | } 82 | } 83 | } -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/Scripts/UnityExtentions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dec315e513fe546449a6c0eb7e1c3e94 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/nox7atra.triangle.net.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nox7atra.triangle.net", 3 | "rootNamespace": "", 4 | "references": [], 5 | "includePlatforms": [], 6 | "excludePlatforms": [], 7 | "allowUnsafeCode": false, 8 | "overrideReferences": false, 9 | "precompiledReferences": [], 10 | "autoReferenced": true, 11 | "defineConstraints": [], 12 | "versionDefines": [], 13 | "noEngineReferences": false 14 | } -------------------------------------------------------------------------------- /Assets/TriangleNet/Runtime/nox7atra.triangle.net.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0a9c05c03e25fee49a644b8ead257dab 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Tests.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a8ed3636d90df3b4d8b93200cbadac48 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Tests/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ae694ec8834ef8f42a0e07f9072ff298 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Tests/Resources/MeshDrawer.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4df0e13bb266ae0429c55b50795167e2 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Tests/Resources/MeshDrawer/ContourMaterial.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: ContourMaterial 10 | m_Shader: {fileID: 10755, guid: 0000000000000000f000000000000000, type: 0} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: -1 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | m_Floats: 58 | - _BumpScale: 1 59 | - _Cutoff: 0.5 60 | - _DetailNormalMapScale: 1 61 | - _DstBlend: 0 62 | - _GlossMapScale: 1 63 | - _Glossiness: 0.5 64 | - _GlossyReflections: 1 65 | - _Metallic: 0 66 | - _Mode: 0 67 | - _OcclusionStrength: 1 68 | - _Parallax: 0.02 69 | - _SmoothnessTextureChannel: 0 70 | - _SpecularHighlights: 1 71 | - _SrcBlend: 1 72 | - _UVSec: 0 73 | - _ZWrite: 1 74 | m_Colors: 75 | - _Color: {r: 0, g: 1, b: 0.26383877, a: 1} 76 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 77 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Tests/Resources/MeshDrawer/ContourMaterial.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6fa92780f22e8154c80cf0ebfd32c7b9 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Tests/Resources/MeshDrawer/DemoMat.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: DemoMat 10 | m_Shader: {fileID: 10752, guid: 0000000000000000f000000000000000, type: 0} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: -1 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 2800000, guid: 3cf450e96267b2b4da6264186503d9f0, type: 3} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | m_Floats: 58 | - _BumpScale: 1 59 | - _Cutoff: 0.5 60 | - _DetailNormalMapScale: 1 61 | - _DstBlend: 0 62 | - _GlossMapScale: 1 63 | - _Glossiness: 0.5 64 | - _GlossyReflections: 1 65 | - _Metallic: 0 66 | - _Mode: 0 67 | - _OcclusionStrength: 1 68 | - _Parallax: 0.02 69 | - _SmoothnessTextureChannel: 0 70 | - _SpecularHighlights: 1 71 | - _SrcBlend: 1 72 | - _UVSec: 0 73 | - _ZWrite: 1 74 | m_Colors: 75 | - _Color: {r: 1, g: 1, b: 1, a: 1} 76 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 77 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Tests/Resources/MeshDrawer/DemoMat.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 02d41328986935248bcb462b109a22ca 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Tests/Resources/MeshDrawer/HoleMat.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: HoleMat 10 | m_Shader: {fileID: 10755, guid: 0000000000000000f000000000000000, type: 0} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: -1 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | m_Floats: 58 | - _BumpScale: 1 59 | - _Cutoff: 0.5 60 | - _DetailNormalMapScale: 1 61 | - _DstBlend: 0 62 | - _GlossMapScale: 1 63 | - _Glossiness: 0.5 64 | - _GlossyReflections: 1 65 | - _Metallic: 0 66 | - _Mode: 0 67 | - _OcclusionStrength: 1 68 | - _Parallax: 0.02 69 | - _SmoothnessTextureChannel: 0 70 | - _SpecularHighlights: 1 71 | - _SrcBlend: 1 72 | - _UVSec: 0 73 | - _ZWrite: 1 74 | m_Colors: 75 | - _Color: {r: 1, g: 0, b: 0.15558338, a: 1} 76 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 77 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Tests/Resources/MeshDrawer/HoleMat.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e97db25afd95b6946aa777b95e2040b8 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Tests/Resources/MeshDrawer/TexturesCom_Brick_Modern_512_albedo.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nox7atra/Triangle.Net-for-Unity/de1bb020f97f730257a1e49f1afd87954663be71/Assets/TriangleNet/Tests/Resources/MeshDrawer/TexturesCom_Brick_Modern_512_albedo.tif -------------------------------------------------------------------------------- /Assets/TriangleNet/Tests/Resources/MeshDrawer/TexturesCom_Brick_Modern_512_albedo.tif.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3cf450e96267b2b4da6264186503d9f0 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | externalObjects: {} 6 | serializedVersion: 7 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: -1 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: -1 38 | wrapV: -1 39 | wrapW: -1 40 | nPOTScale: 1 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 1 52 | alphaIsTransparency: 0 53 | spriteTessellationDetail: -1 54 | textureType: 0 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | platformSettings: 61 | - serializedVersion: 2 62 | buildTarget: DefaultTexturePlatform 63 | maxTextureSize: 2048 64 | resizeAlgorithm: 0 65 | textureFormat: -1 66 | textureCompression: 1 67 | compressionQuality: 50 68 | crunchedCompression: 0 69 | allowsAlphaSplitting: 0 70 | overridden: 0 71 | androidETC2FallbackOverride: 0 72 | spriteSheet: 73 | serializedVersion: 2 74 | sprites: [] 75 | outline: [] 76 | physicsShape: [] 77 | bones: [] 78 | spriteID: 79 | vertices: [] 80 | indices: 81 | edges: [] 82 | weights: [] 83 | spritePackingTag: 84 | pSDRemoveMatte: 0 85 | pSDShowRemoveMatteOption: 0 86 | userData: 87 | assetBundleName: 88 | assetBundleVariant: 89 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Tests/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4838e40f53326a547a478eb0aa937c84 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Tests/Scenes/MeshDrawer.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e7eb695a9bb64584f9aee9ef82dce6c0 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Tests/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 405053c4d92fb3344959761efa1d7a83 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Tests/Scripts/MathUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | public static class MathUtils 6 | { 7 | public static bool IsPointInsideCountour(List contour, Vector2 point) 8 | { 9 | Vector2 p1, p2; 10 | bool inside = false; 11 | 12 | if (contour.Count < 3) 13 | { 14 | return false; 15 | } 16 | 17 | Vector2 oldPoint = new Vector2(contour[contour.Count - 1].x, contour[contour.Count - 1].y); 18 | 19 | for (int i = 0; i < contour.Count; i++) 20 | { 21 | Vector2 newPoint = new Vector2(contour[i].x, contour[i].y); 22 | 23 | if (newPoint.x > oldPoint.x) 24 | { 25 | p1 = oldPoint; 26 | p2 = newPoint; 27 | } 28 | else 29 | { 30 | p1 = newPoint; 31 | p2 = oldPoint; 32 | } 33 | 34 | if ((newPoint.x < point.x) == (point.x <= oldPoint.x) && 35 | (point.y - p1.y) * (p2.x - p1.x) < (p2.y - p1.y) * (point.x - p1.x)) 36 | { 37 | inside = !inside; 38 | } 39 | 40 | oldPoint = newPoint; 41 | } 42 | 43 | return inside; 44 | } 45 | 46 | public static Vector2? LineSegmentsIntersection(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4) 47 | { 48 | Vector2? result = null; 49 | 50 | Vector2 a = p2 - p1; 51 | Vector2 b = p3 - p4; 52 | Vector2 c = p1 - p3; 53 | 54 | float alphaNumerator = b.y * c.x - b.x * c.y; 55 | float alphaDenominator = a.y * b.x - a.x * b.y; 56 | float betaNumerator = a.x * c.y - a.y * c.x; 57 | float betaDenominator = a.y * b.x - a.x * b.y; 58 | 59 | bool doIntersect = true; 60 | 61 | if (alphaDenominator == 0 || betaDenominator == 0) 62 | { 63 | doIntersect = false; 64 | } 65 | else 66 | { 67 | 68 | if (alphaDenominator > 0) 69 | { 70 | if (alphaNumerator < 0 || alphaNumerator > alphaDenominator) 71 | { 72 | doIntersect = false; 73 | } 74 | } 75 | else if (alphaNumerator > 0 || alphaNumerator < alphaDenominator) 76 | { 77 | doIntersect = false; 78 | } 79 | 80 | if (doIntersect && betaDenominator > 0) { 81 | if (betaNumerator < 0 || betaNumerator > betaDenominator) 82 | { 83 | doIntersect = false; 84 | } 85 | } else if (betaNumerator > 0 || betaNumerator < betaDenominator) 86 | { 87 | doIntersect = false; 88 | } 89 | } 90 | 91 | if (doIntersect) 92 | { 93 | 94 | result = p1 + alphaNumerator * (p2 - p1) / alphaDenominator; 95 | } 96 | return result; 97 | } 98 | } -------------------------------------------------------------------------------- /Assets/TriangleNet/Tests/Scripts/MathUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5a705fd136053124583b289ce7af3a61 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Tests/Scripts/MeshDrawer.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 86d59ccacff82634982cf84ba76b7cbb 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Tests/Scripts/MeshDrawer/MeshDrawer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using TriangleNet.Geometry; 5 | using UnityEngine; 6 | 7 | namespace TriangleNet 8 | { 9 | public class MeshDrawer : MonoBehaviour 10 | { 11 | [SerializeField] private Material _MeshMaterial; 12 | [SerializeField] private Material _ContourMaterial; 13 | [SerializeField] private Material _HoleMaterial; 14 | [SerializeField] private float _UVScale; 15 | [SerializeField] private float _ContourLockRadius; 16 | private List _Contour; 17 | private List> _Holes; 18 | 19 | private MeshDrawerState _CurrentState; 20 | private List _CurrentHole; 21 | private Vector3 _CurrentMousePosition; 22 | 23 | private void Start() 24 | { 25 | _Contour = new List(); 26 | _Holes = new List>(); 27 | } 28 | 29 | void Update() 30 | { 31 | if(_CurrentState == MeshDrawerState.Nothing) return;; 32 | 33 | _CurrentMousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); 34 | if (Input.GetMouseButtonDown(0)) 35 | { 36 | var currentContour = _CurrentState == MeshDrawerState.DrawContour ? _Contour : _CurrentHole; 37 | if (currentContour.Count > 1 && Vector2.Distance(currentContour[0], _CurrentMousePosition) < _ContourLockRadius) 38 | { 39 | if (_CurrentState == MeshDrawerState.DrawHole) 40 | { 41 | _Holes.Add(_CurrentHole); 42 | _CurrentHole = null; 43 | } 44 | _CurrentState = MeshDrawerState.Nothing; 45 | 46 | } 47 | else 48 | { 49 | currentContour.Add(_CurrentMousePosition); 50 | } 51 | } 52 | } 53 | 54 | public void StartDrawContour() 55 | { 56 | if(_CurrentState != MeshDrawerState.Nothing) return; 57 | Clear(); 58 | _CurrentState = MeshDrawerState.DrawContour; 59 | } 60 | public void StartDrawHole() 61 | { 62 | if(_CurrentState != MeshDrawerState.Nothing) return; 63 | _CurrentState = MeshDrawerState.DrawHole; 64 | _CurrentHole = new List(); 65 | 66 | } 67 | public void GenerateMesh() 68 | { 69 | if(_CurrentState != MeshDrawerState.Nothing) return; 70 | Polygon poly = new Polygon(); 71 | poly.Add(_Contour); 72 | foreach (var hole in _Holes) 73 | { 74 | poly.Add(hole, true); 75 | } 76 | 77 | var triangleNetMesh = (TriangleNetMesh) poly.Triangulate(); 78 | 79 | GameObject go = new GameObject("Generated mesh"); 80 | var mf = go.AddComponent(); 81 | var mesh = triangleNetMesh.GenerateUnityMesh(); 82 | mesh.uv = GenerateUv(mesh.vertices); 83 | mf.mesh = mesh; 84 | var mr = go.AddComponent(); 85 | mr.sharedMaterial = _MeshMaterial; 86 | 87 | var collider = go.AddComponent(); 88 | collider.points = _Contour.ToArray(); 89 | 90 | var rb = go.AddComponent(); 91 | rb.mass = triangleNetMesh.Triangles.Sum(tris => tris.Area); 92 | Clear(); 93 | } 94 | 95 | private Vector2[] GenerateUv(Vector3[] vertices) 96 | { 97 | Vector2[] uvs = new Vector2[vertices.Length]; 98 | for (int i = 0; i < vertices.Length; i++) 99 | { 100 | uvs[i] = new Vector2(vertices[i].x * _UVScale, vertices[i].y * _UVScale); 101 | } 102 | 103 | return uvs; 104 | } 105 | private void Clear() 106 | { 107 | 108 | _Contour.Clear(); 109 | _Holes.Clear(); 110 | } 111 | 112 | private void OnRenderObject() 113 | { 114 | if (_Contour.Count > 0) 115 | { 116 | _ContourMaterial.SetPass(0); 117 | GL.PushMatrix(); 118 | GL.Begin(GL.LINES); 119 | for (int i = 0; i < _Contour.Count - 1; ++i) 120 | { 121 | GL.Vertex(_Contour[i]); 122 | GL.Vertex(_Contour[i + 1]); 123 | } 124 | 125 | if (_CurrentState == MeshDrawerState.DrawContour) 126 | { 127 | GL.Vertex(_Contour[_Contour.Count - 1]); 128 | GL.Vertex(_CurrentMousePosition); 129 | } 130 | else 131 | { 132 | GL.Vertex(_Contour[_Contour.Count - 1]); 133 | GL.Vertex(_Contour[0]); 134 | } 135 | GL.End(); 136 | GL.PopMatrix(); 137 | } 138 | 139 | _HoleMaterial.SetPass(0); 140 | GL.PushMatrix(); 141 | GL.Begin(GL.LINES); 142 | if (_Holes.Count > 0) 143 | { 144 | for (int i = 0; i < _Holes.Count; i++) 145 | { 146 | for (int j = 0; j < _Holes[i].Count; ++j) 147 | { 148 | GL.Vertex(_Holes[i][j]); 149 | GL.Vertex(_Holes[i][(j + 1) % _Holes[i].Count]); 150 | } 151 | } 152 | } 153 | if (_CurrentHole != null && _CurrentHole.Count > 0) 154 | { 155 | for (int j = 0; j < _CurrentHole.Count - 1; ++j) 156 | { 157 | GL.Vertex(_CurrentHole[j]); 158 | GL.Vertex(_CurrentHole[(j + 1)]); 159 | } 160 | if (_CurrentState == MeshDrawerState.DrawHole) 161 | { 162 | GL.Vertex(_CurrentHole[_CurrentHole.Count - 1]); 163 | GL.Vertex(_CurrentMousePosition); 164 | } 165 | } 166 | 167 | 168 | GL.End(); 169 | GL.PopMatrix(); 170 | } 171 | private enum MeshDrawerState 172 | { 173 | Nothing, 174 | DrawContour, 175 | DrawHole 176 | } 177 | } 178 | } -------------------------------------------------------------------------------- /Assets/TriangleNet/Tests/Scripts/MeshDrawer/MeshDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dcf4b6f2e476b864d988d50b3f7e0169 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Tests/Scripts/TriangulationTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Diagnostics; 5 | using TriangleNet; 6 | using TriangleNet.Geometry; 7 | using TriangleNet.Meshing; 8 | using UnityEngine; 9 | using Debug = UnityEngine.Debug; 10 | using Random = UnityEngine.Random; 11 | 12 | public class TriangulationTest : MonoBehaviour 13 | { 14 | [SerializeField] private int _VertexCount; 15 | 16 | [SerializeField] private List _Contour; 17 | [SerializeField] private MeshFilter _Filter; 18 | private Polygon _Polygon; 19 | private TriangleNetMesh _TriangleNetMesh; 20 | 21 | public void GenerateRandomPoints() 22 | { 23 | _Contour.Clear(); 24 | for (int i = 0; i < _VertexCount; i++) 25 | { 26 | _Contour.Add(new Vector2(Random.Range(0, 10f), Random.Range(0, 10f))); 27 | } 28 | } 29 | public void Triangulate() 30 | { 31 | _Polygon = new Polygon(); 32 | foreach (var vector2 in _Contour) 33 | { 34 | _Polygon.Add(vector2); 35 | } 36 | _TriangleNetMesh = (TriangleNetMesh) _Polygon.Triangulate(); 37 | _Filter.mesh = _TriangleNetMesh.GenerateUnityMesh(); 38 | } 39 | 40 | private void OnDrawGizmosSelected() 41 | { 42 | if(_TriangleNetMesh != null) 43 | _TriangleNetMesh.DrawGizmos(); 44 | } 45 | } 46 | 47 | #if UNITY_EDITOR 48 | [UnityEditor.CustomEditor(typeof(TriangulationTest))] 49 | public class TriangulatorTestEditor : UnityEditor.Editor 50 | { 51 | public override void OnInspectorGUI() 52 | { 53 | base.OnInspectorGUI(); 54 | if (GUILayout.Button("Generate points")) 55 | { 56 | var test = target as TriangulationTest; 57 | test.GenerateRandomPoints(); 58 | } 59 | if (GUILayout.Button("Triangulate")) 60 | { 61 | var test = target as TriangulationTest; 62 | test.Triangulate(); 63 | UnityEditor.SceneView.RepaintAll(); 64 | } 65 | 66 | } 67 | } 68 | #endif -------------------------------------------------------------------------------- /Assets/TriangleNet/Tests/Scripts/TriangulationTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6760f4321cac94e4c9be40ff486451fe 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangleNet/Tests/nox7atra.triangle.net.Tests.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nox7atra.triangle.net.Tests", 3 | "rootNamespace": "", 4 | "references": [ 5 | "GUID:0a9c05c03e25fee49a644b8ead257dab" 6 | ], 7 | "includePlatforms": [], 8 | "excludePlatforms": [], 9 | "allowUnsafeCode": false, 10 | "overrideReferences": false, 11 | "precompiledReferences": [], 12 | "autoReferenced": true, 13 | "defineConstraints": [], 14 | "versionDefines": [], 15 | "noEngineReferences": false 16 | } -------------------------------------------------------------------------------- /Assets/TriangleNet/Tests/nox7atra.triangle.net.Tests.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1bc521bc8b887e94b8563e3fdaa9ec0d 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/TriangleNet/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.nox7atra.triangle.net", 3 | "displayName": "TriangleNetUnity", 4 | "version": "1.0.0", 5 | "description": "A library that triangle.net with unity utility classes.", 6 | "keywords": [ 7 | "unity", 8 | "triangulation", 9 | "triangle.net" 10 | ], 11 | "author": "Nox7atra", 12 | "license": "MIT" 13 | } 14 | -------------------------------------------------------------------------------- /Assets/TriangleNet/package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 71f6f22f9f2bb6a4682e2e8dc59d6978 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Logs/ApiUpdaterCheck.txt: -------------------------------------------------------------------------------- 1 | [api-updater (non-obsolete-error-filter)] 14.02.2022 22:16:40 : Starting F:/Programs/2020.3.21f1/Editor/Data/Tools/ScriptUpdater/APIUpdater.NonObsoleteApiUpdaterDetector.exe 2 | [api-updater (non-obsolete-error-filter)] 3 | ---------------------------------- 4 | jit/startup time : 199,0326ms 5 | moved types parse time: 48ms 6 | candidates parse time : 1ms 7 | C# parse time : 567ms 8 | candidates check time : 93ms 9 | console write time : 0ms 10 | 11 | -------------------------------------------------------------------------------- /Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.2d.sprite": "1.0.0", 4 | "com.unity.2d.tilemap": "1.0.0", 5 | "com.unity.ads": "3.7.5", 6 | "com.unity.analytics": "3.6.11", 7 | "com.unity.collab-proxy": "1.13.5", 8 | "com.unity.ide.rider": "2.0.7", 9 | "com.unity.ide.visualstudio": "2.0.11", 10 | "com.unity.ide.vscode": "1.2.4", 11 | "com.unity.purchasing": "4.0.3", 12 | "com.unity.test-framework": "1.1.29", 13 | "com.unity.textmeshpro": "3.0.6", 14 | "com.unity.timeline": "1.4.8", 15 | "com.unity.ugui": "1.0.0", 16 | "com.unity.xr.legacyinputhelpers": "2.1.8", 17 | "com.unity.modules.ai": "1.0.0", 18 | "com.unity.modules.androidjni": "1.0.0", 19 | "com.unity.modules.animation": "1.0.0", 20 | "com.unity.modules.assetbundle": "1.0.0", 21 | "com.unity.modules.audio": "1.0.0", 22 | "com.unity.modules.cloth": "1.0.0", 23 | "com.unity.modules.director": "1.0.0", 24 | "com.unity.modules.imageconversion": "1.0.0", 25 | "com.unity.modules.imgui": "1.0.0", 26 | "com.unity.modules.jsonserialize": "1.0.0", 27 | "com.unity.modules.particlesystem": "1.0.0", 28 | "com.unity.modules.physics": "1.0.0", 29 | "com.unity.modules.physics2d": "1.0.0", 30 | "com.unity.modules.screencapture": "1.0.0", 31 | "com.unity.modules.terrain": "1.0.0", 32 | "com.unity.modules.terrainphysics": "1.0.0", 33 | "com.unity.modules.tilemap": "1.0.0", 34 | "com.unity.modules.ui": "1.0.0", 35 | "com.unity.modules.uielements": "1.0.0", 36 | "com.unity.modules.umbra": "1.0.0", 37 | "com.unity.modules.unityanalytics": "1.0.0", 38 | "com.unity.modules.unitywebrequest": "1.0.0", 39 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 40 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 41 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 42 | "com.unity.modules.unitywebrequestwww": "1.0.0", 43 | "com.unity.modules.vehicles": "1.0.0", 44 | "com.unity.modules.video": "1.0.0", 45 | "com.unity.modules.vr": "1.0.0", 46 | "com.unity.modules.wind": "1.0.0", 47 | "com.unity.modules.xr": "1.0.0" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | m_Volume: 1 7 | Rolloff Scale: 1 8 | Doppler Factor: 1 9 | Default Speaker Mode: 2 10 | m_SampleRate: 0 11 | m_DSPBufferSize: 1024 12 | m_VirtualVoiceCount: 512 13 | m_RealVoiceCount: 32 14 | m_SpatializerPlugin: 15 | m_AmbisonicDecoderPlugin: 16 | m_DisableAudio: 0 17 | m_VirtualizeEffects: 1 18 | -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 7 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_DefaultSolverIterations: 6 13 | m_DefaultSolverVelocityIterations: 1 14 | m_QueriesHitBackfaces: 0 15 | m_QueriesHitTriggers: 1 16 | m_EnableAdaptiveForce: 0 17 | m_ClothInterCollisionDistance: 0 18 | m_ClothInterCollisionStiffness: 0 19 | m_ContactsGeneration: 1 20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 21 | m_AutoSimulation: 1 22 | m_AutoSyncTransforms: 1 23 | m_ClothInterCollisionSettingsToggle: 0 24 | m_ContactPairsMode: 0 25 | m_BroadphaseType: 0 26 | m_WorldBounds: 27 | m_Center: {x: 0, y: 0, z: 0} 28 | m_Extent: {x: 250, y: 250, z: 250} 29 | m_WorldSubdivisions: 8 30 | -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: 8 | - enabled: 1 9 | path: Assets/Scenes/SampleScene.unity 10 | guid: 99c9720ab356a0642a771bea13969a05 11 | m_configObjects: {} 12 | -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 7 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_LineEndingsForNewScripts: 2 10 | m_DefaultBehaviorMode: 0 11 | m_SpritePackerMode: 0 12 | m_SpritePackerPaddingPower: 1 13 | m_EtcTextureCompressorBehavior: 1 14 | m_EtcTextureFastCompressor: 1 15 | m_EtcTextureNormalCompressor: 2 16 | m_EtcTextureBestCompressor: 4 17 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd 18 | m_ProjectGenerationRootNamespace: 19 | m_UserGeneratedProjectSuffix: 20 | m_CollabEditorSettings: 21 | inProgressEnabled: 1 22 | -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 12 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_AlwaysIncludedShaders: 32 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 33 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 36 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} 37 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 38 | - {fileID: 10783, guid: 0000000000000000f000000000000000, type: 0} 39 | m_PreloadedShaders: [] 40 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 41 | type: 0} 42 | m_CustomRenderPipeline: {fileID: 0} 43 | m_TransparencySortMode: 0 44 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 45 | m_DefaultRenderingPath: 1 46 | m_DefaultMobileRenderingPath: 1 47 | m_TierSettings: [] 48 | m_LightmapStripping: 0 49 | m_FogStripping: 0 50 | m_InstancingStripping: 0 51 | m_LightmapKeepPlain: 1 52 | m_LightmapKeepDirCombined: 1 53 | m_LightmapKeepDynamicPlain: 1 54 | m_LightmapKeepDynamicDirCombined: 1 55 | m_LightmapKeepShadowMask: 1 56 | m_LightmapKeepSubtractive: 1 57 | m_FogKeepLinear: 1 58 | m_FogKeepExp: 1 59 | m_FogKeepExp2: 1 60 | m_AlbedoSwatchInfos: [] 61 | m_LightsUseLinearIntensity: 0 62 | m_LightsUseColorTemperature: 0 63 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | m_LastAgentTypeID: -887442657 73 | m_Settings: 74 | - serializedVersion: 2 75 | agentTypeID: 0 76 | agentRadius: 0.5 77 | agentHeight: 2 78 | agentSlope: 45 79 | agentClimb: 0.75 80 | ledgeDropHeight: 0 81 | maxJumpAcrossDistance: 0 82 | minRegionArea: 2 83 | manualCellSize: 0 84 | cellSize: 0.16666667 85 | manualTileSize: 0 86 | tileSize: 256 87 | accuratePlacement: 0 88 | debug: 89 | m_Flags: 0 90 | m_SettingNames: 91 | - Humanoid 92 | -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!149 &1 4 | NetworkManager: 5 | m_ObjectHideFlags: 0 6 | m_DebugLevel: 0 7 | m_Sendrate: 15 8 | m_AssetToPrefab: {} 9 | -------------------------------------------------------------------------------- /ProjectSettings/PackageManagerSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 61 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | m_EnablePreviewPackages: 0 16 | m_EnablePackageDependencies: 0 17 | m_AdvancedSettingsExpanded: 1 18 | m_ScopedRegistriesSettingsExpanded: 1 19 | oneTimeWarningShown: 0 20 | m_Registries: 21 | - m_Id: main 22 | m_Name: 23 | m_Url: https://packages.unity.com 24 | m_Scopes: [] 25 | m_IsDefault: 1 26 | m_Capabilities: 7 27 | m_UserSelectedRegistryName: 28 | m_UserAddingNewScopedRegistry: 0 29 | m_RegistryInfoDraft: 30 | m_ErrorMessage: 31 | m_Original: 32 | m_Id: 33 | m_Name: 34 | m_Url: 35 | m_Scopes: [] 36 | m_IsDefault: 0 37 | m_Capabilities: 0 38 | m_Modified: 0 39 | m_Name: 40 | m_Url: 41 | m_Scopes: 42 | - 43 | m_SelectedScopeIndex: 0 44 | -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 3 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_BaumgarteScale: 0.2 17 | m_BaumgarteTimeOfImpactScale: 0.75 18 | m_TimeToSleep: 0.5 19 | m_LinearSleepTolerance: 0.01 20 | m_AngularSleepTolerance: 2 21 | m_DefaultContactOffset: 0.01 22 | m_AutoSimulation: 1 23 | m_QueriesHitTriggers: 1 24 | m_QueriesStartInColliders: 1 25 | m_ChangeStopsCallbacks: 0 26 | m_CallbacksOnDisable: 1 27 | m_AutoSyncTransforms: 1 28 | m_AlwaysShowColliders: 0 29 | m_ShowColliderSleep: 1 30 | m_ShowColliderContacts: 0 31 | m_ShowColliderAABB: 0 32 | m_ContactArrowScale: 0.2 33 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 34 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 35 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 36 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 37 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 38 | -------------------------------------------------------------------------------- /ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1386491679 &1 4 | PresetManager: 5 | m_ObjectHideFlags: 0 6 | m_DefaultList: 7 | - type: 8 | m_NativeTypeID: 108 9 | m_ManagedTypePPtr: {fileID: 0} 10 | m_ManagedTypeFallback: 11 | defaultPresets: 12 | - m_Preset: {fileID: 2655988077585873504, guid: c1cf8506f04ef2c4a88b64b6c4202eea, 13 | type: 2} 14 | - type: 15 | m_NativeTypeID: 1020 16 | m_ManagedTypePPtr: {fileID: 0} 17 | m_ManagedTypeFallback: 18 | defaultPresets: 19 | - m_Preset: {fileID: 2655988077585873504, guid: 0cd792cc87e492d43b4e95b205fc5cc6, 20 | type: 2} 21 | - type: 22 | m_NativeTypeID: 1006 23 | m_ManagedTypePPtr: {fileID: 0} 24 | m_ManagedTypeFallback: 25 | defaultPresets: 26 | - m_Preset: {fileID: 2655988077585873504, guid: 7a99f8aa944efe94cb9bd74562b7d5f9, 27 | type: 2} 28 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2020.3.21f1 2 | m_EditorVersionWithRevision: 2020.3.21f1 (a38c86f6690f) 3 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 4 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Very Low 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 15 17 | shadowNearPlaneOffset: 3 18 | shadowCascade2Split: 0.33333334 19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 20 | shadowmaskMode: 0 21 | blendWeights: 1 22 | textureQuality: 1 23 | anisotropicTextures: 0 24 | antiAliasing: 0 25 | softParticles: 0 26 | softVegetation: 0 27 | realtimeReflectionProbes: 0 28 | billboardsFaceCameraPosition: 0 29 | vSyncCount: 0 30 | lodBias: 0.3 31 | maximumLODLevel: 0 32 | particleRaycastBudget: 4 33 | asyncUploadTimeSlice: 2 34 | asyncUploadBufferSize: 4 35 | resolutionScalingFixedDPIFactor: 1 36 | excludedTargetPlatforms: [] 37 | - serializedVersion: 2 38 | name: Low 39 | pixelLightCount: 0 40 | shadows: 0 41 | shadowResolution: 0 42 | shadowProjection: 1 43 | shadowCascades: 1 44 | shadowDistance: 20 45 | shadowNearPlaneOffset: 3 46 | shadowCascade2Split: 0.33333334 47 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 48 | shadowmaskMode: 0 49 | blendWeights: 2 50 | textureQuality: 0 51 | anisotropicTextures: 0 52 | antiAliasing: 0 53 | softParticles: 0 54 | softVegetation: 0 55 | realtimeReflectionProbes: 0 56 | billboardsFaceCameraPosition: 0 57 | vSyncCount: 0 58 | lodBias: 0.4 59 | maximumLODLevel: 0 60 | particleRaycastBudget: 16 61 | asyncUploadTimeSlice: 2 62 | asyncUploadBufferSize: 4 63 | resolutionScalingFixedDPIFactor: 1 64 | excludedTargetPlatforms: [] 65 | - serializedVersion: 2 66 | name: Medium 67 | pixelLightCount: 1 68 | shadows: 1 69 | shadowResolution: 0 70 | shadowProjection: 1 71 | shadowCascades: 1 72 | shadowDistance: 20 73 | shadowNearPlaneOffset: 3 74 | shadowCascade2Split: 0.33333334 75 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 76 | shadowmaskMode: 0 77 | blendWeights: 2 78 | textureQuality: 0 79 | anisotropicTextures: 1 80 | antiAliasing: 0 81 | softParticles: 0 82 | softVegetation: 0 83 | realtimeReflectionProbes: 0 84 | billboardsFaceCameraPosition: 0 85 | vSyncCount: 1 86 | lodBias: 0.7 87 | maximumLODLevel: 0 88 | particleRaycastBudget: 64 89 | asyncUploadTimeSlice: 2 90 | asyncUploadBufferSize: 4 91 | resolutionScalingFixedDPIFactor: 1 92 | excludedTargetPlatforms: [] 93 | - serializedVersion: 2 94 | name: High 95 | pixelLightCount: 2 96 | shadows: 2 97 | shadowResolution: 1 98 | shadowProjection: 1 99 | shadowCascades: 2 100 | shadowDistance: 40 101 | shadowNearPlaneOffset: 3 102 | shadowCascade2Split: 0.33333334 103 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 104 | shadowmaskMode: 1 105 | blendWeights: 2 106 | textureQuality: 0 107 | anisotropicTextures: 1 108 | antiAliasing: 2 109 | softParticles: 0 110 | softVegetation: 1 111 | realtimeReflectionProbes: 1 112 | billboardsFaceCameraPosition: 1 113 | vSyncCount: 1 114 | lodBias: 1 115 | maximumLODLevel: 0 116 | particleRaycastBudget: 256 117 | asyncUploadTimeSlice: 2 118 | asyncUploadBufferSize: 4 119 | resolutionScalingFixedDPIFactor: 1 120 | excludedTargetPlatforms: [] 121 | - serializedVersion: 2 122 | name: Very High 123 | pixelLightCount: 3 124 | shadows: 2 125 | shadowResolution: 2 126 | shadowProjection: 1 127 | shadowCascades: 2 128 | shadowDistance: 40 129 | shadowNearPlaneOffset: 3 130 | shadowCascade2Split: 0.33333334 131 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 132 | shadowmaskMode: 1 133 | blendWeights: 4 134 | textureQuality: 0 135 | anisotropicTextures: 1 136 | antiAliasing: 4 137 | softParticles: 1 138 | softVegetation: 1 139 | realtimeReflectionProbes: 1 140 | billboardsFaceCameraPosition: 1 141 | vSyncCount: 1 142 | lodBias: 1.5 143 | maximumLODLevel: 0 144 | particleRaycastBudget: 1024 145 | asyncUploadTimeSlice: 2 146 | asyncUploadBufferSize: 4 147 | resolutionScalingFixedDPIFactor: 1 148 | excludedTargetPlatforms: [] 149 | - serializedVersion: 2 150 | name: Ultra 151 | pixelLightCount: 4 152 | shadows: 2 153 | shadowResolution: 2 154 | shadowProjection: 1 155 | shadowCascades: 4 156 | shadowDistance: 150 157 | shadowNearPlaneOffset: 3 158 | shadowCascade2Split: 0.33333334 159 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 160 | shadowmaskMode: 1 161 | blendWeights: 4 162 | textureQuality: 0 163 | anisotropicTextures: 1 164 | antiAliasing: 4 165 | softParticles: 1 166 | softVegetation: 1 167 | realtimeReflectionProbes: 1 168 | billboardsFaceCameraPosition: 1 169 | vSyncCount: 1 170 | lodBias: 2 171 | maximumLODLevel: 0 172 | particleRaycastBudget: 4096 173 | asyncUploadTimeSlice: 2 174 | asyncUploadBufferSize: 4 175 | resolutionScalingFixedDPIFactor: 1 176 | excludedTargetPlatforms: [] 177 | m_PerPlatformDefaultQuality: 178 | Android: 2 179 | Nintendo 3DS: 5 180 | Nintendo Switch: 5 181 | PS4: 5 182 | PSP2: 2 183 | Standalone: 5 184 | Tizen: 2 185 | WebGL: 3 186 | WiiU: 5 187 | Windows Store Apps: 5 188 | XboxOne: 5 189 | iPhone: 2 190 | tvOS: 2 191 | -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - PostProcessing 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.1 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | m_Enabled: 0 7 | m_TestMode: 0 8 | m_TestEventUrl: 9 | m_TestConfigUrl: 10 | m_TestInitMode: 0 11 | CrashReportingSettings: 12 | m_EventUrl: https://perf-events.cloud.unity3d.com/api/events/crashes 13 | m_NativeEventUrl: https://perf-events.cloud.unity3d.com/symbolicate 14 | m_Enabled: 0 15 | m_CaptureEditorExceptions: 1 16 | UnityPurchasingSettings: 17 | m_Enabled: 0 18 | m_TestMode: 0 19 | UnityAnalyticsSettings: 20 | m_Enabled: 0 21 | m_InitializeOnStartup: 1 22 | m_TestMode: 0 23 | m_TestEventUrl: 24 | m_TestConfigUrl: 25 | UnityAdsSettings: 26 | m_Enabled: 0 27 | m_InitializeOnStartup: 1 28 | m_TestMode: 0 29 | m_IosGameId: 30 | m_AndroidGameId: 31 | m_GameIds: {} 32 | m_GameId: 33 | PerformanceReportingSettings: 34 | m_Enabled: 0 35 | -------------------------------------------------------------------------------- /ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!937362698 &1 4 | VFXManager: 5 | m_ObjectHideFlags: 0 6 | m_IndirectShader: {fileID: 0} 7 | m_CopyBufferShader: {fileID: 0} 8 | m_SortShader: {fileID: 0} 9 | m_StripUpdateShader: {fileID: 0} 10 | m_RenderPipeSettingsPath: 11 | m_FixedTimeStep: 0.016666668 12 | m_MaxDeltaTime: 0.05 13 | m_CompiledVersion: 0 14 | m_RuntimeVersion: 0 15 | -------------------------------------------------------------------------------- /ProjectSettings/VersionControlSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!890905787 &1 4 | VersionControlSettings: 5 | m_ObjectHideFlags: 0 6 | m_Mode: Visible Meta Files 7 | m_CollabEditorSettings: 8 | inProgressEnabled: 1 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Triangle.Net-for-Unity 2 | 3 | Установка через Unity Package Manager / Add package from git URL: https://github.com/Nox7atra/Triangle.Net-for-Unity.git?path=/Assets/TriangleNet 4 | 5 | Article about (rus): https://habr.com/post/435374/ 6 | 7 | ## Extention Methods 8 | 9 | *public static void Add(this Polygon polygon, List contour, bool isHole = false)* - Add contour to Polygon 10 | 11 | *public static void Add(this Polygon polygon, Vector2 vertex)* - Add vertex to Polygon 12 | 13 | *public static Mesh GenerateUnityMesh(this TriangleNetMesh triangleNetMesh, QualityOptions options = null)* - Generate Unity Mesh 14 | -------------------------------------------------------------------------------- /UserSettings/EditorUserSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nox7atra/Triangle.Net-for-Unity/de1bb020f97f730257a1e49f1afd87954663be71/UserSettings/EditorUserSettings.asset --------------------------------------------------------------------------------