This commit is contained in:
DCFApixels 2025-02-23 20:03:13 +08:00
parent 7029d52d3b
commit 505ac24a09
16 changed files with 2370 additions and 96 deletions

View File

@ -7,8 +7,8 @@ namespace DCFApixels
{
internal const MethodImplOptions LINE = MethodImplOptions.AggressiveInlining;
private const float MinTime = 0f;
private static readonly Color DefaultColor = Color.white;
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;

View File

@ -197,17 +197,28 @@ namespace DCFApixels
#endregion
#region Draw/DrawHandler
private static float GetCurrentDefaultDuration()
{
if(GetCurrentContextController().Context.Camera == null)
{
return DEFAULT_DURATION;
}
else
{
return IMMEDIATE_DURATION;
}
}
public static DrawHandler Draw()
{
return new DrawHandler(MinTime, DefaultColor);
return new DrawHandler(GetCurrentDefaultDuration(), DEFAULT_COLOR);
}
public static DrawHandler Draw(float duration)
{
return new DrawHandler(duration, DefaultColor);
return new DrawHandler(duration, DEFAULT_COLOR);
}
public static DrawHandler Draw(Color color)
{
return new DrawHandler(MinTime, color);
return new DrawHandler(GetCurrentDefaultDuration(), color);
}
public static DrawHandler Draw(float duration, Color color)
{
@ -456,7 +467,7 @@ namespace DCFApixels
GetCurrentContextController().AddRange(values, Duration, Color);
return this;
}
}
private static RenderContextController GetCurrentContextController()
{
//RenderContextController controller;
@ -484,7 +495,6 @@ namespace DCFApixels
}
return _currenRenderContextControler;
}
}
#endregion

View File

