浏览代码

fix clamping of gizmo values

/main
RSlysz 6 年前
当前提交
a824fb71
共有 5 个文件被更改,包括 95 次插入57 次删除
  1. 31
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Handles.cs
  2. 25
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.cs
  3. 9
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedHDReflectionProbe.cs
  4. 42
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Drawers.cs
  5. 45
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Handles.cs

31
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Handles.cs


var o = this;
BakeRealtimeProbeIfPositionChanged(s, p, o);
//if (!s.sceneViewEditing)
// return;
//var mat = Matrix4x4.TRS(p.targetLegacy.transform.position, p.targetLegacy.transform.rotation, Vector3.one);
//EditorGUI.BeginChangeCheck();
//switch (EditMode.editMode)
//{
// // Influence editing
// case EditMode.SceneViewEditMode.ReflectionProbeBox:
// InfluenceVolumeUI.DrawHandles_EditBase(s.influenceVolume, p.target.influenceVolume, o, mat, p.target);
// break;
// // Influence fade editing
// case EditMode.SceneViewEditMode.GridBox:
// InfluenceVolumeUI.DrawHandles_EditInfluence(s.influenceVolume, p.target.influenceVolume, o, mat, p.target);
// break;
// // Influence normal fade editing
// case EditMode.SceneViewEditMode.Collider:
// InfluenceVolumeUI.DrawHandles_EditInfluenceNormal(s.influenceVolume, p.target.influenceVolume, o, mat, p.target);
// break;
// // Origin editing
// case EditMode.SceneViewEditMode.ReflectionProbeOrigin:
// Handle_OriginEditing(s, p, o);
// break;
//}
//if (EditorGUI.EndChangeCheck())
// Repaint();
}
static void Handle_OriginEditing(HDReflectionProbeUI s, SerializedHDReflectionProbe sp, Editor o)

25
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.cs


}
}
}
static void ApplyConstraintsOnTargets(HDReflectionProbeUI s, SerializedHDReflectionProbe sp, Editor o)
{
switch ((InfluenceShape)sp.influenceVolume.shape.enumValueIndex)
{
case InfluenceShape.Box:
{
var maxBlendDistance = sp.influenceVolume.boxSize.vector3Value;
sp.target.influenceVolume.boxBlendDistancePositive = Vector3.Min(sp.target.influenceVolume.boxBlendDistancePositive, maxBlendDistance);
sp.target.influenceVolume.boxBlendDistanceNegative = Vector3.Min(sp.target.influenceVolume.boxBlendDistanceNegative, maxBlendDistance);
sp.target.influenceVolume.boxBlendNormalDistancePositive = Vector3.Min(sp.target.influenceVolume.boxBlendNormalDistancePositive, maxBlendDistance);
sp.target.influenceVolume.boxBlendNormalDistanceNegative = Vector3.Min(sp.target.influenceVolume.boxBlendNormalDistanceNegative, maxBlendDistance);
break;
}
case InfluenceShape.Sphere:
{
var maxBlendDistance = Vector3.one * sp.influenceVolume.sphereRadius.floatValue;
sp.target.influenceVolume.boxBlendDistancePositive = Vector3.Min(sp.target.influenceVolume.boxBlendDistancePositive, maxBlendDistance);
sp.target.influenceVolume.boxBlendDistanceNegative = Vector3.Min(sp.target.influenceVolume.boxBlendDistanceNegative, maxBlendDistance);
sp.target.influenceVolume.boxBlendNormalDistancePositive = Vector3.Min(sp.target.influenceVolume.boxBlendNormalDistancePositive, maxBlendDistance);
sp.target.influenceVolume.boxBlendNormalDistanceNegative = Vector3.Min(sp.target.influenceVolume.boxBlendNormalDistanceNegative, maxBlendDistance);
break;
}
}
}
}
}

9
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedHDReflectionProbe.cs


internal override void Apply()
{
switch(target.influenceVolume.shape)
{
case InfluenceShape.Box:
boxSize.vector3Value = influenceVolume.boxSize.vector3Value;
break;
case InfluenceShape.Sphere:
boxSize.vector3Value = Vector3.one * influenceVolume.sphereRadius.floatValue;
break;
}
serializedLegacyObject.ApplyModifiedProperties();
serializedObject.ApplyModifiedProperties();
}

42
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Drawers.cs


