using System ;
using UnityEditor.IMGUI.Controls ;
using UnityEditorInternal ;
using UnityEngine ;
using UnityEngine.Experimental.Rendering ;
{
partial class HDReflectionProbeEditor
{
internal static Color k_GizmoReflectionProbe = new Color ( 0 xFF / 2 5 5f , 0 xE5 / 2 5 5f , 0 x94 / 2 5 5f , 0 x20 / 2 5 5f ) ;
internal static Color k_GizmoInfluenceVolume = new Color ( 0 xFF / 2 5 5f , 0 xE5 / 2 5 5f , 0 x94 / 2 5 5f , 0 x20 / 2 5 5f ) ;
internal static Color k_GizmoInfluenceNormalVolume = new Color ( 0 x00 / 2 5 5f , 0 xE5 / 2 5 5f , 0 xFF / 2 5 5f , 0 x20 / 2 5 5f ) ;
internal static Color k_GizmoReflectionProbeDisabled = new Color ( 0 x99 / 2 5 5f , 0 x89 / 2 5 5f , 0 x59 / 2 5 5f , 0 x10 / 2 5 5f ) ;
internal static Color k_GizmoHandleReflectionProbe = new Color ( 0 xFF / 2 5 5f , 0 xE5 / 2 5 5f , 0 xAA / 2 5 5f , 0 xFF / 2 5 5f ) ;
switch ( EditMode . editMode )
{
case EditMode . SceneViewEditMode . ReflectionProbeBox :
{
}
{
}
case EditMode . SceneViewEditMode . Collider :
{
if ( p . influenceShape . enumValueIndex = = 0 )
Handle_InfluenceNormalBoxEditing ( s , p , o ) ;
if ( p . influenceShape . enumValueIndex = = 1 )
Handle_InfluenceNormalSphereEditing ( s , p , o ) ;
break ;
}
case EditMode . SceneViewEditMode . ReflectionProbeOrigin :
Handle_OriginEditing ( s , p , o ) ;
break ;
Repaint ( ) ;
}
void BakeRealtimeProbeIfPositionChanged ( UIState s , SerializedReflectionProbe sp , Editor o )
static void Handle_InfluenceBoxEditing ( UIState s , SerializedReflectionProbe sp , Editor o )
{
var blendDistance = sp . target . blendDistance ;
Handle_InfluenceBoxEditing_Internal ( s , sp , o , s . boxBlendHandle , k_GizmoInfluenceVolume , ref blendDistance ) ;
sp . target . blendDistance = blendDistance ;
}
static void Handle_InfluenceNormalBoxEditing ( UIState s , SerializedReflectionProbe sp , Editor o )
{
Handle_InfluenceBoxEditing_Internal ( s , sp , o , s . boxBlendHandle , k_GizmoInfluenceNormalVolume , ref sp . targetData . blendNormalDistance ) ;
}
static void Handle_InfluenceBoxEditing_Internal ( UIState s , SerializedReflectionProbe sp , Editor o , BoxBoundsHandle blendBox , Color blendHandleColor , ref float probeBlendDistance )
{
var p = ( ReflectionProbe ) sp . so . targetObject ;
using ( new Handles . DrawingScope ( GetLocalSpace ( p ) ) )
s . boxBlendHandle . center = p . center ;
s . boxBlendHandle . size = p . size - Vector3 . one * p . blendDistance * 2 ;
blendBox . center = p . center ;
blendBox . size = p . size - Vector3 . one * probeBlendDistance * 2 ;
s . boxBlendHandle . DrawHandle ( ) ;
Handles . color = blendHandleColor ;
blendBox . DrawHandle ( ) ;
var blendSize = s . boxBlendHandle . size ;
var blendSize = blendBox . size ;
? p . blendDistance
? probeBlendDistance
p . blendDistance = Mathf . Max ( blendDistance , 0 ) ;
probeBlendDistance = Mathf . Max ( blendDistance , 0 ) ;
EditorUtility . SetDirty ( p ) ;
}
}
static void Handle_InfluenceSphereEditing ( UIState s , SerializedReflectionProbe sp , Editor o )
{
var blendDistance = sp . target . blendDistance ;
Handle_InfluenceSphereEditing_Internal ( s , sp , o , s . sphereBlendHandle , ref blendDistance ) ;
sp . target . blendDistance = blendDistance ;
}
static void Handle_InfluenceNormalSphereEditing ( UIState s , SerializedReflectionProbe sp , Editor o )
{
Handle_InfluenceSphereEditing_Internal ( s , sp , o , s . sphereBlendHandle , ref sp . targetData . blendNormalDistance ) ;
}
static void Handle_InfluenceSphereEditing_Internal ( UIState s , SerializedReflectionProbe sp , Editor o , SphereBoundsHandle sphereBlend , ref float probeBlendDistance )
{
var p = ( ReflectionProbe ) sp . so . targetObject ;
var reflectionData = p . GetComponent < HDAdditionalReflectionData > ( ) ;
s . influenceSphereHandle . radius = reflectionData . influenceSphereRadius ;
s . s phereBlendHandle . center = p . center ;
s . s phereBlendHandle . radius = Mathf . Min ( reflectionData . influenceSphereRadius - p . b lendDistance * 2 , reflectionData . influenceSphereRadius ) ;
sphereBlend . center = p . center ;
sphereBlend . radius = Mathf . Min ( reflectionData . influenceSphereRadius - probeB lendDistance * 2 , reflectionData . influenceSphereRadius ) ;
s . s phereBlendHandle . DrawHandle ( ) ;
sphereBlend . DrawHandle ( ) ;
if ( influenceChanged | | EditorGUI . EndChangeCheck ( ) )
{
Undo . RecordObject ( reflectionData , "Modified Reflection influence volume" ) ;
? Mathf . Max ( influenceRadius - p . blendDistance * 2 , 0 )
: s . sphereBlendHandle . radius ;
? Mathf . Max ( influenceRadius - probeBlendDistance * 2 , 0 )
: sphereBlend . radius ;
p . blendDistance = blendDistance ;
probeBlendDistance = blendDistance ;
EditorUtility . SetDirty ( p ) ;
EditorUtility . SetDirty ( reflectionData ) ;
}
static void RenderGizmo ( ReflectionProbe reflectionProbe , GizmoType gizmoType )
{
var e = GetEditorFor ( reflectionProbe ) ;
if ( e = = null )
if ( e = = null | | ! e . sceneViewEditing )
if ( e . sceneViewEditing & & EditMode . editMode = = EditMode . SceneViewEditMode . ReflectionProbeBox )
switch ( EditMode . editMode )
var oldColor = Gizmos . color ;
Gizmos . color = k_GizmoReflectionProbe ;
case EditMode . SceneViewEditMode . ReflectionProbeBox :
{
var oldColor = Gizmos . color ;
Gizmos . color = k_GizmoInfluenceVolume ;
Gizmos . matrix = GetLocalSpace ( reflectionProbe ) ;
if ( reflectionData . influenceShape = = ReflectionInfluenceShape . Box )
Gizmos . DrawCube ( reflectionProbe . center , - 1f * reflectionProbe . size ) ;
if ( reflectionData . influenceShape = = ReflectionInfluenceShape . Sphere )
Gizmos . DrawSphere ( reflectionProbe . center , reflectionData . influenceSphereRadius ) ;
Gizmos . matrix = Matrix4x4 . identity ;
Gizmos . color = oldColor ;
break ;
}
case EditMode . SceneViewEditMode . Collider :
{
var oldColor = Gizmos . color ;
Gizmos . color = k_GizmoInfluenceNormalVolume ;
Gizmos . matrix = GetLocalSpace ( reflectionProbe ) ;
if ( reflectionData . influenceShape = = ReflectionInfluenceShape . Box )
Gizmos . DrawCube ( reflectionProbe . center , - 1f * reflectionProbe . size + Vector3 . one * 2f * reflectionData . blendNormalDistance ) ;
if ( reflectionData . influenceShape = = ReflectionInfluenceShape . Sphere )
Gizmos . DrawSphere ( reflectionProbe . center , reflectionData . influenceSphereRadius - reflectionData . blendNormalDistance * 2f ) ;
Gizmos . matrix = GetLocalSpace ( reflectionProbe ) ;
if ( reflectionData . influenceShape = = ReflectionInfluenceShape . Box )
Gizmos . DrawCube ( reflectionProbe . center , - 1f * reflectionProbe . size ) ;
if ( reflectionData . influenceShape = = ReflectionInfluenceShape . Sphere )
Gizmos . DrawSphere ( reflectionProbe . center , reflectionData . influenceSphereRadius ) ;
Gizmos . matrix = Matrix4x4 . identity ;
Gizmos . color = oldColor ;
Gizmos . matrix = Matrix4x4 . identity ;
Gizmos . color = oldColor ;
break ;
}
}
}
Color oldColor = Gizmos . color ;
Gizmos . color = reflectionProbe . isActiveAndEnabled ? k_GizmoReflectionProbe : k_GizmoReflectionProbeDisabled ;
var oldColor = Gizmos . color ;
DrawBoxInfluenceGizmo ( reflectionProbe , oldColor ) ;
DrawBoxInfluenceGizmo ( reflectionProbe , reflectionData ) ;
DrawSphereInfluenceGizmo ( reflectionProbe , oldColor , reflectionData ) ;
DrawSphereInfluenceGizmo ( reflectionProbe , reflectionData ) ;
}
if ( reflectionData . useSeparateProjectionVolume )
{
ChangeVisibility ( reflectionProbe , false ) ;
}
static void DrawBoxInfluenceGizmo ( ReflectionProbe reflectionProbe , Color oldColor )
static void DrawBoxInfluenceGizmo ( ReflectionProbe reflectionProbe , HDAdditionalReflectionData reflectionData )
var influenceColor = reflectionProbe . isActiveAndEnabled ? k_GizmoInfluenceVolume : k_GizmoReflectionProbeDisabled ;
var influenceNormalColor = reflectionProbe . isActiveAndEnabled ? k_GizmoInfluenceNormalVolume : k_GizmoReflectionProbeDisabled ;
Gizmos . color = influenceColor ;
Gizmos . DrawWireCube ( reflectionProbe . center , new Vector3 ( reflectionProbe . size . x - reflectionProbe . blendDistance * 2 , reflectionProbe . size . y - reflectionProbe . blendDistance * 2 , reflectionProbe . size . z - reflectionProbe . blendDistance * 2 ) ) ;
Gizmos . DrawWireCube ( reflectionProbe . center , GetBlendBoxSize ( reflectionProbe , reflectionProbe . blendDistance ) ) ;
}
if ( reflectionData . blendNormalDistance > 0 )
{
Gizmos . color = new Color ( influenceNormalColor . r , influenceNormalColor . g , Gizmos . color . b , 0.3f ) ;
Gizmos . DrawWireCube ( reflectionProbe . center , GetBlendBoxSize ( reflectionProbe , reflectionData . blendNormalDistance ) ) ;
Gizmos . color = oldColor ;
}
static Vector3 GetBlendBoxSize ( ReflectionProbe reflectionProbe , float blendDistance )
{
return new Vector3 ( reflectionProbe . size . x - blendDistance * 2 , reflectionProbe . size . y - blendDistance * 2 , reflectionProbe . size . z - blendDistance * 2 ) ;
static void DrawSphereInfluenceGizmo ( ReflectionProbe reflectionProbe , Color oldColor , HDAdditionalReflectionData reflectionData )
static void DrawSphereInfluenceGizmo ( ReflectionProbe reflectionProbe , HDAdditionalReflectionData reflectionData )
var influenceColor = reflectionProbe . isActiveAndEnabled ? k_GizmoInfluenceVolume : k_GizmoReflectionProbeDisabled ;
var influenceNormalColor = reflectionProbe . isActiveAndEnabled ? k_GizmoInfluenceNormalVolume : k_GizmoReflectionProbeDisabled ;
Gizmos . color = influenceColor ;
Gizmos . matrix = GetLocalSpace ( reflectionProbe ) ;
Gizmos . DrawWireSphere ( reflectionProbe . center , reflectionData . influenceSphereRadius ) ;
if ( reflectionProbe . blendDistance > 0 )
}
if ( reflectionData . blendNormalDistance > 0 )
{
Gizmos . color = new Color ( influenceNormalColor . r , influenceNormalColor . g , influenceNormalColor . b , 0.3f ) ;
Gizmos . DrawWireSphere ( reflectionProbe . center , reflectionData . influenceSphereRadius - 2 * reflectionData . blendNormalDistance ) ;
}
Gizmos . color = oldColor ;
}
static void DrawReprojectionVolumeGizmo ( ReflectionProbe reflectionProbe , HDAdditionalReflectionData reflectionData )