@ -15,15 +15,16 @@ namespace DCFApixels
[IN(LINE)]
public DrawHandler LineFade(Vector3 start, Vector3 end)
{
const int StepsCount = 7;
const int StepsCount = 6;
const float Step = 1f / StepsCount;
const float ColorStep = 1f / (StepsCount + 1);
Color color = Color;
Vector3 startPoint = start;
for (int i = 1; i < StepsCount; i++)
for (int i = 1; i <= StepsCount; i++)
{
Vector3 endPoint = Vector3.Lerp(start, end, i * Step);
color.a = 1f - Color.a * i * Step;
color.a = 1f - Color.a * i * ColorStep;
Setup(color).Line(startPoint, endPoint);
startPoint = endPoint;
}

View File

@ -129,7 +129,7 @@ namespace DCFApixels
#region Raycast2D
[IN(LINE)] public DrawHandler Raycast2D(Ray ray, RaycastHit2D hit) => Raycast2D(ray.origin, ray.direction, hit);
[IN(LINE)]
public DrawHandler Raycast2D(Vector2 origin, Vector2 direction, RaycastHit2D hit)
public DrawHandler Raycast2D(Vector3 origin, Vector2 direction, RaycastHit2D hit)
{
if (hit.collider == null)
{
@ -137,10 +137,10 @@ namespace DCFApixels
}
else
{
Line(origin, origin + direction * hit.distance);
Line(origin, origin + (Vector3)direction * hit.distance);
DotDiamond(hit.point);
RayArrow(hit.point, hit.normal);
DotDiamond(new Vector3(hit.point.x, hit.point.y, origin.z));
RayArrow(new Vector3(hit.point.x, hit.point.y, origin.z), hit.normal);
}
return this;
}
@ -150,7 +150,7 @@ namespace DCFApixels
private static readonly Vector3 Normal2D = Vector3.forward;
[IN(LINE)] public DrawHandler CircleCast2D(Ray ray, float radius, RaycastHit2D hit) => CircleCast2D(ray.origin, ray.direction, radius, hit);
[IN(LINE)]
public DrawHandler CircleCast2D(Vector2 origin, Vector2 direction, float radius, RaycastHit2D hit)
public DrawHandler CircleCast2D(Vector3 origin, Vector2 direction, float radius, RaycastHit2D hit)
{
WireCircle(origin, Normal2D, radius);
if (hit.collider == null)
@ -159,13 +159,13 @@ namespace DCFApixels
}
else
{
Vector2 end = origin + direction * hit.distance;
Vector3 end = origin + (Vector3)direction * hit.distance;
//WidthOutLine(origin, end, radius * 2f);
DotDiamond(hit.point);
DotDiamond(new Vector3(hit.point.x, hit.point.y, origin.z));
WireCircle(end, Normal2D, radius);
RayArrow(hit.point, hit.normal);
RayArrow(new Vector3(hit.point.x, hit.point.y, origin.z), hit.normal);
//Setup(Color.SetAlpha(ShadowAlphaMultiplier)).
Line(origin, end);
@ -177,7 +177,7 @@ namespace DCFApixels
#region BoxCast2D
[IN(LINE)] public DrawHandler BoxCast2D(Ray ray, float angle, Vector3 size, RaycastHit2D hit) => BoxCast2D(ray.origin, ray.direction, angle, size, hit);
[IN(LINE)]
public DrawHandler BoxCast2D(Vector2 origin, Vector2 direction, float angle, Vector3 size, RaycastHit2D hit)
public DrawHandler BoxCast2D(Vector3 origin, Vector2 direction, float angle, Vector3 size, RaycastHit2D hit)
{
size *= 0.5f;
Quaternion rotation = Quaternion.Euler(0, 0, angle);
@ -188,13 +188,13 @@ namespace DCFApixels
}
else
{
Vector3 end = origin + direction * hit.distance;
Vector3 end = origin + (Vector3)direction * hit.distance;
//WidthOutLine(origin, end, size.x * 2f);
DotDiamond(hit.point);
DotDiamond(new Vector3(hit.point.x, hit.point.y, origin.z));
WireQuad(end, rotation, size * 2f);
RayArrow(hit.point, hit.normal);
RayArrow(new Vector3(hit.point.x, hit.point.y, origin.z), hit.normal);
//Setup(Color.SetAlpha(ShadowAlphaMultiplier)).
@ -207,7 +207,7 @@ namespace DCFApixels
#region CapsuleCast2D
[IN(LINE)] public DrawHandler CapsuleCast2D(Ray ray, float angle, Vector2 size, CapsuleDirection2D capsuleDirection, RaycastHit2D hit) => CapsuleCast2D(ray.origin, ray.direction, angle, size, capsuleDirection, hit);
[IN(LINE)]
public DrawHandler CapsuleCast2D(Vector2 origin, Vector2 direction, float angle, Vector2 size, CapsuleDirection2D capsuleDirection, RaycastHit2D hit)
public DrawHandler CapsuleCast2D(Vector3 origin, Vector2 direction, float angle, Vector2 size, CapsuleDirection2D capsuleDirection, RaycastHit2D hit)
{
var rotation = Quaternion.Euler(0, 0, angle);
var height = (capsuleDirection == CapsuleDirection2D.Vertical ? size.y : size.x);
@ -219,13 +219,13 @@ namespace DCFApixels
}
else
{
Vector3 end = origin + direction * hit.distance;
Vector3 end = origin + (Vector3)direction * hit.distance;
//WidthOutLine(origin, end, radius * 2f);
DotDiamond(hit.point);
DotDiamond(new Vector3(hit.point.x, hit.point.y, origin.z));
WireFlatCapsule(end, rotation, radius, height);
RayArrow(hit.point, hit.normal);
RayArrow(new Vector3(hit.point.x, hit.point.y, origin.z), hit.normal);
//Setup(Color.SetAlpha(ShadowAlphaMultiplier)).

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: f5563b73be1540b4d9eae3ee64144b25
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}

View File

@ -0,0 +1,59 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-7614504890241344171
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 9
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: FakeLightMat
m_Shader: {fileID: -6465566751694194690, guid: f5563b73be1540b4d9eae3ee64144b25, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses:
- MOTIONVECTORS
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- unity_Lightmaps:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_LightmapsInd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_ShadowMasks:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _QueueControl: 0
- _QueueOffset: 0
m_Colors:
- _Color: {r: 0, g: 0.06882353, b: 0.09, a: 1}
m_BuildTextureStacks: []
m_AllowLocking: 1

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c2f63c26458d0fc47b7e09470ecca5b2
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -157,9 +157,9 @@ Material:
- _WorkflowMode: 1
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 0.21332264, g: 0.12896049, b: 0.4339623, a: 0.23529412}
- _BaseColor: {r: 0.20061173, g: 0.19406372, b: 0.46226418, a: 0.23529412}
- _CameraFadeParams: {r: 0, g: Infinity, b: 0, a: 0}
- _Color: {r: 0.21332261, g: 0.12896046, b: 0.43396226, a: 0.23529412}
- _Color: {r: 0.20061168, g: 0.1940637, b: 0.46226412, a: 0.23529412}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _Flip: {r: 1, g: 1, b: 1, a: 1}
- _RendererColor: {r: 1, g: 1, b: 1, a: 1}

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,7 @@ using UnityEngine;
namespace DCFApixels
{
[SelectionBase]
public class DebugXSample_Lines : MonoBehaviour
{
public Gradient Gradient;
@ -11,7 +12,18 @@ namespace DCFApixels
public float WidthMultiplier = 1f;
#if UNITY_EDITOR
private void OnDrawGizmos()
{
Draw();
}
#else
private void Update()
{
Draw();
}
#endif
private void Draw()
{
int i = -1;

View File

@ -3,13 +3,26 @@ using UnityEngine;
namespace DCFApixels
{
[SelectionBase]
public class DebugXSample_Other : MonoBehaviour
{
public Gradient Gradient;
public float GradientMultiplier = 5;
public Transform[] Points;
#if UNITY_EDITOR
private void OnDrawGizmos()
{
Draw();
}
#else
private void Update()
{
Draw();
}
#endif
private void Draw()
{
int i = -1;
const float RADIUS_M = 0.5f;

View File

@ -2,13 +2,26 @@ using UnityEngine;
namespace DCFApixels
{
[SelectionBase]
public class DebugXSample_Primitives2D : MonoBehaviour
{
public Gradient Gradient;
public float GradientMultiplier = 5;
public Transform[] Points;
#if UNITY_EDITOR
private void OnDrawGizmos()
{
Draw();
}
#else
private void Update()
{
Draw();
}
#endif
private void Draw()
{
int i = -1;
const float RADIUS_M = 0.5f;

View File

@ -2,13 +2,27 @@ using UnityEngine;
namespace DCFApixels
{
[SelectionBase]
public class DebugXSample_Primitives3D : MonoBehaviour
{
public Gradient Gradient;
public float GradientMultiplier = 5;
public Transform[] Points;
#if UNITY_EDITOR
private void OnDrawGizmos()
{
Draw();
}
#else
private void Update()
{
Draw();
}
#endif
private void Draw()
{
int i = -1;
const float RADIUS_M = 0.5f;

View File

@ -2,13 +2,26 @@ using UnityEngine;
namespace DCFApixels
{
[SelectionBase]
public class DebugXSample_Raycasts2D : MonoBehaviour
{
public Gradient Gradient;
public float GradientMultiplier = 5;
public Transform[] Points;
#if UNITY_EDITOR
private void OnDrawGizmos()
{
Draw();
}
#else
private void Update()
{
Draw();
}
#endif
private void Draw()
{
int i = 0;
const float RADIUS_M = 0.5f;

View File

@ -2,13 +2,26 @@ using UnityEngine;
namespace DCFApixels
{
[SelectionBase]
public class DebugXSample_Raycasts3D : MonoBehaviour
{
public Gradient Gradient;
public float GradientMultiplier = 5;
public Transform[] Points;
#if UNITY_EDITOR
private void OnDrawGizmos()
{
Draw();
}
#else
private void Update()
{
Draw();
}
#endif
private void Draw()
{
int i = 0;
const float RADIUS_M = 0.5f;