var minFadeDistance = Vector3.zero;
EditorGUILayout.BeginHorizontal();
EditorGUI.BeginChangeCheck();
if (EditorGUI.EndChangeCheck())
{
Vector3 blendPositive = d.boxBlendDistancePositive.vector3Value;
Vector3 blendNegative = d.boxBlendDistanceNegative.vector3Value;
Vector3 blendNormalPositive = d.boxBlendNormalDistancePositive.vector3Value;
Vector3 blendNormalNegative = d.boxBlendNormalDistanceNegative.vector3Value;
Vector3 size = d.boxSize.vector3Value;
for(int i = 0; i<3; ++i)
{
size[i] = Mathf.Max(0f, size[i]);
}
d.boxSize.vector3Value = size;
Vector3 halfSize = size * .5f;
for (int i = 0; i < 3; ++i)
{
blendPositive[i] = Mathf.Clamp(blendPositive[i], 0f, halfSize[i]);
blendNegative[i] = Mathf.Clamp(blendNegative[i], 0f, halfSize[i]);
blendNormalPositive[i] = Mathf.Clamp(blendNormalPositive[i], 0f, halfSize[i]);
blendNormalNegative[i] = Mathf.Clamp(blendNormalNegative[i], 0f, halfSize[i]);
}
d.boxBlendDistancePositive.vector3Value = blendPositive;
d.boxBlendDistanceNegative.vector3Value = blendNegative;
d.boxBlendNormalDistancePositive.vector3Value = blendNormalPositive;
d.boxBlendNormalDistanceNegative.vector3Value = blendNormalNegative;
if (d.editorAdvancedModeEnabled.boolValue)
{
d.editorAdvancedModeBlendDistancePositive.vector3Value = d.boxBlendDistancePositive.vector3Value;
d.editorAdvancedModeBlendDistanceNegative.vector3Value = d.boxBlendDistanceNegative.vector3Value;
d.editorAdvancedModeBlendNormalDistancePositive.vector3Value = d.boxBlendNormalDistancePositive.vector3Value;
d.editorAdvancedModeBlendNormalDistanceNegative.vector3Value = d.boxBlendNormalDistanceNegative.vector3Value;
}
else
{
d.editorSimplifiedModeBlendDistance.floatValue = Mathf.Min(blendPositive.x, blendPositive.y, blendPositive.z, blendNegative.x, blendNegative.y, blendNegative.z);
d.boxBlendDistancePositive.vector3Value = d.boxBlendDistanceNegative.vector3Value = Vector3.one * d.editorSimplifiedModeBlendDistance.floatValue;
d.editorSimplifiedModeBlendNormalDistance.floatValue = Mathf.Min(blendNormalPositive.x, blendNormalPositive.y, blendNormalPositive.z, blendNormalNegative.x, blendNormalNegative.y, blendNormalNegative.z);
d.boxBlendNormalDistancePositive.vector3Value = d.boxBlendNormalDistanceNegative.vector3Value = Vector3.one * d.editorSimplifiedModeBlendNormalDistance.floatValue;
}
}
HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.InfluenceShape, o, GUILayout.Width(28f), GUILayout.MinHeight(22f));
EditorGUILayout.EndHorizontal();

}
GUILayout.Space(EditorGUIUtility.standardVerticalSpacing);
EditorGUILayout.BeginHorizontal();
Drawer_AdvancedBlendDistance(
d,

45
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Handles.cs


center = b.center;
size = b.size;
var baseBlendSize = size - s.data.boxBlendDistancePositive.vector3Value - s.data.boxBlendDistanceNegative.vector3Value;
var blendSize = baseBlendSize;
var baseBlendNormalSize = size - s.data.boxBlendNormalDistancePositive.vector3Value - s.data.boxBlendNormalDistanceNegative.vector3Value;
var blendNormalSize = baseBlendNormalSize;
for(int i = 0; i < 3; ++i)
{
blendSize[i] = Mathf.Max(0f, blendSize[i]);
blendNormalSize[i] = Mathf.Max(0f, blendNormalSize[i]);
}
var blendHalfDiff = (baseBlendSize - blendSize) * 0.5f;
var blendNormalHalfDiff = (baseBlendNormalSize - blendNormalSize) * 0.5f;
s.data.boxBlendDistancePositive.vector3Value += blendHalfDiff;
s.data.boxBlendDistanceNegative.vector3Value += blendHalfDiff;
s.data.boxBlendNormalDistancePositive.vector3Value += blendNormalHalfDiff;
s.data.boxBlendNormalDistanceNegative.vector3Value += blendNormalHalfDiff;
if (s.data.editorAdvancedModeEnabled.boolValue)
{
s.data.editorAdvancedModeBlendDistancePositive.vector3Value = s.data.boxBlendDistancePositive.vector3Value;
s.data.editorAdvancedModeBlendDistanceNegative.vector3Value = s.data.boxBlendDistanceNegative.vector3Value;
s.data.editorAdvancedModeBlendNormalDistancePositive.vector3Value = s.data.boxBlendNormalDistancePositive.vector3Value;
s.data.editorAdvancedModeBlendNormalDistanceNegative.vector3Value = s.data.boxBlendNormalDistanceNegative.vector3Value;
}
else
{
s.data.editorSimplifiedModeBlendDistance.floatValue = Mathf.Min(
s.data.boxBlendDistancePositive.vector3Value.x,
s.data.boxBlendDistancePositive.vector3Value.y,
s.data.boxBlendDistancePositive.vector3Value.z,
s.data.boxBlendDistanceNegative.vector3Value.x,
s.data.boxBlendDistanceNegative.vector3Value.y,
s.data.boxBlendDistanceNegative.vector3Value.z);
s.data.boxBlendDistancePositive.vector3Value = s.data.boxBlendDistanceNegative.vector3Value = Vector3.one * s.data.editorSimplifiedModeBlendDistance.floatValue;
s.data.editorSimplifiedModeBlendNormalDistance.floatValue = Mathf.Min(
s.data.boxBlendNormalDistancePositive.vector3Value.x,
s.data.boxBlendNormalDistancePositive.vector3Value.y,
s.data.boxBlendNormalDistancePositive.vector3Value.z,
s.data.boxBlendNormalDistanceNegative.vector3Value.x,
s.data.boxBlendNormalDistanceNegative.vector3Value.y,
s.data.boxBlendNormalDistanceNegative.vector3Value.z);
s.data.boxBlendNormalDistancePositive.vector3Value = s.data.boxBlendNormalDistanceNegative.vector3Value = Vector3.one * s.data.editorSimplifiedModeBlendNormalDistance.floatValue;
}
s.data.Apply();
EditorUtility.SetDirty(sourceAsset);
}
}

正在加载...
取消
保存