diff options
Diffstat (limited to 'src/graphics/engine/engine.cpp')
-rw-r--r-- | src/graphics/engine/engine.cpp | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index 3187dde..068687a 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -142,14 +142,14 @@ Gfx::CEngine::CEngine(CInstanceManager *iMan, CApplication *app) m_eyeDirH = 0.0f; m_eyeDirV = 0.0f; m_backgroundName = ""; // no background image - m_backgroundColorUp = 0; - m_backgroundColorDown = 0; - m_backgroundCloudUp = 0; - m_backgroundCloudDown = 0; + m_backgroundColorUp = Gfx::Color(); + m_backgroundColorDown = Gfx::Color(); + m_backgroundCloudUp = Gfx::Color(); + m_backgroundCloudDown = Gfx::Color(); m_backgroundFull = false; m_backgroundQuarter = false; m_overFront = true; - m_overColor = 0; + m_overColor = Gfx::Color(); m_overMode = ENG_RSTATE_TCOLOR_BLACK; m_highlightRank[0] = -1; // empty list m_highlightTime = 0.0f; @@ -208,7 +208,7 @@ Gfx::CEngine::CEngine(CInstanceManager *iMan, CApplication *app) m_mouseVisible = false; m_texPath = "textures/"; - m_defaultTexParams.format = Gfx::TEX_IMG_RGB; + m_defaultTexParams.format = Gfx::TEX_IMG_AUTO; m_defaultTexParams.mipmap = true; m_defaultTexParams.minFilter = Gfx::TEX_MIN_FILTER_LINEAR_MIPMAP_LINEAR; m_defaultTexParams.magFilter = Gfx::TEX_MAG_FILTER_LINEAR; @@ -260,6 +260,8 @@ bool Gfx::CEngine::Create() m_lightning = new Gfx::CLightning(m_iMan, this); m_planet = new Gfx::CPlanet(m_iMan, this); + m_lightMan->SetDevice(m_device); + m_text->SetDevice(m_device); if (! m_text->Create()) { @@ -979,7 +981,7 @@ Gfx::EngineObjLevel4* Gfx::CEngine::FindTriangles(int objRank, const Gfx::Materi for (int l3 = 0; l3 < static_cast<int>( p2.next.size() ); l3++) { - Gfx::EngineObjLevel3& p3 = p2.next[l1]; + Gfx::EngineObjLevel3& p3 = p2.next[l3]; if (! p3.used) continue; if (p3.min != min || p3.max != max) continue; @@ -1031,7 +1033,7 @@ int Gfx::CEngine::GetPartialTriangles(int objRank, float min, float max, float p for (int l3 = 0; l3 < static_cast<int>( p2.next.size() ); l3++) { - Gfx::EngineObjLevel3& p3 = p2.next[l1]; + Gfx::EngineObjLevel3& p3 = p2.next[l3]; if (! p3.used) continue; if (p3.min != min || p3.max != max) continue; @@ -1126,7 +1128,7 @@ void Gfx::CEngine::ChangeLOD() for (int l3 = 0; l3 < static_cast<int>( p2.next.size() ); l3++) { - Gfx::EngineObjLevel3& p3 = p2.next[l1]; + Gfx::EngineObjLevel3& p3 = p2.next[l3]; if (! p3.used) continue; if ( Math::IsEqual(p3.min, 0.0f ) && @@ -1620,7 +1622,7 @@ void Gfx::CEngine::UpdateGeometry() for (int l3 = 0; l3 < static_cast<int>( p2.next.size() ); l3++) { - Gfx::EngineObjLevel3& p3 = p2.next[l1]; + Gfx::EngineObjLevel3& p3 = p2.next[l3]; if (! p3.used) continue; for (int l4 = 0; l4 < static_cast<int>( p3.next.size() ); l4++) @@ -1712,7 +1714,7 @@ int Gfx::CEngine::DetectObject(Math::Point mouse) for (int l3 = 0; l3 < static_cast<int>( p2.next.size() ); l3++) { - Gfx::EngineObjLevel3& p3 = p2.next[l1]; + Gfx::EngineObjLevel3& p3 = p2.next[l3]; if (! p3.used) continue; if (p3.min != 0.0f) continue; // LOD B or C? @@ -2099,7 +2101,8 @@ void Gfx::CEngine::SetViewParams(const Math::Vector& eyePt, const Math::Vector& if (m_sound == nullptr) m_sound = static_cast<CSoundInterface*>( m_iMan->SearchInstance(CLASS_SOUND) ); - m_sound->SetListener(eyePt, lookatPt); + if (m_sound != nullptr) + m_sound->SetListener(eyePt, lookatPt); } Gfx::Texture Gfx::CEngine::CreateTexture(const std::string& texName, const Gfx::TextureCreateParams& params) @@ -2315,7 +2318,7 @@ void Gfx::CEngine::SetFocus(float focus) m_focus = focus; m_size = m_app->GetVideoConfig().size; - float aspect = (static_cast<float>(m_size.y)) / m_size.x; + float aspect = (static_cast<float>(m_size.x)) / m_size.y; Math::LoadProjectionMatrix(m_matProj, m_focus, aspect, 0.5f, m_deepView[0]); } @@ -2837,7 +2840,7 @@ void Gfx::CEngine::Render() m_statisticTriangle = 0; m_lastState = -1; - m_lastColor = 999; + m_lastColor = Gfx::Color(-1.0f); m_lastMaterial = Gfx::Material(); m_lightMan->UpdateLights(); @@ -2889,6 +2892,8 @@ void Gfx::CEngine::Draw3DScene() if (m_shadowVisible) { + m_lightMan->UpdateLightsEnableState(Gfx::ENG_OBJTYPE_TERRAIN); + // Draw the terrain for (int l1 = 0; l1 < static_cast<int>( m_objectTree.size() ); l1++) @@ -2911,13 +2916,19 @@ void Gfx::CEngine::Draw3DScene() if (! m_objects[objRank].drawWorld) continue; + m_device->SetTransform(Gfx::TRANSFORM_WORLD, m_objects[objRank].transform); + + if (! IsVisible(objRank)) + continue; + for (int l3 = 0; l3 < static_cast<int>( p2.next.size() ); l3++) { - Gfx::EngineObjLevel3& p3 = p2.next[l1]; + Gfx::EngineObjLevel3& p3 = p2.next[l3]; if (! p3.used) continue; if ( m_objects[objRank].distance < p3.min || - m_objects[objRank].distance >= p3.max ) continue; + m_objects[objRank].distance >= p3.max ) + continue; for (int l4 = 0; l4 < static_cast<int>( p3.next.size() ); l4++) { @@ -2985,7 +2996,7 @@ void Gfx::CEngine::Draw3DScene() for (int l3 = 0; l3 < static_cast<int>( p2.next.size() ); l3++) { - Gfx::EngineObjLevel3& p3 = p2.next[l1]; + Gfx::EngineObjLevel3& p3 = p2.next[l3]; if (! p3.used) continue; if ( m_objects[objRank].distance < p3.min || @@ -3074,7 +3085,7 @@ void Gfx::CEngine::Draw3DScene() for (int l3 = 0; l3 < static_cast<int>( p2.next.size() ); l3++) { - Gfx::EngineObjLevel3& p3 = p2.next[l1]; + Gfx::EngineObjLevel3& p3 = p2.next[l3]; if (! p3.used) continue; if ( m_objects[objRank].distance < p3.min || @@ -3189,7 +3200,7 @@ void Gfx::CEngine::DrawInterface() for (int l3 = 0; l3 < static_cast<int>( p2.next.size() ); l3++) { - Gfx::EngineObjLevel3& p3 = p2.next[l1]; + Gfx::EngineObjLevel3& p3 = p2.next[l3]; if (! p3.used) continue; if ( m_objects[objRank].distance < p3.min || |