From 322ce6688cf3d9da072f01cb386171d2945616de Mon Sep 17 00:00:00 2001 From: bartjuhhh <bart.knuiman@wur.nl> Date: Wed, 5 Jul 2023 18:12:30 +0200 Subject: [PATCH] Fixes --- Runtime/VectorTile.cs | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/Runtime/VectorTile.cs b/Runtime/VectorTile.cs index 6288f8c..c978537 100644 --- a/Runtime/VectorTile.cs +++ b/Runtime/VectorTile.cs @@ -119,12 +119,6 @@ namespace Wander return finished; } - static bool IsTriangleCCW( Vector2 vertex1, Vector2 vertex2, Vector2 vertex3 ) - { - float signedArea = (vertex2.x - vertex1.x) * (vertex3.y - vertex1.y) - (vertex3.x - vertex1.x) * (vertex2.y - vertex1.y); - return signedArea > 0; - } - // Number of failed polys to triangulate are returned. public int Triangulate() { @@ -172,15 +166,6 @@ namespace Wander double y = vertices[indices[k]*2+1]; poly.vertices.Add( new Vector2( (float)x, (float)y ) ); } - //for ( int k = 0; k < indices.Count; k += 3) - //{ - // if ( !IsTriangleCCW( poly.vertices[k], poly.vertices[k+1], poly.vertices[k+2] )) - // { - // var t = poly.vertices[k]; - // poly.vertices[k] = poly.vertices[k+2]; - // poly.vertices[k+2] = t; - // } - //} polygons[polygons.Count-1] = poly; UnityEngine.Debug.Assert( poly.vertices.Count % 3 == 0 ); } @@ -319,12 +304,12 @@ namespace Wander layersIdentified = true; } - // Calls callback(x, y, channel) for each raster position (256 channels) where each value represents a single channel. - // If no polygon was hit, 255 is called. - // If polygon was hit, but no feature was matched, 254 is called. + // Generates a raster for each position (pixel) (256 channels) where each value represents a single channel. + // If no polygon was hit, 255 is encoded. + // If polygon was hit, but no feature was matched, 254 is encoded. // Returns a list of failed to match pixels. This can be due to geometry not exactly matching or a layer not being found. - // Also out puts a remap of layer indices. For instance for a specific tile, only layerIdx 1, 6 and 3 are used. - // Then this a remapping of 1->0, 6->1, 3->2. So that in the shader only 3 textures are needed starting from 0, 1.. etc. + // Also outputs a remap of layer indices. For instance for a specific tile, only layerIdx 1, 6 and 3 are used. + // Then it applies a remapping of 1->0, 6->1, 3->2. So that in the shader only 3 textures are needed starting from 0, 1.. etc. public byte[] RenderToTextureSingle( int resolution, out Dictionary<byte, byte> remappedLayerIndices, @@ -377,7 +362,7 @@ namespace Wander { for( int t = 0; t < node.triangles.Count; t++ ) { - int ti = (cachedTriIdx + t) % node.triangles.Count; + int ti = (cachedTriIdx + t) % node.triangles.Count; // Continue searching where we left off int l = node.triangles[ti].Item1; int f = node.triangles[ti].Item2; int t2 = node.triangles[ti].Item3; -- GitLab