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); } if ((showedHandle & HandleType.InfluenceNormal) != 0) { DrawGizmos_FadeHandle( s, d, matrix, d.boxInfluenceNormalOffset, d.boxInfluenceNormalSizeOffset, d.sphereInfluenceNormalRadiusOffset, (editedHandle & HandleType.InfluenceNormal) != 0, k_GizmoThemeColorInfluenceNormal); } }
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 Drawer_Offset(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, bool drawAllOffset) { EditorGUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); float y = 0f; if (drawAllOffset) { EditorGUILayout.PropertyField(d.offset, offsetContent); } else { y = EditorGUILayout.FloatField(yOffsetContent, d.offset.vector3Value.y); } if (EditorGUI.EndChangeCheck()) { //call the offset setter as it will update legacy reflection probe HDProbeEditor editor = (HDProbeEditor)o; InfluenceVolume influenceVolume = editor.GetTarget(editor.target).influenceVolume; if (drawAllOffset) { influenceVolume.offset = d.offset.vector3Value; } else { influenceVolume.offset = new Vector3(0, y, 0); } } HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.CapturePosition, o, GUILayout.Width(28f), GUILayout.MinHeight(22f)); EditorGUILayout.EndHorizontal(); }
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.boxBlendOffset, d.boxBlendSize, -d.sphereBlendDistance, (editedHandle & HandleType.Influence) != 0, k_GizmoThemeColorInfluence, false); } if ((showedHandle & HandleType.InfluenceNormal) != 0) { DrawGizmos_FadeHandle( s, d, matrix, d.boxBlendNormalOffset, d.boxBlendNormalSize, -d.sphereBlendNormalDistance, (editedHandle & HandleType.InfluenceNormal) != 0, k_GizmoThemeColorInfluenceNormal, true); } }
static void DrawBoxFadeHandle( InfluenceVolumeUI s, InfluenceVolume d, Editor o, Object sourceAsset, Func <InfluenceVolumeUI, Gizmo6FacesBox> boundsGetter, Vector3 baseOffset, Vector3 baseSize, ref Vector3 positive, ref Vector3 negative) { var b = boundsGetter(s); b.center = baseOffset - (positive - negative) * 0.5f; b.size = baseSize - positive - negative; b.allHandleControledByOne = !s.data.editorAdvancedModeEnabled.boolValue; EditorGUI.BeginChangeCheck(); b.DrawHandle(); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(sourceAsset, "Modified Influence Volume"); var center = baseOffset; var influenceSize = baseSize; var diff = 2 * (b.center - center); var sum = influenceSize - b.size; var positiveNew = (sum - diff) * 0.5f; var negativeNew = (sum + diff) * 0.5f; var blendDistancePositive = Vector3.Max(Vector3.zero, Vector3.Min(positiveNew, influenceSize)); var blendDistanceNegative = Vector3.Max(Vector3.zero, Vector3.Min(negativeNew, influenceSize)); positive = blendDistancePositive; negative = blendDistanceNegative; EditorUtility.SetDirty(sourceAsset); } }
public static void DrawGizmos(InfluenceVolumeUI s, InfluenceVolume d, Matrix4x4 matrix, HandleType editedHandle, HandleType showedHandle) { using (new Handles.DrawingScope(matrix)) { switch (d.shape) { case InfluenceShape.Box: if ((showedHandle & HandleType.Base) != 0) { s.boxBaseHandle.center = d.offset; s.boxBaseHandle.size = d.boxSize; s.boxBaseHandle.DrawHull((editedHandle & HandleType.Base) != 0); } if ((showedHandle & HandleType.Influence) != 0) { s.boxInfluenceHandle.monoHandle = !s.data.editorAdvancedModeEnabled.boolValue; s.boxInfluenceHandle.center = d.offset + d.boxBlendOffset; s.boxInfluenceHandle.size = d.boxSize + d.boxBlendSize; s.boxInfluenceHandle.DrawHull((editedHandle & HandleType.Influence) != 0); } if ((showedHandle & HandleType.InfluenceNormal) != 0) { s.boxInfluenceNormalHandle.monoHandle = !s.data.editorAdvancedModeEnabled.boolValue; s.boxInfluenceNormalHandle.center = d.offset + d.boxBlendNormalOffset; s.boxInfluenceNormalHandle.size = d.boxSize + d.boxBlendNormalSize; s.boxInfluenceNormalHandle.DrawHull((editedHandle & HandleType.InfluenceNormal) != 0); } break; case InfluenceShape.Sphere: if ((showedHandle & HandleType.Base) != 0) { s.sphereBaseHandle.center = d.offset; s.sphereBaseHandle.radius = d.sphereRadius; s.sphereBaseHandle.DrawHull((editedHandle & HandleType.Base) != 0); } if ((showedHandle & HandleType.Influence) != 0) { s.sphereInfluenceHandle.center = d.offset; s.sphereInfluenceHandle.radius = d.sphereRadius - d.sphereBlendDistance; s.sphereInfluenceHandle.DrawHull((editedHandle & HandleType.Influence) != 0); } if ((showedHandle & HandleType.InfluenceNormal) != 0) { s.sphereInfluenceNormalHandle.center = d.offset; s.sphereInfluenceNormalHandle.radius = d.sphereRadius - d.sphereBlendNormalDistance; s.sphereInfluenceNormalHandle.DrawHull((editedHandle & HandleType.InfluenceNormal) != 0); } break; } } }
public static void DrawHandles_EditInfluence(InfluenceVolumeUI s, InfluenceVolume d, Editor o, Matrix4x4 matrix, Object sourceAsset) { var mat = Handles.matrix; var c = Handles.color; Handles.matrix = matrix; Handles.color = k_GizmoThemeColorInfluence; switch (d.shape) { case InfluenceShape.Box: { var positive = d.boxBlendDistancePositive; var negative = d.boxBlendDistanceNegative; DrawBoxFadeHandle( s, d, o, sourceAsset, s1 => s1.boxInfluenceHandle, d.offset, d.boxSize, ref positive, ref negative); s.data.boxBlendDistancePositive.vector3Value = positive; s.data.boxBlendDistanceNegative.vector3Value = negative; //save advanced/simplified saved data if (s.data.editorAdvancedModeEnabled.boolValue) { s.data.editorAdvancedModeBlendDistancePositive.vector3Value = positive; s.data.editorAdvancedModeBlendDistanceNegative.vector3Value = negative; } else { s.data.editorSimplifiedModeBlendDistance.floatValue = positive.x; } s.data.Apply(); break; } case InfluenceShape.Sphere: { var fade = d.sphereBlendDistance; DrawSphereFadeHandle( s, d, o, sourceAsset, s1 => s1.sphereInfluenceHandle, d.offset, d.sphereRadius, ref fade); d.sphereBlendDistance = fade; break; } } Handles.matrix = mat; Handles.color = c; }
static void DrawGizmos_FadeHandle( InfluenceVolumeUI s, InfluenceVolume d, Matrix4x4 matrix, Vector3 boxOffset, Vector3 boxSizeOffset, float sphereOffset, bool isSolid, Color color) { var mat = Gizmos.matrix; var c = Gizmos.color; Gizmos.matrix = matrix; Gizmos.color = color; switch (d.shapeType) { case ShapeType.Box: { if (isSolid) { Gizmos.DrawCube(d.boxBaseOffset + boxOffset, d.boxBaseSize + boxSizeOffset); } else { Gizmos.DrawWireCube(d.boxBaseOffset + boxOffset, d.boxBaseSize + boxSizeOffset); } 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; }
static void DrawSphereHandle( InfluenceVolumeUI s, InfluenceVolume d, Editor o, Object sourceAsset, Func <InfluenceVolumeUI, SphereBoundsHandle> boundsGetter, ref Vector3 center, ref float radius) { var b = boundsGetter(s); b.center = center; b.radius = radius; EditorGUI.BeginChangeCheck(); b.DrawHandle(); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(sourceAsset, "Modified Base Volume AABB"); radius = b.radius; EditorUtility.SetDirty(sourceAsset); } }
public static void DrawHandles_EditBase(InfluenceVolumeUI s, InfluenceVolume d, Editor o, Matrix4x4 matrix, Object sourceAsset) { var mat = Handles.matrix; var c = Handles.color; Handles.matrix = matrix; Handles.color = k_GizmoThemeColorBase; switch (d.shape) { case InfluenceShape.Box: { var center = d.offset; var size = d.boxSize; DrawBoxHandle( s, d, o, sourceAsset, s1 => s1.boxBaseHandle, ref center, ref size); d.offset = center; d.boxSize = size; break; } case InfluenceShape.Sphere: { var center = d.offset; var radius = d.sphereRadius; DrawSphereHandle( s, d, o, sourceAsset, s1 => s1.sphereBaseHandle, ref center, ref radius); d.offset = center; d.sphereRadius = radius; break; } } Handles.matrix = mat; Handles.color = c; }
static void DrawSphereFadeHandle( InfluenceVolumeUI s, InfluenceVolume d, Editor o, Object sourceAsset, Func <InfluenceVolumeUI, SphereBoundsHandle> boundsGetter, Vector3 baseOffset, float baseRadius, ref float radius) { var b = boundsGetter(s); b.center = baseOffset; b.radius = Mathf.Clamp(baseRadius - radius, 0, baseRadius); EditorGUI.BeginChangeCheck(); b.DrawHandle(); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(sourceAsset, "Modified Influence volume"); radius = Mathf.Clamp(baseRadius - b.radius, 0, baseRadius); EditorUtility.SetDirty(sourceAsset); } }
static void DrawBoxHandle( InfluenceVolumeUI s, InfluenceVolume d, Editor o, Object sourceAsset, Func <InfluenceVolumeUI, Gizmo6FacesBox> boundsGetter, ref Vector3 center, ref Vector3 size) { var b = boundsGetter(s); b.center = center; b.size = size; EditorGUI.BeginChangeCheck(); b.DrawHandle(); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(sourceAsset, "Modified Base Volume AABB"); center = b.center; size = b.size; EditorUtility.SetDirty(sourceAsset); } }
public static void DrawHandles_EditInfluenceNormal(InfluenceVolumeUI s, InfluenceVolume d, Editor o, Matrix4x4 matrix, Object sourceAsset) { var mat = Handles.matrix; var c = Handles.color; Handles.matrix = matrix; Handles.color = k_GizmoThemeColorInfluenceNormal; switch (d.shapeType) { case ShapeType.Box: { var positive = d.boxInfluenceNormalPositiveFade; var negative = d.boxInfluenceNormalNegativeFade; DrawBoxFadeHandle( s, d, o, sourceAsset, s1 => s1.boxInfluenceNormalHandle, d.boxBaseOffset, d.boxBaseSize, ref positive, ref negative); d.boxInfluenceNormalPositiveFade = positive; d.boxInfluenceNormalNegativeFade = negative; break; } case ShapeType.Sphere: { var fade = d.sphereInfluenceNormalFade; DrawSphereFadeHandle( s, d, o, sourceAsset, s1 => s1.sphereInfluenceNormalHandle, d.sphereBaseOffset, d.sphereBaseRadius, ref fade); d.sphereInfluenceNormalFade = fade; break; } } Handles.matrix = mat; Handles.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; }
public static void DrawGizmos(InfluenceVolume serialized, Matrix4x4 matrix, HandleType editedHandle, HandleType showedHandle) { var mat = Handles.matrix; Handles.matrix = matrix; if ((showedHandle & HandleType.Base) != 0) { switch (serialized.shape) { case InfluenceShape.Box: s_BoxBaseHandle.baseColor = k_GizmoThemeColorBase; s_BoxBaseHandle.center = Vector3.zero; s_BoxBaseHandle.size = serialized.boxSize; s_BoxBaseHandle.DrawHull(false); break; case InfluenceShape.Sphere: s_SphereBaseHandle.baseColor = k_GizmoThemeColorBase; s_SphereBaseHandle.center = Vector3.zero; s_SphereBaseHandle.radius = serialized.sphereRadius; s_SphereBaseHandle.DrawHull(false); break; } } if ((showedHandle & HandleType.Influence) != 0) { switch (serialized.shape) { case InfluenceShape.Box: s_BoxBaseHandle.baseColor = k_GizmoThemeColorInfluence; s_BoxBaseHandle.center = serialized.boxBlendOffset; s_BoxBaseHandle.size = serialized.boxSize + serialized.boxBlendSize; s_BoxBaseHandle.DrawHull(false); break; case InfluenceShape.Sphere: s_SphereBaseHandle.baseColor = k_GizmoThemeColorInfluence; s_SphereBaseHandle.center = Vector3.zero; s_SphereBaseHandle.radius = serialized.sphereRadius - serialized.sphereBlendDistance; s_SphereBaseHandle.DrawHull(false); break; } } if ((showedHandle & HandleType.InfluenceNormal) != 0) { switch (serialized.shape) { case InfluenceShape.Box: s_BoxBaseHandle.baseColor = k_GizmoThemeColorInfluenceNormal; s_BoxBaseHandle.center = serialized.boxBlendNormalOffset; s_BoxBaseHandle.size = serialized.boxSize + serialized.boxBlendNormalSize; s_BoxBaseHandle.DrawHull(false); break; case InfluenceShape.Sphere: s_SphereBaseHandle.baseColor = k_GizmoThemeColorInfluenceNormal; s_SphereBaseHandle.center = Vector3.zero; s_SphereBaseHandle.radius = serialized.sphereRadius - serialized.sphereBlendNormalDistance; s_SphereBaseHandle.DrawHull(false); break; } } Handles.matrix = mat; }