/// <summary> /// Performs a raycast on all world bodies. /// </summary> public bool RayCast( ref VoltRayCast ray, ref VoltRayResult result, VoltBodyFilter filter = null, int ticksBehind = 0) { if (ticksBehind < 0) { throw new ArgumentOutOfRangeException("ticksBehind"); } this.reusableBuffer.Clear(); this.staticBroadphase.RayCast(ref ray, this.reusableBuffer); this.dynamicBroadphase.RayCast(ref ray, this.reusableBuffer); for (int i = 0; i < this.reusableBuffer.Count; i++) { VoltBody body = this.reusableBuffer[i]; if (VoltBody.Filter(body, filter)) { body.RayCast(ref ray, ref result, ticksBehind); if (result.IsContained) { return(true); } } } return(result.IsValid); }
/// <summary> /// Tests all valid explosion targets for a given ray. /// </summary> private void TestTargets( VoltRayCast ray, VoltExplosionCallback callback, int ticksBehind, FP minOccluderDistance, FP rayWeight) { for (int i = 0; i < this.targetBodies.Count; i++) { VoltBody targetBody = this.targetBodies[i]; VoltRayResult result = default(VoltRayResult); if (targetBody.RayCast(ref ray, ref result, ticksBehind)) { if (result.Distance < minOccluderDistance) { callback.Invoke(ray, result, rayWeight); } } } }