From bb09c2189ad2719f42572ad447a8456fb9aac044 Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 27 Mar 2012 00:45:25 +0200 Subject: [PATCH 1/7] lower rendering distance for small objects (reduce batch count) --- apps/openmw/mwrender/objects.cpp | 70 ++++++++++++++++++++++++-------- apps/openmw/mwrender/objects.hpp | 1 + 2 files changed, 55 insertions(+), 16 deletions(-) diff --git a/apps/openmw/mwrender/objects.cpp b/apps/openmw/mwrender/objects.cpp index e4e721227..1c2873b4e 100644 --- a/apps/openmw/mwrender/objects.cpp +++ b/apps/openmw/mwrender/objects.cpp @@ -88,35 +88,61 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh) NifOgre::NIFLoader::load(mesh); Ogre::Entity *ent = mRenderer.getScene()->createEntity(mesh); + Ogre::Vector3 extents = ent->getBoundingBox().getSize(); + extents *= insert->getScale(); + float size = std::max(std::max(extents.x, extents.y), extents.z); + + bool small = (size < 250); /// \todo config value + + // do not fade out doors. that will cause holes and look stupid + if (ptr.getTypeName().find("Door") != std::string::npos) + small = false; + if(!mIsStatic) { insert->attachObject(ent); + + ent->setRenderingDistance(small ? 2500 : 0); /// \todo config value } else { Ogre::StaticGeometry* sg = 0; - if(mStaticGeometry.find(ptr.getCell()) == mStaticGeometry.end()) + + if (small) { - uniqueID = uniqueID +1; - sg = mRenderer.getScene()->createStaticGeometry( "sg" + Ogre::StringConverter::toString(uniqueID)); - //Create the scenenode and put it in the map - mStaticGeometry[ptr.getCell()] = sg; + if( mStaticGeometrySmall.find(ptr.getCell()) == mStaticGeometrySmall.end()) + { + uniqueID = uniqueID +1; + sg = mRenderer.getScene()->createStaticGeometry( "sg" + Ogre::StringConverter::toString(uniqueID)); + mStaticGeometrySmall[ptr.getCell()] = sg; - // This specifies the size of a single batch region. - // If it is set too high: - // - there will be problems choosing the correct lights - // - the culling will be more inefficient - // If it is set too low: - // - there will be too many batches. - sg->setRegionDimensions(Ogre::Vector3(2500,2500,2500)); - - mBounds[ptr.getCell()] = Ogre::AxisAlignedBox::BOX_NULL; - mBounds[ptr.getCell()].merge(ent->getBoundingBox()); + sg->setRenderingDistance(2500); /// \todo config value + } + else + sg = mStaticGeometrySmall[ptr.getCell()]; } else { - sg = mStaticGeometry[ptr.getCell()]; + if( mStaticGeometry.find(ptr.getCell()) == mStaticGeometry.end()) + { + + uniqueID = uniqueID +1; + sg = mRenderer.getScene()->createStaticGeometry( "sg" + Ogre::StringConverter::toString(uniqueID)); + mStaticGeometry[ptr.getCell()] = sg; + } + else + sg = mStaticGeometry[ptr.getCell()]; } + + // This specifies the size of a single batch region. + // If it is set too high: + // - there will be problems choosing the correct lights + // - the culling will be more inefficient + // If it is set too low: + // - there will be too many batches. + sg->setRegionDimensions(Ogre::Vector3(2500,2500,2500)); + + mBounds[ptr.getCell()].merge(ent->getBoundingBox()); sg->addEntity(ent,insert->_getDerivedPosition(),insert->_getDerivedOrientation(),insert->_getDerivedScale()); mBounds[ptr.getCell()].merge(insert->_getDerivedPosition()); @@ -206,6 +232,13 @@ void Objects::removeCell(MWWorld::Ptr::CellStore* store) mRenderer.getScene()->destroyStaticGeometry (sg); sg = 0; } + if(mStaticGeometrySmall.find(store) != mStaticGeometrySmall.end()) + { + Ogre::StaticGeometry* sg = mStaticGeometrySmall[store]; + mStaticGeometrySmall.erase(store); + mRenderer.getScene()->destroyStaticGeometry (sg); + sg = 0; + } if(mBounds.find(store) != mBounds.end()) mBounds.erase(store); @@ -218,6 +251,11 @@ void Objects::buildStaticGeometry(ESMS::CellStore& cell) Ogre::StaticGeometry* sg = mStaticGeometry[&cell]; sg->build(); } + if(mStaticGeometrySmall.find(&cell) != mStaticGeometrySmall.end()) + { + Ogre::StaticGeometry* sg = mStaticGeometrySmall[&cell]; + sg->build(); + } } Ogre::AxisAlignedBox Objects::getDimensions(MWWorld::Ptr::CellStore* cell) diff --git a/apps/openmw/mwrender/objects.hpp b/apps/openmw/mwrender/objects.hpp index 1ca81331d..265de875b 100644 --- a/apps/openmw/mwrender/objects.hpp +++ b/apps/openmw/mwrender/objects.hpp @@ -14,6 +14,7 @@ class Objects{ OEngine::Render::OgreRenderer &mRenderer; std::map mCellSceneNodes; std::map mStaticGeometry; + std::map mStaticGeometrySmall; std::map mBounds; Ogre::SceneNode* mMwRoot; bool mIsStatic; From fa4c4b8f2129316697d9bbc88350946e0c3ff4db Mon Sep 17 00:00:00 2001 From: Lukasz Gromanowski Date: Tue, 27 Mar 2012 23:07:25 +0200 Subject: [PATCH 2/7] Issue #225: Initialize members in class constructor. --- apps/openmw/mwgui/layouts.cpp | 15 ++++++++++++++- apps/openmw/mwgui/layouts.hpp | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/layouts.cpp b/apps/openmw/mwgui/layouts.cpp index dbd6154b7..f2c650fb3 100644 --- a/apps/openmw/mwgui/layouts.cpp +++ b/apps/openmw/mwgui/layouts.cpp @@ -182,7 +182,9 @@ void HUD::setPlayerPos(const float x, const float y) } MapWindow::MapWindow() - : Layout("openmw_map_window_layout.xml"), mGlobal(false) + : Layout("openmw_map_window_layout.xml") + , mGlobal(false) + , mVisible(false) { setCoord(500,0,320,300); setText("WorldButton", "World"); @@ -272,6 +274,17 @@ void MapWindow::onWorldButtonClicked(MyGUI::Widget* _sender) mButton->setCaption( mGlobal ? "Local" : "World" ); } +LocalMapBase::LocalMapBase() + : mCurX(0) + , mCurY(0) + , mInterior(false) + , mLocalMap(NULL) + , mPrefix() + , mChanged(false) + , mLayout(NULL) +{ +} + void LocalMapBase::init(MyGUI::ScrollView* widget, OEngine::GUI::Layout* layout) { mLocalMap = widget; diff --git a/apps/openmw/mwgui/layouts.hpp b/apps/openmw/mwgui/layouts.hpp index 8d9a41a22..614479ccc 100644 --- a/apps/openmw/mwgui/layouts.hpp +++ b/apps/openmw/mwgui/layouts.hpp @@ -34,6 +34,7 @@ namespace MWGui class LocalMapBase { public: + LocalMapBase(); void init(MyGUI::ScrollView* widget, OEngine::GUI::Layout* layout); void setCellPrefix(const std::string& prefix); @@ -85,6 +86,7 @@ namespace MWGui { public: MapWindow(); + virtual ~MapWindow(){} void setVisible(bool b); void setPlayerPos(const float x, const float y); From f86d53636d0611f9fd45c60f7507b69d6671db81 Mon Sep 17 00:00:00 2001 From: Lukasz Gromanowski Date: Wed, 28 Mar 2012 21:36:38 +0200 Subject: [PATCH 3/7] Issue #225: Correction to commit fa4c4b8. Correction to commit fa4c4b8 - memeber mChanged should be set to true, otherwise the map won't display if the game is started in (0, 0) cell. --- apps/openmw/mwgui/layouts.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/layouts.cpp b/apps/openmw/mwgui/layouts.cpp index f2c650fb3..de74214ee 100644 --- a/apps/openmw/mwgui/layouts.cpp +++ b/apps/openmw/mwgui/layouts.cpp @@ -280,7 +280,7 @@ LocalMapBase::LocalMapBase() , mInterior(false) , mLocalMap(NULL) , mPrefix() - , mChanged(false) + , mChanged(true) , mLayout(NULL) { } From 4488be33cef2182ca17a6bfac0f2b062181b9393 Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet Date: Thu, 29 Mar 2012 00:12:34 +0200 Subject: [PATCH 4/7] Added missing slash to launcher CMakeLists.txt --- apps/launcher/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/launcher/CMakeLists.txt b/apps/launcher/CMakeLists.txt index fd736e011..ccefee1ee 100644 --- a/apps/launcher/CMakeLists.txt +++ b/apps/launcher/CMakeLists.txt @@ -95,5 +95,5 @@ else() "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/launcher.qss") configure_file(${CMAKE_SOURCE_DIR}/files/launcher.cfg - "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}launcher.cfg") + "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/launcher.cfg") endif() From f45c6509756c77f0b33087338d80e3ef470e10b7 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 29 Mar 2012 16:47:59 +0200 Subject: [PATCH 5/7] bounds fix --- apps/openmw/mwrender/objects.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwrender/objects.cpp b/apps/openmw/mwrender/objects.cpp index 1c2873b4e..906e7e0a3 100644 --- a/apps/openmw/mwrender/objects.cpp +++ b/apps/openmw/mwrender/objects.cpp @@ -98,6 +98,13 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh) if (ptr.getTypeName().find("Door") != std::string::npos) small = false; + if (mBounds.find(ptr.getCell()) == mBounds.end()) + mBounds[ptr.getCell()] = Ogre::AxisAlignedBox::BOX_NULL; + + Ogre::AxisAlignedBox bounds = ent->getBoundingBox(); + bounds.scale(insert->getScale()); + mBounds[ptr.getCell()].merge(bounds); + if(!mIsStatic) { insert->attachObject(ent); @@ -142,10 +149,7 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh) // - there will be too many batches. sg->setRegionDimensions(Ogre::Vector3(2500,2500,2500)); - mBounds[ptr.getCell()].merge(ent->getBoundingBox()); - sg->addEntity(ent,insert->_getDerivedPosition(),insert->_getDerivedOrientation(),insert->_getDerivedScale()); - mBounds[ptr.getCell()].merge(insert->_getDerivedPosition()); mRenderer.getScene()->destroyEntity(ent); } From 19c801f53870d7c75a1bafdff65edff840ce0b99 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 29 Mar 2012 16:56:30 +0200 Subject: [PATCH 6/7] disabled rendering distance for now --- apps/openmw/mwrender/objects.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/openmw/mwrender/objects.cpp b/apps/openmw/mwrender/objects.cpp index 906e7e0a3..5594d623e 100644 --- a/apps/openmw/mwrender/objects.cpp +++ b/apps/openmw/mwrender/objects.cpp @@ -92,11 +92,14 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh) extents *= insert->getScale(); float size = std::max(std::max(extents.x, extents.y), extents.z); +/* bool small = (size < 250); /// \todo config value // do not fade out doors. that will cause holes and look stupid if (ptr.getTypeName().find("Door") != std::string::npos) small = false; +*/ + const bool small = false; if (mBounds.find(ptr.getCell()) == mBounds.end()) mBounds[ptr.getCell()] = Ogre::AxisAlignedBox::BOX_NULL; From 10b4c1d9046ff9e7ad0542709c25dc6bd6ef2827 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 29 Mar 2012 18:04:52 +0200 Subject: [PATCH 7/7] silenced a warning --- apps/openmw/mwrender/objects.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwrender/objects.cpp b/apps/openmw/mwrender/objects.cpp index 5594d623e..6b7956c3f 100644 --- a/apps/openmw/mwrender/objects.cpp +++ b/apps/openmw/mwrender/objects.cpp @@ -90,7 +90,7 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh) Ogre::Vector3 extents = ent->getBoundingBox().getSize(); extents *= insert->getScale(); - float size = std::max(std::max(extents.x, extents.y), extents.z); +// float size = std::max(std::max(extents.x, extents.y), extents.z); /* bool small = (size < 250); /// \todo config value @@ -143,7 +143,7 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh) else sg = mStaticGeometry[ptr.getCell()]; } - + // This specifies the size of a single batch region. // If it is set too high: // - there will be problems choosing the correct lights @@ -246,7 +246,7 @@ void Objects::removeCell(MWWorld::Ptr::CellStore* store) mRenderer.getScene()->destroyStaticGeometry (sg); sg = 0; } - + if(mBounds.find(store) != mBounds.end()) mBounds.erase(store); }