From 3c934e3e44ae0a3cc87beb51a2dc2e1fe378bb33 Mon Sep 17 00:00:00 2001 From: Jacob Essex Date: Fri, 2 Mar 2012 22:31:17 +0000 Subject: [PATCH 1/5] Fixed a bug with fog not being applied to initially created terrain when starting in exteriors. --- apps/openmw/mwrender/renderingmanager.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index e204b5856..1c7edb7da 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -25,6 +25,10 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const mRendering.createScene("PlayerCam", 55, 5); mTerrainManager = new TerrainManager(mRendering.getScene()); + //The fog type must be set before any terrain objects are created as if the + //fog type is set to FOG_NONE then the initially created terrain won't have any fog + configureFog(1, ColourValue(1,1,1)); + // Set default mipmap level (NB some APIs ignore this) TextureManager::getSingleton().setDefaultNumMipmaps(5); From a8939bc3180a8475be9dd38878228c924a31e9b0 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 4 Mar 2012 00:08:56 +0100 Subject: [PATCH 2/5] disabled the composite map, improves loading time a lot --- apps/openmw/mwrender/terrain.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwrender/terrain.cpp b/apps/openmw/mwrender/terrain.cpp index ca218388f..a66b4ad3f 100644 --- a/apps/openmw/mwrender/terrain.cpp +++ b/apps/openmw/mwrender/terrain.cpp @@ -51,6 +51,7 @@ namespace MWRender mActiveProfile->setLayerNormalMappingEnabled(false); mActiveProfile->setLayerParallaxMappingEnabled(false); mActiveProfile->setReceiveDynamicShadowsEnabled(false); + mActiveProfile->setCompositeMapEnabled(false); mTerrainGroup = OGRE_NEW Ogre::TerrainGroup(mgr, Ogre::Terrain::ALIGN_X_Z, @@ -160,10 +161,6 @@ namespace MWRender else mActiveProfile->setGlobalColourMapEnabled(false); - /// \todo are we possibly generating the materials twice? - mActiveProfile->generate(terrain); - mActiveProfile->generateForCompositeMap(terrain); - if ( store->land[1][1]->landData->usingColours ) { Ogre::TexturePtr vertex = getVertexColours(store, @@ -173,10 +170,10 @@ namespace MWRender //this is a hack to get around the fact that Ogre seems to //corrupt the global colour map leading to rendering errors - MaterialPtr mat = terrain->_getMaterial(); - mat->getTechnique(0)->getPass(0)->getTextureUnitState(1)->setTextureName( vertex->getName() ); - mat = terrain->_getCompositeMapMaterial(); + MaterialPtr mat = terrain->getMaterial(); mat->getTechnique(0)->getPass(0)->getTextureUnitState(1)->setTextureName( vertex->getName() ); + //mat = terrain->_getCompositeMapMaterial(); + //mat->getTechnique(0)->getPass(0)->getTextureUnitState(1)->setTextureName( vertex->getName() ); } } } From bcd2371baa318b9393ccec684a34d1b1a5bc3f53 Mon Sep 17 00:00:00 2001 From: Jacob Essex Date: Sun, 4 Mar 2012 11:21:47 +0000 Subject: [PATCH 3/5] Code cleanup: Removed unneeded Ogre namespace --- apps/openmw/mwrender/terrain.cpp | 56 ++++++++++++++++---------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/apps/openmw/mwrender/terrain.cpp b/apps/openmw/mwrender/terrain.cpp index 9cc0a9f37..3db5dfc8c 100644 --- a/apps/openmw/mwrender/terrain.cpp +++ b/apps/openmw/mwrender/terrain.cpp @@ -15,16 +15,16 @@ namespace MWRender //---------------------------------------------------------------------------------------------- - TerrainManager::TerrainManager(Ogre::SceneManager* mgr) + TerrainManager::TerrainManager(SceneManager* mgr) { - mTerrainGlobals = OGRE_NEW Ogre::TerrainGlobalOptions(); + mTerrainGlobals = OGRE_NEW TerrainGlobalOptions(); - Ogre::TerrainMaterialGeneratorPtr matGen; + TerrainMaterialGeneratorPtr matGen; TerrainMaterialGeneratorB* matGenP = new TerrainMaterialGeneratorB(); matGen.bind(matGenP); mTerrainGlobals->setDefaultMaterialGenerator(matGen); - Ogre::TerrainMaterialGenerator::Profile* const activeProfile = + TerrainMaterialGenerator::Profile* const activeProfile = mTerrainGlobals->getDefaultMaterialGenerator() ->getActiveProfile(); TerrainMaterialGeneratorB::SM2Profile* matProfile = @@ -54,16 +54,16 @@ namespace MWRender matProfile->setReceiveDynamicShadowsEnabled(false); matProfile->setGlobalColourMapEnabled(true); - mTerrainGroup = OGRE_NEW Ogre::TerrainGroup(mgr, - Ogre::Terrain::ALIGN_X_Z, + mTerrainGroup = OGRE_NEW TerrainGroup(mgr, + Terrain::ALIGN_X_Z, mLandSize, mWorldSize); - mTerrainGroup->setOrigin(Ogre::Vector3(mWorldSize/2, + mTerrainGroup->setOrigin(Vector3(mWorldSize/2, 0, -mWorldSize/2)); - Ogre::Terrain::ImportData& importSettings = + Terrain::ImportData& importSettings = mTerrainGroup->getDefaultImportSettings(); importSettings.inputBias = 0; @@ -85,14 +85,14 @@ namespace MWRender //---------------------------------------------------------------------------------------------- - void TerrainManager::setDiffuse(const Ogre::ColourValue& diffuse) + void TerrainManager::setDiffuse(const ColourValue& diffuse) { mTerrainGlobals->setCompositeMapDiffuse(diffuse); } //---------------------------------------------------------------------------------------------- - void TerrainManager::setAmbient(const Ogre::ColourValue& ambient) + void TerrainManager::setAmbient(const ColourValue& ambient) { mTerrainGlobals->setCompositeMapAmbient(ambient); } @@ -112,7 +112,7 @@ namespace MWRender { for ( int y = 0; y < 2; y++ ) { - Ogre::Terrain::ImportData terrainData = + Terrain::ImportData terrainData = mTerrainGroup->getDefaultImportSettings(); const int terrainX = cellX * 2 + x; @@ -120,10 +120,10 @@ namespace MWRender //it makes far more sense to reallocate the memory here, //and let Ogre deal with it due to the issues with deleting - //it at the wrong time if using threads (Which Ogre::Terrain does) + //it at the wrong time if using threads (Which Terrain does) terrainData.inputFloat = OGRE_ALLOC_T(float, mLandSize*mLandSize, - Ogre::MEMCATEGORY_GEOMETRY); + MEMCATEGORY_GEOMETRY); //copy the height data row by row for ( int terrainCopyY = 0; terrainCopyY < mLandSize; terrainCopyY++ ) @@ -150,7 +150,7 @@ namespace MWRender mTerrainGroup->loadTerrain(terrainX, terrainY, true); - Ogre::Terrain* terrain = mTerrainGroup->getTerrain(terrainX, terrainY); + Terrain* terrain = mTerrainGroup->getTerrain(terrainX, terrainY); initTerrainBlendMaps(terrain, store, x * numTextures, y * numTextures, numTextures, @@ -158,7 +158,7 @@ namespace MWRender if ( store->land[1][1]->landData->usingColours ) { - Ogre::TexturePtr vertex = getVertexColours(store, + TexturePtr vertex = getVertexColours(store, x*(mLandSize-1), y*(mLandSize-1), mLandSize); @@ -193,7 +193,7 @@ namespace MWRender //---------------------------------------------------------------------------------------------- - void TerrainManager::initTerrainTextures(Ogre::Terrain::ImportData* terrainData, + void TerrainManager::initTerrainTextures(Terrain::ImportData* terrainData, MWWorld::Ptr::CellStore* store, int fromX, int fromY, int size, std::map& indexes) @@ -257,7 +257,7 @@ namespace MWRender } const size_t position = terrainData->layerList.size(); - terrainData->layerList.push_back(Ogre::Terrain::LayerInstance()); + terrainData->layerList.push_back(Terrain::LayerInstance()); terrainData->layerList[position].worldSize = 256; terrainData->layerList[position].textureNames.push_back("textures\\" + texture); @@ -276,7 +276,7 @@ namespace MWRender //---------------------------------------------------------------------------------------------- - void TerrainManager::initTerrainBlendMaps(Ogre::Terrain* terrain, + void TerrainManager::initTerrainBlendMaps(Terrain* terrain, MWWorld::Ptr::CellStore* store, int fromX, int fromY, int size, const std::map& indexes) @@ -361,7 +361,7 @@ namespace MWRender for ( int i = 1; i < terrain->getLayerCount(); i++ ) { - Ogre::TerrainLayerBlendMap* blend = terrain->getLayerBlendMap(i); + TerrainLayerBlendMap* blend = terrain->getLayerBlendMap(i); blend->dirty(); blend->update(); } @@ -418,10 +418,10 @@ namespace MWRender //---------------------------------------------------------------------------------------------- - Ogre::TexturePtr TerrainManager::getVertexColours(MWWorld::Ptr::CellStore* store, + TexturePtr TerrainManager::getVertexColours(MWWorld::Ptr::CellStore* store, int fromX, int fromY, int size) { - Ogre::TextureManager* const texMgr = Ogre::TextureManager::getSingletonPtr(); + TextureManager* const texMgr = TextureManager::getSingletonPtr(); const std::string colourTextureName = "VtexColours_" + boost::lexical_cast(store->cell->getGridX()) + @@ -432,22 +432,22 @@ namespace MWRender "_" + boost::lexical_cast(fromY); - Ogre::TexturePtr tex = texMgr->getByName(colourTextureName); + TexturePtr tex = texMgr->getByName(colourTextureName); if ( !tex.isNull() ) { return tex; } tex = texMgr->createManual(colourTextureName, - Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, - Ogre::TEX_TYPE_2D, size, size, 0, Ogre::PF_BYTE_BGR); + ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, + TEX_TYPE_2D, size, size, 0, PF_BYTE_BGR); - Ogre::HardwarePixelBufferSharedPtr pixelBuffer = tex->getBuffer(); + HardwarePixelBufferSharedPtr pixelBuffer = tex->getBuffer(); - pixelBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD); - const Ogre::PixelBox& pixelBox = pixelBuffer->getCurrentLock(); + pixelBuffer->lock(HardwareBuffer::HBL_DISCARD); + const PixelBox& pixelBox = pixelBuffer->getCurrentLock(); - Ogre::uint8* pDest = static_cast(pixelBox.data); + uint8* pDest = static_cast(pixelBox.data); const char* const colours = store->land[1][1]->landData->colours; for ( int y = 0; y < size; y++ ) From eca91d17bb823a6f0fda3b88764b9a8a8c84274a Mon Sep 17 00:00:00 2001 From: Jacob Essex Date: Sun, 4 Mar 2012 11:46:33 +0000 Subject: [PATCH 4/5] Indentation tweaks and code cleanup --- apps/openmw/mwrender/terrain.cpp | 42 +++++++++++++++----------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/apps/openmw/mwrender/terrain.cpp b/apps/openmw/mwrender/terrain.cpp index d9e6c1cf6..64acd9fe3 100644 --- a/apps/openmw/mwrender/terrain.cpp +++ b/apps/openmw/mwrender/terrain.cpp @@ -27,17 +27,14 @@ namespace MWRender TerrainMaterialGenerator::Profile* const activeProfile = mTerrainGlobals->getDefaultMaterialGenerator() ->getActiveProfile(); - mActiveProfile = - static_cast(activeProfile); + mActiveProfile = static_cast(activeProfile); //The pixel error should be as high as possible without it being noticed //as it governs how fast mesh quality decreases. mTerrainGlobals->setMaxPixelError(8); mTerrainGlobals->setLayerBlendMapSize(32); - mTerrainGlobals->setLightMapSize(256); - mTerrainGlobals->setCompositeMapSize(256); - mTerrainGlobals->setDefaultGlobalColourMapSize(256); + mTerrainGlobals->setDefaultGlobalColourMapSize(65); //10 (default) didn't seem to be quite enough mTerrainGlobals->setSkirtSize(128); @@ -51,19 +48,21 @@ namespace MWRender mActiveProfile->setLayerNormalMappingEnabled(false); mActiveProfile->setLayerParallaxMappingEnabled(false); mActiveProfile->setReceiveDynamicShadowsEnabled(false); + + //composite maps lead to a drastic reduction in loading time so are + //disabled mActiveProfile->setCompositeMapEnabled(false); mTerrainGroup = OGRE_NEW TerrainGroup(mgr, - Terrain::ALIGN_X_Z, - mLandSize, - mWorldSize); + Terrain::ALIGN_X_Z, + mLandSize, + mWorldSize); mTerrainGroup->setOrigin(Vector3(mWorldSize/2, - 0, - -mWorldSize/2)); + 0, + -mWorldSize/2)); - Terrain::ImportData& importSettings = - mTerrainGroup->getDefaultImportSettings(); + Terrain::ImportData& importSettings = mTerrainGroup->getDefaultImportSettings(); importSettings.inputBias = 0; importSettings.terrainSize = mLandSize; @@ -103,7 +102,6 @@ namespace MWRender const int cellX = store->cell->getGridX(); const int cellY = store->cell->getGridY(); - //split the cell terrain into four segments const int numTextures = ESM::Land::LAND_TEXTURE_SIZE/2; @@ -155,18 +153,14 @@ namespace MWRender numTextures, indexes); - // disable or enable global colour map (depends on available vertex colours) if ( store->land[1][1]->landData->usingColours ) + { + // disable or enable global colour map (depends on available vertex colours) mActiveProfile->setGlobalColourMapEnabled(true); - else - mActiveProfile->setGlobalColourMapEnabled(false); - - if ( store->land[1][1]->landData->usingColours ) - { TexturePtr vertex = getVertexColours(store, - x*(mLandSize-1), - y*(mLandSize-1), - mLandSize); + x*(mLandSize-1), + y*(mLandSize-1), + mLandSize); //this is a hack to get around the fact that Ogre seems to //corrupt the global colour map leading to rendering errors @@ -175,6 +169,10 @@ namespace MWRender //mat = terrain->_getCompositeMapMaterial(); //mat->getTechnique(0)->getPass(0)->getTextureUnitState(1)->setTextureName( vertex->getName() ); } + else + { + mActiveProfile->setGlobalColourMapEnabled(false); + } } } } From d22678faab028d31283d4ef0ccbd26c14f19d5ef Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 13 Mar 2012 17:14:02 +0100 Subject: [PATCH 5/5] fixed wrong merge --- CMakeLists.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index cc1dea25c..18c312229 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -255,6 +255,20 @@ if (APPLE) configure_file(${OpenMW_SOURCE_DIR}/files/mac/openmw.icns "${APP_BUNDLE_DIR}/Contents/Resources/OpenMW.icns" COPYONLY) + # prepare plugins + if (${CMAKE_BUILD_TYPE} MATCHES "Release") + set(OPENMW_RELEASE_BUILD 1) + endif() + if (${CMAKE_BUILD_TYPE} MATCHES "RelWithDebugInfo") + set(OPENMW_RELEASE_BUILD 1) + endif() + + if (${OPENMW_RELEASE_BUILD}) + set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_REL}) + else() + set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_DBG}) + endif() + foreach(plugin ${USED_OGRE_PLUGINS}) configure_file("${OGRE_PLUGIN_DIR}/${plugin}.dylib" "${APP_BUNDLE_DIR}/Contents/Plugins/${plugin}.dylib"