您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
108 行
3.8 KiB
108 行
3.8 KiB
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.Experimental.Rendering.HDPipeline;
|
|
using UnityEngine.Experimental.Rendering;
|
|
|
|
namespace UnityEditor.Experimental.Rendering.HDPipeline
|
|
{
|
|
partial class InfluenceVolumeUI
|
|
{
|
|
[Flags]
|
|
public enum HandleType
|
|
{
|
|
None = 0,
|
|
Base = 1,
|
|
Influence = 1 << 1,
|
|
InfluenceNormal = 1 << 2,
|
|
|
|
All = ~0
|
|
}
|
|
|
|
public static void DrawGizmos(InfluenceVolumeUI s, InfluenceVolume d, Matrix4x4 matrix, HandleType editedHandle, HandleType showedHandle)
|
|
{
|
|
if ((showedHandle & HandleType.Base) != 0)
|
|
DrawGizmos_BaseHandle(s, d, matrix, (editedHandle & HandleType.Base) != 0, k_GizmoThemeColorBase);
|
|
|
|
if ((showedHandle & HandleType.Influence) != 0)
|
|
DrawGizmos_FadeHandle(
|
|
s, d, matrix,
|
|
d.boxInfluenceOffset, d.boxInfluenceSizeOffset,
|
|
d.sphereInfluenceRadiusOffset,
|
|
(editedHandle & HandleType.Influence) != 0,
|
|
k_GizmoThemeColorInfluence,
|
|
false);
|
|
|
|
if ((showedHandle & HandleType.InfluenceNormal) != 0)
|
|
DrawGizmos_FadeHandle(
|
|
s, d, matrix,
|
|
d.boxInfluenceNormalOffset, d.boxInfluenceNormalSizeOffset,
|
|
d.sphereInfluenceNormalRadiusOffset,
|
|
(editedHandle & HandleType.InfluenceNormal) != 0,
|
|
k_GizmoThemeColorInfluenceNormal,
|
|
true);
|
|
}
|
|
|
|
static void DrawGizmos_BaseHandle(
|
|
InfluenceVolumeUI s, InfluenceVolume d, Matrix4x4 matrix,
|
|
bool isSolid, Color color)
|
|
{
|
|
var mat = Gizmos.matrix;
|
|
var c = Gizmos.color;
|
|
Gizmos.matrix = matrix;
|
|
Gizmos.color = color;
|
|
switch (d.shapeType)
|
|
{
|
|
case ShapeType.Box:
|
|
{
|
|
s.boxBaseHandle.center = d.boxBaseOffset;
|
|
s.boxBaseHandle.size = d.boxBaseSize;
|
|
s.boxBaseHandle.DrawHull(isSolid);
|
|
break;
|
|
}
|
|
case ShapeType.Sphere:
|
|
{
|
|
if (isSolid)
|
|
Gizmos.DrawSphere(d.sphereBaseOffset, d.sphereBaseRadius);
|
|
else
|
|
Gizmos.DrawWireSphere(d.sphereBaseOffset, d.sphereBaseRadius);
|
|
break;
|
|
}
|
|
}
|
|
Gizmos.matrix = mat;
|
|
Gizmos.color = c;
|
|
}
|
|
|
|
static void DrawGizmos_FadeHandle(
|
|
InfluenceVolumeUI s, InfluenceVolume d, Matrix4x4 matrix,
|
|
Vector3 boxOffset, Vector3 boxSizeOffset,
|
|
float sphereOffset,
|
|
bool isSolid, Color color, bool isNormal)
|
|
{
|
|
var mat = Gizmos.matrix;
|
|
var c = Gizmos.color;
|
|
Gizmos.matrix = matrix;
|
|
Gizmos.color = color;
|
|
switch (d.shapeType)
|
|
{
|
|
case ShapeType.Box:
|
|
{
|
|
Gizmo6FacesBox refBox = isNormal ? s.boxInfluenceNormalHandle : s.boxInfluenceHandle;
|
|
refBox.center = d.boxBaseOffset + boxOffset;
|
|
refBox.size = d.boxBaseSize + boxSizeOffset;
|
|
refBox.DrawHull(isSolid);
|
|
break;
|
|
}
|
|
case ShapeType.Sphere:
|
|
{
|
|
if (isSolid)
|
|
Gizmos.DrawSphere(d.sphereBaseOffset, d.sphereBaseRadius + sphereOffset);
|
|
else
|
|
Gizmos.DrawWireSphere(d.sphereBaseOffset, d.sphereBaseRadius + sphereOffset);
|
|
break;
|
|
}
|
|
}
|
|
Gizmos.matrix = mat;
|
|
Gizmos.color = c;
|
|
}
|
|
}
|
|
}
|