mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-04 20:38:24 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
67 lines
2.0 KiB
C#
67 lines
2.0 KiB
C#
namespace Sandbox;
|
|
|
|
public partial class DebugOverlaySystem
|
|
{
|
|
readonly Material LineMaterial;
|
|
|
|
/// <summary>
|
|
/// Draw a line
|
|
/// </summary>
|
|
public void Normal( Vector3 position, Vector3 direction, Color color = new Color(), float duration = 0, Transform transform = default, bool overlay = false )
|
|
{
|
|
Line( position, position + direction, color, duration, transform, overlay );
|
|
}
|
|
|
|
/// <summary>
|
|
/// Draw a line
|
|
/// </summary>
|
|
public void Line( Line line, Color color = new Color(), float duration = 0, Transform transform = default, bool overlay = false )
|
|
{
|
|
Line( line.Start, line.End, color, duration, transform, overlay );
|
|
}
|
|
|
|
/// <summary>
|
|
/// Draw a line
|
|
/// </summary>
|
|
public void Line( Vector3 from, Vector3 to, Color color = new Color(), float duration = 0, Transform transform = default, bool overlay = false )
|
|
{
|
|
if ( transform == default ) transform = Transform.Zero;
|
|
if ( color == default ) color = Color.White;
|
|
|
|
var so = new SceneDynamicObject( Scene.SceneWorld );
|
|
so.Transform = transform;
|
|
so.Material = LineMaterial;
|
|
so.Flags.CastShadows = false;
|
|
so.RenderLayer = overlay ? SceneRenderLayer.OverlayWithoutDepth : SceneRenderLayer.OverlayWithDepth;
|
|
so.Init( Graphics.PrimitiveType.Lines );
|
|
|
|
so.AddVertex( new Vertex( from, color ) );
|
|
so.AddVertex( new Vertex( to, color ) );
|
|
|
|
Add( duration, so );
|
|
}
|
|
|
|
/// <summary>
|
|
/// Draw a line
|
|
/// </summary>
|
|
public void Line( IEnumerable<Vector3> points, Color color = new Color(), float duration = 0, Transform transform = default, bool overlay = false )
|
|
{
|
|
if ( transform == default ) transform = Transform.Zero;
|
|
if ( color == default ) color = Color.White;
|
|
|
|
var so = new SceneDynamicObject( Scene.SceneWorld );
|
|
so.Transform = Transform.Zero;
|
|
so.Material = LineMaterial;
|
|
so.Flags.CastShadows = false;
|
|
so.RenderLayer = overlay ? SceneRenderLayer.OverlayWithoutDepth : SceneRenderLayer.OverlayWithDepth;
|
|
so.Init( Graphics.PrimitiveType.LineStrip );
|
|
|
|
foreach ( var p in points )
|
|
{
|
|
so.AddVertex( new Vertex( p, color ) );
|
|
}
|
|
|
|
Add( duration, so );
|
|
}
|
|
}
|