mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-02 18:45:32 +00:00
Merge remote-tracking branch 'zini/master' into animation2
This commit is contained in:
commit
a14132b5a0
24 changed files with 542 additions and 353 deletions
1
.gitmodules
vendored
1
.gitmodules
vendored
|
@ -1 +0,0 @@
|
|||
|
|
@ -336,7 +336,8 @@ void OMW::Engine::go()
|
|||
|
||||
// Create the world
|
||||
mEnvironment.setWorld (new MWWorld::World (*mOgre, mFileCollections, mMaster,
|
||||
mResDir, mCfgMgr.getCachePath(), mNewGame, &encoder, mFallbackMap));
|
||||
mResDir, mCfgMgr.getCachePath(), mNewGame, &encoder, mFallbackMap,
|
||||
mActivationDistanceOverride));
|
||||
|
||||
//Load translation data
|
||||
mTranslationDataStorage.setEncoder(&encoder);
|
||||
|
@ -427,12 +428,7 @@ void OMW::Engine::activate()
|
|||
if (MWBase::Environment::get().getWindowManager()->isGuiMode())
|
||||
return;
|
||||
|
||||
std::string handle = MWBase::Environment::get().getWorld()->getFacedHandle();
|
||||
|
||||
if (handle.empty())
|
||||
return;
|
||||
|
||||
MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->searchPtrViaHandle (handle);
|
||||
MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getFacedObject();
|
||||
|
||||
if (ptr.isEmpty())
|
||||
return;
|
||||
|
@ -514,3 +510,9 @@ void OMW::Engine::setStartupScript (const std::string& path)
|
|||
{
|
||||
mStartupScript = path;
|
||||
}
|
||||
|
||||
|
||||
void OMW::Engine::setActivationDistanceOverride (int distance)
|
||||
{
|
||||
mActivationDistanceOverride = distance;
|
||||
}
|
||||
|
|
|
@ -76,6 +76,7 @@ namespace OMW
|
|||
std::map<std::string,std::string> mFallbackMap;
|
||||
bool mScriptConsoleMode;
|
||||
std::string mStartupScript;
|
||||
int mActivationDistanceOverride;
|
||||
|
||||
Compiler::Extensions mExtensions;
|
||||
Compiler::Context *mScriptContext;
|
||||
|
@ -167,6 +168,9 @@ namespace OMW
|
|||
/// Set path for a script that is run on startup in the console.
|
||||
void setStartupScript (const std::string& path);
|
||||
|
||||
/// Override the game setting specified activation distance.
|
||||
void setActivationDistanceOverride (int distance);
|
||||
|
||||
private:
|
||||
Files::ConfigurationManager& mCfgMgr;
|
||||
};
|
||||
|
|
|
@ -149,6 +149,8 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||
("fallback", bpo::value<FallbackMap>()->default_value(FallbackMap(), "")
|
||||
->multitoken()->composing(), "fallback values")
|
||||
|
||||
("activate-dist", bpo::value <int> ()->default_value (-1), "activation distance override");
|
||||
|
||||
;
|
||||
|
||||
bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv)
|
||||
|
@ -236,6 +238,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||
engine.setFallbackValues(variables["fallback"].as<FallbackMap>().mMap);
|
||||
engine.setScriptConsoleMode (variables["script-console"].as<bool>());
|
||||
engine.setStartupScript (variables["script-run"].as<std::string>());
|
||||
engine.setActivationDistanceOverride (variables["activate-dist"].as<int>());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -199,8 +199,8 @@ namespace MWBase
|
|||
|
||||
virtual void markCellAsUnchanged() = 0;
|
||||
|
||||
virtual std::string getFacedHandle() = 0;
|
||||
///< Return handle of the object the player is looking at
|
||||
virtual MWWorld::Ptr getFacedObject() = 0;
|
||||
///< Return pointer to the object the player is looking at, if it is within activation range
|
||||
|
||||
virtual void deleteObject (const MWWorld::Ptr& ptr) = 0;
|
||||
|
||||
|
|
|
@ -244,8 +244,7 @@ void HUD::onWorldClicked(MyGUI::Widget* _sender)
|
|||
if ( (mode != GM_Console) && (mode != GM_Container) && (mode != GM_Inventory) )
|
||||
return;
|
||||
|
||||
std::string handle = MWBase::Environment::get().getWorld()->getFacedHandle();
|
||||
MWWorld::Ptr object = MWBase::Environment::get().getWorld()->searchPtrViaHandle(handle);
|
||||
MWWorld::Ptr object = MWBase::Environment::get().getWorld()->getFacedObject();
|
||||
|
||||
if (mode == GM_Console)
|
||||
MWBase::Environment::get().getWindowManager()->getConsole()->setSelectedObject(object);
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace MWGui
|
|||
|
||||
setCoord(0, 342, 498, 258);
|
||||
|
||||
MWBase::Environment::get().getWorld ()->setupExternalRendering (mPreview);
|
||||
mPreview.setup();
|
||||
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
openContainer(player);
|
||||
|
|
|
@ -106,7 +106,7 @@ void RaceDialog::open()
|
|||
updateSpellPowers();
|
||||
|
||||
mPreview = new MWRender::RaceSelectionPreview();
|
||||
MWBase::Environment::get().getWorld ()->setupExternalRendering (*mPreview);
|
||||
mPreview->setup();
|
||||
mPreview->update (0);
|
||||
|
||||
const ESM::NPC proto = mPreview->getPrototype();
|
||||
|
|
|
@ -80,9 +80,8 @@ void ToolTips::onFrame(float frameDuration)
|
|||
|| (mWindowManager->getMode() == GM_Container)
|
||||
|| (mWindowManager->getMode() == GM_Inventory)))
|
||||
{
|
||||
std::string handle = MWBase::Environment::get().getWorld()->getFacedHandle();
|
||||
mFocusObject = MWBase::Environment::get().getWorld()->getFacedObject();
|
||||
|
||||
mFocusObject = MWBase::Environment::get().getWorld()->searchPtrViaHandle(handle);
|
||||
if (mFocusObject.isEmpty ())
|
||||
return;
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
|
||||
#include <OgreSceneManager.h>
|
||||
#include <OgreRoot.h>
|
||||
#include <OgreHardwarePixelBuffer.h>
|
||||
|
||||
#include <libs/openengine/ogre/selectionbuffer.hpp>
|
||||
|
@ -36,13 +37,18 @@ namespace MWRender
|
|||
|
||||
}
|
||||
|
||||
void CharacterPreview::setup (Ogre::SceneManager *sceneManager)
|
||||
void CharacterPreview::setup ()
|
||||
{
|
||||
mSceneMgr = sceneManager;
|
||||
mSceneMgr = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC);
|
||||
mCamera = mSceneMgr->createCamera (mName);
|
||||
mCamera->setAspectRatio (float(mSizeX) / float(mSizeY));
|
||||
|
||||
mNode = static_cast<Ogre::SceneNode*>(mSceneMgr->getRootSceneNode()->getChild("mwRoot"))->createChildSceneNode ();
|
||||
Ogre::SceneNode* renderRoot = mSceneMgr->getRootSceneNode()->createChildSceneNode("renderRoot");
|
||||
|
||||
//we do this with mwRoot in renderingManager, do it here too.
|
||||
renderRoot->pitch(Ogre::Degree(-90));
|
||||
|
||||
mNode = renderRoot->createChildSceneNode();
|
||||
|
||||
mAnimation = new NpcAnimation(mCharacter, mNode,
|
||||
MWWorld::Class::get(mCharacter).getInventoryStore (mCharacter), RV_PlayerPreview);
|
||||
|
@ -80,6 +86,7 @@ namespace MWRender
|
|||
//Ogre::TextureManager::getSingleton().remove(mName);
|
||||
mSceneMgr->destroyCamera (mName);
|
||||
delete mAnimation;
|
||||
Ogre::Root::getSingleton().destroySceneManager(mSceneMgr);
|
||||
}
|
||||
|
||||
void CharacterPreview::rebuild()
|
||||
|
|
|
@ -23,14 +23,14 @@ namespace MWRender
|
|||
|
||||
class NpcAnimation;
|
||||
|
||||
class CharacterPreview : public ExternalRendering
|
||||
class CharacterPreview
|
||||
{
|
||||
public:
|
||||
CharacterPreview(MWWorld::Ptr character, int sizeX, int sizeY, const std::string& name,
|
||||
Ogre::Vector3 position, Ogre::Vector3 lookAt);
|
||||
virtual ~CharacterPreview();
|
||||
|
||||
virtual void setup (Ogre::SceneManager *sceneManager);
|
||||
virtual void setup ();
|
||||
virtual void onSetup();
|
||||
|
||||
virtual void rebuild();
|
||||
|
|
|
@ -64,7 +64,8 @@ void Audiere_Decoder::open(const std::string &fname)
|
|||
close();
|
||||
|
||||
mSoundFile = audiere::FilePtr(new OgreFile(mResourceMgr.openResource(fname)));
|
||||
mSoundSource = audiere::OpenSampleSource(file);
|
||||
mSoundSource = audiere::OpenSampleSource(mSoundFile);
|
||||
mSoundFileName = fname;
|
||||
|
||||
int channels, srate;
|
||||
audiere::SampleFormat format;
|
||||
|
@ -95,7 +96,7 @@ void Audiere_Decoder::close()
|
|||
|
||||
std::string Audiere_Decoder::getName()
|
||||
{
|
||||
return mSoundFile->getName();
|
||||
return mSoundFileName;
|
||||
}
|
||||
|
||||
void Audiere_Decoder::getInfo(int *samplerate, ChannelConfig *chans, SampleType *type)
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace MWSound
|
|||
{
|
||||
class Audiere_Decoder : public Sound_Decoder
|
||||
{
|
||||
std::string mSoundFileName;
|
||||
audiere::FilePtr mSoundFile;
|
||||
audiere::SampleSourcePtr mSoundSource;
|
||||
int mSampleRate;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
||||
#include "inventorystore.hpp"
|
||||
#include "player.hpp"
|
||||
|
@ -15,8 +16,7 @@ namespace MWWorld
|
|||
|
||||
void ActionEquip::executeImp (const Ptr& actor)
|
||||
{
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
MWWorld::InventoryStore& invStore = MWWorld::Class::get(player).getInventoryStore(player);
|
||||
MWWorld::InventoryStore& invStore = MWWorld::Class::get(actor).getInventoryStore(actor);
|
||||
|
||||
// slots that this item can be equipped in
|
||||
std::pair<std::vector<int>, bool> slots = MWWorld::Class::get(getTarget()).getEquipmentSlots(getTarget());
|
||||
|
@ -32,11 +32,61 @@ namespace MWWorld
|
|||
}
|
||||
|
||||
assert(it != invStore.end());
|
||||
|
||||
std::string npcRace = actor.get<ESM::NPC>()->mBase->mRace;
|
||||
|
||||
// equip the item in the first free slot
|
||||
for (std::vector<int>::const_iterator slot=slots.first.begin();
|
||||
slot!=slots.first.end(); ++slot)
|
||||
{
|
||||
|
||||
// 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){
|
||||
std::vector<ESM::PartReference> parts;
|
||||
|
||||
if(it.getType() == MWWorld::ContainerStore::Type_Clothing)
|
||||
parts = it->get<ESM::Clothing>()->mBase->mParts.mParts;
|
||||
else
|
||||
parts = it->get<ESM::Armor>()->mBase->mParts.mParts;
|
||||
|
||||
bool allow = true;
|
||||
for(std::vector<ESM::PartReference>::iterator itr = parts.begin(); itr != parts.end(); ++itr)
|
||||
{
|
||||
if((*itr).mPart == ESM::PartReferenceType::PRT_Head)
|
||||
{
|
||||
if(actor == MWBase::Environment::get().getWorld()->getPlayer().getPlayer() )
|
||||
MWBase::Environment::get().getWindowManager()->messageBox ("#{sNotifyMessage13}", std::vector<std::string>());
|
||||
|
||||
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() )
|
||||
{
|
||||
if(it.getType() == MWWorld::ContainerStore::Type_Clothing){ // It's shoes
|
||||
MWBase::Environment::get().getWindowManager()->messageBox ("#{sNotifyMessage15}", std::vector<std::string>());
|
||||
}
|
||||
|
||||
else // It's boots
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->messageBox ("#{sNotifyMessage14}", std::vector<std::string>());
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// if all slots are occupied, replace the last slot
|
||||
if (slot == --slots.first.end())
|
||||
{
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace MWWorld
|
|||
return mEngine;
|
||||
}
|
||||
|
||||
std::pair<std::string, float> PhysicsSystem::getFacedHandle (MWWorld::World& world)
|
||||
std::pair<float, std::string> PhysicsSystem::getFacedHandle (MWWorld::World& world, float queryDistance)
|
||||
{
|
||||
btVector3 dir(0, 1, 0);
|
||||
dir = dir.rotate(btVector3(1, 0, 0), mPlayerData.pitch);
|
||||
|
@ -56,11 +56,14 @@ namespace MWWorld
|
|||
mPlayerData.eyepos.z);
|
||||
origin += dir * 5;
|
||||
|
||||
btVector3 dest = origin + dir * 500;
|
||||
return mEngine->rayTest(origin, dest);
|
||||
btVector3 dest = origin + dir * queryDistance;
|
||||
std::pair <std::string, float> result;
|
||||
/*auto*/ result = mEngine->rayTest(origin, dest);
|
||||
result.second *= queryDistance;
|
||||
return std::make_pair (result.second, result.first);
|
||||
}
|
||||
|
||||
std::vector < std::pair <float, std::string> > PhysicsSystem::getFacedObjects ()
|
||||
std::vector < std::pair <float, std::string> > PhysicsSystem::getFacedHandles (float queryDistance)
|
||||
{
|
||||
btVector3 dir(0, 1, 0);
|
||||
dir = dir.rotate(btVector3(1, 0, 0), mPlayerData.pitch);
|
||||
|
@ -73,22 +76,32 @@ namespace MWWorld
|
|||
mPlayerData.eyepos.z);
|
||||
origin += dir * 5;
|
||||
|
||||
btVector3 dest = origin + dir * 500;
|
||||
return mEngine->rayTest2(origin, dest);
|
||||
btVector3 dest = origin + dir * queryDistance;
|
||||
std::vector < std::pair <float, std::string> > results;
|
||||
/* auto */ results = mEngine->rayTest2(origin, dest);
|
||||
std::vector < std::pair <float, std::string> >::iterator i;
|
||||
for (/* auto */ i = results.begin (); i != results.end (); ++i)
|
||||
i->first *= queryDistance;
|
||||
return results;
|
||||
}
|
||||
|
||||
std::vector < std::pair <float, std::string> > PhysicsSystem::getFacedObjects (float mouseX, float mouseY)
|
||||
std::vector < std::pair <float, std::string> > PhysicsSystem::getFacedHandles (float mouseX, float mouseY, float queryDistance)
|
||||
{
|
||||
Ray ray = mRender.getCamera()->getCameraToViewportRay(mouseX, mouseY);
|
||||
Ogre::Vector3 from = ray.getOrigin();
|
||||
Ogre::Vector3 to = ray.getPoint(500); /// \todo make this distance (ray length) configurable
|
||||
Ogre::Vector3 to = ray.getPoint(queryDistance);
|
||||
|
||||
btVector3 _from, _to;
|
||||
// OGRE to MW coordinates
|
||||
_from = btVector3(from.x, -from.z, from.y);
|
||||
_to = btVector3(to.x, -to.z, to.y);
|
||||
|
||||
return mEngine->rayTest2(_from,_to);
|
||||
std::vector < std::pair <float, std::string> > results;
|
||||
/* auto */ results = mEngine->rayTest2(_from,_to);
|
||||
std::vector < std::pair <float, std::string> >::iterator i;
|
||||
for (/* auto */ i = results.begin (); i != results.end (); ++i)
|
||||
i->first *= queryDistance;
|
||||
return results;
|
||||
}
|
||||
|
||||
void PhysicsSystem::setCurrentWater(bool hasWater, int waterHeight)
|
||||
|
@ -110,7 +123,7 @@ namespace MWWorld
|
|||
Ray centerRay = mRender.getCamera()->getCameraToViewportRay(
|
||||
mRender.getViewport()->getWidth()/2,
|
||||
mRender.getViewport()->getHeight()/2);
|
||||
btVector3 result(centerRay.getPoint(500*extent).x,-centerRay.getPoint(500*extent).z,centerRay.getPoint(500*extent).y); /// \todo make this distance (ray length) configurable
|
||||
btVector3 result(centerRay.getPoint(extent).x,-centerRay.getPoint(extent).z,centerRay.getPoint(extent).y);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -118,7 +131,7 @@ namespace MWWorld
|
|||
{
|
||||
//get a ray pointing to the center of the viewport
|
||||
Ray centerRay = mRender.getCamera()->getCameraToViewportRay(mouseX, mouseY);
|
||||
btVector3 result(centerRay.getPoint(500*extent).x,-centerRay.getPoint(500*extent).z,centerRay.getPoint(500*extent).y); /// \todo make this distance (ray length) configurable
|
||||
btVector3 result(centerRay.getPoint(extent).x,-centerRay.getPoint(extent).z,centerRay.getPoint(extent).y);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,14 +41,13 @@ namespace MWWorld
|
|||
|
||||
bool toggleCollisionMode();
|
||||
|
||||
std::pair<std::string, float> getFacedHandle (MWWorld::World& world);
|
||||
std::pair<float, std::string> getFacedHandle (MWWorld::World& world, float queryDistance);
|
||||
std::vector < std::pair <float, std::string> > getFacedHandles (float queryDistance);
|
||||
std::vector < std::pair <float, std::string> > getFacedHandles (float mouseX, float mouseY, float queryDistance);
|
||||
|
||||
btVector3 getRayPoint(float extent);
|
||||
btVector3 getRayPoint(float extent, float mouseX, float mouseY);
|
||||
|
||||
std::vector < std::pair <float, std::string> > getFacedObjects ();
|
||||
|
||||
std::vector < std::pair <float, std::string> > getFacedObjects (float mouseX, float mouseY);
|
||||
|
||||
// cast ray, return true if it hit something
|
||||
bool castRay(const Ogre::Vector3& from, const Ogre::Vector3& to);
|
||||
|
|
|
@ -170,10 +170,10 @@ namespace MWWorld
|
|||
World::World (OEngine::Render::OgreRenderer& renderer,
|
||||
const Files::Collections& fileCollections,
|
||||
const std::string& master, const boost::filesystem::path& resDir, const boost::filesystem::path& cacheDir, bool newGame,
|
||||
ToUTF8::Utf8Encoder* encoder, std::map<std::string,std::string> fallbackMap)
|
||||
ToUTF8::Utf8Encoder* encoder, std::map<std::string,std::string> fallbackMap, int mActivationDistanceOverride)
|
||||
: mPlayer (0), mLocalScripts (mStore), mGlobalVariables (0),
|
||||
mSky (true), mCells (mStore, mEsm),
|
||||
mNumFacing(0)
|
||||
mNumFacing(0), mActivationDistanceOverride (mActivationDistanceOverride)
|
||||
{
|
||||
mPhysics = new PhysicsSystem(renderer);
|
||||
mPhysEngine = mPhysics->getEngine();
|
||||
|
@ -573,23 +573,55 @@ namespace MWWorld
|
|||
return mWorldScene->markCellAsUnchanged();
|
||||
}
|
||||
|
||||
std::string World::getFacedHandle()
|
||||
float World::getMaxActivationDistance ()
|
||||
{
|
||||
if (mActivationDistanceOverride >= 0)
|
||||
return mActivationDistanceOverride;
|
||||
|
||||
return (std::max) (getNpcActivationDistance (), getObjectActivationDistance ());
|
||||
}
|
||||
|
||||
float World::getNpcActivationDistance ()
|
||||
{
|
||||
if (mActivationDistanceOverride >= 0)
|
||||
return mActivationDistanceOverride;
|
||||
|
||||
return getStore().get<ESM::GameSetting>().find ("iMaxActivateDist")->getInt()*5/4;
|
||||
}
|
||||
|
||||
float World::getObjectActivationDistance ()
|
||||
{
|
||||
if (mActivationDistanceOverride >= 0)
|
||||
return mActivationDistanceOverride;
|
||||
|
||||
return getStore().get<ESM::GameSetting>().find ("iMaxActivateDist")->getInt();
|
||||
}
|
||||
|
||||
MWWorld::Ptr World::getFacedObject()
|
||||
{
|
||||
std::pair<float, std::string> result;
|
||||
|
||||
if (!mRendering->occlusionQuerySupported())
|
||||
{
|
||||
std::pair<std::string, float> result = mPhysics->getFacedHandle (*this);
|
||||
|
||||
if (result.first.empty() ||
|
||||
result.second>getStore().get<ESM::GameSetting>().find ("iMaxActivateDist")->getInt())
|
||||
return "";
|
||||
|
||||
return result.first;
|
||||
}
|
||||
result = mPhysics->getFacedHandle (*this, getMaxActivationDistance ());
|
||||
else
|
||||
{
|
||||
// updated every few frames in update()
|
||||
return mFacedHandle;
|
||||
}
|
||||
result = std::make_pair (mFacedDistance, mFacedHandle);
|
||||
|
||||
if (result.second.empty())
|
||||
return MWWorld::Ptr ();
|
||||
|
||||
MWWorld::Ptr object = searchPtrViaHandle (result.second);
|
||||
|
||||
float ActivationDistance;
|
||||
|
||||
if (object.getTypeName ().find("NPC") != std::string::npos)
|
||||
ActivationDistance = getNpcActivationDistance ();
|
||||
else
|
||||
ActivationDistance = getObjectActivationDistance ();
|
||||
|
||||
if (result.first > ActivationDistance)
|
||||
return MWWorld::Ptr ();
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
void World::deleteObject (const Ptr& ptr)
|
||||
|
@ -884,8 +916,6 @@ namespace MWWorld
|
|||
|
||||
void World::update (float duration, bool paused)
|
||||
{
|
||||
/// \todo split this function up into subfunctions
|
||||
|
||||
mWorldScene->update (duration, paused);
|
||||
|
||||
float pitch, yaw;
|
||||
|
@ -895,8 +925,15 @@ namespace MWWorld
|
|||
|
||||
mWeatherManager->update (duration);
|
||||
|
||||
performUpdateSceneQueries ();
|
||||
|
||||
updateWindowManager ();
|
||||
}
|
||||
|
||||
void World::updateWindowManager ()
|
||||
{
|
||||
// inform the GUI about focused object
|
||||
MWWorld::Ptr object = searchPtrViaHandle(mFacedHandle);
|
||||
MWWorld::Ptr object = getFacedObject ();
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->setFocusObject(object);
|
||||
|
||||
|
@ -918,7 +955,10 @@ namespace MWWorld
|
|||
screenCoords[0], screenCoords[1], screenCoords[2], screenCoords[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void World::performUpdateSceneQueries ()
|
||||
{
|
||||
if (!mRendering->occlusionQuerySupported())
|
||||
{
|
||||
// cast a ray from player to sun to detect if the sun is visible
|
||||
|
@ -937,121 +977,154 @@ namespace MWWorld
|
|||
MWRender::OcclusionQuery* query = mRendering->getOcclusionQuery();
|
||||
if (!query->occlusionTestPending())
|
||||
{
|
||||
// get result of last query
|
||||
if (mNumFacing == 0) mFacedHandle = "";
|
||||
else if (mNumFacing == 1)
|
||||
{
|
||||
bool result = query->getTestResult();
|
||||
mFacedHandle = result ? mFaced1Name : "";
|
||||
}
|
||||
else if (mNumFacing == 2)
|
||||
{
|
||||
bool result = query->getTestResult();
|
||||
mFacedHandle = result ? mFaced2Name : mFaced1Name;
|
||||
}
|
||||
|
||||
// send new query
|
||||
// figure out which object we want to test against
|
||||
std::vector < std::pair < float, std::string > > results;
|
||||
if (MWBase::Environment::get().getWindowManager()->isGuiMode())
|
||||
{
|
||||
float x, y;
|
||||
MWBase::Environment::get().getWindowManager()->getMousePosition(x, y);
|
||||
results = mPhysics->getFacedObjects(x, y);
|
||||
}
|
||||
else
|
||||
results = mPhysics->getFacedObjects();
|
||||
|
||||
// ignore the player and other things we're not interested in
|
||||
std::vector < std::pair < float, std::string > >::iterator it = results.begin();
|
||||
while (it != results.end())
|
||||
{
|
||||
if ( (*it).second.find("HeightField") != std::string::npos // not interested in terrain
|
||||
|| getPtrViaHandle((*it).second) == mPlayer->getPlayer() ) // not interested in player (unless you want to talk to yourself)
|
||||
{
|
||||
it = results.erase(it);
|
||||
}
|
||||
else
|
||||
++it;
|
||||
}
|
||||
|
||||
if (results.size() == 0)
|
||||
{
|
||||
mNumFacing = 0;
|
||||
}
|
||||
else if (results.size() == 1)
|
||||
{
|
||||
mFaced1 = getPtrViaHandle(results.front().second);
|
||||
mFaced1Name = results.front().second;
|
||||
mNumFacing = 1;
|
||||
|
||||
btVector3 p;
|
||||
if (MWBase::Environment::get().getWindowManager()->isGuiMode())
|
||||
{
|
||||
float x, y;
|
||||
MWBase::Environment::get().getWindowManager()->getMousePosition(x, y);
|
||||
p = mPhysics->getRayPoint(results.front().first, x, y);
|
||||
}
|
||||
else
|
||||
p = mPhysics->getRayPoint(results.front().first);
|
||||
Ogre::Vector3 pos(p.x(), p.z(), -p.y());
|
||||
Ogre::SceneNode* node = mFaced1.getRefData().getBaseNode();
|
||||
|
||||
//std::cout << "Num facing 1 : " << mFaced1Name << std::endl;
|
||||
//std::cout << "Type 1 " << mFaced1.getTypeName() << std::endl;
|
||||
|
||||
query->occlusionTest(pos, node);
|
||||
}
|
||||
else
|
||||
{
|
||||
mFaced1Name = results.front().second;
|
||||
mFaced2Name = results[1].second;
|
||||
mFaced1 = getPtrViaHandle(results.front().second);
|
||||
mFaced2 = getPtrViaHandle(results[1].second);
|
||||
mNumFacing = 2;
|
||||
|
||||
btVector3 p;
|
||||
if (MWBase::Environment::get().getWindowManager()->isGuiMode())
|
||||
{
|
||||
float x, y;
|
||||
MWBase::Environment::get().getWindowManager()->getMousePosition(x, y);
|
||||
p = mPhysics->getRayPoint(results[1].first, x, y);
|
||||
}
|
||||
else
|
||||
p = mPhysics->getRayPoint(results[1].first);
|
||||
Ogre::Vector3 pos(p.x(), p.z(), -p.y());
|
||||
Ogre::SceneNode* node1 = mFaced1.getRefData().getBaseNode();
|
||||
Ogre::SceneNode* node2 = mFaced2.getRefData().getBaseNode();
|
||||
|
||||
// no need to test if the first node is not occluder
|
||||
if (!query->isPotentialOccluder(node1) && (mFaced1.getTypeName().find("Static") == std::string::npos))
|
||||
{
|
||||
mFacedHandle = mFaced1Name;
|
||||
//std::cout << "node1 Not an occluder" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
// no need to test if the second object is static (thus cannot be activated)
|
||||
if (mFaced2.getTypeName().find("Static") != std::string::npos)
|
||||
{
|
||||
mFacedHandle = mFaced1Name;
|
||||
return;
|
||||
}
|
||||
|
||||
// work around door problems
|
||||
if (mFaced1.getTypeName().find("Static") != std::string::npos
|
||||
&& mFaced2.getTypeName().find("Door") != std::string::npos)
|
||||
{
|
||||
mFacedHandle = mFaced2Name;
|
||||
return;
|
||||
}
|
||||
|
||||
query->occlusionTest(pos, node2);
|
||||
}
|
||||
processFacedQueryResults (query);
|
||||
beginFacedQueryProcess (query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void World::processFacedQueryResults (MWRender::OcclusionQuery* query)
|
||||
{
|
||||
// get result of last query
|
||||
if (mNumFacing == 0)
|
||||
{
|
||||
mFacedHandle = "";
|
||||
mFacedDistance = FLT_MAX;
|
||||
}
|
||||
else if (mNumFacing == 1)
|
||||
{
|
||||
bool result = query->getTestResult();
|
||||
mFacedHandle = result ? mFaced1Name : "";
|
||||
mFacedDistance = result ? mFaced1Distance : FLT_MAX;
|
||||
}
|
||||
else if (mNumFacing == 2)
|
||||
{
|
||||
bool result = query->getTestResult();
|
||||
mFacedHandle = result ? mFaced2Name : mFaced1Name;
|
||||
mFacedDistance = result ? mFaced1Distance : mFaced1Distance;
|
||||
}
|
||||
}
|
||||
|
||||
void World::beginFacedQueryProcess (MWRender::OcclusionQuery* query)
|
||||
{
|
||||
// send new query
|
||||
// figure out which object we want to test against
|
||||
std::vector < std::pair < float, std::string > > results;
|
||||
if (MWBase::Environment::get().getWindowManager()->isGuiMode())
|
||||
{
|
||||
float x, y;
|
||||
MWBase::Environment::get().getWindowManager()->getMousePosition(x, y);
|
||||
results = mPhysics->getFacedHandles(x, y, getMaxActivationDistance ());
|
||||
}
|
||||
else
|
||||
{
|
||||
results = mPhysics->getFacedHandles(getMaxActivationDistance ());
|
||||
}
|
||||
|
||||
// ignore the player and other things we're not interested in
|
||||
std::vector < std::pair < float, std::string > >::iterator it = results.begin();
|
||||
while (it != results.end())
|
||||
{
|
||||
if ( (*it).second.find("HeightField") != std::string::npos // not interested in terrain
|
||||
|| getPtrViaHandle((*it).second) == mPlayer->getPlayer() ) // not interested in player (unless you want to talk to yourself)
|
||||
{
|
||||
it = results.erase(it);
|
||||
}
|
||||
else
|
||||
++it;
|
||||
}
|
||||
|
||||
if (results.size() == 0)
|
||||
{
|
||||
mNumFacing = 0;
|
||||
}
|
||||
else if (results.size() == 1)
|
||||
{
|
||||
beginSingleFacedQueryProcess (query, results);
|
||||
}
|
||||
else
|
||||
{
|
||||
beginDoubleFacedQueryProcess (query, results);
|
||||
}
|
||||
}
|
||||
|
||||
void World::beginSingleFacedQueryProcess (MWRender::OcclusionQuery* query, std::vector < std::pair < float, std::string > > const & results)
|
||||
{
|
||||
mFaced1 = getPtrViaHandle(results.front().second);
|
||||
mFaced1Name = results.front().second;
|
||||
mFaced1Distance = results.front().first;
|
||||
mNumFacing = 1;
|
||||
|
||||
btVector3 p;
|
||||
if (MWBase::Environment::get().getWindowManager()->isGuiMode())
|
||||
{
|
||||
float x, y;
|
||||
MWBase::Environment::get().getWindowManager()->getMousePosition(x, y);
|
||||
p = mPhysics->getRayPoint(results.front().first, x, y);
|
||||
}
|
||||
else
|
||||
p = mPhysics->getRayPoint(results.front().first);
|
||||
Ogre::Vector3 pos(p.x(), p.z(), -p.y());
|
||||
Ogre::SceneNode* node = mFaced1.getRefData().getBaseNode();
|
||||
|
||||
//std::cout << "Num facing 1 : " << mFaced1Name << std::endl;
|
||||
//std::cout << "Type 1 " << mFaced1.getTypeName() << std::endl;
|
||||
|
||||
query->occlusionTest(pos, node);
|
||||
}
|
||||
|
||||
void World::beginDoubleFacedQueryProcess (MWRender::OcclusionQuery* query, std::vector < std::pair < float, std::string > > const & results)
|
||||
{
|
||||
mFaced1Name = results.at (0).second;
|
||||
mFaced2Name = results.at (1).second;
|
||||
mFaced1Distance = results.at (0).first;
|
||||
mFaced2Distance = results.at (1).first;
|
||||
mFaced1 = getPtrViaHandle(results.at (0).second);
|
||||
mFaced2 = getPtrViaHandle(results.at (1).second);
|
||||
mNumFacing = 2;
|
||||
|
||||
btVector3 p;
|
||||
if (MWBase::Environment::get().getWindowManager()->isGuiMode())
|
||||
{
|
||||
float x, y;
|
||||
MWBase::Environment::get().getWindowManager()->getMousePosition(x, y);
|
||||
p = mPhysics->getRayPoint(results.at (1).first, x, y);
|
||||
}
|
||||
else
|
||||
p = mPhysics->getRayPoint(results.at (1).first);
|
||||
Ogre::Vector3 pos(p.x(), p.z(), -p.y());
|
||||
Ogre::SceneNode* node1 = mFaced1.getRefData().getBaseNode();
|
||||
Ogre::SceneNode* node2 = mFaced2.getRefData().getBaseNode();
|
||||
|
||||
// no need to test if the first node is not occluder
|
||||
if (!query->isPotentialOccluder(node1) && (mFaced1.getTypeName().find("Static") == std::string::npos))
|
||||
{
|
||||
mFacedHandle = mFaced1Name;
|
||||
mFacedDistance = mFaced1Distance;
|
||||
//std::cout << "node1 Not an occluder" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
// no need to test if the second object is static (thus cannot be activated)
|
||||
if (mFaced2.getTypeName().find("Static") != std::string::npos)
|
||||
{
|
||||
mFacedHandle = mFaced1Name;
|
||||
mFacedDistance = mFaced1Distance;
|
||||
return;
|
||||
}
|
||||
|
||||
// work around door problems
|
||||
if (mFaced1.getTypeName().find("Static") != std::string::npos
|
||||
&& mFaced2.getTypeName().find("Door") != std::string::npos)
|
||||
{
|
||||
mFacedHandle = mFaced2Name;
|
||||
mFacedDistance = mFaced2Distance;
|
||||
return;
|
||||
}
|
||||
|
||||
query->occlusionTest(pos, node2);
|
||||
}
|
||||
|
||||
bool World::isCellExterior() const
|
||||
{
|
||||
Ptr::CellStore *currentCell = mWorldScene->getCurrentCell();
|
||||
|
|
|
@ -71,11 +71,15 @@ namespace MWWorld
|
|||
|
||||
Ptr getPtrViaHandle (const std::string& handle, Ptr::CellStore& cellStore);
|
||||
|
||||
int mActivationDistanceOverride;
|
||||
std::string mFacedHandle;
|
||||
float mFacedDistance;
|
||||
Ptr mFaced1;
|
||||
Ptr mFaced2;
|
||||
std::string mFaced1Name;
|
||||
std::string mFaced2Name;
|
||||
float mFaced1Distance;
|
||||
float mFaced2Distance;
|
||||
int mNumFacing;
|
||||
std::map<std::string,std::string> mFallback;
|
||||
|
||||
|
@ -90,12 +94,23 @@ namespace MWWorld
|
|||
virtual void
|
||||
copyObjectToCell(const Ptr &ptr, CellStore &cell, const ESM::Position &pos);
|
||||
|
||||
void updateWindowManager ();
|
||||
void performUpdateSceneQueries ();
|
||||
void processFacedQueryResults (MWRender::OcclusionQuery* query);
|
||||
void beginFacedQueryProcess (MWRender::OcclusionQuery* query);
|
||||
void beginSingleFacedQueryProcess (MWRender::OcclusionQuery* query, std::vector < std::pair < float, std::string > > const & results);
|
||||
void beginDoubleFacedQueryProcess (MWRender::OcclusionQuery* query, std::vector < std::pair < float, std::string > > const & results);
|
||||
|
||||
float getMaxActivationDistance ();
|
||||
float getNpcActivationDistance ();
|
||||
float getObjectActivationDistance ();
|
||||
|
||||
public:
|
||||
|
||||
World (OEngine::Render::OgreRenderer& renderer,
|
||||
const Files::Collections& fileCollections,
|
||||
const std::string& master, const boost::filesystem::path& resDir, const boost::filesystem::path& cacheDir, bool newGame,
|
||||
ToUTF8::Utf8Encoder* encoder, std::map<std::string,std::string> fallbackMap);
|
||||
ToUTF8::Utf8Encoder* encoder, std::map<std::string,std::string> fallbackMap, int mActivationDistanceOverride);
|
||||
|
||||
virtual ~World();
|
||||
|
||||
|
@ -217,8 +232,8 @@ namespace MWWorld
|
|||
|
||||
virtual void markCellAsUnchanged();
|
||||
|
||||
virtual std::string getFacedHandle();
|
||||
///< Return handle of the object the player is looking at
|
||||
virtual MWWorld::Ptr getFacedObject();
|
||||
///< Return pointer to the object the player is looking at, if it is within activation range
|
||||
|
||||
virtual void deleteObject (const Ptr& ptr);
|
||||
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
#include <OgreArchiveManager.h>
|
||||
#include "bsa_file.hpp"
|
||||
|
||||
#include "../files/constrainedfiledatastream.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
|
@ -60,104 +62,64 @@ public:
|
|||
static bool fsstrict = false;
|
||||
|
||||
/// An OGRE Archive wrapping a BSAFile archive
|
||||
class DirArchive: public Ogre::FileSystemArchive
|
||||
class DirArchive: public Ogre::Archive
|
||||
{
|
||||
boost::filesystem::path currentdir;
|
||||
std::map<std::string, std::vector<std::string>, ciLessBoost> m;
|
||||
unsigned int cutoff;
|
||||
typedef std::map <std::string, std::string> index;
|
||||
|
||||
bool findFile(const String& filename, std::string& copy) const
|
||||
index mIndex;
|
||||
|
||||
static char strict_normalize_char(char ch)
|
||||
{
|
||||
copy = filename;
|
||||
std::replace(copy.begin(), copy.end(), '\\', '/');
|
||||
|
||||
if(copy.at(0) == '/')
|
||||
copy.erase(0, 1);
|
||||
|
||||
if(fsstrict == true)
|
||||
return true;
|
||||
|
||||
std::string folder;
|
||||
//int delimiter = 0;
|
||||
size_t lastSlash = copy.rfind('/');
|
||||
if (lastSlash != std::string::npos)
|
||||
{
|
||||
folder = copy.substr(0, lastSlash);
|
||||
//delimiter = lastSlash+1;
|
||||
}
|
||||
|
||||
std::vector<std::string> current;
|
||||
{
|
||||
std::map<std::string,std::vector<std::string>,ciLessBoost>::const_iterator found = m.find(folder);
|
||||
|
||||
if (found == m.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
current = found->second;
|
||||
}
|
||||
|
||||
std::vector<std::string>::iterator find = std::lower_bound(current.begin(), current.end(), copy, ciLessBoost());
|
||||
if (find != current.end() && !ciLessBoost()(copy, current.front()))
|
||||
{
|
||||
if (!boost::iequals(copy, *find))
|
||||
if ((find = std::find_if(current.begin(), current.end(), pathComparer(copy))) == current.end()) //\todo Check if this line is actually needed
|
||||
return false;
|
||||
|
||||
copy = *find;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return ch == '\\' ? '/' : ch;
|
||||
}
|
||||
|
||||
public:
|
||||
static char nonstrict_normalize_char(char ch)
|
||||
{
|
||||
return ch == '\\' ? '/' : std::tolower (ch);
|
||||
}
|
||||
|
||||
static std::string normalize_path (std::string::const_iterator begin, std::string::const_iterator end)
|
||||
{
|
||||
std::string normalized;
|
||||
normalized.reserve (end-begin);
|
||||
char (*normalize_char) (char) = fsstrict ? &strict_normalize_char : &nonstrict_normalize_char;
|
||||
std::transform (begin, end, std::back_inserter (normalized), normalize_char);
|
||||
return normalized;
|
||||
}
|
||||
|
||||
index::const_iterator lookup_filename (std::string const & filename) const
|
||||
{
|
||||
std::string normalized = normalize_path (filename.begin (), filename.end ());
|
||||
|
||||
return mIndex.find (normalized);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
DirArchive(const String& name)
|
||||
: FileSystemArchive(name, "Dir"), currentdir (name)
|
||||
: Archive(name, "Dir")
|
||||
{
|
||||
mType = "Dir";
|
||||
std::string s = name;
|
||||
cutoff = s.size() + 1;
|
||||
if(fsstrict == false)
|
||||
populateMap(currentdir);
|
||||
typedef boost::filesystem::recursive_directory_iterator directory_iterator;
|
||||
|
||||
}
|
||||
void populateMap(boost::filesystem::path d){
|
||||
//need to cut off first
|
||||
boost::filesystem::directory_iterator dir_iter(d), dir_end;
|
||||
std::vector<std::string> filesind;
|
||||
for(;dir_iter != dir_end; dir_iter++)
|
||||
{
|
||||
if(boost::filesystem::is_directory(*dir_iter))
|
||||
populateMap(*dir_iter);
|
||||
else
|
||||
directory_iterator end;
|
||||
|
||||
size_t prefix = name.size ();
|
||||
|
||||
if (name.size () > 0 && name [prefix - 1] != '\\' && name [prefix - 1] != '/')
|
||||
++prefix;
|
||||
|
||||
for (directory_iterator i (name); i != end; ++i)
|
||||
{
|
||||
std::string s = dir_iter->path().string();
|
||||
std::replace(s.begin(), s.end(), '\\', '/');
|
||||
if(boost::filesystem::is_directory (*i))
|
||||
continue;
|
||||
|
||||
std::string small;
|
||||
if(cutoff < s.size())
|
||||
small = s.substr(cutoff, s.size() - cutoff);
|
||||
else
|
||||
small = s.substr(cutoff - 1, s.size() - cutoff);
|
||||
std::string proper = i->path ().string ();
|
||||
|
||||
filesind.push_back(small);
|
||||
std::string searchable = normalize_path (proper.begin () + prefix, proper.end ());
|
||||
|
||||
mIndex.insert (std::make_pair (std::move (searchable), std::move (proper)));
|
||||
}
|
||||
}
|
||||
std::sort(filesind.begin(), filesind.end(), ciLessBoost());
|
||||
|
||||
std::string small;
|
||||
std::string original = d.string();
|
||||
std::replace(original.begin(), original.end(), '\\', '/');
|
||||
if(cutoff < original.size())
|
||||
small = original.substr(cutoff, original.size() - cutoff);
|
||||
else
|
||||
small = original.substr(cutoff - 1, original.size() - cutoff);
|
||||
|
||||
m[small] = filesind;
|
||||
}
|
||||
|
||||
bool isCaseSensitive() const { return fsstrict; }
|
||||
|
||||
|
@ -165,26 +127,76 @@ class DirArchive: public Ogre::FileSystemArchive
|
|||
void load() {}
|
||||
void unload() {}
|
||||
|
||||
bool exists(const String& filename) {
|
||||
std::string copy;
|
||||
|
||||
if (findFile(filename, copy))
|
||||
return FileSystemArchive::exists(copy);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
DataStreamPtr open(const String& filename, bool readonly = true) const
|
||||
{
|
||||
std::string copy;
|
||||
{
|
||||
index::const_iterator i = lookup_filename (filename);
|
||||
|
||||
if (findFile(filename, copy))
|
||||
return FileSystemArchive::open(copy, readonly);
|
||||
if (i == mIndex.end ())
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << "The file '" << filename << "' could not be found.";
|
||||
throw std::runtime_error (os.str ());
|
||||
}
|
||||
|
||||
DataStreamPtr p;
|
||||
return p;
|
||||
}
|
||||
return openConstrainedFileDataStream (i->second.c_str ());
|
||||
}
|
||||
|
||||
StringVectorPtr list(bool recursive = true, bool dirs = false)
|
||||
{
|
||||
StringVectorPtr ptr = StringVectorPtr(new StringVector());
|
||||
std::cout << "DirArchive<" << getName () << ">::list" << std::endl;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
FileInfoListPtr listFileInfo(bool recursive = true, bool dirs = false)
|
||||
{
|
||||
FileInfoListPtr ptr = FileInfoListPtr(new FileInfoList());
|
||||
std::cout << "DirArchive<" << getName () << ">::listFileInfo" << std::endl;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
StringVectorPtr find(const String& pattern, bool recursive = true,
|
||||
bool dirs = false)
|
||||
{
|
||||
StringVectorPtr ptr = StringVectorPtr(new StringVector());
|
||||
|
||||
if (pattern == "*")
|
||||
for (index::const_iterator i = mIndex.begin (); i != mIndex.end (); ++i)
|
||||
ptr->push_back (i->first);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
bool exists(const String& filename)
|
||||
{
|
||||
return lookup_filename (filename) != mIndex.end ();
|
||||
}
|
||||
|
||||
time_t getModifiedTime(const String&) { return 0; }
|
||||
|
||||
FileInfoListPtr findFileInfo(const String& pattern, bool recursive = true,
|
||||
bool dirs = false) const
|
||||
{
|
||||
FileInfoListPtr ptr = FileInfoListPtr(new FileInfoList());
|
||||
|
||||
index::const_iterator i = lookup_filename (pattern);
|
||||
|
||||
if (i != mIndex.end ())
|
||||
{
|
||||
FileInfo fi;
|
||||
|
||||
std::size_t npos = i->first.rfind ('/');
|
||||
|
||||
fi.archive = this;
|
||||
fi.filename = npos != std::string::npos ? i->first.substr (npos) : i->first;
|
||||
fi.path = npos != std::string::npos ? i->first.substr (0, npos) : "";
|
||||
fi.compressedSize = fi.uncompressedSize = 0;
|
||||
|
||||
ptr->push_back(fi);
|
||||
}
|
||||
|
||||
return ptr;
|
||||
}
|
||||
};
|
||||
|
||||
class BSAArchive : public Archive
|
||||
|
@ -249,6 +261,13 @@ public:
|
|||
//std::cout << "find(" << pattern << ", " << recursive
|
||||
// << ", " << dirs << ")\n";
|
||||
StringVectorPtr ptr = StringVectorPtr(new StringVector());
|
||||
|
||||
BSAFile::FileList const & files = arc.getList ();
|
||||
|
||||
if (pattern == "*")
|
||||
for (BSAFile::FileList::const_iterator i = files.begin (); i != files.end (); ++i)
|
||||
ptr->push_back (i->name);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
|
3
extern/shiny/CMakeLists.txt
vendored
3
extern/shiny/CMakeLists.txt
vendored
|
@ -70,3 +70,6 @@ endif()
|
|||
|
||||
|
||||
link_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
set(SHINY_LIBRARY ${SHINY_LIBRARY} PARENT_SCOPE)
|
||||
set(SHINY_OGREPLATFORM_LIBRARY ${SHINY_OGREPLATFORM_LIBRARY} PARENT_SCOPE)
|
||||
|
|
2
extern/shiny/Main/Factory.cpp
vendored
2
extern/shiny/Main/Factory.cpp
vendored
|
@ -224,7 +224,7 @@ namespace sh
|
|||
if (!mShadersEnabled)
|
||||
newInstance.setShadersEnabled (false);
|
||||
|
||||
newInstance.setSourceFile (it->second->m_fileName);
|
||||
newInstance.setSourceFile (it->second->mFileName);
|
||||
|
||||
std::vector<ScriptNode*> props = it->second->getChildren();
|
||||
for (std::vector<ScriptNode*>::const_iterator propIt = props.begin(); propIt != props.end(); ++propIt)
|
||||
|
|
8
extern/shiny/Main/MaterialInstance.cpp
vendored
8
extern/shiny/Main/MaterialInstance.cpp
vendored
|
@ -72,6 +72,8 @@ namespace sh
|
|||
allowFixedFunction = retrieveValue<BooleanValue>(getProperty("allow_fixed_function"), NULL).get();
|
||||
}
|
||||
|
||||
bool useShaders = mShadersEnabled || !allowFixedFunction;
|
||||
|
||||
// get passes of the top-most parent
|
||||
PassVector passes = getPasses();
|
||||
if (passes.size() == 0)
|
||||
|
@ -91,7 +93,7 @@ namespace sh
|
|||
// create or retrieve shaders
|
||||
bool hasVertex = it->hasProperty("vertex_program");
|
||||
bool hasFragment = it->hasProperty("fragment_program");
|
||||
if (mShadersEnabled || !allowFixedFunction)
|
||||
if (useShaders)
|
||||
{
|
||||
it->setContext(context);
|
||||
it->mShaderProperties.setContext(context);
|
||||
|
@ -144,7 +146,7 @@ namespace sh
|
|||
bool foundVertex = std::find(usedTextureSamplersVertex.begin(), usedTextureSamplersVertex.end(), texIt->getName()) != usedTextureSamplersVertex.end();
|
||||
bool foundFragment = std::find(usedTextureSamplersFragment.begin(), usedTextureSamplersFragment.end(), texIt->getName()) != usedTextureSamplersFragment.end();
|
||||
if ( (foundVertex || foundFragment)
|
||||
|| (((!mShadersEnabled || (!hasVertex || !hasFragment)) && allowFixedFunction) && texIt->hasProperty("create_in_ffp") && retrieveValue<BooleanValue>(texIt->getProperty("create_in_ffp"), this).get()))
|
||||
|| (((!useShaders || (!hasVertex || !hasFragment)) && allowFixedFunction) && texIt->hasProperty("create_in_ffp") && retrieveValue<BooleanValue>(texIt->getProperty("create_in_ffp"), this).get()))
|
||||
{
|
||||
boost::shared_ptr<TextureUnitState> texUnit = pass->createTextureUnitState ();
|
||||
texIt->copyAll (texUnit.get(), context);
|
||||
|
@ -152,7 +154,7 @@ namespace sh
|
|||
mTexUnits.push_back(texUnit);
|
||||
|
||||
// set texture unit indices (required by GLSL)
|
||||
if (mShadersEnabled && ((hasVertex && foundVertex) || (hasFragment && foundFragment)) && mFactory->getCurrentLanguage () == Language_GLSL)
|
||||
if (useShaders && ((hasVertex && foundVertex) || (hasFragment && foundFragment)) && mFactory->getCurrentLanguage () == Language_GLSL)
|
||||
{
|
||||
pass->setTextureUnitIndex (foundVertex ? GPT_Vertex : GPT_Fragment, texIt->getName(), i);
|
||||
|
||||
|
|
110
extern/shiny/Main/ScriptLoader.cpp
vendored
110
extern/shiny/Main/ScriptLoader.cpp
vendored
|
@ -14,9 +14,9 @@ namespace sh
|
|||
for ( boost::filesystem::recursive_directory_iterator end, dir(path); dir != end; ++dir )
|
||||
{
|
||||
boost::filesystem::path p(*dir);
|
||||
if(p.extension() == c->m_fileEnding)
|
||||
if(p.extension() == c->mFileEnding)
|
||||
{
|
||||
c->m_currentFileName = (*dir).path().string();
|
||||
c->mCurrentFileName = (*dir).path().string();
|
||||
std::ifstream in((*dir).path().string().c_str(), std::ios::binary);
|
||||
c->parseScript(in);
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace sh
|
|||
|
||||
ScriptLoader::ScriptLoader(const std::string& fileEnding)
|
||||
{
|
||||
m_fileEnding = fileEnding;
|
||||
mFileEnding = fileEnding;
|
||||
}
|
||||
|
||||
ScriptLoader::~ScriptLoader()
|
||||
|
@ -70,7 +70,7 @@ namespace sh
|
|||
{
|
||||
//Get first token
|
||||
_nextToken(stream);
|
||||
if (tok == TOKEN_EOF)
|
||||
if (mToken == TOKEN_EOF)
|
||||
{
|
||||
stream.close();
|
||||
return;
|
||||
|
@ -87,7 +87,7 @@ namespace sh
|
|||
//EOF token
|
||||
if (!stream.good())
|
||||
{
|
||||
tok = TOKEN_EOF;
|
||||
mToken = TOKEN_EOF;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ namespace sh
|
|||
|
||||
if (!stream.good())
|
||||
{
|
||||
tok = TOKEN_EOF;
|
||||
mToken = TOKEN_EOF;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -115,21 +115,21 @@ namespace sh
|
|||
|
||||
stream.unget();
|
||||
|
||||
tok = TOKEN_NewLine;
|
||||
mToken = TOKEN_NewLine;
|
||||
return;
|
||||
}
|
||||
|
||||
//Open brace token
|
||||
else if (ch == '{')
|
||||
{
|
||||
tok = TOKEN_OpenBrace;
|
||||
mToken = TOKEN_OpenBrace;
|
||||
return;
|
||||
}
|
||||
|
||||
//Close brace token
|
||||
else if (ch == '}')
|
||||
{
|
||||
tok = TOKEN_CloseBrace;
|
||||
mToken = TOKEN_CloseBrace;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -139,8 +139,8 @@ namespace sh
|
|||
throw std::runtime_error("Parse Error: Invalid character, ConfigLoader::load()");
|
||||
}
|
||||
|
||||
tokVal = "";
|
||||
tok = TOKEN_Text;
|
||||
mTokenValue = "";
|
||||
mToken = TOKEN_Text;
|
||||
do
|
||||
{
|
||||
//Skip comments
|
||||
|
@ -157,13 +157,13 @@ namespace sh
|
|||
ch = stream.get();
|
||||
} while (ch != '\r' && ch != '\n' && !stream.eof());
|
||||
|
||||
tok = TOKEN_NewLine;
|
||||
mToken = TOKEN_NewLine;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//Add valid char to tokVal
|
||||
tokVal += (char)ch;
|
||||
mTokenValue += (char)ch;
|
||||
|
||||
//Next char
|
||||
ch = stream.get();
|
||||
|
@ -177,7 +177,7 @@ namespace sh
|
|||
|
||||
void ScriptLoader::_skipNewLines(std::ifstream &stream)
|
||||
{
|
||||
while (tok == TOKEN_NewLine)
|
||||
while (mToken == TOKEN_NewLine)
|
||||
{
|
||||
_nextToken(stream);
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ namespace sh
|
|||
|
||||
while (true)
|
||||
{
|
||||
switch (tok)
|
||||
switch (mToken)
|
||||
{
|
||||
//Node
|
||||
case TOKEN_Text:
|
||||
|
@ -198,23 +198,23 @@ namespace sh
|
|||
ScriptNode *newNode;
|
||||
if (parent)
|
||||
{
|
||||
newNode = parent->addChild(tokVal);
|
||||
newNode = parent->addChild(mTokenValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
newNode = new ScriptNode(0, tokVal);
|
||||
newNode = new ScriptNode(0, mTokenValue);
|
||||
}
|
||||
|
||||
//Get values
|
||||
_nextToken(stream);
|
||||
std::string valueStr;
|
||||
int i=0;
|
||||
while (tok == TOKEN_Text)
|
||||
while (mToken == TOKEN_Text)
|
||||
{
|
||||
if (i == 0)
|
||||
valueStr += tokVal;
|
||||
valueStr += mTokenValue;
|
||||
else
|
||||
valueStr += " " + tokVal;
|
||||
valueStr += " " + mTokenValue;
|
||||
_nextToken(stream);
|
||||
++i;
|
||||
}
|
||||
|
@ -235,13 +235,13 @@ namespace sh
|
|||
_skipNewLines(stream);
|
||||
|
||||
//Add any sub-nodes
|
||||
if (tok == TOKEN_OpenBrace)
|
||||
if (mToken == TOKEN_OpenBrace)
|
||||
{
|
||||
//Parse nodes
|
||||
_nextToken(stream);
|
||||
_parseNodes(stream, newNode);
|
||||
//Check for matching closing brace
|
||||
if (tok != TOKEN_CloseBrace)
|
||||
if (mToken != TOKEN_CloseBrace)
|
||||
{
|
||||
throw std::runtime_error("Parse Error: Expecting closing brace");
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ namespace sh
|
|||
_skipNewLines(stream);
|
||||
}
|
||||
|
||||
newNode->m_fileName = m_currentFileName;
|
||||
newNode->mFileName = mCurrentFileName;
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -276,16 +276,16 @@ namespace sh
|
|||
|
||||
ScriptNode::ScriptNode(ScriptNode *parent, const std::string &name)
|
||||
{
|
||||
m_name = name;
|
||||
m_parent = parent;
|
||||
_removeSelf = true; //For proper destruction
|
||||
m_lastChildFound = -1;
|
||||
mName = name;
|
||||
mParent = parent;
|
||||
mRemoveSelf = true; //For proper destruction
|
||||
mLastChildFound = -1;
|
||||
|
||||
//Add self to parent's child list (unless this is the root node being created)
|
||||
if (parent != NULL)
|
||||
{
|
||||
m_parent->m_children.push_back(this);
|
||||
_iter = --(m_parent->m_children.end());
|
||||
mParent->mChildren.push_back(this);
|
||||
mIter = --(mParent->mChildren.end());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -293,18 +293,18 @@ namespace sh
|
|||
{
|
||||
//Delete all children
|
||||
std::vector<ScriptNode*>::iterator i;
|
||||
for (i = m_children.begin(); i != m_children.end(); i++)
|
||||
for (i = mChildren.begin(); i != mChildren.end(); i++)
|
||||
{
|
||||
ScriptNode *node = *i;
|
||||
node->_removeSelf = false;
|
||||
node->mRemoveSelf = false;
|
||||
delete node;
|
||||
}
|
||||
m_children.clear();
|
||||
mChildren.clear();
|
||||
|
||||
//Remove self from parent's child list
|
||||
if (_removeSelf && m_parent != NULL)
|
||||
if (mRemoveSelf && mParent != NULL)
|
||||
{
|
||||
m_parent->m_children.erase(_iter);
|
||||
mParent->mChildren.erase(mIter);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -324,20 +324,20 @@ namespace sh
|
|||
ScriptNode *ScriptNode::findChild(const std::string &name, bool recursive)
|
||||
{
|
||||
int indx, prevC, nextC;
|
||||
int childCount = (int)m_children.size();
|
||||
int childCount = (int)mChildren.size();
|
||||
|
||||
if (m_lastChildFound != -1)
|
||||
if (mLastChildFound != -1)
|
||||
{
|
||||
//If possible, try checking the nodes neighboring the last successful search
|
||||
//(often nodes searched for in sequence, so this will boost search speeds).
|
||||
prevC = m_lastChildFound-1; if (prevC < 0) prevC = 0; else if (prevC >= childCount) prevC = childCount-1;
|
||||
nextC = m_lastChildFound+1; if (nextC < 0) nextC = 0; else if (nextC >= childCount) nextC = childCount-1;
|
||||
prevC = mLastChildFound-1; if (prevC < 0) prevC = 0; else if (prevC >= childCount) prevC = childCount-1;
|
||||
nextC = mLastChildFound+1; if (nextC < 0) nextC = 0; else if (nextC >= childCount) nextC = childCount-1;
|
||||
for (indx = prevC; indx <= nextC; ++indx)
|
||||
{
|
||||
ScriptNode *node = m_children[indx];
|
||||
if (node->m_name == name)
|
||||
ScriptNode *node = mChildren[indx];
|
||||
if (node->mName == name)
|
||||
{
|
||||
m_lastChildFound = indx;
|
||||
mLastChildFound = indx;
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
@ -346,17 +346,17 @@ namespace sh
|
|||
//already searched area above.
|
||||
for (indx = nextC + 1; indx < childCount; ++indx)
|
||||
{
|
||||
ScriptNode *node = m_children[indx];
|
||||
if (node->m_name == name) {
|
||||
m_lastChildFound = indx;
|
||||
ScriptNode *node = mChildren[indx];
|
||||
if (node->mName == name) {
|
||||
mLastChildFound = indx;
|
||||
return node;
|
||||
}
|
||||
}
|
||||
for (indx = 0; indx < prevC; ++indx)
|
||||
{
|
||||
ScriptNode *node = m_children[indx];
|
||||
if (node->m_name == name) {
|
||||
m_lastChildFound = indx;
|
||||
ScriptNode *node = mChildren[indx];
|
||||
if (node->mName == name) {
|
||||
mLastChildFound = indx;
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
@ -365,9 +365,9 @@ namespace sh
|
|||
{
|
||||
//Search for the node from start to finish
|
||||
for (indx = 0; indx < childCount; ++indx){
|
||||
ScriptNode *node = m_children[indx];
|
||||
if (node->m_name == name) {
|
||||
m_lastChildFound = indx;
|
||||
ScriptNode *node = mChildren[indx];
|
||||
if (node->mName == name) {
|
||||
mLastChildFound = indx;
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ namespace sh
|
|||
{
|
||||
for (indx = 0; indx < childCount; ++indx)
|
||||
{
|
||||
m_children[indx]->findChild(name, recursive);
|
||||
mChildren[indx]->findChild(name, recursive);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -389,13 +389,13 @@ namespace sh
|
|||
void ScriptNode::setParent(ScriptNode *newParent)
|
||||
{
|
||||
//Remove self from current parent
|
||||
m_parent->m_children.erase(_iter);
|
||||
mParent->mChildren.erase(mIter);
|
||||
|
||||
//Set new parent
|
||||
m_parent = newParent;
|
||||
mParent = newParent;
|
||||
|
||||
//Add self to new parent
|
||||
m_parent->m_children.push_back(this);
|
||||
_iter = --(m_parent->m_children.end());
|
||||
mParent->mChildren.push_back(this);
|
||||
mIter = --(mParent->mChildren.end());
|
||||
}
|
||||
}
|
||||
|
|
42
extern/shiny/Main/ScriptLoader.hpp
vendored
42
extern/shiny/Main/ScriptLoader.hpp
vendored
|
@ -23,7 +23,7 @@ namespace sh
|
|||
ScriptLoader(const std::string& fileEnding);
|
||||
virtual ~ScriptLoader();
|
||||
|
||||
std::string m_fileEnding;
|
||||
std::string mFileEnding;
|
||||
|
||||
// For a line like
|
||||
// entity animals/dog
|
||||
|
@ -38,11 +38,11 @@ namespace sh
|
|||
|
||||
void parseScript(std::ifstream &stream);
|
||||
|
||||
std::string m_currentFileName;
|
||||
std::string mCurrentFileName;
|
||||
|
||||
protected:
|
||||
|
||||
float m_LoadOrder;
|
||||
float mLoadOrder;
|
||||
// like "*.object"
|
||||
|
||||
std::map <std::string, ScriptNode*> m_scriptList;
|
||||
|
@ -56,8 +56,8 @@ namespace sh
|
|||
TOKEN_EOF
|
||||
};
|
||||
|
||||
Token tok, lastTok;
|
||||
std::string tokVal;
|
||||
Token mToken, mLastToken;
|
||||
std::string mTokenValue;
|
||||
|
||||
void _parseNodes(std::ifstream &stream, ScriptNode *parent);
|
||||
void _nextToken(std::ifstream &stream);
|
||||
|
@ -74,22 +74,22 @@ namespace sh
|
|||
|
||||
inline void setName(const std::string &name)
|
||||
{
|
||||
this->m_name = name;
|
||||
this->mName = name;
|
||||
}
|
||||
|
||||
inline std::string &getName()
|
||||
{
|
||||
return m_name;
|
||||
return mName;
|
||||
}
|
||||
|
||||
inline void setValue(const std::string &value)
|
||||
{
|
||||
m_value = value;
|
||||
mValue = value;
|
||||
}
|
||||
|
||||
inline std::string &getValue()
|
||||
{
|
||||
return m_value;
|
||||
return mValue;
|
||||
}
|
||||
|
||||
ScriptNode *addChild(const std::string &name = "untitled", bool replaceExisting = false);
|
||||
|
@ -97,36 +97,36 @@ namespace sh
|
|||
|
||||
inline std::vector<ScriptNode*> &getChildren()
|
||||
{
|
||||
return m_children;
|
||||
return mChildren;
|
||||
}
|
||||
|
||||
inline ScriptNode *getChild(unsigned int index = 0)
|
||||
{
|
||||
assert(index < m_children.size());
|
||||
return m_children[index];
|
||||
assert(index < mChildren.size());
|
||||
return mChildren[index];
|
||||
}
|
||||
|
||||
void setParent(ScriptNode *newParent);
|
||||
|
||||
inline ScriptNode *getParent()
|
||||
{
|
||||
return m_parent;
|
||||
return mParent;
|
||||
}
|
||||
|
||||
std::string m_fileName;
|
||||
std::string mFileName;
|
||||
|
||||
|
||||
private:
|
||||
std::string m_name;
|
||||
std::string m_value;
|
||||
std::vector<ScriptNode*> m_children;
|
||||
ScriptNode *m_parent;
|
||||
std::string mName;
|
||||
std::string mValue;
|
||||
std::vector<ScriptNode*> mChildren;
|
||||
ScriptNode *mParent;
|
||||
|
||||
|
||||
int m_lastChildFound; //The last child node's index found with a call to findChild()
|
||||
int mLastChildFound; //The last child node's index found with a call to findChild()
|
||||
|
||||
std::vector<ScriptNode*>::iterator _iter;
|
||||
bool _removeSelf;
|
||||
std::vector<ScriptNode*>::iterator mIter;
|
||||
bool mRemoveSelf;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue