internal static LightId Create(uint GID) { var id = new LightId { Index = Lights.Allocate() }; Lights.Data[id.Index] = new MyLightInfo { FlareId = FlareId.NULL }; MyArrayHelpers.Reserve(ref Pointlights, id.Index + 1); MyArrayHelpers.Reserve(ref Spotlights, id.Index + 1); var p1 = new MyPointlightInfo { LastBvhUpdatePosition = Vector3.PositiveInfinity, BvhProxyId = -1 }; Pointlights[id.Index] = p1; var p2 = new MySpotlightInfo { LastBvhUpdatePosition = Vector3.PositiveInfinity, BvhProxyId = -1 }; Spotlights[id.Index] = p2; IdIndex[GID] = id; return(id); }
internal static BoundingBoxD MakeAabbFromSpotlightCone(ref MySpotlightInfo spotlight, Vector3D position) { float ratio = (float)Math.Sqrt(1 - spotlight.ApertureCos * spotlight.ApertureCos) / spotlight.ApertureCos; float h = ratio * spotlight.Range; var bb = BoundingBoxD.CreateInvalid(); bb.Include(new Vector3D(-h, -h, 0)); bb.Include(new Vector3D(h, h, -spotlight.Range)); return(bb.Transform(MatrixD.CreateLookAtInverse(position, position + spotlight.Direction, spotlight.Up))); }
internal static BoundingBoxD MakeAabbFromSpotlightCone(ref MySpotlightInfo spotlight, Vector3D position) { float ratio = (float)Math.Sqrt(1 - spotlight.ApertureCos * spotlight.ApertureCos) / spotlight.ApertureCos; float h = ratio * spotlight.Range; var bb = BoundingBoxD.CreateInvalid(); bb.Include(new Vector3D(-h, -h, 0)); bb.Include(new Vector3D(h, h, -spotlight.Range)); return bb.Transform(MatrixD.CreateLookAtInverse(position, position + spotlight.Direction, spotlight.Up)); }