public LRect GetBounds() { //TODO var col = collider; var tran = transform; var type = (EShape2D)col.TypeId; switch (type) { case EShape2D.Circle: { var radius = ((CCircle)col).radius; return(LRect.CreateRect(tran.pos, new LVector2(radius, radius))); } case EShape2D.AABB: { var halfSize = ((CAABB)col).size; return(LRect.CreateRect(tran.pos, halfSize)); } case EShape2D.OBB: { var radius = ((COBB)col).radius; return(LRect.CreateRect(tran.pos, new LVector2(radius, radius))); } } Debug.LogError("No support type" + type); return(new LRect()); }
public void QueryRegion(int layerType, LVector2 pos, LVector2 size, LVector2 forward, FuncCollision callback) { Debug.Trace($"QueryRegion layerType:{layerType} pos:{pos} size:{size} forward:{forward} "); tempCallback = callback; _tempSize = size; _tempForward = forward; _tempPos = pos; var radius = size.magnitude; var checkBounds = LRect.CreateRect(pos, new LVector2(radius, radius)); GetBoundTree(layerType).CheckCollision(ref checkBounds, _CheckRegionOBB); }
public void CheckCollision(LVector2 pos, LFloat radius, FuncCollision callback) { var rect = LRect.CreateRect(pos, new LVector2(radius, radius)); rootNode.CheckCollision(rect, callback); }
public void CheckCollision(ColliderProxy obj, FuncCollision callback) { var checkBounds = LRect.CreateRect(obj.pos, new LVector2(obj.MaxSideSize, obj.MaxSideSize)); rootNode.CheckCollision(ref checkBounds, callback); }