Archived
Emergency backup
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user