Beispiel #1
0
        internal NativeArray <bool> GetVertexMarkerFromMeshUV(int lod)
        {
            int dimension = GGeometryJobUtilities.VERTEX_MARKER_DIMENSION;
            NativeArray <bool> markers = new NativeArray <bool>(dimension * dimension, Allocator.TempJob);

            Mesh m = GetMesh(lod);

            Vector2[] uvs = m.uv;
            int       x   = 0;
            int       y   = 0;
            Vector2   uv  = Vector2.zero;

            for (int i = 0; i < uvs.Length; ++i)
            {
                uv = uvs[i];
                x  = (int)(uv.x * (dimension - 1));
                y  = (int)(uv.y * (dimension - 1));
                markers[GGeometryJobUtilities.To1DIndex(ref x, ref y, ref dimension)] = true;
            }

            GUtilities.EnsureArrayLength(ref vertexMarker_Cache, markers.Length);
            markers.CopyTo(vertexMarker_Cache);

            return(markers);
        }
        public static void MarkVertex(ref NativeArray <bool> markerArray, ref Vector2 p)
        {
            int dimension = VERTEX_MARKER_DIMENSION;
            int x         = (int)(p.x * (dimension - 1));
            int y         = (int)(p.y * (dimension - 1));

            markerArray[GGeometryJobUtilities.To1DIndex(ref x, ref y, ref dimension)] = true;
        }
        public static bool GetVertexMark(NativeArray <bool> markers, Vector2 p, bool flipX = false, bool flipY = false)
        {
            if (flipX)
            {
                p.x = 1 - p.x;
            }
            if (flipY)
            {
                p.y = 1 - p.y;
            }

            int dimension = VERTEX_MARKER_DIMENSION;
            int x         = (int)(p.x * (dimension - 1));
            int y         = (int)(p.y * (dimension - 1));

            //mark = markerArray[GGeometryJobUtilities.To1DIndex(ref x, ref y, ref dimension)];
            return(markers[GGeometryJobUtilities.To1DIndex(ref x, ref y, ref dimension)]);
        }