Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into release-2021.2
Browse files Browse the repository at this point in the history
  • Loading branch information
lokesku committed Jul 2, 2021
2 parents 19b90e5 + 90c47ce commit 9e22149
Show file tree
Hide file tree
Showing 22 changed files with 117 additions and 91 deletions.
39 changes: 37 additions & 2 deletions Assets/Scripts/Editor/Map/MapAnnotations.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2019-2020 LG Electronics, Inc.
* Copyright (c) 2019-2021 LG Electronics, Inc.
*
* This software contains code licensed as described in LICENSE.
*
Expand All @@ -16,6 +16,7 @@
using UnityEngine.SceneManagement;
using System.Text.RegularExpressions;
using Simulator.Editor;
using UnityEditor.SceneManagement;

public class MapAnnotations : EditorWindow
{
Expand Down Expand Up @@ -84,6 +85,8 @@ private enum SignType { STOP, YIELD };
private Vector2 scrollPos;
private int ExtraLinesCnt;

private Scene CurrentActiveScene;

[MenuItem("Simulator/Annotate HD Map #&m", false, 100)]
public static void Open()
{
Expand Down Expand Up @@ -231,6 +234,7 @@ private void OnEnable()
if (targetWaypointGO != null)
DestroyImmediate(targetWaypointGO);
mapHolder = FindObjectOfType<MapHolder>();
CurrentActiveScene = EditorSceneManager.GetActiveScene();
}

private void OnSelectionChange()
Expand Down Expand Up @@ -271,6 +275,13 @@ private void OnDisable()

private void Update()
{
if (CurrentActiveScene != EditorSceneManager.GetActiveScene())
{
CurrentActiveScene = EditorSceneManager.GetActiveScene();
mapHolder = FindObjectOfType<MapHolder>();
OnSelectionChange();
}

switch (MapAnnotationTool.createMode)
{
case MapAnnotationTool.CreateMode.NONE:
Expand Down Expand Up @@ -368,6 +379,28 @@ private void OnGUI()
GUILayout.EndHorizontal();
GUILayout.Space(20);

if (mapHolder)
{
MapAnnotationTool.WAYPOINT_SIZE = mapHolder.MapWaypointSize;
EditorGUILayout.LabelField("Gizmo Size", titleLabelStyle, GUILayout.ExpandWidth(true));
GUILayout.BeginHorizontal("box");
if (!EditorGUIUtility.isProSkin)
GUI.backgroundColor = nonProColor;
GUILayout.Space(10);
var prevSize = MapAnnotationTool.WAYPOINT_SIZE;
MapAnnotationTool.WAYPOINT_SIZE = EditorGUILayout.Slider(MapAnnotationTool.WAYPOINT_SIZE, 0.02f, 1f, GUILayout.ExpandWidth(true));
mapHolder.MapWaypointSize = MapAnnotationTool.WAYPOINT_SIZE;
if (prevSize != MapAnnotationTool.WAYPOINT_SIZE)
{
SceneView.RepaintAll();
EditorUtility.SetDirty(mapHolder);
}
if (!EditorGUIUtility.isProSkin)
GUI.backgroundColor = Color.white;
GUILayout.EndHorizontal();
GUILayout.Space(20);
}

EditorGUILayout.LabelField("Create Modes", titleLabelStyle, GUILayout.ExpandWidth(true));
if (!EditorGUIUtility.isProSkin)
GUI.backgroundColor = nonProColor;
Expand Down Expand Up @@ -981,6 +1014,8 @@ private void CreateMapHolder()
{
MapAnnotations tool = (MapAnnotations)GetWindow(typeof(MapAnnotations));

MapOrigin.Find();

var tempGO = new GameObject("Map" + SceneManager.GetActiveScene().name);
tempGO.transform.position = Vector3.zero;
tempGO.transform.rotation = Quaternion.identity;
Expand All @@ -994,7 +1029,7 @@ private void CreateMapHolder()
Undo.RegisterCreatedObjectUndo(tempGO, nameof(tempGO));

SceneView.RepaintAll();
Debug.Log("Holder object for this scenes annotations, intersections and lanes created");
Debug.Log("MapHolder object for this scenes annotations created", tempGO);
}

private void CreateIntersectionHolder()
Expand Down
16 changes: 8 additions & 8 deletions Assets/Scripts/Editor/Map/MapOriginEditor.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2019 LG Electronics, Inc.
* Copyright (c) 2019-2021 LG Electronics, Inc.
*
* This software contains code licensed as described in LICENSE.
*
Expand Down Expand Up @@ -48,14 +48,11 @@ public override void OnInspectorGUI()
origin.AltitudeOffset = EditorGUILayout.FloatField("Altitude Offset", origin.AltitudeOffset);

int currentlySelected = -1;
if (origin.TimeZoneSerialized != null)
currentlySelected = Array.FindIndex(TimeZones, tz => tz.DisplayName == origin.TimeZoneString);
if (currentlySelected == -1)
{
currentlySelected = Array.FindIndex(TimeZones, tz => tz.DisplayName == origin.TimeZoneString);
if (currentlySelected == -1)
{
var timeZone = origin.TimeZone;
currentlySelected = Array.FindIndex(TimeZones, tz => tz.BaseUtcOffset == timeZone.BaseUtcOffset);
}
var timeZone = origin.TimeZone;
currentlySelected = Array.FindIndex(TimeZones, tz => tz.BaseUtcOffset == timeZone.BaseUtcOffset);
}

var values = TimeZones.Select(tz => tz.DisplayName.Replace("&", "&&")).ToArray();
Expand All @@ -66,9 +63,12 @@ public override void OnInspectorGUI()
{
origin.TimeZoneSerialized = TimeZones[currentlySelected].ToSerializedString();
origin.TimeZoneString = TimeZones[currentlySelected].DisplayName;

EditorUtility.SetDirty(origin);
Repaint();
}
}

if (GUILayout.Button("Add Reference Point"))
{
AddReferencePoint(origin);
Expand Down
5 changes: 2 additions & 3 deletions Assets/Scripts/Map/MapAnnotationTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
*
*/

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Simulator.Map
Expand Down Expand Up @@ -41,6 +39,7 @@ public enum PedestrianPathType
public static bool SHOW_MAP_SELECTED { get; set; } = false;
public static float PROXIMITY { get; set; } = 1.0f;
public static float EXPORT_SCALE_FACTOR = 1.0f;
public static float ARROWSIZE = 50.0f;
public static float ARROWSIZE => 100f * WAYPOINT_SIZE;
public static float WAYPOINT_SIZE { get; set; } = 0.5f;
}
}
9 changes: 2 additions & 7 deletions Assets/Scripts/Map/MapClearArea.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
/**
* Copyright (c) 2019 LG Electronics, Inc.
* Copyright (c) 2019-2021 LG Electronics, Inc.
*
* This software contains code licensed as described in LICENSE.
*
*/

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Simulator.Map;

namespace Simulator.Map
{
public class MapClearArea : MapDataPoints, IMapType
Expand All @@ -23,7 +18,7 @@ public override void Draw()
{
if (mapLocalPositions.Count < 3) return;

AnnotationGizmos.DrawWaypoints(transform, mapLocalPositions, MapAnnotationTool.PROXIMITY * 0.5f, clearAreaColor + selectedColor);
AnnotationGizmos.DrawWaypoints(transform, mapLocalPositions, MapAnnotationTool.WAYPOINT_SIZE, clearAreaColor + selectedColor);
AnnotationGizmos.DrawLines(transform, mapLocalPositions, clearAreaColor + selectedColor);
if (MapAnnotationTool.SHOW_HELP)
{
Expand Down
9 changes: 2 additions & 7 deletions Assets/Scripts/Map/MapCrossWalk.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
/**
* Copyright (c) 2019 LG Electronics, Inc.
* Copyright (c) 2019-2021 LG Electronics, Inc.
*
* This software contains code licensed as described in LICENSE.
*
*/

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Simulator.Map;

namespace Simulator.Map
{
public class MapCrossWalk : MapDataPoints, IMapType
Expand All @@ -23,7 +18,7 @@ public override void Draw()
{
if (mapLocalPositions.Count < 3) return;

AnnotationGizmos.DrawWaypoints(transform, mapLocalPositions, MapAnnotationTool.PROXIMITY * 0.5f, crossWalkColor + selectedColor);
AnnotationGizmos.DrawWaypoints(transform, mapLocalPositions, MapAnnotationTool.WAYPOINT_SIZE, crossWalkColor + selectedColor);
AnnotationGizmos.DrawLines(transform, mapLocalPositions, crossWalkColor + selectedColor);

if (MapAnnotationTool.SHOW_HELP)
Expand Down
6 changes: 2 additions & 4 deletions Assets/Scripts/Map/MapData.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
/**
* Copyright (c) 2019 LG Electronics, Inc.
* Copyright (c) 2019-2021 LG Electronics, Inc.
*
* This software contains code licensed as described in LICENSE.
*
*/

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Simulator.Map;

namespace Simulator.Map
{
Expand Down Expand Up @@ -195,7 +193,7 @@ public static void DrawArrowHeads(Transform mainTrans, List<Vector3> localPoints
{
var start = mainTrans.TransformPoint(localPoints[i]);
var end = mainTrans.TransformPoint(localPoints[i + 1]);
DrawArrowHead(start, end, lineColor, arrowHeadScale: MapAnnotationTool.ARROWSIZE * 1f, arrowPositionRatio: 0.5f); // TODO why reference map annotation tool?
DrawArrowHead(start, end, lineColor, arrowHeadScale: MapAnnotationTool.ARROWSIZE, arrowPositionRatio: 0.5f);
}
}

Expand Down
6 changes: 3 additions & 3 deletions Assets/Scripts/Map/MapHolder.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
/**
* Copyright (c) 2019 LG Electronics, Inc.
* Copyright (c) 2019-2021 LG Electronics, Inc.
*
* This software contains code licensed as described in LICENSE.
*
*/

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Simulator.Map
Expand All @@ -15,5 +13,7 @@ public class MapHolder : MonoBehaviour
{
public Transform trafficLanesHolder;
public Transform intersectionsHolder;
[HideInInspector]
public float MapWaypointSize = 0.5f;
}
}
4 changes: 1 addition & 3 deletions Assets/Scripts/Map/MapIntersection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

using System.Collections.Generic;
using UnityEngine;
using Simulator.Controllable;
using Simulator.Utilities;

namespace Simulator.Map
Expand Down Expand Up @@ -35,7 +34,6 @@ public class MapIntersection : MapData

[System.NonSerialized]
List<MapSignal> signalGroup = new List<MapSignal>();
private MonoBehaviour FixedUpdateManager;
public bool isStopSignIntersection = false;

public void SetIntersectionData()
Expand Down Expand Up @@ -268,7 +266,7 @@ public override void Draw()
var start = transform.position;
var end = start + transform.up * 6f;

AnnotationGizmos.DrawWaypoint(transform.position, MapAnnotationTool.PROXIMITY * 0.5f, intersectionColor + selectedColor);
AnnotationGizmos.DrawWaypoint(transform.position, MapAnnotationTool.WAYPOINT_SIZE, intersectionColor + selectedColor);
Gizmos.color = intersectionColor + selectedColor;
Gizmos.DrawLine(start, end);
AnnotationGizmos.DrawArrowHead(start, end, intersectionColor + selectedColor, arrowHeadScale: MapAnnotationTool.ARROWSIZE, arrowPositionRatio: 1f);
Expand Down
9 changes: 2 additions & 7 deletions Assets/Scripts/Map/MapJunction.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
/**
* Copyright (c) 2019 LG Electronics, Inc.
* Copyright (c) 2019-2021 LG Electronics, Inc.
*
* This software contains code licensed as described in LICENSE.
*
*/

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Simulator.Map;

namespace Simulator.Map
{
public class MapJunction : MapDataPoints, IMapType
Expand All @@ -24,7 +19,7 @@ public override void Draw()
{
if (mapLocalPositions.Count < 2) return;

AnnotationGizmos.DrawWaypoints(transform, mapLocalPositions, MapAnnotationTool.PROXIMITY * 0.5f, junctionColor);
AnnotationGizmos.DrawWaypoints(transform, mapLocalPositions, MapAnnotationTool.WAYPOINT_SIZE, junctionColor);
AnnotationGizmos.DrawLines(transform, mapLocalPositions, junctionColor);
if (MapAnnotationTool.SHOW_HELP)
{
Expand Down
4 changes: 2 additions & 2 deletions Assets/Scripts/Map/MapLaneSection.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2019-2020 LG Electronics, Inc.
* Copyright (c) 2019-2021 LG Electronics, Inc.
*
* This software contains code licensed as described in LICENSE.
*
Expand Down Expand Up @@ -170,7 +170,7 @@ public override void Draw()
{
var start = transform.position;
var end = start + transform.up * 2f;
var size = new Vector3(MapAnnotationTool.PROXIMITY * 0.75f, MapAnnotationTool.PROXIMITY * 0.75f, MapAnnotationTool.PROXIMITY * 0.75f);
var size = new Vector3(MapAnnotationTool.WAYPOINT_SIZE, MapAnnotationTool.WAYPOINT_SIZE, MapAnnotationTool.WAYPOINT_SIZE);
AnnotationGizmos.DrawCubeWaypoint(transform.position, size, laneColor + selectedColor);
Gizmos.color = laneColor + selectedColor;
Gizmos.DrawLine(start, end);
Expand Down
6 changes: 2 additions & 4 deletions Assets/Scripts/Map/MapLine.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
/**
* Copyright (c) 2019 LG Electronics, Inc.
* Copyright (c) 2019-2021 LG Electronics, Inc.
*
* This software contains code licensed as described in LICENSE.
*
*/

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Simulator.Map;

namespace Simulator.Map
{
Expand Down Expand Up @@ -69,7 +67,7 @@ public override void Draw()
UnityEditor.Handles.Label(transform.position, " " + lineType + " LINE");
#endif
}
AnnotationGizmos.DrawWaypoints(transform, mapLocalPositions, MapAnnotationTool.PROXIMITY * 0.5f, typeColor + selectedColor);
AnnotationGizmos.DrawWaypoints(transform, mapLocalPositions, MapAnnotationTool.WAYPOINT_SIZE, typeColor + selectedColor);
AnnotationGizmos.DrawLines(transform, mapLocalPositions, typeColor + selectedColor);
}
}
Expand Down
10 changes: 7 additions & 3 deletions Assets/Scripts/Map/MapOrigin.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2019-2020 LG Electronics, Inc.
* Copyright (c) 2019-2021 LG Electronics, Inc.
*
* This software contains code licensed as described in LICENSE.
*
Expand Down Expand Up @@ -42,7 +42,7 @@ public partial class MapOrigin : MonoBehaviour
public double OriginEasting;
public double OriginNorthing;
public int UTMZoneId;
public float AltitudeOffset;
public float AltitudeOffset = 0f;

[HideInInspector]
public string TimeZoneSerialized;
Expand All @@ -58,7 +58,7 @@ public partial class MapOrigin : MonoBehaviour
public bool IgnorePedBounds = false;
[HideInInspector]
public bool IgnorePedVisible = false; // TODO fix this disabled for now in SpawnManager
public int NPCSizeMask = 1;
public int NPCSizeMask = 1<<0 | 1<<1 | 1<<2 | 1<<3| 1<<4 | 1<<5 | 1<<6 | 1<<7 | 1<<8 | 1<<9 | 1<<11 | 1<<12;
public int NPCMaxCount = 10;
public int NPCSpawnBoundSize = 200;

Expand All @@ -74,6 +74,10 @@ public static MapOrigin Find()
{
Debug.LogWarning("Map is missing MapOrigin component! Adding temporary MapOrigin. Please add to scene and set origin");
origin = new GameObject("MapOrigin").AddComponent<MapOrigin>();
origin.transform.SetPositionAndRotation(Vector3.zero, Quaternion.identity);
origin.OriginEasting = 592720;
origin.OriginNorthing = 4134479;
origin.UTMZoneId = 10;
}

return origin;
Expand Down
Loading

0 comments on commit 9e22149

Please sign in to comment.