From ed9a9904b431bb27ed9725e7c83023cf5fd11bab Mon Sep 17 00:00:00 2001 From: Emanuel Guevel Date: Thu, 24 Jan 2013 19:39:31 +0100 Subject: [PATCH 01/20] Dialogue filter: search script variables case-insensitively --- apps/openmw/mwdialogue/filter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index 5d56e94b0..c1542515a 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -169,7 +169,7 @@ bool MWDialogue::Filter::testSelectStructNumeric (const SelectWrapper& select) c int i = 0; for (; i (script->mVarNames.size()); ++i) - if (script->mVarNames[i]==name) + if (Misc::StringUtils::lowerCase(script->mVarNames[i]) == name) break; if (i>=static_cast (script->mVarNames.size())) From 19dff822f4f963fdab88d5f8f80c9b026edd6f91 Mon Sep 17 00:00:00 2001 From: Emanuel Guevel Date: Thu, 24 Jan 2013 19:43:21 +0100 Subject: [PATCH 02/20] Dialogue: do not filter on disposition for creatures --- apps/openmw/mwdialogue/filter.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index c1542515a..09bb0ddc4 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -123,6 +123,11 @@ bool MWDialogue::Filter::testSelectStructs (const ESM::DialInfo& info) const bool MWDialogue::Filter::testDisposition (const ESM::DialInfo& info) const { + bool isCreature = (mActor.getTypeName() != typeid (ESM::NPC).name()); + + if (isCreature) + return true; + int actorDisposition = MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mActor); return actorDisposition >= info.mData.mDisposition; From 4e46f403a9710ed3cda61b6615e3c0c7bdf992d8 Mon Sep 17 00:00:00 2001 From: Nathan Jeffords Date: Mon, 28 Jan 2013 22:07:39 -0800 Subject: [PATCH 03/20] added some more warning to ignore in MSVC --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2313d2d95..9c4ce5cd8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -496,7 +496,7 @@ if (WIN32) # Warnings that aren't enabled normally and don't need to be enabled # They're unneeded and sometimes completely retarded warnings that /Wall enables # Not going to bother commenting them as they tend to warn on every standard library files - 4061 4263 4264 4266 4350 4514 4548 4571 4610 4619 4623 4625 4626 4628 4640 4668 4710 4711 4820 4826 4917 4946 + 4061 4263 4264 4266 4350 4371 4514 4548 4571 4610 4619 4623 4625 4626 4628 4640 4668 4710 4711 4820 4826 4917 4946 # Warnings that are thrown on standard libraries and not OpenMW 4347 # Non-template function with same name and parameter count as template function @@ -506,6 +506,11 @@ if (WIN32) 4738 # Storing 32-bit float result in memory, possible loss of performance 4986 # Undocumented warning that occurs in the crtdbg.h file 4996 # Function was declared deprecated + + # cause by ogre extensivly + 4193 # #pragma warning(pop) : no matching '#pragma warning(push)' + 4251 # class 'XXXX' needs to have dll-interface to be used by clients of class 'YYYY' + 4275 # non dll-interface struct 'XXXX' used as base for dll-interface class 'YYYY' # OpenMW specific warnings 4099 # Type mismatch, declared class or struct is defined with other type From 85697e4628d3cd983f7b706dc890da97e0634027 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 2 Feb 2013 13:24:28 +0100 Subject: [PATCH 04/20] reverted to C++03 --- CMakeLists.txt | 4 ++-- apps/openmw/mwworld/actionequip.cpp | 12 ++++++------ components/bsa/bsa_archive.cpp | 2 +- components/files/constrainedfiledatastream.cpp | 9 +++------ 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c4ce5cd8..c944730ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -306,7 +306,7 @@ endif() # Compiler settings if (CMAKE_COMPILER_IS_GNUCC) - add_definitions (-Wall -Wextra -Wno-unused-parameter -Wno-reorder -std=c++0x -pedantic) + add_definitions (-Wall -Wextra -Wno-unused-parameter -Wno-reorder -std=c++03 -pedantic -Wno-long-long) # Silence warnings in OGRE headers. Remove once OGRE got fixed! add_definitions (-Wno-ignored-qualifiers) @@ -506,7 +506,7 @@ if (WIN32) 4738 # Storing 32-bit float result in memory, possible loss of performance 4986 # Undocumented warning that occurs in the crtdbg.h file 4996 # Function was declared deprecated - + # cause by ogre extensivly 4193 # #pragma warning(pop) : no matching '#pragma warning(push)' 4251 # class 'XXXX' needs to have dll-interface to be used by clients of class 'YYYY' diff --git a/apps/openmw/mwworld/actionequip.cpp b/apps/openmw/mwworld/actionequip.cpp index 60260a812..f3191e8bb 100644 --- a/apps/openmw/mwworld/actionequip.cpp +++ b/apps/openmw/mwworld/actionequip.cpp @@ -32,7 +32,7 @@ namespace MWWorld } assert(it != invStore.end()); - + std::string npcRace = actor.get()->mBase->mRace; // equip the item in the first free slot @@ -43,7 +43,7 @@ namespace MWWorld // Beast races cannot equip shoes / boots, or full helms (head part vs hair part) if(npcRace == "argonian" || npcRace == "khajiit") { - if(*slot == MWWorld::InventoryStore::Slot_Helmet){ + if(*slot == MWWorld::InventoryStore::Slot_Helmet){ std::vector parts; if(it.getType() == MWWorld::ContainerStore::Type_Clothing) @@ -54,22 +54,22 @@ namespace MWWorld bool allow = true; for(std::vector::iterator itr = parts.begin(); itr != parts.end(); ++itr) { - if((*itr).mPart == ESM::PartReferenceType::PRT_Head) + if((*itr).mPart == ESM::PRT_Head) { if(actor == MWBase::Environment::get().getWorld()->getPlayer().getPlayer() ) MWBase::Environment::get().getWindowManager()->messageBox ("#{sNotifyMessage13}", std::vector()); - + allow = false; break; } } - + if(!allow) break; } if (*slot == MWWorld::InventoryStore::Slot_Boots) - { + { // Only notify the player, not npcs if(actor == MWBase::Environment::get().getWorld()->getPlayer().getPlayer() ) { diff --git a/components/bsa/bsa_archive.cpp b/components/bsa/bsa_archive.cpp index 5274564a6..8117dbdfd 100644 --- a/components/bsa/bsa_archive.cpp +++ b/components/bsa/bsa_archive.cpp @@ -91,7 +91,7 @@ public: std::string searchable = normalize_path (proper.begin () + prefix, proper.end ()); - mIndex.insert (std::make_pair (std::move (searchable), std::move (proper))); + mIndex.insert (std::make_pair (searchable, proper)); } } diff --git a/components/files/constrainedfiledatastream.cpp b/components/files/constrainedfiledatastream.cpp index dd2985e56..321bcf7c8 100644 --- a/components/files/constrainedfiledatastream.cpp +++ b/components/files/constrainedfiledatastream.cpp @@ -3,11 +3,8 @@ #include #include -#ifndef __clang__ -#include -#else -#include -#endif + +#include namespace { @@ -29,7 +26,7 @@ public: mBufferOrigin = 0; mBufferExtent = 0; } - + size_t read(void* buf, size_t count) { From 827261e8b4c4fb2761429fa79c1c88721ae1602e Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 2 Feb 2013 13:42:11 +0100 Subject: [PATCH 05/20] increased version number --- CMakeLists.txt | 2 +- readme.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c944730ab..165db6b79 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ include (OpenMWMacros) # Version set (OPENMW_VERSION_MAJOR 0) -set (OPENMW_VERSION_MINOR 20) +set (OPENMW_VERSION_MINOR 21) set (OPENMW_VERSION_RELEASE 0) set (OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}") diff --git a/readme.txt b/readme.txt index 21ae85530..d94ccd7f0 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ OpenMW: A reimplementation of The Elder Scrolls III: Morrowind OpenMW is an attempt at recreating the engine for the popular role-playing game Morrowind by Bethesda Softworks. You need to own and install the original game for OpenMW to work. -Version: 0.20.0 +Version: 0.21.0 License: GPL (see GPL3.txt for more information) Website: http://www.openmw.org From d6a73a2a02d4d49bb733a59d8e1442ed819d831c Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 3 Feb 2013 11:41:31 +0100 Subject: [PATCH 06/20] updated changelog --- readme.txt | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/readme.txt b/readme.txt index d94ccd7f0..91690ff57 100644 --- a/readme.txt +++ b/readme.txt @@ -94,6 +94,38 @@ Allowed options: CHANGELOG +0.21.0 + +Bug #253: Dialogs don't work for Russian version of Morrowind +Bug #267: Activating creatures without dialogue can still activate the dialogue GUI +Bug #354: True flickering lights +Bug #386: The main menu's first entry is wrong (in french) +Bug #479: Adding the spell "Ash Woe Blight" to the player causes strange attribute oscillations +Bug #495: Activation Range +Bug #497: Failed Disposition check doesn't stop a dialogue entry from being returned +Bug #498: Failing a disposition check shouldn't eliminate topics from the the list of those available +Bug #500: Disposition for most NPCs is 0/100 +Bug #501: Getdisposition command wrongly returns base disposition +Bug #506: Journal UI doesn't update anymore +Bug #507: EnableRestMenu is not a valid command - change it to EnableRest +Bug #508: Crash in Ald Daedroth Shrine +Bug #517: Wrong price calculation when untrading an item +Bug #521: MWGui::InventoryWindow creates a duplicate player actor at the origin +Bug #524: Beast races are able to wear shoes +Bug #527: Background music fails to play +Bug #533: The arch at Gnisis entrance is not displayed +Bug #536: The same entry can be added multiple times to the journal +Bug #539: Race selection is broken +Feature #39: Video Playback +Feature #151: ^-escape sequences in text output +Feature #392: Add AI related script functions +Feature #456: Determine required ini fallback values and adjust the ini importer accordingly +Feature #460: Experimental DirArchives improvements +Feature #540: Execute scripts of objects in containers/inventories in active cells +Task #401: Review GMST fixing +Task #453: Unify case smashing/folding +Task #512: Rewrite utf8 component + 0.20.0 Bug #366: Changing the player's race during character creation does not change the look of the player character From a4872e321717ca7f3017bf5bbcbe36d2e8232da1 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 3 Feb 2013 13:30:40 +0100 Subject: [PATCH 07/20] rewrote the opencs cmake scripts (more compact and no more annoying warnings) --- apps/opencs/CMakeLists.txt | 101 ++++++++++++++++++++++++------------- cmake/OpenMWMacros.cmake | 48 ++++++++++++++++++ 2 files changed, 113 insertions(+), 36 deletions(-) diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index abbc953ca..d1cfbea52 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -1,46 +1,75 @@ -set (OPENCS_SRC - main.cpp editor.cpp +set (OPENCS_SRC main.cpp) - model/doc/documentmanager.cpp model/doc/document.cpp +opencs_units (. editor) - model/world/universalid.cpp model/world/idcollection.cpp model/world/data.cpp model/world/idtable.cpp - model/world/commands.cpp model/world/idtableproxymodel.cpp model/world/record.cpp - model/world/columnbase.cpp - model/tools/tools.cpp model/tools/operation.cpp model/tools/stage.cpp model/tools/verifier.cpp - model/tools/mandatoryid.cpp model/tools/reportmodel.cpp - - view/doc/viewmanager.cpp view/doc/view.cpp view/doc/operations.cpp view/doc/operation.cpp view/doc/subviewfactory.cpp - view/doc/subview.cpp - - view/world/table.cpp view/world/tablesubview.cpp view/world/subviews.cpp view/world/util.cpp - view/world/dialoguesubview.cpp - - view/tools/reportsubview.cpp view/tools/subviews.cpp +opencs_units (model/doc + document ) -set (OPENCS_HDR - editor.hpp - - model/doc/documentmanager.hpp model/doc/document.hpp model/doc/state.hpp - - model/world/universalid.hpp model/world/record.hpp model/world/idcollection.hpp model/world/data.hpp - model/world/idtable.hpp model/world/columns.hpp model/world/idtableproxymodel.hpp - model/world/commands.hpp model/world/columnbase.hpp - - model/tools/tools.hpp model/tools/operation.hpp model/tools/stage.hpp model/tools/verifier.hpp - model/tools/mandatoryid.hpp model/tools/reportmodel.hpp - - view/doc/viewmanager.hpp view/doc/view.hpp view/doc/operations.hpp view/doc/operation.hpp view/doc/subviewfactory.hpp - view/doc/subview.hpp view/doc/subviewfactoryimp.hpp - - view/world/table.hpp view/world/tablesubview.hpp view/world/subviews.hpp view/world/util.hpp - view/world/dialoguesubview.hpp - - view/tools/reportsubview.hpp view/tools/subviews.hpp +opencs_units_noqt (model/doc + documentmanager ) +opencs_hdrs_noqt (model/doc + state + ) + + +opencs_units (model/world + idtable idtableproxymodel + ) + +opencs_units_noqt (model/world + universalid data record idcollection commands columnbase + ) + +opencs_hdrs_noqt (model/world + columns + ) + + +opencs_units (model/tools + tools operation reportmodel + ) + +opencs_units_noqt (model/tools + stage verifier mandatoryid + ) + + +opencs_units (view/doc + viewmanager view operations operation subview + ) + +opencs_units_noqt (view/doc + subviewfactory + ) + +opencs_hdrs_noqt (view/doc + subviewfactoryimp + ) + + +opencs_units (view/world + table tablesubview + ) + +opencs_units_noqt (view/world + dialoguesubview util subviews + ) + + +opencs_units (view/tools + reportsubview + ) + +opencs_units_noqt (view/tools + subviews + ) + + set (OPENCS_US ) @@ -57,7 +86,7 @@ find_package(Qt4 COMPONENTS QtCore QtGui QtXml QtXmlPatterns REQUIRED) include(${QT_USE_FILE}) qt4_wrap_ui(OPENCS_UI_HDR ${OPENCS_UI}) -qt4_wrap_cpp(OPENCS_MOC_SRC ${OPENCS_HDR}) +qt4_wrap_cpp(OPENCS_MOC_SRC ${OPENCS_HDR_QT}) qt4_add_resources(OPENCS_RES_SRC ${OPENCS_RES}) include_directories(${CMAKE_CURRENT_BINARY_DIR}) diff --git a/cmake/OpenMWMacros.cmake b/cmake/OpenMWMacros.cmake index e6f45fdb1..d13568a68 100644 --- a/cmake/OpenMWMacros.cmake +++ b/cmake/OpenMWMacros.cmake @@ -29,3 +29,51 @@ get_filename_component(filename ${f} NAME) configure_file(${source_dir}/${f} ${destination_dir}/${filename} COPYONLY) endforeach (f) endmacro (copy_all_files) + +macro (add_file project type file) +list (APPEND ${project}${type} ${file}) +endmacro (add_file) + +macro (add_unit project dir unit) +add_file (${project} _HDR ${comp} "${dir}/${unit}.hpp") +add_file (${project} _SRC ${comp} "${dir}/${unit}.cpp") +endmacro (add_unit) + +macro (add_qt_unit project dir unit) +add_file (${project} _HDR ${comp} "${dir}/${unit}.hpp") +add_file (${project} _HDR_QT ${comp} "${dir}/${unit}.hpp") +add_file (${project} _SRC ${comp} "${dir}/${unit}.cpp") +endmacro (add_qt_unit) + +macro (add_hdr project dir unit) +add_file (${project} _HDR ${comp} "${dir}/${unit}.hpp") +endmacro (add_hdr) + +macro (add_qt_hdr project dir unit) +add_file (${project} _HDR ${comp} "${dir}/${unit}.hpp") +add_file (${project} _HDR_QT ${comp} "${dir}/${unit}.hpp") +endmacro (add_qt_hdr) + +macro (opencs_units dir) +foreach (u ${ARGN}) +add_qt_unit (OPENCS ${dir} ${u}) +endforeach (u) +endmacro (opencs_units) + +macro (opencs_units_noqt dir) +foreach (u ${ARGN}) +add_unit (OPENCS ${dir} ${u}) +endforeach (u) +endmacro (opencs_units) + +macro (opencs_hdrs dir) +foreach (u ${ARGN}) +add_qt_hdr (OPENCS ${dir} ${u}) +endforeach (u) +endmacro (opencs_hdrs) + +macro (opencs_hdrs_noqt dir) +foreach (u ${ARGN}) +add_hdr (OPENCS ${dir} ${u}) +endforeach (u) +endmacro (opencs_hdrs) From c97553703a6f11d82d0e3c11bc2311ae5a1cb4d1 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 3 Feb 2013 13:47:55 +0100 Subject: [PATCH 08/20] fixes for static build without cg --- apps/openmw/CMakeLists.txt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 482007090..e2cb0e5c4 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -72,15 +72,20 @@ add_openmw_dir (mwbase ) # Main executable + IF(OGRE_STATIC) +ADD_DEFINITIONS(-DENABLE_PLUGIN_OctreeSceneManager -DENABLE_PLUGIN_ParticleFX -DENABLE_PLUGIN_GL) +set(OGRE_STATIC_PLUGINS ${OGRE_Plugin_OctreeSceneManager_LIBRARIES} ${OGRE_Plugin_ParticleFX_LIBRARIES} ${OGRE_RenderSystem_GL_LIBRARIES}) IF(WIN32) -ADD_DEFINITIONS(-DENABLE_PLUGIN_CgProgramManager -DENABLE_PLUGIN_OctreeSceneManager -DENABLE_PLUGIN_ParticleFX -DENABLE_PLUGIN_-DENABLE_PLUGIN_Direct3D9 -DENABLE_PLUGIN_GL) -set(OGRE_STATIC_PLUGINS ${OGRE_Plugin_CgProgramManager_LIBRARIES} ${OGRE_Plugin_OctreeSceneManager_LIBRARIES} ${OGRE_Plugin_ParticleFX_LIBRARIES} ${OGRE_RenderSystem_Direct3D9_LIBRARIES} ${OGRE_RenderSystem_GL_LIBRARIES}) -ELSE(WIN32) -ADD_DEFINITIONS(-DENABLE_PLUGIN_CgProgramManager -DENABLE_PLUGIN_OctreeSceneManager -DENABLE_PLUGIN_ParticleFX -DENABLE_PLUGIN_GL) -set(OGRE_STATIC_PLUGINS ${OGRE_Plugin_CgProgramManager_LIBRARIES} ${Cg_LIBRARIES} ${OGRE_Plugin_OctreeSceneManager_LIBRARIES} ${OGRE_Plugin_ParticleFX_LIBRARIES} ${OGRE_RenderSystem_GL_LIBRARIES}) +ADD_DEFINITIONS(-DENABLE_PLUGIN_Direct3D9) +list (APPEND OGRE_STATIC_PLUGINS ${OGRE_RenderSystem_Direct3D9_LIBRARIES}) ENDIF(WIN32) +IF (Cg_FOUND) +ADD_DEFINITIONS(-DENABLE_PLUGIN_CgProgramManager) +list (APPEND OGRE_STATIC_PLUGINS ${OGRE_Plugin_CgProgramManager_LIBRARIES} ${Cg_LIBRARIES}) +ENDIF (Cg_FOUND) ENDIF(OGRE_STATIC) + add_executable(openmw ${OPENMW_LIBS} ${OPENMW_LIBS_HEADER} ${OPENMW_FILES} From a002b253d10fd882a29ef5917ac46f0cc281a932 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 3 Feb 2013 16:18:17 +0100 Subject: [PATCH 09/20] silenced a cmake warning --- cmake/OpenMWMacros.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/OpenMWMacros.cmake b/cmake/OpenMWMacros.cmake index d13568a68..bb200ee57 100644 --- a/cmake/OpenMWMacros.cmake +++ b/cmake/OpenMWMacros.cmake @@ -64,7 +64,7 @@ macro (opencs_units_noqt dir) foreach (u ${ARGN}) add_unit (OPENCS ${dir} ${u}) endforeach (u) -endmacro (opencs_units) +endmacro (opencs_units_noqt) macro (opencs_hdrs dir) foreach (u ${ARGN}) @@ -76,4 +76,4 @@ macro (opencs_hdrs_noqt dir) foreach (u ${ARGN}) add_hdr (OPENCS ${dir} ${u}) endforeach (u) -endmacro (opencs_hdrs) +endmacro (opencs_hdrs_noqt) From bf037b7d299c4ca0ebb4c50e9e656056f7f030e6 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 4 Feb 2013 18:03:03 +0100 Subject: [PATCH 10/20] Removed problematic ModVertexAlpha method, now done in shader --- apps/openmw/mwrender/sky.cpp | 45 ---------------------------- apps/openmw/mwrender/sky.hpp | 2 -- extern/shiny/CMakeLists.txt | 7 ----- extern/shiny/Main/ShaderInstance.cpp | 20 ++++++------- files/materials/atmosphere.shader | 9 +++--- files/materials/clouds.shader | 9 +++--- 6 files changed, 18 insertions(+), 74 deletions(-) diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index 60ecd4303..f8499d1e5 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -203,48 +203,6 @@ unsigned int Moon::getPhaseInt() const return 0; } -void SkyManager::ModVertexAlpha(Entity* ent, unsigned int meshType) -{ - // Get the vertex colour buffer of this mesh - const Ogre::VertexElement* ves_diffuse = ent->getMesh()->getSubMesh(0)->vertexData->vertexDeclaration->findElementBySemantic( Ogre::VES_DIFFUSE ); - HardwareVertexBufferSharedPtr colourBuffer = ent->getMesh()->getSubMesh(0)->vertexData->vertexBufferBinding->getBuffer(ves_diffuse->getSource()); - - // Lock - void* pData = colourBuffer->lock(HardwareBuffer::HBL_NORMAL); - - // Iterate over all vertices - int vertex_size = colourBuffer->getVertexSize(); - float * currentVertex = NULL; - for (unsigned int i=0; igetNumVertices(); ++i) - { - // Get a pointer to the vertex colour - ves_diffuse->baseVertexPointerToElement( pData, ¤tVertex ); - - unsigned char alpha=0; - if (meshType == 0) alpha = i%2 ? 0 : 255; // this is a cylinder, so every second vertex belongs to the bottom-most row - else if (meshType == 1) - { - if (i>= 49 && i <= 64) alpha = 0; // bottom-most row - else if (i>= 33 && i <= 48) alpha = 64; // second bottom-most row - else alpha = 255; - } - // NB we would have to swap R and B depending on rendersystem specific VertexElementType, but doesn't matter since they are both 1 - uint8 tmpR = static_cast(255); - uint8 tmpG = static_cast(255); - uint8 tmpB = static_cast(255); - uint8 tmpA = static_cast(alpha); - - // Modify - *((uint32*)currentVertex) = tmpR | (tmpG << 8) | (tmpB << 16) | (tmpA << 24); - - // Move to the next vertex - pData = static_cast (pData) + vertex_size; - } - - // Unlock - ent->getMesh()->getSubMesh(0)->vertexData->vertexBufferBinding->getBuffer(ves_diffuse->getSource())->unlock(); -} - SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera) : mHour(0.0f) , mDay(0) @@ -357,7 +315,6 @@ void SkyManager::create() atmosphere_ent->setRenderQueueGroup(RQG_SkiesEarly); atmosphere_ent->setVisibilityFlags(RV_Sky); atmosphere_ent->getSubEntity (0)->setMaterialName ("openmw_atmosphere"); - ModVertexAlpha(atmosphere_ent, 0); } @@ -371,8 +328,6 @@ void SkyManager::create() clouds_ent->setRenderQueueGroup(RQG_SkiesEarly+5); clouds_ent->getSubEntity(0)->setMaterialName ("openmw_clouds"); clouds_ent->setCastShadows(false); - - ModVertexAlpha(clouds_ent, 1); } mCreated = true; diff --git a/apps/openmw/mwrender/sky.hpp b/apps/openmw/mwrender/sky.hpp index ee1360853..52fd7b4aa 100644 --- a/apps/openmw/mwrender/sky.hpp +++ b/apps/openmw/mwrender/sky.hpp @@ -218,8 +218,6 @@ namespace MWRender float mGlare; // target float mGlareFade; // actual - void ModVertexAlpha(Ogre::Entity* ent, unsigned int meshType); - bool mEnabled; bool mSunEnabled; bool mMasserEnabled; diff --git a/extern/shiny/CMakeLists.txt b/extern/shiny/CMakeLists.txt index 603336413..6eadcc167 100644 --- a/extern/shiny/CMakeLists.txt +++ b/extern/shiny/CMakeLists.txt @@ -24,13 +24,6 @@ set(SOURCE_FILES Main/ShaderSet.cpp ) -# In Debug mode, write the shader sources to the current directory -if (DEFINED CMAKE_BUILD_TYPE) - if (CMAKE_BUILD_TYPE STREQUAL "Debug") - add_definitions(-DSHINY_WRITE_SHADER_DEBUG) - endif() -endif() - if (DEFINED SHINY_USE_WAVE_SYSTEM_INSTALL) # use system install else() diff --git a/extern/shiny/Main/ShaderInstance.cpp b/extern/shiny/Main/ShaderInstance.cpp index 07ef8dfe2..0e074c7b4 100644 --- a/extern/shiny/Main/ShaderInstance.cpp +++ b/extern/shiny/Main/ShaderInstance.cpp @@ -363,12 +363,12 @@ namespace sh if (Factory::getInstance ().getShaderDebugOutputEnabled ()) writeDebugFile(source, name + ".pre"); - else - { - #ifdef SHINY_WRITE_SHADER_DEBUG - writeDebugFile(source, name + ".pre"); - #endif - } + else + { + #ifdef SHINY_WRITE_SHADER_DEBUG + writeDebugFile(source, name + ".pre"); + #endif + } // why do we need our own preprocessor? there are several custom commands available in the shader files // (for example for binding uniforms to properties or auto constants) - more below. it is important that these @@ -648,12 +648,12 @@ namespace sh if (Factory::getInstance ().getShaderDebugOutputEnabled ()) writeDebugFile(source, name); - else - { + else + { #ifdef SHINY_WRITE_SHADER_DEBUG - writeDebugFile(source, name); + writeDebugFile(source, name); #endif - } + } if (!mProgram->getSupported()) { diff --git a/files/materials/atmosphere.shader b/files/materials/atmosphere.shader index 295fa9376..16edc78c5 100644 --- a/files/materials/atmosphere.shader +++ b/files/materials/atmosphere.shader @@ -7,19 +7,18 @@ SH_BEGIN_PROGRAM shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix) - shColourInput(float4) - shOutput(float4, colourPassthrough) + shOutput(float, alphaFade) SH_START_PROGRAM { shOutputPosition = shMatrixMult(wvp, shInputPosition); - colourPassthrough = colour; + alphaFade = shInputPosition.z < 150.0 ? 0.0 : 1.0; } #else SH_BEGIN_PROGRAM - shInput(float4, colourPassthrough) + shInput(float, alphaFade) #if MRT shDeclareMrtOutput(1) #endif @@ -27,7 +26,7 @@ SH_START_PROGRAM { - shOutputColour(0) = colourPassthrough * atmosphereColour; + shOutputColour(0) = atmosphereColour * float4(1,1,1,alphaFade); #if MRT shOutputColour(1) = float4(1,1,1,1); diff --git a/files/materials/clouds.shader b/files/materials/clouds.shader index f4258bf5d..9126ae423 100644 --- a/files/materials/clouds.shader +++ b/files/materials/clouds.shader @@ -8,21 +8,20 @@ shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix) shVertexInput(float2, uv0) shOutput(float2, UV) - shColourInput(float4) - shOutput(float4, colourPassthrough) + shOutput(float, alphaFade) SH_START_PROGRAM { - colourPassthrough = colour; shOutputPosition = shMatrixMult(wvp, shInputPosition); UV = uv0; + alphaFade = shInputPosition.z < 100.f ? 0 : 1; } #else SH_BEGIN_PROGRAM shInput(float2, UV) - shInput(float4, colourPassthrough) + shInput(float, alphaFade) #if MRT shDeclareMrtOutput(1) #endif @@ -42,7 +41,7 @@ float4 albedo = shSample(diffuseMap1, scrolledUV) * (1-cloudBlendFactor) + shSample(diffuseMap2, scrolledUV) * cloudBlendFactor; - shOutputColour(0) = colourPassthrough * float4(cloudColour, 1) * albedo * float4(1,1,1, cloudOpacity); + shOutputColour(0) = float4(cloudColour, 1) * albedo * float4(1,1,1, cloudOpacity * alphaFade); #if MRT shOutputColour(1) = float4(1,1,1,1); From a7d910614f516092cccc0ada7625de2e451e1902 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 4 Feb 2013 18:04:09 +0100 Subject: [PATCH 11/20] extern/shiny update: made caching more robust --- extern/shiny/Main/Factory.cpp | 43 ++++++++++++++++++++++++---- extern/shiny/Main/Factory.hpp | 1 + extern/shiny/Main/ShaderInstance.cpp | 15 +--------- extern/shiny/Main/ShaderSet.cpp | 1 - extern/shiny/Main/ShaderSet.hpp | 7 ----- 5 files changed, 40 insertions(+), 27 deletions(-) diff --git a/extern/shiny/Main/Factory.cpp b/extern/shiny/Main/Factory.cpp index 82d664811..c63a9e367 100644 --- a/extern/shiny/Main/Factory.cpp +++ b/extern/shiny/Main/Factory.cpp @@ -191,15 +191,48 @@ namespace sh &mGlobalSettings); int lastModified = boost::filesystem::last_write_time (boost::filesystem::path(sourceFile)); + mShadersLastModifiedNew[sourceFile] = lastModified; if (mShadersLastModified.find(sourceFile) != mShadersLastModified.end() && mShadersLastModified[sourceFile] != lastModified) { - newSet.markDirty (); + // delete any outdated shaders based on this shader set. + if ( boost::filesystem::exists(mPlatform->getCacheFolder()) + && boost::filesystem::is_directory(mPlatform->getCacheFolder())) + { + boost::filesystem::directory_iterator end_iter; + for( boost::filesystem::directory_iterator dir_iter(mPlatform->getCacheFolder()) ; dir_iter != end_iter ; ++dir_iter) + { + if (boost::filesystem::is_regular_file(dir_iter->status()) ) + { + boost::filesystem::path file = dir_iter->path(); + + std::string pathname = file.filename().string(); + + // get first part of filename, e.g. main_fragment_546457654 -> main_fragment + // there is probably a better method for this... + std::vector tokens; + boost::split(tokens, pathname, boost::is_any_of("_")); + tokens.erase(--tokens.end()); + std::string shaderName; + for (std::vector::const_iterator vector_iter = tokens.begin(); vector_iter != tokens.end();) + { + shaderName += *(vector_iter++); + if (vector_iter != tokens.end()) + shaderName += "_"; + } + + if (shaderName == it->first) + { + boost::filesystem::remove(file); + std::cout << "Removing outdated file: " << file << std::endl; + } + } + } + } + anyShaderDirty = true; } - mShadersLastModified[sourceFile] = lastModified; - mShaderSets.insert(std::make_pair(it->first, newSet)); } } @@ -313,11 +346,11 @@ namespace sh if (mReadSourceCache) { - // save the last modified time of shader sources + // save the last modified time of shader sources (as of when they were loaded) std::ofstream file; file.open(std::string(mPlatform->getCacheFolder () + "/lastModified.txt").c_str()); - for (LastModifiedMap::const_iterator it = mShadersLastModified.begin(); it != mShadersLastModified.end(); ++it) + for (LastModifiedMap::const_iterator it = mShadersLastModifiedNew.begin(); it != mShadersLastModifiedNew.end(); ++it) { file << it->first << "\n" << it->second << std::endl; } diff --git a/extern/shiny/Main/Factory.hpp b/extern/shiny/Main/Factory.hpp index 799dd71eb..1062c079c 100644 --- a/extern/shiny/Main/Factory.hpp +++ b/extern/shiny/Main/Factory.hpp @@ -185,6 +185,7 @@ namespace sh ConfigurationMap mConfigurations; LodConfigurationMap mLodConfigurations; LastModifiedMap mShadersLastModified; + LastModifiedMap mShadersLastModifiedNew; PropertySetGet mGlobalSettings; diff --git a/extern/shiny/Main/ShaderInstance.cpp b/extern/shiny/Main/ShaderInstance.cpp index 0e074c7b4..1539128ab 100644 --- a/extern/shiny/Main/ShaderInstance.cpp +++ b/extern/shiny/Main/ShaderInstance.cpp @@ -337,8 +337,7 @@ namespace sh size_t pos; bool readCache = Factory::getInstance ().getReadSourceCache () && boost::filesystem::exists( - Factory::getInstance ().getCacheFolder () + "/" + mName) - && !mParent->isDirty (); + Factory::getInstance ().getCacheFolder () + "/" + mName); bool writeCache = Factory::getInstance ().getWriteSourceCache (); @@ -363,12 +362,6 @@ namespace sh if (Factory::getInstance ().getShaderDebugOutputEnabled ()) writeDebugFile(source, name + ".pre"); - else - { - #ifdef SHINY_WRITE_SHADER_DEBUG - writeDebugFile(source, name + ".pre"); - #endif - } // why do we need our own preprocessor? there are several custom commands available in the shader files // (for example for binding uniforms to properties or auto constants) - more below. it is important that these @@ -648,12 +641,6 @@ namespace sh if (Factory::getInstance ().getShaderDebugOutputEnabled ()) writeDebugFile(source, name); - else - { -#ifdef SHINY_WRITE_SHADER_DEBUG - writeDebugFile(source, name); -#endif - } if (!mProgram->getSupported()) { diff --git a/extern/shiny/Main/ShaderSet.cpp b/extern/shiny/Main/ShaderSet.cpp index 2702ece19..413d7d1a2 100644 --- a/extern/shiny/Main/ShaderSet.cpp +++ b/extern/shiny/Main/ShaderSet.cpp @@ -17,7 +17,6 @@ namespace sh , mName(name) , mCgProfile(cgProfile) , mHlslProfile(hlslProfile) - , mIsDirty(false) { if (type == "vertex") mType = GPT_Vertex; diff --git a/extern/shiny/Main/ShaderSet.hpp b/extern/shiny/Main/ShaderSet.hpp index 776750598..a423b6779 100644 --- a/extern/shiny/Main/ShaderSet.hpp +++ b/extern/shiny/Main/ShaderSet.hpp @@ -30,9 +30,6 @@ namespace sh /// so it does not matter if you pass any extra properties that the shader does not care about. ShaderInstance* getInstance (PropertySetGet* properties); - void markDirty() { mIsDirty = true; } - ///< Signals that the cache is out of date, and thus should not be used this time - private: PropertySetGet* getCurrentGlobalSettings() const; std::string getBasePath() const; @@ -41,12 +38,8 @@ namespace sh std::string getHlslProfile() const; int getType() const; - bool isDirty() { return mIsDirty; } - friend class ShaderInstance; - bool mIsDirty; - private: GpuProgramType mType; std::string mSource; From e94976592256a70d76218753992b77a02eeecd99 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 4 Feb 2013 19:21:47 +0100 Subject: [PATCH 12/20] cloud blending now as before (0 -> 0.25 -> 1) --- files/materials/clouds.shader | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/materials/clouds.shader b/files/materials/clouds.shader index 9126ae423..4b1868fb4 100644 --- a/files/materials/clouds.shader +++ b/files/materials/clouds.shader @@ -14,7 +14,7 @@ { shOutputPosition = shMatrixMult(wvp, shInputPosition); UV = uv0; - alphaFade = shInputPosition.z < 100.f ? 0 : 1; + alphaFade = (shInputPosition.z <= 200.f) ? ((shInputPosition.z <= 100.f) ? 0.0 : 0.25) : 1.0; } #else From 596628d339472e19864d7433675e1d4e146a04d2 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 4 Feb 2013 23:13:01 +0100 Subject: [PATCH 13/20] Fix terrain derived data update (bug 534, bug 544) --- apps/openmw/mwrender/terrain.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/openmw/mwrender/terrain.cpp b/apps/openmw/mwrender/terrain.cpp index e5a1362d7..5b24bbd45 100644 --- a/apps/openmw/mwrender/terrain.cpp +++ b/apps/openmw/mwrender/terrain.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "../mwworld/esmstore.hpp" @@ -151,6 +152,16 @@ namespace MWRender mTerrainGroup.loadTerrain(terrainX, terrainY, true); + // when loading from a heightmap, Ogre::Terrain does not update the derived data (normal map, LOD) + // synchronously, even if we supply synchronous = true parameter to loadTerrain. + // the following to be the only way to make sure derived data is ready when rendering the next frame. + while (mTerrainGroup.isDerivedDataUpdateInProgress()) + { + // we need to wait for this to finish + OGRE_THREAD_SLEEP(5); + Root::getSingleton().getWorkQueue()->processResponses(); + } + Terrain* terrain = mTerrainGroup.getTerrain(terrainX, terrainY); initTerrainBlendMaps(terrain, cellX, cellY, From 58cf182db2df6e47e8e98e35c2c49d157857c88b Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 5 Feb 2013 00:21:29 +0100 Subject: [PATCH 14/20] better place for syncing --- apps/openmw/mwrender/terrain.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwrender/terrain.cpp b/apps/openmw/mwrender/terrain.cpp index 5b24bbd45..f4ad261c5 100644 --- a/apps/openmw/mwrender/terrain.cpp +++ b/apps/openmw/mwrender/terrain.cpp @@ -152,16 +152,6 @@ namespace MWRender mTerrainGroup.loadTerrain(terrainX, terrainY, true); - // when loading from a heightmap, Ogre::Terrain does not update the derived data (normal map, LOD) - // synchronously, even if we supply synchronous = true parameter to loadTerrain. - // the following to be the only way to make sure derived data is ready when rendering the next frame. - while (mTerrainGroup.isDerivedDataUpdateInProgress()) - { - // we need to wait for this to finish - OGRE_THREAD_SLEEP(5); - Root::getSingleton().getWorkQueue()->processResponses(); - } - Terrain* terrain = mTerrainGroup.getTerrain(terrainX, terrainY); initTerrainBlendMaps(terrain, cellX, cellY, @@ -189,6 +179,16 @@ namespace MWRender } } + // when loading from a heightmap, Ogre::Terrain does not update the derived data (normal map, LOD) + // synchronously, even if we supply synchronous = true parameter to loadTerrain. + // the following to be the only way to make sure derived data is ready when rendering the next frame. + while (mTerrainGroup.isDerivedDataUpdateInProgress()) + { + // we need to wait for this to finish + OGRE_THREAD_SLEEP(5); + Root::getSingleton().getWorkQueue()->processResponses(); + } + mTerrainGroup.freeTemporaryResources(); } From 3fe5757770b9abecd02cbb288f371c8208f92892 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 5 Feb 2013 10:28:49 +0100 Subject: [PATCH 15/20] updated changelog for 0.21.0 again --- readme.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.txt b/readme.txt index 91690ff57..3124744c3 100644 --- a/readme.txt +++ b/readme.txt @@ -114,8 +114,10 @@ Bug #521: MWGui::InventoryWindow creates a duplicate player actor at the origin Bug #524: Beast races are able to wear shoes Bug #527: Background music fails to play Bug #533: The arch at Gnisis entrance is not displayed +Bug #534: Terrain gets its correct shape only some time after the cell is loaded Bug #536: The same entry can be added multiple times to the journal Bug #539: Race selection is broken +Bug #544: Terrain normal map corrupt when the map is rendered Feature #39: Video Playback Feature #151: ^-escape sequences in text output Feature #392: Add AI related script functions From cfceb450095db1ea1a8d91c21f86ecc81a85c6b1 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 5 Feb 2013 11:53:48 +0100 Subject: [PATCH 16/20] adjusted gcc settings again to avoid problems with older compiler versions --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 165db6b79..577b6f6b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -306,7 +306,7 @@ endif() # Compiler settings if (CMAKE_COMPILER_IS_GNUCC) - add_definitions (-Wall -Wextra -Wno-unused-parameter -Wno-reorder -std=c++03 -pedantic -Wno-long-long) + add_definitions (-Wall -Wextra -Wno-unused-parameter -Wno-reorder -std=c++98 -pedantic -Wno-long-long) # Silence warnings in OGRE headers. Remove once OGRE got fixed! add_definitions (-Wno-ignored-qualifiers) From c409f1184e9667d193eda048980329c9edbe1c71 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 5 Feb 2013 12:19:06 +0100 Subject: [PATCH 17/20] cleaned up object movement and fixed a bug regarding local scripts --- apps/openmw/mwworld/worldimp.cpp | 64 ++++++++++++++++---------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 24d139b37..609b6582d 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -302,26 +302,26 @@ namespace MWWorld { return mGlobalVariables->getGlobals(); } - + std::string World::getCurrentCellName () const { std::string name; Ptr::CellStore *cell = mWorldScene->getCurrentCell(); if (cell->mCell->isExterior()) - { + { if (cell->mCell->mName != "") - { + { name = cell->mCell->mName; - } - else - { + } + else + { const ESM::Region* region = MWBase::Environment::get().getWorld()->getStore().get().search(cell->mCell->mRegion); if (region) name = region->mName; else - { + { const ESM::GameSetting *setting = MWBase::Environment::get().getWorld()->getStore().get().search("sDefaultCellname"); @@ -331,13 +331,13 @@ namespace MWWorld name = "Wilderness"; } - } - } - else - { + } + } + else + { name = cell->mCell->mName; - } - + } + return name; } @@ -426,12 +426,12 @@ namespace MWWorld if (!reference.getRefData().isEnabled()) { reference.getRefData().enable(); - + if(mWorldScene->getActiveCells().find (reference.getCell()) != mWorldScene->getActiveCells().end() && reference.getRefData().getCount()) mWorldScene->addObjectToScene (reference); } } - + void World::removeContainerScripts(const Ptr& reference) { if( reference.getTypeName()==typeid (ESM::Container).name() || @@ -456,7 +456,7 @@ namespace MWWorld if (reference.getRefData().isEnabled()) { reference.getRefData().disable(); - + if(mWorldScene->getActiveCells().find (reference.getCell())!=mWorldScene->getActiveCells().end() && reference.getRefData().getCount()) mWorldScene->removeObjectFromScene (reference); } @@ -687,14 +687,14 @@ namespace MWWorld void World::moveObject(const Ptr &ptr, CellStore &newCell, float x, float y, float z) { ESM::Position &pos = ptr.getRefData().getPosition(); - pos.pos[0] = x, pos.pos[1] = y, pos.pos[2] = z; + pos.pos[0] = x; + pos.pos[1] = y; + pos.pos[2] = z; Ogre::Vector3 vec(x, y, z); CellStore *currCell = ptr.getCell(); bool isPlayer = ptr == mPlayer->getPlayer(); bool haveToMove = mWorldScene->isCellActive(*currCell) || isPlayer; - - removeContainerScripts(ptr); if (*currCell != newCell) { @@ -707,7 +707,8 @@ namespace MWWorld int cellY = newCell.mCell->getGridY(); mWorldScene->changeCell(cellX, cellY, pos, false); } - else { + else + { if (!mWorldScene->isCellActive(*currCell)) copyObjectToCell(ptr, newCell, pos); else if (!mWorldScene->isCellActive(newCell)) @@ -715,6 +716,7 @@ namespace MWWorld MWWorld::Class::get(ptr).copyToCell(ptr, newCell); mWorldScene->removeObjectFromScene(ptr); mLocalScripts.remove(ptr); + removeContainerScripts (ptr); haveToMove = false; } else @@ -722,10 +724,18 @@ namespace MWWorld MWWorld::Ptr copy = MWWorld::Class::get(ptr).copyToCell(ptr, newCell); - addContainerScripts(copy, &newCell); - mRendering->moveObjectToCell(copy, vec, currCell); + std::string script = + MWWorld::Class::get(ptr).getScript(ptr); + if (!script.empty()) + { + mLocalScripts.remove(ptr); + removeContainerScripts (ptr); + mLocalScripts.add(script, copy); + addContainerScripts (copy, &newCell); + } + if (MWWorld::Class::get(ptr).isActor()) { MWBase::MechanicsManager *mechMgr = @@ -734,16 +744,6 @@ namespace MWWorld mechMgr->removeActor(ptr); mechMgr->addActor(copy); } - else - { - std::string script = - MWWorld::Class::get(ptr).getScript(ptr); - if (!script.empty()) - { - mLocalScripts.remove(ptr); - mLocalScripts.add(script, copy); - } - } } ptr.getRefData().setCount(0); } From 814969dcae6ab8428b582bc86921ca38d072274e Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 7 Feb 2013 02:23:41 +0100 Subject: [PATCH 18/20] Cache integrity check uses relative paths, so that changing the build folder works without reset --- extern/shiny/Main/Factory.cpp | 99 ++++++++++++++++++++--------------- extern/shiny/Main/Factory.hpp | 2 + 2 files changed, 58 insertions(+), 43 deletions(-) diff --git a/extern/shiny/Main/Factory.cpp b/extern/shiny/Main/Factory.cpp index c63a9e367..21f13e30b 100644 --- a/extern/shiny/Main/Factory.cpp +++ b/extern/shiny/Main/Factory.cpp @@ -50,7 +50,7 @@ namespace sh { assert(mCurrentLanguage != Language_None); - bool anyShaderDirty = false; + bool removeBinaryCache = false; if (boost::filesystem::exists (mPlatform->getCacheFolder () + "/lastModified.txt")) { @@ -182,57 +182,33 @@ namespace sh } } - std::string sourceFile = mPlatform->getBasePath() + "/" + it->second->findChild("source")->getValue(); + std::string sourceAbsolute = mPlatform->getBasePath() + "/" + it->second->findChild("source")->getValue(); + std::string sourceRelative = it->second->findChild("source")->getValue(); ShaderSet newSet (it->second->findChild("type")->getValue(), cg_profile, hlsl_profile, - sourceFile, + sourceAbsolute, mPlatform->getBasePath(), it->first, &mGlobalSettings); - int lastModified = boost::filesystem::last_write_time (boost::filesystem::path(sourceFile)); - mShadersLastModifiedNew[sourceFile] = lastModified; - if (mShadersLastModified.find(sourceFile) != mShadersLastModified.end() - && mShadersLastModified[sourceFile] != lastModified) + int lastModified = boost::filesystem::last_write_time (boost::filesystem::path(sourceAbsolute)); + mShadersLastModifiedNew[sourceRelative] = lastModified; + if (mShadersLastModified.find(sourceRelative) != mShadersLastModified.end()) { - // delete any outdated shaders based on this shader set. - if ( boost::filesystem::exists(mPlatform->getCacheFolder()) - && boost::filesystem::is_directory(mPlatform->getCacheFolder())) + if (mShadersLastModified[sourceRelative] != lastModified) { - boost::filesystem::directory_iterator end_iter; - for( boost::filesystem::directory_iterator dir_iter(mPlatform->getCacheFolder()) ; dir_iter != end_iter ; ++dir_iter) - { - if (boost::filesystem::is_regular_file(dir_iter->status()) ) - { - boost::filesystem::path file = dir_iter->path(); - - std::string pathname = file.filename().string(); - - // get first part of filename, e.g. main_fragment_546457654 -> main_fragment - // there is probably a better method for this... - std::vector tokens; - boost::split(tokens, pathname, boost::is_any_of("_")); - tokens.erase(--tokens.end()); - std::string shaderName; - for (std::vector::const_iterator vector_iter = tokens.begin(); vector_iter != tokens.end();) - { - shaderName += *(vector_iter++); - if (vector_iter != tokens.end()) - shaderName += "_"; - } - - if (shaderName == it->first) - { - boost::filesystem::remove(file); - std::cout << "Removing outdated file: " << file << std::endl; - } - } - } + // delete any outdated shaders based on this shader set + removeCache (it->first); + // remove the whole binary cache (removing only the individual shaders does not seem to be possible at this point with OGRE) + removeBinaryCache = true; } - - anyShaderDirty = true; } - + else + { + // if we get here, this is either the first run or a new shader file was added + // in both cases we can safely delete + removeCache (it->first); + } mShaderSets.insert(std::make_pair(it->first, newSet)); } } @@ -326,7 +302,7 @@ namespace sh } } - if (mPlatform->supportsShaderSerialization () && mReadMicrocodeCache && !anyShaderDirty) + if (mPlatform->supportsShaderSerialization () && mReadMicrocodeCache && !removeBinaryCache) { std::string file = mPlatform->getCacheFolder () + "/shShaderCache.txt"; if (boost::filesystem::exists(file)) @@ -613,4 +589,41 @@ namespace sh assert(m); m->createForConfiguration (configuration, 0); } + + void Factory::removeCache(const std::string& pattern) + { + if ( boost::filesystem::exists(mPlatform->getCacheFolder()) + && boost::filesystem::is_directory(mPlatform->getCacheFolder())) + { + boost::filesystem::directory_iterator end_iter; + for( boost::filesystem::directory_iterator dir_iter(mPlatform->getCacheFolder()) ; dir_iter != end_iter ; ++dir_iter) + { + if (boost::filesystem::is_regular_file(dir_iter->status()) ) + { + boost::filesystem::path file = dir_iter->path(); + + std::string pathname = file.filename().string(); + + // get first part of filename, e.g. main_fragment_546457654 -> main_fragment + // there is probably a better method for this... + std::vector tokens; + boost::split(tokens, pathname, boost::is_any_of("_")); + tokens.erase(--tokens.end()); + std::string shaderName; + for (std::vector::const_iterator vector_iter = tokens.begin(); vector_iter != tokens.end();) + { + shaderName += *(vector_iter++); + if (vector_iter != tokens.end()) + shaderName += "_"; + } + + if (shaderName == pattern) + { + boost::filesystem::remove(file); + std::cout << "Removing outdated shader: " << file << std::endl; + } + } + } + } + } } diff --git a/extern/shiny/Main/Factory.hpp b/extern/shiny/Main/Factory.hpp index 1062c079c..6d4175c97 100644 --- a/extern/shiny/Main/Factory.hpp +++ b/extern/shiny/Main/Factory.hpp @@ -202,6 +202,8 @@ namespace sh MaterialInstance* findInstance (const std::string& name); MaterialInstance* searchInstance (const std::string& name); + + void removeCache (const std::string& pattern); }; } From 0d4b0bfd9396846971f112c948f8334fb89f9dc4 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Thu, 7 Feb 2013 23:40:20 +0400 Subject: [PATCH 19/20] Trying to resolve sound issues on OS X with ffmpeg backend --- apps/openmw/CMakeLists.txt | 6 ++++++ apps/openmw/mwsound/ffmpeg_decoder.cpp | 1 + 2 files changed, 7 insertions(+) diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index e2cb0e5c4..b685c6083 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -125,6 +125,12 @@ if(APPLE) find_library(COCOA_FRAMEWORK Cocoa) find_library(IOKIT_FRAMEWORK IOKit) target_link_libraries(openmw ${CARBON_FRAMEWORK} ${COCOA_FRAMEWORK} ${IOKIT_FRAMEWORK}) + + if (FFMPEG_FOUND) + find_library(COREVIDEO_FRAMEWORK CoreVideo) + find_library(VDA_FRAMEWORK VideoDecodeAcceleration) + target_link_libraries(openmw ${COREVIDEO_FRAMEWORK} ${VDA_FRAMEWORK}) + endif() endif(APPLE) if(DPKG_PROGRAM) diff --git a/apps/openmw/mwsound/ffmpeg_decoder.cpp b/apps/openmw/mwsound/ffmpeg_decoder.cpp index 261a86ca6..00530a962 100644 --- a/apps/openmw/mwsound/ffmpeg_decoder.cpp +++ b/apps/openmw/mwsound/ffmpeg_decoder.cpp @@ -160,6 +160,7 @@ void FFmpeg_Decoder::open(const std::string &fname) { if(mFormatCtx->streams[j]->codec->codec_type == AVMEDIA_TYPE_AUDIO) { + mFormatCtx->streams[j]->codec->request_sample_fmt = AV_SAMPLE_FMT_S16; mStream = &mFormatCtx->streams[j]; break; } From 62c711d709d9c3bf314b97bd31b198f3768255e9 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 11 Feb 2013 02:28:02 +0100 Subject: [PATCH 20/20] Small change to delete microcode cache more aggressively. --- extern/shiny/Main/Factory.cpp | 18 +++++++++++------- extern/shiny/Main/Factory.hpp | 5 ++++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/extern/shiny/Main/Factory.cpp b/extern/shiny/Main/Factory.cpp index 21f13e30b..40c695fd4 100644 --- a/extern/shiny/Main/Factory.cpp +++ b/extern/shiny/Main/Factory.cpp @@ -15,6 +15,7 @@ namespace sh { Factory* Factory::sThis = 0; + const std::string Factory::mBinaryCacheName = "binaryCache"; Factory& Factory::getInstance() { @@ -198,16 +199,16 @@ namespace sh if (mShadersLastModified[sourceRelative] != lastModified) { // delete any outdated shaders based on this shader set - removeCache (it->first); - // remove the whole binary cache (removing only the individual shaders does not seem to be possible at this point with OGRE) - removeBinaryCache = true; + if (removeCache (it->first)) + removeBinaryCache = true; } } else { // if we get here, this is either the first run or a new shader file was added // in both cases we can safely delete - removeCache (it->first); + if (removeCache (it->first)) + removeBinaryCache = true; } mShaderSets.insert(std::make_pair(it->first, newSet)); } @@ -304,7 +305,7 @@ namespace sh if (mPlatform->supportsShaderSerialization () && mReadMicrocodeCache && !removeBinaryCache) { - std::string file = mPlatform->getCacheFolder () + "/shShaderCache.txt"; + std::string file = mPlatform->getCacheFolder () + "/" + mBinaryCacheName; if (boost::filesystem::exists(file)) { mPlatform->deserializeShaders (file); @@ -316,7 +317,7 @@ namespace sh { if (mPlatform->supportsShaderSerialization () && mWriteMicrocodeCache) { - std::string file = mPlatform->getCacheFolder () + "/shShaderCache.txt"; + std::string file = mPlatform->getCacheFolder () + "/" + mBinaryCacheName; mPlatform->serializeShaders (file); } @@ -590,8 +591,9 @@ namespace sh m->createForConfiguration (configuration, 0); } - void Factory::removeCache(const std::string& pattern) + bool Factory::removeCache(const std::string& pattern) { + bool ret = false; if ( boost::filesystem::exists(mPlatform->getCacheFolder()) && boost::filesystem::is_directory(mPlatform->getCacheFolder())) { @@ -620,10 +622,12 @@ namespace sh if (shaderName == pattern) { boost::filesystem::remove(file); + ret = true; std::cout << "Removing outdated shader: " << file << std::endl; } } } } + return ret; } } diff --git a/extern/shiny/Main/Factory.hpp b/extern/shiny/Main/Factory.hpp index 6d4175c97..846860b89 100644 --- a/extern/shiny/Main/Factory.hpp +++ b/extern/shiny/Main/Factory.hpp @@ -203,7 +203,10 @@ namespace sh MaterialInstance* findInstance (const std::string& name); MaterialInstance* searchInstance (const std::string& name); - void removeCache (const std::string& pattern); + /// @return was anything removed? + bool removeCache (const std::string& pattern); + + static const std::string mBinaryCacheName; }; }