lab6 dop
This commit is contained in:
1 parent
bca661e132
commit
ed0437638b
9 files changed
+3442
-17
No files matched your search
@@ -9,6 +9,11 @@ namespace Code.Lab6
|
||||
{
|
||||
public int id = -1;
|
||||
public List<Edge> neighbours;
|
||||
|
||||
[Header("Weight Settings")]
|
||||
[Range(0.1f, 10f)]
|
||||
public float weight = 1f;
|
||||
|
||||
[HideInInspector]
|
||||
public Vertex prev;
|
||||
|
||||
@@ -19,18 +24,27 @@ namespace Code.Lab6
|
||||
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
Gizmos.color = Color.cyan;
|
||||
Gizmos.DrawSphere(transform.position, 0.2f);
|
||||
var t = Mathf.InverseLerp(0.1f, 10f, weight);
|
||||
Gizmos.color = Color.Lerp(Color.white, Color.black, t);
|
||||
Gizmos.DrawSphere(transform.position, 0.2f + weight * 0.05f);
|
||||
}
|
||||
|
||||
private void OnDrawGizmosSelected()
|
||||
{
|
||||
if (neighbours == null) return;
|
||||
|
||||
Gizmos.color = Color.yellow;
|
||||
foreach (var edge in neighbours.Where(edge => edge?.Vertex != null))
|
||||
{
|
||||
var t = Mathf.InverseLerp(0.1f, 10f, edge.cost);
|
||||
Gizmos.color = Color.Lerp(Color.green, Color.red, t);
|
||||
Gizmos.DrawLine(transform.position, edge.Vertex.transform.position);
|
||||
|
||||
#if UNITY_EDITOR
|
||||
var midPoint = (transform.position + edge.Vertex.transform.position) / 2f;
|
||||
midPoint.y += 0.5f;
|
||||
UnityEditor.Handles.color = Color.yellow;
|
||||
UnityEditor.Handles.Label(midPoint, $"{edge.cost:F1}");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user