public static void Update() { //TODO: use only for profiling /* * long startTime; * MyWindowsAPIWrapper.QueryPerformanceCounter(out startTime); */ bool renderEnviromentMaps = MyRender.EnableLights && MyRender.EnableLightsRuntime && MyRender.EnableSun && (MyRender.EnableEnvironmentMapAmbient || MyRender.EnableEnvironmentMapReflection); if (!renderEnviromentMaps) { return; } if (BlendDistance > MainMapMaxDistance) { throw new InvalidOperationException("BlendDistance must be lower than MainMapMaxDistance"); } MyRender.RenderOcclusionsImmediatelly = true; Vector3 cameraPos = MyCamera.Position; if (MainMapPosition.HasValue && (cameraPos - MainMapPosition.Value).Length() > InstantRefreshDistance) { m_renderInstantly = true; } // Makes evironment camera pos 300m in front of real camera //cameraPos += Vector3.Normalize(MyCamera.ForwardVector) * 300 if (MainMapPosition == null) { LastUpdateTime = 0; MainMapPosition = cameraPos; m_environmentMapRendererMain.StartUpdate(MainMapPosition.Value, m_renderInstantly); m_renderInstantly = false; BlendFactor = 0.0f; } else { float mainMapDistance = (MainMapPosition.Value - cameraPos).Length(); // When behind blend distance if (mainMapDistance > BlendDistance) { // Create AuxMap if not created if (AuxMapPosition == null) { LastUpdateTime = 0; AuxMapPosition = cameraPos; m_environmentMapRendererAux.StartUpdate(AuxMapPosition.Value, m_renderInstantly); m_renderInstantly = false; } // Wait till rendering done before blending if (m_environmentMapRendererAux.IsDone()) { // Set proper blend factor BlendFactor = (mainMapDistance - BlendDistance) / (MainMapMaxDistance - BlendDistance); } } else if ((mainMapDistance + Hysteresis) < BlendDistance) { AuxMapPosition = null; } // If MainMap should not be even displayed...swap aux and main and display if (mainMapDistance > MainMapMaxDistance && m_environmentMapRendererAux.IsDone()) { var tmp = m_environmentMapRendererAux; m_environmentMapRendererAux = m_environmentMapRendererMain; m_environmentMapRendererMain = tmp; MainMapPosition = cameraPos + MyMwcUtils.Normalize(MainMapPosition.Value - cameraPos) * BlendDistance; AuxMapPosition = null; BlendFactor = 0.0f; } } m_environmentMapRendererMain.ContinueUpdate(); m_environmentMapRendererAux.ContinueUpdate(); MyRender.RenderOcclusionsImmediatelly = false; /* * long frq; * MyWindowsAPIWrapper.QueryPerformanceFrequency(out frq); * * long stopTime; * MyWindowsAPIWrapper.QueryPerformanceCounter(out stopTime); * * float updateTime = ((float)(stopTime - startTime)) / frq * 1000.0f; * if(updateTime > LastUpdateTime) * { * LastUpdateTime = updateTime; * } * */ }