|
|
|
|
|
|
using UnityEditor.Experimental.Rendering.HDPipeline; |
|
|
|
using UnityEditorInternal; |
|
|
|
using UnityEngine; |
|
|
|
using UnityEngine.Experimental.Rendering; |
|
|
|
|
|
|
[DrawGizmo(GizmoType.Active)] |
|
|
|
static void RenderGizmo(ReflectionProbe reflectionProbe, GizmoType gizmoType) |
|
|
|
{ |
|
|
|
var e = GetEditorFor(reflectionProbe); |
|
|
|
HDReflectionProbeEditor e = GetEditorFor(reflectionProbe); |
|
|
|
var mat = reflectionProbe.transform.localToWorldMatrix; |
|
|
|
Gizmos_Influence(reflectionProbe, reflectionData, e, true); |
|
|
|
InfluenceVolumeUI.DrawGizmos(e.m_InfluenceVolumeUI, reflectionData.influenceVolume, mat, InfluenceVolumeUI.HandleType.Base, InfluenceVolumeUI.HandleType.All); |
|
|
|
Gizmos_InfluenceFade(reflectionProbe, reflectionData, e, InfluenceType.Standard, true); |
|
|
|
InfluenceVolumeUI.DrawGizmos(e.m_InfluenceVolumeUI, reflectionData.influenceVolume, mat, InfluenceVolumeUI.HandleType.Influence, InfluenceVolumeUI.HandleType.All); |
|
|
|
Gizmos_InfluenceFade(reflectionProbe, reflectionData, e, InfluenceType.Normal, true); |
|
|
|
InfluenceVolumeUI.DrawGizmos(e.m_InfluenceVolumeUI, reflectionData.influenceVolume, mat, InfluenceVolumeUI.HandleType.InfluenceNormal, InfluenceVolumeUI.HandleType.All); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
//Gizmos_Influence(reflectionProbe, reflectionData, e, false);
|
|
|
|
Gizmos_InfluenceFade(reflectionProbe, reflectionData, null, InfluenceType.Standard, false); |
|
|
|
Gizmos_InfluenceFade(reflectionProbe, reflectionData, null, InfluenceType.Normal, false); |
|
|
|
|
|
|
|
DrawVerticalRay(reflectionProbe.transform); |
|
|
|
} |
|
|
|
|
|
|
|
static void Gizmos_InfluenceFade(ReflectionProbe p, HDAdditionalReflectionData a, HDReflectionProbeEditor e, InfluenceType type, bool isEdit) |
|
|
|
{ |
|
|
|
var col = Gizmos.color; |
|
|
|
var mat = Gizmos.matrix; |
|
|
|
|
|
|
|
Gizmo6FacesBoxContained box; |
|
|
|
Vector3 boxCenterOffset; |
|
|
|
Vector3 boxSizeOffset; |
|
|
|
float sphereRadiusOffset; |
|
|
|
Color color; |
|
|
|
switch (type) |
|
|
|
{ |
|
|
|
default: |
|
|
|
case InfluenceType.Standard: |
|
|
|
{ |
|
|
|
box = e != null ? e.m_UIState.alternativeBoxBlendHandle : null; |
|
|
|
boxCenterOffset = a.boxBlendCenterOffset; |
|
|
|
boxSizeOffset = a.boxBlendSizeOffset; |
|
|
|
sphereRadiusOffset = a.sphereBlendRadiusOffset; |
|
|
|
color = isEdit ? k_GizmoThemeColorInfluenceBlendFace : k_GizmoThemeColorInfluenceBlend; |
|
|
|
break; |
|
|
|
} |
|
|
|
case InfluenceType.Normal: |
|
|
|
{ |
|
|
|
box = e != null ? e.m_UIState.alternativeBoxBlendNormalHandle : null; |
|
|
|
boxCenterOffset = a.boxBlendNormalCenterOffset; |
|
|
|
boxSizeOffset = a.boxBlendNormalSizeOffset; |
|
|
|
sphereRadiusOffset = a.sphereBlendNormalRadiusOffset; |
|
|
|
color = isEdit ? k_GizmoThemeColorInfluenceNormalBlendFace : k_GizmoThemeColorInfluenceNormalBlend; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Gizmos.matrix = HDReflectionProbeEditorUtility.GetLocalSpace(p); |
|
|
|
switch (a.influenceShape) |
|
|
|
{ |
|
|
|
case ShapeType.Box: |
|
|
|
{ |
|
|
|
Gizmos.color = color; |
|
|
|
if (e != null) // e == null may occure when editor have still not been created at selection while the tool is not used for this part
|
|
|
|
{ |
|
|
|
box.DrawHull(isEdit); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if (isEdit) |
|
|
|
Gizmos.DrawCube(p.center + boxCenterOffset, p.size + boxSizeOffset); |
|
|
|
else |
|
|
|
Gizmos.DrawWireCube(p.center + boxCenterOffset, p.size + boxSizeOffset); |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
case ShapeType.Sphere: |
|
|
|
{ |
|
|
|
Gizmos.color = color; |
|
|
|
if (isEdit) |
|
|
|
Gizmos.DrawSphere(p.center, a.influenceSphereRadius + sphereRadiusOffset); |
|
|
|
else |
|
|
|
Gizmos.DrawWireSphere(p.center, a.influenceSphereRadius + sphereRadiusOffset); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Gizmos.matrix = mat; |
|
|
|
Gizmos.color = col; |
|
|
|
} |
|
|
|
|
|
|
|
static void Gizmos_Influence(ReflectionProbe p, HDAdditionalReflectionData a, HDReflectionProbeEditor e, bool isEdit) |
|
|
|
{ |
|
|
|
var col = Gizmos.color; |
|
|
|
var mat = Gizmos.matrix; |
|
|
|
//Gizmos_InfluenceFade(reflectionProbe, reflectionData, null, InfluenceType.Standard, false);
|
|
|
|
//Gizmos_InfluenceFade(reflectionProbe, reflectionData, null, InfluenceType.Normal, false);
|
|
|
|
Gizmos.matrix = HDReflectionProbeEditorUtility.GetLocalSpace(p); |
|
|
|
switch (a.influenceShape) |
|
|
|
{ |
|
|
|
case ShapeType.Box: |
|
|
|
{ |
|
|
|
Gizmos.color = k_GizmoThemeColorExtentFace; |
|
|
|
e.m_UIState.alternativeBoxInfluenceHandle.DrawHull(isEdit); |
|
|
|
break; |
|
|
|
} |
|
|
|
case ShapeType.Sphere: |
|
|
|
{ |
|
|
|
Gizmos.color = k_GizmoThemeColorExtentFace; |
|
|
|
if (isEdit) |
|
|
|
Gizmos.DrawSphere(p.center, a.influenceSphereRadius); |
|
|
|
else |
|
|
|
Gizmos.DrawWireSphere(p.center, a.influenceSphereRadius); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
//[TODO:] DrawInfluence here
|
|
|
|
Gizmos.matrix = mat; |
|
|
|
Gizmos.color = col; |
|
|
|
DrawVerticalRay(reflectionProbe.transform); |
|
|
|
} |
|
|
|
|
|
|
|
static void DrawVerticalRay(Transform transform) |
|
|
|