diff options
author | chai <215380520@qq.com> | 2023-05-12 10:32:11 +0800 |
---|---|---|
committer | chai <215380520@qq.com> | 2023-05-12 10:32:11 +0800 |
commit | 2fc9585797067730f28b03b0727bf05f9deed091 (patch) | |
tree | 8807e37b85ba922045eaa17ac445dd0a1d2d730c /marching/Assets/Scripts/Physics/PhysicsManager_Collide.cs | |
parent | 2a1cd4fda8a4a8e649910d16b4dfa1ce7ae63543 (diff) |
+ worldline keepers
Diffstat (limited to 'marching/Assets/Scripts/Physics/PhysicsManager_Collide.cs')
-rw-r--r-- | marching/Assets/Scripts/Physics/PhysicsManager_Collide.cs | 186 |
1 files changed, 0 insertions, 186 deletions
diff --git a/marching/Assets/Scripts/Physics/PhysicsManager_Collide.cs b/marching/Assets/Scripts/Physics/PhysicsManager_Collide.cs deleted file mode 100644 index 4710b2e..0000000 --- a/marching/Assets/Scripts/Physics/PhysicsManager_Collide.cs +++ /dev/null @@ -1,186 +0,0 @@ -using mh; -using System.Collections; -using System.Collections.Generic; -using Unity.VisualScripting.Antlr3.Runtime.Tree; -using UnityEngine; -using UnityEngine.UIElements; - -/// <summary> -/// 物理查询 -/// </summary> -public partial class PhysicsManager : Singleton<PhysicsManager> -{ - // 碰撞检测结果 - private List<IQuadTreeObject> m_SharedCollideResults = new List<IQuadTreeObject>(); - - public static Vector4 GetCircleBound(Vector3 circle) - { - float size = circle.z * 2; - return new Vector4(circle.x, circle.y, size, size); - } - - public static Vector4 GetBoxBound(Vector4 box) - { - return box; - } - - public static Vector4 GetRayBound(Vector4 ray) - { - Vector2 tr = ray.xy() + ray.zw(); - Vector4 bound = new Vector4(); - bound.x = (tr.x + ray.x) / 2; - bound.y = (tr.y + ray.y) / 2; - bound.z = Mathf.Max(Mathf.Abs(tr.x - ray.x), 1); - bound.w = Mathf.Max(Mathf.Abs(tr.y - ray.y), 1); - return bound; - } - - public static Vector4 GetRaySegment(Vector4 ray) - { - Vector2 tr = ray.xy() + ray.zw(); - Vector4 seg = new Vector4(); - seg.x = ray.x; - seg.y = ray.y; - seg.z = tr.x; - seg.w = tr.y; - return seg; - } - - public static Vector4 GetPointBound(Vector2 point) - { - Vector4 bound = new Vector4(); - bound.x = point.x; - bound.y = point.y; - bound.z = 1; - bound.w = 1; - return bound; - } - - /// <summary> - /// 把x,y,w,h的box转换为lowerx,higherx,lowery,highery - /// </summary> - /// <returns></returns> - public static Vector4 GetBoxRange(Vector4 box) - { - Vector4 Range = new(); - Range.x = box.x - box.z / 2; - Range.y = box.x + box.z / 2; - Range.z = box.y - box.w / 2; - Range.w = box.y + box.w / 2; - return Range; - } - - public ref readonly List<IQuadTreeObject> CircleCast(ColliderType target, Vector3 circle) - { - m_SharedCollideResults.Clear(); - var retriver = GetRetriverByType(target); - if(retriver != null) - { - if (retriver(GetCircleBound(circle))) - { - for(int i = 0; i < m_SharedRetriveResults.Count; ++i) - { - var collider = m_SharedRetriveResults[i]; - if(collider != null) - { - if(collider is FastCircleCollider) - { - if(CircleVsCircle((collider as FastCircleCollider).circle, circle)) - { - m_SharedCollideResults.Add(collider); - } - } - else if(collider is FastBoxCollider) - { - if (BoxVsCircle((collider as FastBoxCollider).box, circle)) - { - m_SharedCollideResults.Add(collider); - } - } - } - } - } - } - return ref m_SharedCollideResults; - } - - public ref readonly List<IQuadTreeObject> BoxCast(ColliderType target, Vector4 box) - { - m_SharedCollideResults.Clear(); - var retriver = GetRetriverByType(target); - if (retriver != null) - { - if (retriver(GetBoxBound(box))) - { - for (int i = 0; i < m_SharedRetriveResults.Count; ++i) - { - var collider = m_SharedRetriveResults[i]; - if (collider != null) - { - if (collider is FastCircleCollider) - { - if (BoxVsCircle(box, (collider as FastCircleCollider).circle)) - { - m_SharedCollideResults.Add(collider); - } - } - else if (collider is FastBoxCollider) - { - if (BoxVsBox(box, (collider as FastBoxCollider).box)) - { - m_SharedCollideResults.Add(collider); - } - } - } - } - } - } - return ref m_SharedCollideResults; - } - - /// <summary> - /// x,y dir.x dir.y(dir带长度) - /// </summary> - /// <param name="target"></param> - /// <param name="line"></param> - /// <returns></returns> - public ref readonly List<IQuadTreeObject> RayCast(ColliderType target, Vector4 ray) - { - m_SharedCollideResults.Clear(); - var retriver = GetRetriverByType(target); - if(retriver != null) - { - if(retriver(GetRayBound(ray))) - { - for (int i = 0; i < m_SharedRetriveResults.Count; ++i) - { - var collider = m_SharedRetriveResults[i]; - if (collider != null) - { - if (collider is FastCircleCollider) - { - if (RayVsCircle(ray, (collider as FastCircleCollider).circle)) - { - m_SharedCollideResults.Add(collider); - } - } - else if (collider is FastBoxCollider) - { - if (RayVsBox(ray, (collider as FastBoxCollider).box)) - { - m_SharedCollideResults.Add(collider); - } - } - } - } - } - } - return ref m_SharedCollideResults; - } - - public ref readonly List<IQuadTreeObject> PointCast(ColliderType target, Vector2 point) - { - return ref m_SharedCollideResults; - } - -}
\ No newline at end of file |