private static void OnElementFoundHandler(int tag, long id, IntPtr tagPtr, int tagCount,
                                                  IntPtr vertexPtr, int vertexCount, IntPtr stylePtr, int styleCount)
        {
            // NOTE see note above
            var vertices = MarshalUtils.ReadDoubles(vertexPtr, vertexCount);
            var tags     = MarshalUtils.ReadStrings(tagPtr, tagCount);
            var styles   = MarshalUtils.ReadStrings(stylePtr, styleCount);

            Element element = MapDataAdapter.AdaptElement(id, tags, vertices, styles);

            foreach (var observer in _queryObservers)
            {
                observer.OnNext(element);
            }
        }
示例#2
0
        private static void OnElementLoadedHandler(int tag, long id, IntPtr tagPtr, int tagCount,
                                                   IntPtr vertexPtr, int vertexCount, IntPtr stylePtr, int styleCount)
        {
            Tile tile;

            if (!Tiles.TryGetValue(tag, out tile) || tile.IsDisposed)
            {
                return;
            }

            // NOTE see note above
            var vertices = MarshalUtils.ReadDoubles(vertexPtr, vertexCount);
            var tags     = MarshalUtils.ReadStrings(tagPtr, tagCount);
            var styles   = MarshalUtils.ReadStrings(stylePtr, styleCount);

            MapDataAdapter.AdaptElement(tile, _sMaterialProvider, _observers, _trace, id, vertices, tags, styles);
        }
示例#3
0
        private static void OnMeshBuiltHandler(int tag, string name, IntPtr vertexPtr, int vertexCount,
                                               IntPtr trianglePtr, int triangleCount, IntPtr colorPtr, int colorCount,
                                               IntPtr uvPtr, int uvCount, IntPtr uvMapPtr, int uvMapCount)
        {
            Tile tile;

            if (!Tiles.TryGetValue(tag, out tile) || tile.IsDisposed)
            {
                return;
            }

            // NOTE ideally, arrays should be marshalled automatically which could enable some optimizations,
            // especially, for il2cpp. However, I was not able to make it work using il2cpp setting: all arrays
            // were passed to this method with just one element. I gave up and decided to use manual marshalling
            // here and in AdaptElement method below.
            var vertices  = MarshalUtils.ReadDoubles(vertexPtr, vertexCount);
            var triangles = MarshalUtils.ReadInts(trianglePtr, triangleCount);
            var colors    = MarshalUtils.ReadInts(colorPtr, colorCount);
            var uvs       = MarshalUtils.ReadDoubles(uvPtr, uvCount);
            var uvMap     = MarshalUtils.ReadInts(uvMapPtr, uvMapCount);

            MapDataAdapter.AdaptMesh(tile, _sMaterialProvider, _observers, _trace, name, vertices, triangles, colors, uvs, uvMap);
        }