Emergency backup

This commit is contained in:
2023-11-28 09:20:50 +08:00
parent f67b26667b
commit 1910b0e3f7
6 changed files with 849 additions and 114 deletions
+35 -2
View File
@@ -2,11 +2,44 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XericLibrary.Runtime.MacroLibrary;
namespace XericLibrary.Runtime.CollisionLOD
{
public class LodSphereCollider : LodColliderBase
{
}
#region 字段属性
/// <summary>
/// 半径
/// </summary>
private float radius;
#endregion
#region 碰撞检测
private static bool CheckCollision(LodSphereCollider sphere1, LodSphereCollider sphere2)
{
return Vector3.Distance(sphere1.BoundSize.center, sphere2.BoundSize.center)
< sphere1.radius + sphere2.radius;
}
private static bool CheckCollision(LodSphereCollider sphere, LodBoxCollider box)
{
/*
* 对于任意AABB和圆的最近点的计算:
* 获取圆心C与AABB中心B的偏移量D
* 用AABB的范围去限制这个偏移量
* 此时矢量总是位于AABB的边缘处
*/
return (sphere.BoundSize.center - box.BoundSize.center)
.Clamp(box.BoundSize.min, box.BoundSize.max)
.Add(box.BoundSize.center)
.Distance(sphere.BoundSize.center) <= sphere.radius;
}
#endregion
}
}