perf: Improve performance for line renderer
This commit is contained in:
@@ -150,12 +150,8 @@ namespace Cryville.EEW.Unity.Map {
|
|||||||
_mesh.Clear();
|
_mesh.Clear();
|
||||||
if (_positions == null) return;
|
if (_positions == null) return;
|
||||||
if (_positionCount <= 1) return;
|
if (_positionCount <= 1) return;
|
||||||
float hw = m_width / 2;
|
|
||||||
int maxVertexCount = 4 * (_positionCount - 1);
|
|
||||||
var vbuf = ArrayPool<Vector3>.Shared.Rent(maxVertexCount);
|
|
||||||
var ubuf = ArrayPool<Vector2>.Shared.Rent(maxVertexCount);
|
|
||||||
var ibuf = ArrayPool<int>.Shared.Rent(3 * (2 + 4 * (_positionCount - 2)));
|
|
||||||
|
|
||||||
|
float hw = m_width / 2;
|
||||||
int i, vi = 0, ii = 0, li = 0, ri = 1;
|
int i, vi = 0, ii = 0, li = 0, ri = 1;
|
||||||
float uvScale = 1 / (m_tilingScale * m_width);
|
float uvScale = 1 / (m_tilingScale * m_width);
|
||||||
Vector2 p0 = _positions[0], p1 = default;
|
Vector2 p0 = _positions[0], p1 = default;
|
||||||
@@ -163,6 +159,12 @@ namespace Cryville.EEW.Unity.Map {
|
|||||||
if ((p1 = _positions[i]) != p0) break;
|
if ((p1 = _positions[i]) != p0) break;
|
||||||
}
|
}
|
||||||
if (i >= _positionCount) return;
|
if (i >= _positionCount) return;
|
||||||
|
|
||||||
|
int maxVertexCount = 4 * (_positionCount - 1);
|
||||||
|
var vbuf = ArrayPool<Vector3>.Shared.Rent(maxVertexCount);
|
||||||
|
var ubuf = ArrayPool<Vector2>.Shared.Rent(maxVertexCount);
|
||||||
|
var ibuf = ArrayPool<int>.Shared.Rent(3 * (2 + 4 * (_positionCount - 2)));
|
||||||
|
|
||||||
Vector2 dp0 = NormalizeSmallVector(p1 - p0), np0 = GetNormal(dp0 * hw);
|
Vector2 dp0 = NormalizeSmallVector(p1 - p0), np0 = GetNormal(dp0 * hw);
|
||||||
vbuf[vi] = p0 - np0; ubuf[vi++] = new(0, 0);
|
vbuf[vi] = p0 - np0; ubuf[vi++] = new(0, 0);
|
||||||
vbuf[vi] = p0 + np0; ubuf[vi++] = new(0, 1);
|
vbuf[vi] = p0 + np0; ubuf[vi++] = new(0, 1);
|
||||||
|
Reference in New Issue
Block a user