private List <Vector3> GetRayCastPositionsOnCharacterBoundByVelocity(FRay[] insideCastRays, BoundBase characterBound, Vector3 boundMax, Vector3 boundMin, Vector3 boundOrigin) { List <Vector3> rayCastPositions = new List <Vector3>(); for (Int32 i = 0; i < insideCastRays.Length; i++) { FRay ray = insideCastRays[i]; float localIntersectionDistance = -1.0f; BoundBase.BoundType boundType = characterBound.GetBoundType(); if ((boundType & BoundBase.BoundType.AABB) == BoundBase.BoundType.AABB) { localIntersectionDistance = GeometryMath.Intersection_RayAABBExt(ray, boundMax, boundMin); } else if ((boundType & BoundBase.BoundType.OBB) == BoundBase.BoundType.OBB) { localIntersectionDistance = GeometryMath.Intersection_RayOBBExt(ray, (characterBound as OBB).GetTangetX(), (characterBound as OBB).GetTangetY(), (characterBound as OBB).GetTangetZ(), boundOrigin, (characterBound as OBB).GetExtent()); } if (localIntersectionDistance > -1.0f) { Vector3 intersectionPosition = ray.GetPositionInTime(localIntersectionDistance); rayCastPositions.Add(new Vector3(intersectionPosition)); } } return(rayCastPositions); }
private RayCastOutputData GetClosestRayCastResult(FRay ray, List <BoundBase> collidedBounds) { float resultShortestDistance = -1.0f; BoundBase resultBound = null; // DO RAY CAST IN ALL COLLIDED BOUNDING BOXES for (Int32 i = 0; i < collidedBounds.Count; i++) { float localIntersectionDistance = 0.0f; BoundBase.BoundType boundType = collidedBounds[i].GetBoundType(); if ((boundType & BoundBase.BoundType.AABB) == BoundBase.BoundType.AABB) { localIntersectionDistance = GeometryMath.Intersection_RayAABB(ray, collidedBounds[i] as AABB); } else if ((boundType & BoundBase.BoundType.OBB) == BoundBase.BoundType.OBB) { localIntersectionDistance = GeometryMath.Intersection_RayOBB(ray, collidedBounds[i] as OBB); } if (resultShortestDistance <= -1.0f || (localIntersectionDistance > 0.0f && localIntersectionDistance < resultShortestDistance)) { resultShortestDistance = localIntersectionDistance; resultBound = collidedBounds[i]; } } Vector3 intersectionPosition = ray.GetPositionInTime(resultShortestDistance); return(new RayCastOutputData(ray, resultBound, resultShortestDistance, intersectionPosition)); }
private bool BoundBaseCollision_Ext(BoundBase characterBound, BoundBase collidedRootBound) { bool bHasCollision = false; BoundBase.BoundType collisionType = characterBound.GetBoundType() | collidedRootBound.GetBoundType(); if (collisionType == (BoundBase.BoundType.AABB | BoundBase.BoundType.OBB)) { AABB aabb = characterBound.GetBoundType() == BoundBase.BoundType.AABB ? characterBound as AABB : collidedRootBound as AABB; OBB obb = collidedRootBound.GetBoundType() == BoundBase.BoundType.OBB ? collidedRootBound as OBB : characterBound as OBB; bHasCollision = GeometryMath.AABBOBB(aabb, obb); } else if (collisionType == (BoundBase.BoundType.AABB | BoundBase.BoundType.AABB)) { bHasCollision = GeometryMath.AABBAABB(characterBound as AABB, collidedRootBound as AABB); } else { bHasCollision = GeometryMath.OBBOBB(characterBound as OBB, collidedRootBound as OBB); } return(bHasCollision); }