1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 18:35:20 +00:00

Merge branch 'master' into graphics

This commit is contained in:
scrawl 2013-02-08 18:35:41 +01:00
commit 6805c7bab4
5 changed files with 93 additions and 76 deletions

View File

@ -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)

View File

@ -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<ESM::Region>().search(cell->mCell->mRegion);
if (region)
name = region->mName;
else
{
{
const ESM::GameSetting *setting =
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().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);
}

View File

@ -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<std::string> tokens;
boost::split(tokens, pathname, boost::is_any_of("_"));
tokens.erase(--tokens.end());
std::string shaderName;
for (std::vector<std::string>::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<std::string> tokens;
boost::split(tokens, pathname, boost::is_any_of("_"));
tokens.erase(--tokens.end());
std::string shaderName;
for (std::vector<std::string>::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;
}
}
}
}
}
}

View File

@ -202,6 +202,8 @@ namespace sh
MaterialInstance* findInstance (const std::string& name);
MaterialInstance* searchInstance (const std::string& name);
void removeCache (const std::string& pattern);
};
}

View File

@ -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