Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
315a1d8
add third party asset: UnityMainThreadDispatcher
wilhelmberg Apr 24, 2017
764a3c1
change mapbox-sdk-cs dependency to branch BergWerkGIS-multithread-fil…
wilhelmberg Apr 24, 2017
99de9fa
threaded slippy test scene
Apr 24, 2017
8ea362a
Fixing some compile errors.
Apr 24, 2017
7a43ae2
remove Mapbox.Unity.Utilities.HTTPRequest
wilhelmberg Apr 25, 2017
4857a89
Merge branch 'BergWerkGIS-multithread-filesource' of https://github.c…
wilhelmberg Apr 25, 2017
4f2f538
update mapbox-sdk-cs
wilhelmberg Apr 25, 2017
af041f2
UnityMainThreadDispatcher
wilhelmberg Apr 25, 2017
56f2334
update vector-tile-cs
wilhelmberg Apr 25, 2017
9e195a4
MapboxAccess: add CertificateValidationCallback
wilhelmberg Apr 25, 2017
69d29d8
revert update of vector-tile-cs as latest changes (generic geometry, …
wilhelmberg Apr 25, 2017
cb8cfe7
Fixed thread dispatcher so that it works outside the editor. Profilin…
Apr 25, 2017
3cc01e6
add UnityToolbag Dispatcher
wilhelmberg Apr 26, 2017
5bbbf86
update mapbox-sdk-cs for much(!) improved HTTPWebRequest speed
wilhelmberg Apr 26, 2017
eeb36d4
updated scene with toolbag and slippy for testing
Apr 27, 2017
7ed290a
update mapbox-sdk-cs to latest HTTPRequest dev
wilhelmberg May 3, 2017
cd235ca
Merge branch 'develop' of https://github.com/mapbox/mapbox-unity-sdk …
wilhelmberg May 3, 2017
a239948
remove UnityMainThreadDispatcher
wilhelmberg May 3, 2017
792adab
fixes for latest mapbox-sdk-cs multithreaded HTTPRequets
wilhelmberg May 3, 2017
2802a74
UnityToolbagDispatcher: UWP fix
wilhelmberg May 3, 2017
7a94551
[wip] make UnityToolbag.Dispatcher work in Editor mode
wilhelmberg May 4, 2017
d337a8a
revert UnityToolbag.Dispatcher
wilhelmberg May 5, 2017
e3f1f6e
update mapbox-sdk-cs to use Mapbox.Unity.DispatcherEditor
wilhelmberg May 5, 2017
40d17d8
UnityToolbag.Dispatcher: make '_instanceExists' public
wilhelmberg May 5, 2017
cbbda55
add Mapbox.Unity.DispatcherEditor.cs
wilhelmberg May 5, 2017
399c035
update mapbox-sdk-cs to latest IAsyncRequestFactory branch
wilhelmberg May 8, 2017
02f8e05
update to latest mapbox-sdk-cs@IAsyncFactory
wilhelmberg May 9, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dependencies/mapbox-sdk-cs
Submodule mapbox-sdk-cs updated 44 files
+0 −34 MapboxSdkCs.sln
+1 −0 src/Map/ClassicRasterTile.cs
+22 −0 src/Map/ClassicRetinaRasterTile.cs
+2 −16 src/Map/Map.csproj
+1 −1 src/Map/Map.project.json
+2 −0 src/Map/MapUWP.csproj
+22 −0 src/Map/RetinaRasterTile.cs
+74 −70 src/Map/Tile.cs
+46 −36 src/Map/TileResource.cs
+18 −35 src/Map/VectorTile.cs
+0 −78 src/Mono/FileSource.cs
+0 −73 src/Mono/HTTPRequest.cs
+0 −64 src/Mono/Mono.csproj
+0 −4 src/Mono/Mono.project.json
+0 −144 src/Mono/MonoUWP.csproj
+0 −23 src/Mono/Properties/AssemblyInfo.cs
+0 −33 src/Mono/Properties/MonoUWP.rd.xml
+0 −5 src/Mono/packages.config
+0 −16 src/Mono/project.json
+149 −0 src/Platform/FileSource.cs
+337 −0 src/Platform/HTTPRequestNonThreaded.cs
+400 −0 src/Platform/HTTPRequestThreaded-2.cs
+416 −0 src/Platform/HTTPRequestThreaded.cs
+8 −4 src/Platform/IAsyncRequest.cs
+35 −0 src/Platform/IAsyncRequestFactory.cs
+3 −5 src/Platform/IFileSource.cs
+4 −0 src/Platform/Platform.csproj
+4 −0 src/Platform/PlatformUWP.csproj
+50 −6 src/Platform/Response.cs
+43 −0 src/Utils/UnixTimestampUtils.cs
+1 −0 src/Utils/Utils.csproj
+1 −0 src/Utils/UtilsUWP.csproj
+24 −27 test/UnitTest/CompressionTest.cs
+2 −1 test/UnitTest/DirectionsTest.cs
+194 −0 test/UnitTest/FileSourceMockApiTest.cs
+105 −105 test/UnitTest/FileSourceTest.cs
+15 −18 test/UnitTest/GeocoderTest.cs
+18 −26 test/UnitTest/MapTest.cs
+3 −2 test/UnitTest/TileTest.cs
+15 −4 test/UnitTest/UnitTest.csproj
+63 −60 test/UnitTest/Utils.cs
+45 −37 test/UnitTest/VectorTileTest.cs
+11 −0 test/UnitTest/app.config
+3 −0 test/UnitTest/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private void Run(UnityTile tile)
var rasterTile = parameters.MapId.StartsWith("mapbox://") ? new RasterTile() : new ClassicRasterTile();
rasterTile.Initialize(parameters, (Action)(() =>
{
if (rasterTile.Error != null)
if (rasterTile.HasError)
{
tile.ImageDataState = TilePropertyState.Error;
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
namespace Mapbox.Unity.MeshGeneration.Factories
{
using System.Collections.Generic;
using UnityEngine;
using Mapbox.Unity.MeshGeneration.Enums;
using Mapbox.Unity.MeshGeneration.Data;
using Mapbox.Unity.MeshGeneration.Interfaces;
using Mapbox.Platform;
using System.Collections.Generic;
using UnityEngine;
using Mapbox.Unity.MeshGeneration.Enums;
using Mapbox.Unity.MeshGeneration.Data;
using Mapbox.Unity.MeshGeneration.Interfaces;
using Mapbox.Platform;
using System.Linq;

/// <summary>
/// Uses vector tile api to visualize vector data.
/// Fetches the vector data for given tile and passes layer data to layer visualizers.
/// </summary>
[CreateAssetMenu(menuName = "Mapbox/Factories/Mesh Factory")]
/// <summary>
/// Uses vector tile api to visualize vector data.
/// Fetches the vector data for given tile and passes layer data to layer visualizers.
/// </summary>
[CreateAssetMenu(menuName = "Mapbox/Factories/Mesh Factory")]
public class MeshFactory : Factory
{
[SerializeField]
Expand Down Expand Up @@ -107,9 +108,9 @@ private void CreateMeshes(UnityTile tile, object e)
var vectorTile = new Mapbox.Map.VectorTile();
vectorTile.Initialize(parameters, () =>
{
if (vectorTile.Error != null)
if (vectorTile.HasError)
{
Debug.Log(vectorTile.Error);
Debug.Log(string.Join(System.Environment.NewLine, vectorTile.Exceptions.Select(ex=>ex.Message).ToArray()));
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private void CreateTerrainHeight(UnityTile tile, float heightMultiplier = 1)
var pngRasterTile = new RawPngRasterTile();
pngRasterTile.Initialize(parameters, () =>
{
if (pngRasterTile.Error != null)
if (pngRasterTile.HasError)
{
tile.HeightDataState = TilePropertyState.Error;
return;
Expand Down
51 changes: 51 additions & 0 deletions sdkproject/Assets/Mapbox/Core/Unity/Utilities/DispatcherEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
namespace Mapbox.Unity {


using System;
using System.Collections.Generic;
using System.Threading;
using UnityEditor;


[InitializeOnLoad]
public static class DispatcherEditor {


static DispatcherEditor() {
_mainThread = Thread.CurrentThread;
EditorApplication.update += Update;
}


private static object _lock = new object();
private static readonly Queue<Action> _actions = new Queue<Action>();
private static Thread _mainThread;


private static bool isMainThread {
get { return Thread.CurrentThread == _mainThread; }
}


public static void Update() {
lock (_lock) {
while (_actions.Count > 0) {
_actions.Dequeue()();
}
}
}


public static void InvokeAsync(Action action) {
if (isMainThread) {
action();
}else {
lock (_lock) {
_actions.Enqueue(action);
}
}
}


}
}
61 changes: 0 additions & 61 deletions sdkproject/Assets/Mapbox/Core/Unity/Utilities/HTTPRequest.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void ToggleDropdownStyles(int target)
/// <param name="tile">Tile.</param>
public void OnNext(RasterTile tile)
{
if (tile.CurrentState != Tile.State.Loaded || tile.Error != null)
if (tile.CurrentState != Tile.State.Loaded || tile.HasError)
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void Redraw()
/// <param name="tile">Tile.</param>
public void OnNext(VectorTile tile)
{
if (tile.CurrentState != Tile.State.Loaded || tile.Error != null)
if (tile.CurrentState != Tile.State.Loaded || tile.HasError)
{
return;
}
Expand Down
4 changes: 2 additions & 2 deletions sdkproject/Assets/Mapbox/Examples/Voxels/Scripts/VoxelTile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void FetchWorldData(Vector2d coordinates)

public void OnNext(RasterTile tile)
{
if (tile.CurrentState == Tile.State.Loaded && string.IsNullOrEmpty(tile.Error))
if (tile.CurrentState == Tile.State.Loaded && !tile.HasError)
{
_rasterTexture = new Texture2D(2, 2);
_rasterTexture.LoadImage(tile.Data);
Expand All @@ -131,7 +131,7 @@ public void OnNext(RasterTile tile)

public void OnNext(RawPngRasterTile tile)
{
if (tile.CurrentState == Tile.State.Loaded && string.IsNullOrEmpty(tile.Error))
if (tile.CurrentState == Tile.State.Loaded && !tile.HasError)
{
_elevationTexture = new Texture2D(2, 2);
_elevationTexture.LoadImage(tile.Data);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
using UnityEngine;
using System;
using System.Collections.Generic;
using System.Threading;

namespace UnityToolbag {
/// <summary>
/// A system for dispatching code to execute on the main thread.
/// </summary>
[AddComponentMenu("UnityToolbag/Dispatcher")]
public class Dispatcher : MonoBehaviour {
private static Dispatcher _instance;

// We can't use the behaviour reference from other threads, so we use a separate bool
// to track the instance so we can use that on the other threads.
// edit by BergWerkGIS: make public to see if dispatcher is attached
public static bool _instanceExists;

private static Thread _mainThread;
private static object _lockObject = new object();
private static readonly Queue<Action> _actions = new Queue<Action>();

/// <summary>
/// Gets a value indicating whether or not the current thread is the game's main thread.
/// </summary>
public static bool isMainThread {
get {
return Thread.CurrentThread == _mainThread;
}
}

/// <summary>
/// Queues an action to be invoked on the main game thread.
/// </summary>
/// <param name="action">The action to be queued.</param>
public static void InvokeAsync(Action action) {

if (!_instanceExists) {
Debug.LogError("No Dispatcher exists in the scene. Actions will not be invoked!");
return;
}

if (isMainThread) {
// Don't bother queuing work on the main thread; just execute it.
action();
} else {
lock (_lockObject) {
_actions.Enqueue(action);
}
}
}

/// <summary>
/// Queues an action to be invoked on the main game thread and blocks the
/// current thread until the action has been executed.
/// </summary>
/// <param name="action">The action to be queued.</param>
public static void Invoke(Action action) {

if (!_instanceExists) {
Debug.LogError("No Dispatcher exists in the scene. Actions will not be invoked!");
return;
}


bool hasRun = false;

InvokeAsync(() => {
action();
hasRun = true;
});

// Lock until the action has run
while (!hasRun) {
#if !NETFX_CORE
Thread.Sleep(5);
#else
System.Threading.Tasks.Task.Delay(5).Wait();
#endif
}
}

void Awake() {
if (_instance) {
DestroyImmediate(this);
} else {
_instance = this;
_instanceExists = true;
_mainThread = Thread.CurrentThread;
}
}

void OnDestroy() {
if (_instance == this) {
_instance = null;
_instanceExists = false;
}
}

//int cnt = 0;
void Update() {
//cnt++;
//if (cnt < 100) { return; }
//cnt = 0;
////if (_actions.Count > 0) UnityEngine.Debug.Log("-------------------- update -----------------" + DateTime.Now.Ticks);
lock (_lockObject) {
while (_actions.Count > 0) {
//UnityEngine.Debug.Log("QUEUE: " + _actions.Count + " " + DateTime.Now.Ticks);
_actions.Dequeue()();
}
}
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading