您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

41 行
1.4 KiB

using UnityEngine;
using UnityEngine.Experimental.Rendering;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
public static class HDReflectionProbeEditorUtility
{
public static Matrix4x4 GetLocalSpace(ReflectionProbe probe)
{
var t = probe.transform.position;
return Matrix4x4.TRS(t, GetLocalSpaceRotation(probe), Vector3.one);
}
public static Quaternion GetLocalSpaceRotation(ReflectionProbe probe)
{
var supportsRotation = (SupportedRenderingFeatures.active.reflectionProbeSupportFlags & SupportedRenderingFeatures.ReflectionProbeSupportFlags.Rotation) != 0;
return supportsRotation
? probe.transform.rotation
: Quaternion.identity;
}
// Ensures that probe's AABB encapsulates probe's position
// Returns true, if center or size was modified
public static bool ValidateAABB(ReflectionProbe p, ref Vector3 center, ref Vector3 size)
{
var localSpace = GetLocalSpace(p);
var localTransformPosition = localSpace.inverse.MultiplyPoint3x4(p.transform.position);
var b = new Bounds(center, size);
if (b.Contains(localTransformPosition))
return false;
b.Encapsulate(localTransformPosition);
center = b.center;
size = b.size;
return true;
}
}
}