Files
sbox-public/engine/Sandbox.Engine/Scene/GameObjectSystems/DebugOverlay/DebugOverlaySystem.DrawPoint.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

40 lines
1.2 KiB
C#

namespace Sandbox;
public partial class DebugOverlaySystem
{
internal void Point( Vector3 position, float size, Color color = new Color(), float duration = 0, bool overlay = false )
{
if ( color == default ) color = Color.White;
Add( duration, new PointSceneObject( Scene.SceneWorld, size )
{
ColorTint = color,
Transform = new Transform( position ),
RenderLayer = overlay ? SceneRenderLayer.OverlayWithoutDepth : SceneRenderLayer.OverlayWithDepth,
Bounds = BBox.FromPositionAndSize( position, size )
} );
}
}
file class PointSceneObject : SceneCustomObject
{
public float Size;
public PointSceneObject( SceneWorld sceneWorld, float size ) : base( sceneWorld )
{
Size = size;
Flags.CastShadows = false;
managedNative.ExecuteOnMainThread = false;
}
public override void RenderSceneObject()
{
var rect = new Rect( Size * -0.5f, Size );
Attributes.SetCombo( "D_WORLDPANEL", 1 );
Attributes.Set( "WorldMat", Matrix.CreateRotation( Graphics.CameraRotation ) );
Attributes.Set( "TransformMat", Matrix.CreateRotation( Rotation.From( 0, -90, 90 ) ) );
Attributes.Set( "Texture", Texture.White );
Graphics.DrawQuad( rect, Material.UI.Basic, ColorTint, Attributes );
}
}