rescale all objects to the range of [0.5, 2] when a cell becomes active

This commit is contained in:
Marc Zinnschlag 2013-03-10 10:00:20 +01:00
parent 5e113627b7
commit 6cef7fb610
2 changed files with 38 additions and 29 deletions

View file

@ -21,7 +21,7 @@ namespace
template<typename T> template<typename T>
void insertCellRefList(MWRender::RenderingManager& rendering, void insertCellRefList(MWRender::RenderingManager& rendering,
T& cellRefList, MWWorld::CellStore &cell, MWWorld::PhysicsSystem& physics) T& cellRefList, MWWorld::CellStore &cell, MWWorld::PhysicsSystem& physics, bool rescale)
{ {
if (!cellRefList.mList.empty()) if (!cellRefList.mList.empty())
{ {
@ -31,6 +31,14 @@ namespace
for (typename T::List::iterator it = cellRefList.mList.begin(); for (typename T::List::iterator it = cellRefList.mList.begin();
it != cellRefList.mList.end(); it++) it != cellRefList.mList.end(); it++)
{ {
if (rescale)
{
if (it->mRef.mScale<0.5)
it->mRef.mScale = 0.5;
else if (it->mRef.mScale>2)
it->mRef.mScale = 2;
}
++current; ++current;
if (it->mData.getCount() || it->mData.isEnabled()) if (it->mData.getCount() || it->mData.isEnabled())
@ -107,7 +115,9 @@ namespace MWWorld
if(result.second) if(result.second)
{ {
insertCell(*cell); /// \todo rescale depending on the state of a new GMST
insertCell (*cell, true);
mRendering.cellAdded (cell); mRendering.cellAdded (cell);
float verts = ESM::Land::LAND_SIZE; float verts = ESM::Land::LAND_SIZE;
@ -415,29 +425,29 @@ namespace MWWorld
mCellChanged = false; mCellChanged = false;
} }
void Scene::insertCell (Ptr::CellStore &cell) void Scene::insertCell (Ptr::CellStore &cell, bool rescale)
{ {
// Loop through all references in the cell // Loop through all references in the cell
insertCellRefList(mRendering, cell.mActivators, cell, *mPhysics); insertCellRefList(mRendering, cell.mActivators, cell, *mPhysics, rescale);
insertCellRefList(mRendering, cell.mPotions, cell, *mPhysics); insertCellRefList(mRendering, cell.mPotions, cell, *mPhysics, rescale);
insertCellRefList(mRendering, cell.mAppas, cell, *mPhysics); insertCellRefList(mRendering, cell.mAppas, cell, *mPhysics, rescale);
insertCellRefList(mRendering, cell.mArmors, cell, *mPhysics); insertCellRefList(mRendering, cell.mArmors, cell, *mPhysics, rescale);
insertCellRefList(mRendering, cell.mBooks, cell, *mPhysics); insertCellRefList(mRendering, cell.mBooks, cell, *mPhysics, rescale);
insertCellRefList(mRendering, cell.mClothes, cell, *mPhysics); insertCellRefList(mRendering, cell.mClothes, cell, *mPhysics, rescale);
insertCellRefList(mRendering, cell.mContainers, cell, *mPhysics); insertCellRefList(mRendering, cell.mContainers, cell, *mPhysics, rescale);
insertCellRefList(mRendering, cell.mCreatures, cell, *mPhysics); insertCellRefList(mRendering, cell.mCreatures, cell, *mPhysics, rescale);
insertCellRefList(mRendering, cell.mDoors, cell, *mPhysics); insertCellRefList(mRendering, cell.mDoors, cell, *mPhysics, rescale);
insertCellRefList(mRendering, cell.mIngreds, cell, *mPhysics); insertCellRefList(mRendering, cell.mIngreds, cell, *mPhysics, rescale);
insertCellRefList(mRendering, cell.mCreatureLists, cell, *mPhysics); insertCellRefList(mRendering, cell.mCreatureLists, cell, *mPhysics, rescale);
insertCellRefList(mRendering, cell.mItemLists, cell, *mPhysics); insertCellRefList(mRendering, cell.mItemLists, cell, *mPhysics, rescale);
insertCellRefList(mRendering, cell.mLights, cell, *mPhysics); insertCellRefList(mRendering, cell.mLights, cell, *mPhysics, rescale);
insertCellRefList(mRendering, cell.mLockpicks, cell, *mPhysics); insertCellRefList(mRendering, cell.mLockpicks, cell, *mPhysics, rescale);
insertCellRefList(mRendering, cell.mMiscItems, cell, *mPhysics); insertCellRefList(mRendering, cell.mMiscItems, cell, *mPhysics, rescale);
insertCellRefList(mRendering, cell.mNpcs, cell, *mPhysics); insertCellRefList(mRendering, cell.mNpcs, cell, *mPhysics, rescale);
insertCellRefList(mRendering, cell.mProbes, cell, *mPhysics); insertCellRefList(mRendering, cell.mProbes, cell, *mPhysics, rescale);
insertCellRefList(mRendering, cell.mRepairs, cell, *mPhysics); insertCellRefList(mRendering, cell.mRepairs, cell, *mPhysics, rescale);
insertCellRefList(mRendering, cell.mStatics, cell, *mPhysics); insertCellRefList(mRendering, cell.mStatics, cell, *mPhysics, rescale);
insertCellRefList(mRendering, cell.mWeapons, cell, *mPhysics); insertCellRefList(mRendering, cell.mWeapons, cell, *mPhysics, rescale);
} }
void Scene::addObjectToScene (const Ptr& ptr) void Scene::addObjectToScene (const Ptr& ptr)

View file

@ -56,6 +56,7 @@ namespace MWWorld
void playerCellChange (CellStore *cell, const ESM::Position& position, void playerCellChange (CellStore *cell, const ESM::Position& position,
bool adjustPlayerPos = true); bool adjustPlayerPos = true);
void insertCell (Ptr::CellStore &cell, bool rescale);
public: public:
@ -86,8 +87,6 @@ namespace MWWorld
void markCellAsUnchanged(); void markCellAsUnchanged();
void insertCell (Ptr::CellStore &cell);
void update (float duration, bool paused); void update (float duration, bool paused);
void addObjectToScene (const Ptr& ptr); void addObjectToScene (const Ptr& ptr);