mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 15:15:31 +00:00
Merge pull request #2192 from Capostrophic/bzzt
Port minor fixes from bzzt's branch
This commit is contained in:
commit
12cef51122
15 changed files with 31 additions and 27 deletions
|
@ -1436,7 +1436,7 @@ namespace MWRender
|
|||
return sceneMgr->createInstance(found->second);
|
||||
}
|
||||
else
|
||||
return sceneMgr->createInstance(model);
|
||||
return sceneMgr->getInstance(model);
|
||||
}
|
||||
|
||||
void Animation::setObjectRoot(const std::string &model, bool forceskeleton, bool baseonly, bool isCreature)
|
||||
|
|
|
@ -409,7 +409,8 @@ namespace MWWorld
|
|||
if (getPlayerPtr().isInCell())
|
||||
{
|
||||
mWorldScene->preloadCell(getPlayerPtr().getCell(), true);
|
||||
mWorldScene->preloadTerrain(getPlayerPtr().getRefData().getPosition().asVec3());
|
||||
if (getPlayerPtr().getCell()->isExterior())
|
||||
mWorldScene->preloadTerrain(getPlayerPtr().getRefData().getPosition().asVec3());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -244,10 +244,8 @@ namespace NifOsg
|
|||
osg::ref_ptr<NifOsg::KeyframeController> callback(new NifOsg::KeyframeController(key->data.getPtr()));
|
||||
callback->setFunction(std::shared_ptr<NifOsg::ControllerFunction>(new NifOsg::ControllerFunction(key)));
|
||||
|
||||
if (target.mKeyframeControllers.find(strdata->string) != target.mKeyframeControllers.end())
|
||||
if (!target.mKeyframeControllers.emplace(strdata->string, callback).second)
|
||||
Log(Debug::Verbose) << "Controller " << strdata->string << " present more than once in " << nif->getFilename() << ", ignoring later version";
|
||||
else
|
||||
target.mKeyframeControllers[strdata->string] = callback;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,10 +75,11 @@ void ObjectCache::updateTimeStampOfObjectsInCacheWithExternalReferences(double r
|
|||
itr!=_objectCache.end();
|
||||
++itr)
|
||||
{
|
||||
// if ref count is greater the 1 the object has an external reference.
|
||||
if (itr->second.first->referenceCount()>1)
|
||||
// If ref count is greater than 1, the object has an external reference.
|
||||
// If the timestamp is yet to be initialized, it needs to be updated too.
|
||||
if (itr->second.first->referenceCount()>1 || itr->second.second == 0.0)
|
||||
{
|
||||
// so update it time stamp.
|
||||
// So update it.
|
||||
itr->second.second = referenceTime;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -729,6 +729,7 @@ namespace Resource
|
|||
|
||||
void SceneManager::reportStats(unsigned int frameNumber, osg::Stats *stats) const
|
||||
{
|
||||
if (mIncrementalCompileOperation)
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(*mIncrementalCompileOperation->getToCompiledMutex());
|
||||
stats->setAttribute(frameNumber, "Compiling", mIncrementalCompileOperation->getToCompile().size());
|
||||
|
|
|
@ -234,6 +234,7 @@ namespace SceneUtil
|
|||
{
|
||||
osg::ref_ptr<osg::StateSet> stateset = new osg::StateSet;
|
||||
std::vector<osg::ref_ptr<osg::Light> > lights;
|
||||
lights.reserve(lightList.size());
|
||||
for (unsigned int i=0; i<lightList.size();++i)
|
||||
{
|
||||
lights.push_back(lightList[i]->mLightSource->getLight(frameNum));
|
||||
|
|
|
@ -61,10 +61,7 @@ namespace SceneUtil
|
|||
{
|
||||
// Take transformation for first found node in file
|
||||
const std::string nodeName = Misc::StringUtils::lowerCase(trans.getName());
|
||||
if (mMap.find(nodeName) == mMap.end())
|
||||
{
|
||||
mMap[nodeName] = &trans;
|
||||
}
|
||||
mMap.emplace(nodeName, &trans);
|
||||
|
||||
traverse(trans);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "world.hpp"
|
||||
#include "../esm/loadland.hpp"
|
||||
|
||||
namespace MWRender
|
||||
namespace Terrain
|
||||
{
|
||||
|
||||
CellBorder::CellBorder(Terrain::World *world, osg::Group *root, int borderMask):
|
||||
|
|
|
@ -7,10 +7,7 @@
|
|||
namespace Terrain
|
||||
{
|
||||
class World;
|
||||
}
|
||||
|
||||
namespace MWRender
|
||||
{
|
||||
/**
|
||||
* @Brief Handles the debug cell borders.
|
||||
*/
|
||||
|
|
|
@ -122,6 +122,8 @@ void CompositeMapRenderer::compile(CompositeMap &compositeMap, osg::RenderInfo &
|
|||
|
||||
++compositeMap.mCompiled;
|
||||
|
||||
compositeMap.mDrawables[i] = nullptr;
|
||||
|
||||
if (timeLeft)
|
||||
{
|
||||
*timeLeft -= timer.time_s();
|
||||
|
@ -131,6 +133,8 @@ void CompositeMapRenderer::compile(CompositeMap &compositeMap, osg::RenderInfo &
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (compositeMap.mCompiled == compositeMap.mDrawables.size())
|
||||
compositeMap.mDrawables = std::vector<osg::ref_ptr<osg::Drawable>>();
|
||||
|
||||
state.haveAppliedAttribute(osg::StateAttribute::VIEWPORT);
|
||||
|
||||
|
|
|
@ -163,25 +163,29 @@ public:
|
|||
boundingBox.expandBy(child->getBoundingBox());
|
||||
}
|
||||
|
||||
parent->setBoundingBox(boundingBox);
|
||||
if (!boundingBox.valid())
|
||||
parent->removeChildren(0, 4);
|
||||
else
|
||||
parent->setBoundingBox(boundingBox);
|
||||
}
|
||||
|
||||
QuadTreeNode* addChild(QuadTreeNode* parent, ChildDirection direction, float size)
|
||||
{
|
||||
float halfSize = size/2.f;
|
||||
osg::Vec2f center;
|
||||
switch (direction)
|
||||
{
|
||||
case SW:
|
||||
center = parent->getCenter() + osg::Vec2f(-size/2.f,-size/2.f);
|
||||
center = parent->getCenter() + osg::Vec2f(-halfSize,-halfSize);
|
||||
break;
|
||||
case SE:
|
||||
center = parent->getCenter() + osg::Vec2f(size/2.f, -size/2.f);
|
||||
center = parent->getCenter() + osg::Vec2f(halfSize, -halfSize);
|
||||
break;
|
||||
case NW:
|
||||
center = parent->getCenter() + osg::Vec2f(-size/2.f, size/2.f);
|
||||
center = parent->getCenter() + osg::Vec2f(-halfSize, halfSize);
|
||||
break;
|
||||
case NE:
|
||||
center = parent->getCenter() + osg::Vec2f(size/2.f, size/2.f);
|
||||
center = parent->getCenter() + osg::Vec2f(halfSize, halfSize);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -203,8 +207,8 @@ public:
|
|||
mStorage->getMinMaxHeights(size, center, minZ, maxZ);
|
||||
|
||||
float cellWorldSize = mStorage->getCellWorldSize();
|
||||
osg::BoundingBox boundingBox(osg::Vec3f((center.x()-size)*cellWorldSize, (center.y()-size)*cellWorldSize, minZ),
|
||||
osg::Vec3f((center.x()+size)*cellWorldSize, (center.y()+size)*cellWorldSize, maxZ));
|
||||
osg::BoundingBox boundingBox(osg::Vec3f((center.x()-halfSize)*cellWorldSize, (center.y()-halfSize)*cellWorldSize, minZ),
|
||||
osg::Vec3f((center.x()+halfSize)*cellWorldSize, (center.y()+halfSize)*cellWorldSize, maxZ));
|
||||
node->setBoundingBox(boundingBox);
|
||||
|
||||
return node;
|
||||
|
|
|
@ -84,7 +84,7 @@ void TerrainGrid::loadCell(int x, int y)
|
|||
|
||||
void TerrainGrid::unloadCell(int x, int y)
|
||||
{
|
||||
MWRender::CellBorder::CellGrid::iterator it = mGrid.find(std::make_pair(x,y));
|
||||
CellBorder::CellGrid::iterator it = mGrid.find(std::make_pair(x,y));
|
||||
if (it == mGrid.end())
|
||||
return;
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace Terrain
|
|||
// split each ESM::Cell into mNumSplits*mNumSplits terrain chunks
|
||||
unsigned int mNumSplits;
|
||||
|
||||
MWRender::CellBorder::CellGrid mGrid;
|
||||
CellBorder::CellGrid mGrid;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ World::World(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSyst
|
|||
|
||||
mTextureManager.reset(new TextureManager(mResourceSystem->getSceneManager()));
|
||||
mChunkManager.reset(new ChunkManager(mStorage, mResourceSystem->getSceneManager(), mTextureManager.get(), mCompositeMapRenderer));
|
||||
mCellBorder.reset(new MWRender::CellBorder(this,mTerrainRoot.get(),borderMask));
|
||||
mCellBorder.reset(new CellBorder(this,mTerrainRoot.get(),borderMask));
|
||||
|
||||
mResourceSystem->addResourceManager(mChunkManager.get());
|
||||
mResourceSystem->addResourceManager(mTextureManager.get());
|
||||
|
|
|
@ -116,7 +116,7 @@ namespace Terrain
|
|||
std::unique_ptr<TextureManager> mTextureManager;
|
||||
std::unique_ptr<ChunkManager> mChunkManager;
|
||||
|
||||
std::unique_ptr<MWRender::CellBorder> mCellBorder;
|
||||
std::unique_ptr<CellBorder> mCellBorder;
|
||||
|
||||
bool mBorderVisible;
|
||||
|
||||
|
|
Loading…
Reference in a new issue