62 lines
1.7 KiB
C#
62 lines
1.7 KiB
C#
using Unity.Collections;
|
|
using Unity.Mathematics;
|
|
using UnityEngine;
|
|
|
|
namespace NBF
|
|
{
|
|
public partial class Rope
|
|
{
|
|
#if UNITY_EDITOR
|
|
public struct EditorColors
|
|
{
|
|
public Color ropeSegments;
|
|
public Color simulationParticle;
|
|
public Color collisionParticle;
|
|
public Color spawnPointHandle;
|
|
}
|
|
|
|
public static readonly EditorColors Colors = new EditorColors()
|
|
{
|
|
ropeSegments = Color.black,
|
|
simulationParticle = new Color(0.2f, 0.8f, 0.2f, 0.5f),
|
|
collisionParticle = new Color(1.0f, 0.92f, 0.016f, 0.5f),
|
|
spawnPointHandle = new Color(0.1f, 0.5f, 0.8f),
|
|
};
|
|
|
|
public void OnDrawGizmos()
|
|
{
|
|
if (Application.isPlaying || spawnPoints.Count < 2 || !enabled)
|
|
{
|
|
return;
|
|
}
|
|
|
|
ComputeRealCurve(Allocator.Temp, out Measurements measurements, out NativeArray<float3> points);
|
|
|
|
Gizmos.color = Colors.ropeSegments;
|
|
for (int i = 0; i < points.Length - 1; i++)
|
|
{
|
|
Gizmos.DrawLine(points[i], points[i + 1]);
|
|
}
|
|
|
|
if (UnityEditor.Selection.Contains(gameObject))
|
|
{
|
|
for (int i = 0; i < points.Length; i++)
|
|
{
|
|
if (collisions.enabled && i % collisions.stride == 0)
|
|
{
|
|
Gizmos.color = Colors.collisionParticle;
|
|
}
|
|
else
|
|
{
|
|
Gizmos.color = Colors.simulationParticle;
|
|
}
|
|
|
|
Gizmos.DrawSphere(points[i], radius);
|
|
}
|
|
}
|
|
|
|
points.Dispose();
|
|
}
|
|
#endif
|
|
}
|
|
} |