polishing

This commit is contained in:
DCFApixels 2025-02-24 18:18:49 +08:00
parent 5274939632
commit 17d7f8a5a8
8 changed files with 61 additions and 51 deletions

View File

@ -25,7 +25,7 @@ namespace DCFApixels.DebugXCore.Internal
private static bool _isCompilation;
private bool? _isHasDisableDebugXInBuildSymbols = false;
private const string DEFINE_NAME = nameof(DebugX.DISABLE_DEBUGX_INBUILD);
private const string DEFINE_NAME = nameof(DebugXDefines.DISABLE_DEBUGX_INBUILD);
private void OnGUI()
{

View File

@ -1,8 +1,17 @@
using System.Runtime.CompilerServices;
using UnityEngine;
using UnityEngine.Rendering;
namespace DCFApixels
{
public static class DebugXConsts
{
public const float IMMEDIATE_DURATION = -1;
public const float DOT_SIZE = 0.05f;
public readonly static bool IsSRP = GraphicsSettings.currentRenderPipeline != null;
public readonly static bool IsSupportsComputeShaders = SystemInfo.supportsComputeShaders;
}
public static partial class DebugX
{
internal const MethodImplOptions LINE = MethodImplOptions.AggressiveInlining;
@ -10,9 +19,6 @@ namespace DCFApixels
private const float DEFAULT_DURATION = 0f;
private static readonly Color DEFAULT_COLOR = Color.white;
private const float DOT_SIZE = DOT_RADIUS * 2f;
private const float DOT_RADIUS = 0.05f;
private const string GLOBAL_TIME_SCALE_PREF_NAME = "DCFApixels.DebugX.TimeScale";
private const string GLOBAL_DOT_SIZE_PREF_NAME = "DCFApixels.DebugX.DotSize";
private const string GLOBAL_COLOR_PREF_NAME = "DCFApixels.DebugX.Color";
@ -21,18 +27,7 @@ namespace DCFApixels
private readonly static int GlobalColorPropertyID = Shader.PropertyToID("_DebugX_GlobalColor");
internal readonly static int ColorPropertyID = Shader.PropertyToID("_Color");
public const float IMMEDIATE_DURATION = -1;
public readonly static bool IsSRP;
public readonly static bool IsSupportsComputeShaders = SystemInfo.supportsComputeShaders;
public const bool DISABLE_DEBUGX_INBUILD =
#if DISABLE_DEBUGX_INBUILD
true;
#else
false;
#endif
private enum PauseStateX
{
@ -47,4 +42,16 @@ namespace DCFApixels
Arrow,
Fade,
}
}
namespace DCFApixels.DebugXCore
{
public static class DebugXDefines
{
public const bool DISABLE_DEBUGX_INBUILD =
#if DISABLE_DEBUGX_INBUILD
true;
#else
false;
#endif
}
}

View File

@ -19,7 +19,7 @@ using UnityEditor;
namespace DCFApixels
{
using IN = System.Runtime.CompilerServices.MethodImplAttribute;
using static DebugXConsts;
public static unsafe partial class DebugX
{
private static PauseStateX _pauseState = PauseStateX.Unpaused;
@ -59,10 +59,6 @@ namespace DCFApixels
{
InitGlobals();
Meshes = DebugXUtility.LoadStaticData(new MeshesList(), $"DCFApixels.DebugX/MeshesList");
Materials = DebugXUtility.LoadStaticData(new MaterialsList(), $"DCFApixels.DebugX/MaterialsList");
IsSRP = GraphicsSettings.currentRenderPipeline != null;
if (IsSRP)
{

View File

@ -11,7 +11,9 @@ using UnityEditor;
namespace DCFApixels
{
using static DebugXConsts;
using IN = System.Runtime.CompilerServices.MethodImplAttribute;
public static unsafe partial class DebugX
{
public readonly partial struct DrawHandler

View File

@ -7,7 +7,7 @@ using DCFApixels.DebugXCore;
namespace DCFApixels
{
using IN = System.Runtime.CompilerServices.MethodImplAttribute;
using static DebugXConsts;
public unsafe static partial class DebugX
{
public readonly partial struct DrawHandler
@ -123,11 +123,11 @@ namespace DCFApixels
#endregion
#region Dot
[IN(LINE)] public DrawHandler Dot(Vector3 position) => Mesh<DotMesh, DotMat>(position, Quaternion.identity, new Vector3(DOT_RADIUS, DOT_RADIUS, DOT_RADIUS));
[IN(LINE)] public DrawHandler Dot(Vector3 position) => Mesh<DotMesh, DotMat>(position, Quaternion.identity, new Vector3(DOT_SIZE, DOT_SIZE, DOT_SIZE));
#endregion
#region WireDot
[IN(LINE)] public DrawHandler WireDot(Vector3 position) => Mesh<WireCircleMesh, DotMat>(position, Quaternion.identity, new Vector3(DOT_RADIUS / 2, DOT_RADIUS / 2, DOT_RADIUS / 2));
[IN(LINE)] public DrawHandler WireDot(Vector3 position) => Mesh<WireCircleMesh, DotMat>(position, Quaternion.identity, new Vector3(DOT_SIZE / 2, DOT_SIZE / 2, DOT_SIZE / 2));
#endregion
#region Capsule
@ -397,11 +397,11 @@ namespace DCFApixels
#endregion
#region DotQuad
[IN(LINE)] public DrawHandler DotQuad(Vector3 position) => Mesh<DotQuadMesh, DotMat>(position, Quaternion.identity, new Vector3(DOT_RADIUS, DOT_RADIUS, DOT_RADIUS));
[IN(LINE)] public DrawHandler DotQuad(Vector3 position) => Mesh<DotQuadMesh, DotMat>(position, Quaternion.identity, new Vector3(DOT_SIZE, DOT_SIZE, DOT_SIZE));
#endregion
#region DotDiamond
[IN(LINE)] public DrawHandler DotDiamond(Vector3 position) => Mesh<DotDiamondMesh, DotMat>(position, Quaternion.identity, new Vector3(DOT_RADIUS * 0.9f, DOT_RADIUS * 0.9f, DOT_RADIUS * 0.9f));
[IN(LINE)] public DrawHandler DotDiamond(Vector3 position) => Mesh<DotDiamondMesh, DotMat>(position, Quaternion.identity, new Vector3(DOT_SIZE * 0.9f, DOT_SIZE * 0.9f, DOT_SIZE * 0.9f));
#endregion
}
}

View File

@ -1,9 +1,14 @@
using UnityEngine;
namespace DCFApixels
namespace DCFApixels.DebugXCore
{
public static partial class DebugX
public static partial class DebugXAssets
{
static DebugXAssets()
{
Meshes = DebugXUtility.LoadStaticData(new MeshesList(), $"DCFApixels.DebugX/MeshesList");
Materials = DebugXUtility.LoadStaticData(new MaterialsList(), $"DCFApixels.DebugX/MaterialsList");
}
public static MeshesList Meshes;
public readonly struct MeshesList
{

View File

@ -17,105 +17,105 @@ namespace DCFApixels.DebugXCore
public readonly struct LitMat : IStaticMaterial
{
public int GetExecuteOrder() => 0;
public Material GetMaterial() => DebugX.Materials.Lit;
public Material GetMaterial() => DebugXAssets.Materials.Lit;
}
public readonly struct UnlitMat : IStaticMaterial
{
public int GetExecuteOrder() => 100_000;
public Material GetMaterial() => DebugX.Materials.Unlit;
public Material GetMaterial() => DebugXAssets.Materials.Unlit;
}
public readonly struct BillboardMat : IStaticMaterial
{
public int GetExecuteOrder() => 200_000;
public Material GetMaterial() => DebugX.Materials.Billboard;
public Material GetMaterial() => DebugXAssets.Materials.Billboard;
}
public readonly struct DotMat : IStaticMaterial
{
public int GetExecuteOrder() => 300_000;
public Material GetMaterial() => DebugX.Materials.Dot;
public Material GetMaterial() => DebugXAssets.Materials.Dot;
}
public readonly struct GeometryUnlitMat : IStaticMaterial
{
public int GetExecuteOrder() => 1_000_000;
public Material GetMaterial() => DebugX.Materials.Unlit;
public Material GetMaterial() => DebugXAssets.Materials.Unlit;
}
public readonly struct WireMat : IStaticMaterial
{
public int GetExecuteOrder() => 1_000_000;
public Material GetMaterial() => DebugX.Materials.Wire;
public Material GetMaterial() => DebugXAssets.Materials.Wire;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public readonly struct SphereMesh : IStaticMesh
{
public Mesh GetMesh() => DebugX.Meshes.Sphere;
public Mesh GetMesh() => DebugXAssets.Meshes.Sphere;
}
public readonly struct CubeMesh : IStaticMesh
{
public Mesh GetMesh() => DebugX.Meshes.Cube;
public Mesh GetMesh() => DebugXAssets.Meshes.Cube;
}
public readonly struct QuadMesh : IStaticMesh
{
public Mesh GetMesh() => DebugX.Meshes.Quad;
public Mesh GetMesh() => DebugXAssets.Meshes.Quad;
}
public readonly struct CircleMesh : IStaticMesh
{
public Mesh GetMesh() => DebugX.Meshes.Circle;
public Mesh GetMesh() => DebugXAssets.Meshes.Circle;
}
public readonly struct CapsuleBodyMesh : IStaticMesh
{
public Mesh GetMesh() => DebugX.Meshes.CapsuleBody;
public Mesh GetMesh() => DebugXAssets.Meshes.CapsuleBody;
}
public readonly struct CapsuleHeadMesh : IStaticMesh
{
public Mesh GetMesh() => DebugX.Meshes.CapsuleHead;
public Mesh GetMesh() => DebugXAssets.Meshes.CapsuleHead;
}
public readonly struct FlatCapsuleBodyMesh : IStaticMesh
{
public Mesh GetMesh() => DebugX.Meshes.FlatCapsuleBody;
public Mesh GetMesh() => DebugXAssets.Meshes.FlatCapsuleBody;
}
public readonly struct FlatCapsuleHeadMesh : IStaticMesh
{
public Mesh GetMesh() => DebugX.Meshes.FlatCapsuleHead;
public Mesh GetMesh() => DebugXAssets.Meshes.FlatCapsuleHead;
}
public readonly struct ArrowMesh : IStaticMesh
{
public Mesh GetMesh() => DebugX.Meshes.Arrow;
public Mesh GetMesh() => DebugXAssets.Meshes.Arrow;
}
public readonly struct DotMesh : IStaticMesh
{
public Mesh GetMesh() => DebugX.Meshes.Dot;
public Mesh GetMesh() => DebugXAssets.Meshes.Dot;
}
public readonly struct DotQuadMesh : IStaticMesh
{
public Mesh GetMesh() => DebugX.Meshes.DotQuad;
public Mesh GetMesh() => DebugXAssets.Meshes.DotQuad;
}
public readonly struct DotDiamondMesh : IStaticMesh
{
public Mesh GetMesh() => DebugX.Meshes.DotDiamond;
public Mesh GetMesh() => DebugXAssets.Meshes.DotDiamond;
}
public readonly struct DotCrossMesh : IStaticMesh
{
public Mesh GetMesh() => DebugX.Meshes.DotCross;
public Mesh GetMesh() => DebugXAssets.Meshes.DotCross;
}
public readonly struct WireLineMesh : IStaticMesh
{
public Mesh GetMesh() => DebugX.Meshes.WireLine;
public Mesh GetMesh() => DebugXAssets.Meshes.WireLine;
}
public readonly struct WireCubeMesh : IStaticMesh
{
public Mesh GetMesh() => DebugX.Meshes.WireCube;
public Mesh GetMesh() => DebugXAssets.Meshes.WireCube;
}
public readonly struct WireArcMesh : IStaticMesh
{
public Mesh GetMesh() => DebugX.Meshes.WireArc;
public Mesh GetMesh() => DebugXAssets.Meshes.WireArc;
}
public readonly struct WireCircleMesh : IStaticMesh
{
public Mesh GetMesh() => DebugX.Meshes.WireCircle;
public Mesh GetMesh() => DebugXAssets.Meshes.WireCircle;
}
public readonly struct WireSphereMesh : IStaticMesh
{
public Mesh GetMesh() => DebugX.Meshes.WireSphere;
public Mesh GetMesh() => DebugXAssets.Meshes.WireSphere;
}
}