Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions sdkproject/Assets/Mapbox/Core/Unity/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace Mapbox.Unity
{
using UnityEngine;

public static class Constants
{
public static class Path
Expand All @@ -9,5 +11,15 @@ public static class Path
/// </summary>
public const string TOKEN_FILE = "MapboxAccess.text";
}

/// <summary>
/// Store common vector constants to avoid the method access cost of Unity's convenience getters.
/// </summary>
public static class Math
{
public static readonly Vector3 Vector3Zero = new Vector3(0, 0, 0);
public static readonly Vector3 Vector3Up = new Vector3(0, 1, 0);
public static readonly Vector3 Vector3Down = new Vector3(0, -1, 0);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public override void OnInspectorGUI()
EditorGUILayout.PropertyField(mapIdType_Prop);
switch ((MapIdType)mapIdType_Prop.enumValueIndex)
{
case MapIdType.StandardHeight:
case MapIdType.Standard:
GUI.enabled = false;
EditorGUILayout.PropertyField(mapId_Prop, new GUIContent("Map Id"));
mapId_Prop.stringValue = _defaultMapId;
Expand All @@ -74,7 +74,7 @@ public override void OnInspectorGUI()
EditorGUILayout.PropertyField(mapIdType_Prop);
switch ((MapIdType)mapIdType_Prop.enumValueIndex)
{
case MapIdType.StandardHeight:
case MapIdType.Standard:
GUI.enabled = false;
EditorGUILayout.PropertyField(mapId_Prop, new GUIContent("Map Id"));
mapId_Prop.stringValue = _defaultMapId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public enum TerrainGenerationType

public enum MapIdType
{
StandardHeight,
Standard,
Custom
}

Expand Down Expand Up @@ -142,7 +142,6 @@ private void GenerateTerrainMesh(UnityTile tile, float heightMultiplier)
var go = tile.gameObject;
var mesh = new MeshData();
mesh.Vertices = new List<Vector3>(_sampleCount * _sampleCount);
mesh.Normals = new List<Vector3>(_sampleCount * _sampleCount);
var step = 1f / (_sampleCount - 1);
for (float y = 0; y < _sampleCount; y++)
{
Expand All @@ -161,12 +160,11 @@ private void GenerateTerrainMesh(UnityTile tile, float heightMultiplier)
(int)((1 - yrat) * 255)),
tile.RelativeScale),
(float)(yy - tile.Rect.Center.y)));
mesh.Normals.Add(Unity.Constants.Math.Vector3Up);
mesh.UV[0].Add(new Vector2(x * step, 1 - (y * step)));
}
}

//we can read these from a hardcoded dictionary as well
//no need to calculate this every single time unless we need a really high range for sampleCount
var trilist = new List<int>();
var dir = Vector3.zero;
int vertA, vertB, vertC;
Expand Down