Skip to content

Commit 9039f98

Browse files
committed
draw with width. prepare for PR.
1 parent 1e06360 commit 9039f98

3 files changed

Lines changed: 17 additions & 14 deletions

File tree

Line.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,9 @@ namespace EPPZ.Lines
1616
[Serializable]
1717
public class Line
1818
{
19-
20-
2119
public Vector3 from;
2220
public Vector3 to;
2321
public Color color;
22+
public float width = 1;
2423
}
2524
}
26-
27-

LineRendererBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,4 @@ protected void DrawLineWithTransform(Vector2 from, Vector2 to, Color color, Tran
197197

198198

199199
}
200-
}
200+
}

LineRendererCamera.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
77
//
88
using UnityEngine;
9-
using System.Collections;
109
using System.Collections.Generic;
1110

1211

@@ -60,7 +59,7 @@ void Awake()
6059
Destroy(this);
6160
return;
6261
}
63-
shared = this;
62+
shared = this;
6463
_camera = GetComponent<Camera>();
6564
}
6665

@@ -128,15 +127,22 @@ void DrawLines()
128127
void DrawCall()
129128
{
130129
// Assign vertex color material.
131-
material.SetPass(0); // Single draw call (set pass call)
132-
133-
// Send vertices in GL_LINES Immediate Mode.
134-
GL.Begin(GL.LINES);
135-
foreach (EPPZ.Lines.Line eachLine in lineBatch)
130+
// Single draw call (set pass call)
131+
material.SetPass(0);
132+
// Draw with width
133+
GL.Begin(GL.QUADS);
134+
foreach (Line eachLine in lineBatch)
136135
{
137136
GL.Color(eachLine.color);
138-
GL.Vertex(eachLine.from);
139-
GL.Vertex(eachLine.to);
137+
138+
Vector3 v = eachLine.to - eachLine.from;
139+
Vector3 u = new Vector3(-v.y, v.x, v.z).normalized * .1f * eachLine.width;
140+
u.z = v.z;
141+
142+
GL.Vertex(eachLine.from - u);
143+
GL.Vertex(eachLine.from + u);
144+
GL.Vertex(eachLine.to + u);
145+
GL.Vertex(eachLine.to - u);
140146
}
141147
GL.End();
142148
}

0 commit comments

Comments
 (0)