Skip to content
Snippets Groups Projects
Commit 40e0d8a1 authored by Martins Mozeiko's avatar Martins Mozeiko
Browse files

Scale debug point/line size by DPI setting.

parent f7bfd1b2
No related branches found
No related tags found
No related merge requests found
......@@ -836,7 +836,7 @@ namespace Simulator.Sensors
var lidarToWorld = Compensated ? Matrix4x4.identity : transform.localToWorldMatrix;
PointCloudMaterial.SetMatrix("_LocalToWorld", lidarToWorld);
PointCloudMaterial.SetFloat("_Size", PointSize);
PointCloudMaterial.SetFloat("_Size", PointSize * Utility.GetDpiScale());
PointCloudMaterial.SetColor("_Color", PointColor);
Graphics.DrawProcedural(PointCloudMaterial, new Bounds(transform.position, MaxDistance * Vector3.one), MeshTopology.Points, PointCloudBuffer.count, layer: LayerMask.NameToLayer("Sensor"));
......
......@@ -55,7 +55,8 @@ namespace Simulator.Utilities
min = 2f * min * new Vector2(1f / Camera.pixelWidth, 1f / Camera.pixelHeight) - Vector2.one;
max = 2f * max * new Vector2(1f / Camera.pixelWidth, 1f / Camera.pixelHeight) - Vector2.one;
var size = new Vector2(LineWidth / Camera.pixelWidth, LineWidth / Camera.pixelHeight);
var width = LineWidth * Utility.GetDpiScale();
var size = new Vector2(width / Camera.pixelWidth, width / Camera.pixelHeight);
var p0 = new Vector2(min.x, max.y);
var p1 = new Vector2(max.x, min.y);
......
......@@ -423,5 +423,16 @@ namespace Simulator.Utilities
return controlActions;
}
public static float GetDpiScale()
{
if (Screen.dpi == 0)
{
return 1f;
}
float defaultDpi = 96f;
return Screen.dpi / defaultDpi;
}
}
}
\ No newline at end of file
......@@ -74,7 +74,7 @@ namespace Simulator.Utilities
}
Buffer.SetData(Boxes, 0, 0, Boxes.Count);
Material.SetFloat("_LineWidth", LineWidth);
Material.SetFloat("_LineWidth", LineWidth * Utility.GetDpiScale());
// TODO: big number for size to include everything in scene
var bounds = new Bounds(Vector3.zero, new Vector3(10000, 10000, 10000));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment