public bool RayLeaf <T>(RaycastInput input, int rigidBodyIndex, ref T collector) where T : struct, ICollector <RaycastHit> { rigidBodyIndex += BaseRigidBodyIndex; RigidBody body = m_Bodies[rigidBodyIndex]; var worldFromBody = new MTransform(body.WorldFromBody); // Transform the ray into body space RaycastInput inputLs = input; { MTransform bodyFromWorld = Inverse(worldFromBody); inputLs.Ray.Origin = Mul(bodyFromWorld, input.Ray.Origin); inputLs.Ray.Displacement = math.mul(bodyFromWorld.Rotation, input.Ray.Displacement); inputLs.QueryContext = new QueryContext { RigidBodyIndex = rigidBodyIndex, NumColliderKeyBits = 0, ColliderKey = ColliderKey.Empty, WorldFromLocalTransform = worldFromBody, Entity = body.Entity, IsInitialized = true }; } return(body.CastRay(inputLs, ref collector)); }
public bool RayLeaf <T>(RaycastInput input, int rigidBodyIndex, ref T collector) where T : struct, ICollector <RaycastHit> { rigidBodyIndex += BaseRigidBodyIndex; RigidBody body = m_Bodies[rigidBodyIndex]; var worldFromBody = new MTransform(body.WorldFromBody); // Transform the ray into body space RaycastInput inputLs = input; { MTransform bodyFromWorld = Inverse(worldFromBody); inputLs.Ray.Origin = Mul(bodyFromWorld, input.Ray.Origin); inputLs.Ray.Displacement = math.mul(bodyFromWorld.Rotation, input.Ray.Displacement); } float fraction = collector.MaxFraction; int numHits = collector.NumHits; if (body.CastRay(inputLs, ref collector)) { // Transform results back into world space collector.TransformNewHits(numHits, fraction, worldFromBody, rigidBodyIndex); return(true); } return(false); }
public bool RayLeaf <T>(RaycastInput input, int rigidBodyIndex, ref T collector) where T : struct, ICollector <RaycastHit> { rigidBodyIndex += BaseRigidBodyIndex; input.QueryContext.IsInitialized = true; input.QueryContext.RigidBodyIndex = rigidBodyIndex; RigidBody body = m_Bodies[rigidBodyIndex]; return(body.CastRay(input, ref collector)); }