private void Update() { // Check if this source's transform has changed. if (transform.hasChanged) { m_Dirty = true; // Recalculate camera bounds. m_CameraBounds = LOSHelper.CalculateSourceBounds(m_Camera); // Reset transform changed flag. transform.hasChanged = false; } // Check if this source and it's frustum are visible to the camera used by the LOS mask. m_IsVisibile = GeometryUtility.TestPlanesAABB(LOSMask.CameraFrustumPlanes, m_CameraBounds); // Only update frustum planes when the source is visible and dirty. if (m_IsVisibile && m_Dirty) { // Recalculate frustum planes. LOSHelper.ExtractFrustumPlanes(m_FrustumPlanes, m_Camera); m_Dirty = false; } }
private void OnEnable() { // Register with LOS manager singleton. LOSManager.Instance.AddLOSSource(this); // Check if component can be enabled. enabled &= Util.Verify(m_Camera != null, "Camera Component missing"); if (enabled) { // Alert user if camera is set to orthographic. Debug.Assert(!m_Camera.orthographic, "Cameras attached to an LOS source can't be orthographic, changing to perspective!"); // Initiliaze source camera. LOSHelper.InitSourceCamera(m_Camera); // Initiliaze bounds. m_CameraBounds = LOSHelper.CalculateSourceBounds(m_Camera); // Initiliaze frustum planes. LOSHelper.ExtractFrustumPlanes(m_FrustumPlanes, m_Camera); } }