1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-01 07:45:33 +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 # Compiler settings
if (CMAKE_COMPILER_IS_GNUCC) 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! # Silence warnings in OGRE headers. Remove once OGRE got fixed!
add_definitions (-Wno-ignored-qualifiers) add_definitions (-Wno-ignored-qualifiers)

View file

@ -687,15 +687,15 @@ namespace MWWorld
void World::moveObject(const Ptr &ptr, CellStore &newCell, float x, float y, float z) void World::moveObject(const Ptr &ptr, CellStore &newCell, float x, float y, float z)
{ {
ESM::Position &pos = ptr.getRefData().getPosition(); 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); Ogre::Vector3 vec(x, y, z);
CellStore *currCell = ptr.getCell(); CellStore *currCell = ptr.getCell();
bool isPlayer = ptr == mPlayer->getPlayer(); bool isPlayer = ptr == mPlayer->getPlayer();
bool haveToMove = mWorldScene->isCellActive(*currCell) || isPlayer; bool haveToMove = mWorldScene->isCellActive(*currCell) || isPlayer;
removeContainerScripts(ptr);
if (*currCell != newCell) if (*currCell != newCell)
{ {
if (isPlayer) if (isPlayer)
@ -707,7 +707,8 @@ namespace MWWorld
int cellY = newCell.mCell->getGridY(); int cellY = newCell.mCell->getGridY();
mWorldScene->changeCell(cellX, cellY, pos, false); mWorldScene->changeCell(cellX, cellY, pos, false);
} }
else { else
{
if (!mWorldScene->isCellActive(*currCell)) if (!mWorldScene->isCellActive(*currCell))
copyObjectToCell(ptr, newCell, pos); copyObjectToCell(ptr, newCell, pos);
else if (!mWorldScene->isCellActive(newCell)) else if (!mWorldScene->isCellActive(newCell))
@ -715,6 +716,7 @@ namespace MWWorld
MWWorld::Class::get(ptr).copyToCell(ptr, newCell); MWWorld::Class::get(ptr).copyToCell(ptr, newCell);
mWorldScene->removeObjectFromScene(ptr); mWorldScene->removeObjectFromScene(ptr);
mLocalScripts.remove(ptr); mLocalScripts.remove(ptr);
removeContainerScripts (ptr);
haveToMove = false; haveToMove = false;
} }
else else
@ -722,10 +724,18 @@ namespace MWWorld
MWWorld::Ptr copy = MWWorld::Ptr copy =
MWWorld::Class::get(ptr).copyToCell(ptr, newCell); MWWorld::Class::get(ptr).copyToCell(ptr, newCell);
addContainerScripts(copy, &newCell);
mRendering->moveObjectToCell(copy, vec, currCell); 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()) if (MWWorld::Class::get(ptr).isActor())
{ {
MWBase::MechanicsManager *mechMgr = MWBase::MechanicsManager *mechMgr =
@ -734,16 +744,6 @@ namespace MWWorld
mechMgr->removeActor(ptr); mechMgr->removeActor(ptr);
mechMgr->addActor(copy); 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); ptr.getRefData().setCount(0);
} }

View file

@ -50,7 +50,7 @@ namespace sh
{ {
assert(mCurrentLanguage != Language_None); assert(mCurrentLanguage != Language_None);
bool anyShaderDirty = false; bool removeBinaryCache = false;
if (boost::filesystem::exists (mPlatform->getCacheFolder () + "/lastModified.txt")) 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, ShaderSet newSet (it->second->findChild("type")->getValue(), cg_profile, hlsl_profile,
sourceFile, sourceAbsolute,
mPlatform->getBasePath(), mPlatform->getBasePath(),
it->first, it->first,
&mGlobalSettings); &mGlobalSettings);
int lastModified = boost::filesystem::last_write_time (boost::filesystem::path(sourceFile)); int lastModified = boost::filesystem::last_write_time (boost::filesystem::path(sourceAbsolute));
mShadersLastModifiedNew[sourceFile] = lastModified; mShadersLastModifiedNew[sourceRelative] = lastModified;
if (mShadersLastModified.find(sourceFile) != mShadersLastModified.end() if (mShadersLastModified.find(sourceRelative) != mShadersLastModified.end())
&& mShadersLastModified[sourceFile] != lastModified)
{ {
// delete any outdated shaders based on this shader set. if (mShadersLastModified[sourceRelative] != lastModified)
if ( boost::filesystem::exists(mPlatform->getCacheFolder())
&& boost::filesystem::is_directory(mPlatform->getCacheFolder()))
{ {
boost::filesystem::directory_iterator end_iter; // delete any outdated shaders based on this shader set
for( boost::filesystem::directory_iterator dir_iter(mPlatform->getCacheFolder()) ; dir_iter != end_iter ; ++dir_iter) removeCache (it->first);
{ // remove the whole binary cache (removing only the individual shaders does not seem to be possible at this point with OGRE)
if (boost::filesystem::is_regular_file(dir_iter->status()) ) removeBinaryCache = true;
{
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;
}
}
}
} }
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)); 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"; std::string file = mPlatform->getCacheFolder () + "/shShaderCache.txt";
if (boost::filesystem::exists(file)) if (boost::filesystem::exists(file))
@ -613,4 +589,41 @@ namespace sh
assert(m); assert(m);
m->createForConfiguration (configuration, 0); 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* findInstance (const std::string& name);
MaterialInstance* searchInstance (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 #524: Beast races are able to wear shoes
Bug #527: Background music fails to play Bug #527: Background music fails to play
Bug #533: The arch at Gnisis entrance is not displayed 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 #536: The same entry can be added multiple times to the journal
Bug #539: Race selection is broken Bug #539: Race selection is broken
Bug #544: Terrain normal map corrupt when the map is rendered
Feature #39: Video Playback Feature #39: Video Playback
Feature #151: ^-escape sequences in text output Feature #151: ^-escape sequences in text output
Feature #392: Add AI related script functions Feature #392: Add AI related script functions