internal static LightId Create(uint GID) { var id = new LightId { Index = m_lights.Allocate() }; m_lights.Data[id.Index] = new MyLightInfo { FlareId = FlareId.NULL }; MyArrayHelpers.Reserve(ref m_pointlights, id.Index + 1); MyArrayHelpers.Reserve(ref m_spotlights, id.Index + 1); var p1 = new MyPointlightInfo { LastBvhUpdatePosition = Vector3.PositiveInfinity, BvhProxyId = -1 }; m_pointlights[id.Index] = p1; var p2 = new MySpotlightInfo { LastBvhUpdatePosition = Vector3.PositiveInfinity, BvhProxyId = -1 }; m_spotlights[id.Index] = p2; m_idIndex[GID] = id; return(id); }
private static BoundingBoxD MakeAabbFromSpotlightCone(ref MySpotlightInfo spotlight, Vector3D position, Vector3 dir, Vector3 up) { float ratio = (float)Math.Sqrt(1 - spotlight.Spotlight.ApertureCos * spotlight.Spotlight.ApertureCos) / spotlight.Spotlight.ApertureCos; float h = ratio * spotlight.Spotlight.Light.Range; var bb = BoundingBoxD.CreateInvalid(); bb.Include(new Vector3D(-h, -h, 0)); bb.Include(new Vector3D(h, h, -spotlight.Spotlight.Light.Range)); return(bb.TransformFast(MatrixD.CreateLookAtInverse(position, position + dir, up))); }