mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 07:23:51 +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);
|
return sceneMgr->createInstance(found->second);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return sceneMgr->createInstance(model);
|
return sceneMgr->getInstance(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animation::setObjectRoot(const std::string &model, bool forceskeleton, bool baseonly, bool isCreature)
|
void Animation::setObjectRoot(const std::string &model, bool forceskeleton, bool baseonly, bool isCreature)
|
||||||
|
|
|
@ -409,6 +409,7 @@ namespace MWWorld
|
||||||
if (getPlayerPtr().isInCell())
|
if (getPlayerPtr().isInCell())
|
||||||
{
|
{
|
||||||
mWorldScene->preloadCell(getPlayerPtr().getCell(), true);
|
mWorldScene->preloadCell(getPlayerPtr().getCell(), true);
|
||||||
|
if (getPlayerPtr().getCell()->isExterior())
|
||||||
mWorldScene->preloadTerrain(getPlayerPtr().getRefData().getPosition().asVec3());
|
mWorldScene->preloadTerrain(getPlayerPtr().getRefData().getPosition().asVec3());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -244,10 +244,8 @@ namespace NifOsg
|
||||||
osg::ref_ptr<NifOsg::KeyframeController> callback(new NifOsg::KeyframeController(key->data.getPtr()));
|
osg::ref_ptr<NifOsg::KeyframeController> callback(new NifOsg::KeyframeController(key->data.getPtr()));
|
||||||
callback->setFunction(std::shared_ptr<NifOsg::ControllerFunction>(new NifOsg::ControllerFunction(key)));
|
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";
|
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!=_objectCache.end();
|
||||||
++itr)
|
++itr)
|
||||||
{
|
{
|
||||||
// if ref count is greater the 1 the object has an external reference.
|
// If ref count is greater than 1, the object has an external reference.
|
||||||
if (itr->second.first->referenceCount()>1)
|
// 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;
|
itr->second.second = referenceTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -729,6 +729,7 @@ namespace Resource
|
||||||
|
|
||||||
void SceneManager::reportStats(unsigned int frameNumber, osg::Stats *stats) const
|
void SceneManager::reportStats(unsigned int frameNumber, osg::Stats *stats) const
|
||||||
{
|
{
|
||||||
|
if (mIncrementalCompileOperation)
|
||||||
{
|
{
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(*mIncrementalCompileOperation->getToCompiledMutex());
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(*mIncrementalCompileOperation->getToCompiledMutex());
|
||||||
stats->setAttribute(frameNumber, "Compiling", mIncrementalCompileOperation->getToCompile().size());
|
stats->setAttribute(frameNumber, "Compiling", mIncrementalCompileOperation->getToCompile().size());
|
||||||
|
|
|
@ -234,6 +234,7 @@ namespace SceneUtil
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::StateSet> stateset = new osg::StateSet;
|
osg::ref_ptr<osg::StateSet> stateset = new osg::StateSet;
|
||||||
std::vector<osg::ref_ptr<osg::Light> > lights;
|
std::vector<osg::ref_ptr<osg::Light> > lights;
|
||||||
|
lights.reserve(lightList.size());
|
||||||
for (unsigned int i=0; i<lightList.size();++i)
|
for (unsigned int i=0; i<lightList.size();++i)
|
||||||
{
|
{
|
||||||
lights.push_back(lightList[i]->mLightSource->getLight(frameNum));
|
lights.push_back(lightList[i]->mLightSource->getLight(frameNum));
|
||||||
|
|
|
@ -61,10 +61,7 @@ namespace SceneUtil
|
||||||
{
|
{
|
||||||
// Take transformation for first found node in file
|
// Take transformation for first found node in file
|
||||||
const std::string nodeName = Misc::StringUtils::lowerCase(trans.getName());
|
const std::string nodeName = Misc::StringUtils::lowerCase(trans.getName());
|
||||||
if (mMap.find(nodeName) == mMap.end())
|
mMap.emplace(nodeName, &trans);
|
||||||
{
|
|
||||||
mMap[nodeName] = &trans;
|
|
||||||
}
|
|
||||||
|
|
||||||
traverse(trans);
|
traverse(trans);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include "world.hpp"
|
#include "world.hpp"
|
||||||
#include "../esm/loadland.hpp"
|
#include "../esm/loadland.hpp"
|
||||||
|
|
||||||
namespace MWRender
|
namespace Terrain
|
||||||
{
|
{
|
||||||
|
|
||||||
CellBorder::CellBorder(Terrain::World *world, osg::Group *root, int borderMask):
|
CellBorder::CellBorder(Terrain::World *world, osg::Group *root, int borderMask):
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
namespace Terrain
|
namespace Terrain
|
||||||
{
|
{
|
||||||
class World;
|
class World;
|
||||||
}
|
|
||||||
|
|
||||||
namespace MWRender
|
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* @Brief Handles the debug cell borders.
|
* @Brief Handles the debug cell borders.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -122,6 +122,8 @@ void CompositeMapRenderer::compile(CompositeMap &compositeMap, osg::RenderInfo &
|
||||||
|
|
||||||
++compositeMap.mCompiled;
|
++compositeMap.mCompiled;
|
||||||
|
|
||||||
|
compositeMap.mDrawables[i] = nullptr;
|
||||||
|
|
||||||
if (timeLeft)
|
if (timeLeft)
|
||||||
{
|
{
|
||||||
*timeLeft -= timer.time_s();
|
*timeLeft -= timer.time_s();
|
||||||
|
@ -131,6 +133,8 @@ void CompositeMapRenderer::compile(CompositeMap &compositeMap, osg::RenderInfo &
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (compositeMap.mCompiled == compositeMap.mDrawables.size())
|
||||||
|
compositeMap.mDrawables = std::vector<osg::ref_ptr<osg::Drawable>>();
|
||||||
|
|
||||||
state.haveAppliedAttribute(osg::StateAttribute::VIEWPORT);
|
state.haveAppliedAttribute(osg::StateAttribute::VIEWPORT);
|
||||||
|
|
||||||
|
|
|
@ -163,25 +163,29 @@ public:
|
||||||
boundingBox.expandBy(child->getBoundingBox());
|
boundingBox.expandBy(child->getBoundingBox());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!boundingBox.valid())
|
||||||
|
parent->removeChildren(0, 4);
|
||||||
|
else
|
||||||
parent->setBoundingBox(boundingBox);
|
parent->setBoundingBox(boundingBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
QuadTreeNode* addChild(QuadTreeNode* parent, ChildDirection direction, float size)
|
QuadTreeNode* addChild(QuadTreeNode* parent, ChildDirection direction, float size)
|
||||||
{
|
{
|
||||||
|
float halfSize = size/2.f;
|
||||||
osg::Vec2f center;
|
osg::Vec2f center;
|
||||||
switch (direction)
|
switch (direction)
|
||||||
{
|
{
|
||||||
case SW:
|
case SW:
|
||||||
center = parent->getCenter() + osg::Vec2f(-size/2.f,-size/2.f);
|
center = parent->getCenter() + osg::Vec2f(-halfSize,-halfSize);
|
||||||
break;
|
break;
|
||||||
case SE:
|
case SE:
|
||||||
center = parent->getCenter() + osg::Vec2f(size/2.f, -size/2.f);
|
center = parent->getCenter() + osg::Vec2f(halfSize, -halfSize);
|
||||||
break;
|
break;
|
||||||
case NW:
|
case NW:
|
||||||
center = parent->getCenter() + osg::Vec2f(-size/2.f, size/2.f);
|
center = parent->getCenter() + osg::Vec2f(-halfSize, halfSize);
|
||||||
break;
|
break;
|
||||||
case NE:
|
case NE:
|
||||||
center = parent->getCenter() + osg::Vec2f(size/2.f, size/2.f);
|
center = parent->getCenter() + osg::Vec2f(halfSize, halfSize);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -203,8 +207,8 @@ public:
|
||||||
mStorage->getMinMaxHeights(size, center, minZ, maxZ);
|
mStorage->getMinMaxHeights(size, center, minZ, maxZ);
|
||||||
|
|
||||||
float cellWorldSize = mStorage->getCellWorldSize();
|
float cellWorldSize = mStorage->getCellWorldSize();
|
||||||
osg::BoundingBox boundingBox(osg::Vec3f((center.x()-size)*cellWorldSize, (center.y()-size)*cellWorldSize, minZ),
|
osg::BoundingBox boundingBox(osg::Vec3f((center.x()-halfSize)*cellWorldSize, (center.y()-halfSize)*cellWorldSize, minZ),
|
||||||
osg::Vec3f((center.x()+size)*cellWorldSize, (center.y()+size)*cellWorldSize, maxZ));
|
osg::Vec3f((center.x()+halfSize)*cellWorldSize, (center.y()+halfSize)*cellWorldSize, maxZ));
|
||||||
node->setBoundingBox(boundingBox);
|
node->setBoundingBox(boundingBox);
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
|
|
|
@ -84,7 +84,7 @@ void TerrainGrid::loadCell(int x, int y)
|
||||||
|
|
||||||
void TerrainGrid::unloadCell(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())
|
if (it == mGrid.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace Terrain
|
||||||
// split each ESM::Cell into mNumSplits*mNumSplits terrain chunks
|
// split each ESM::Cell into mNumSplits*mNumSplits terrain chunks
|
||||||
unsigned int mNumSplits;
|
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()));
|
mTextureManager.reset(new TextureManager(mResourceSystem->getSceneManager()));
|
||||||
mChunkManager.reset(new ChunkManager(mStorage, mResourceSystem->getSceneManager(), mTextureManager.get(), mCompositeMapRenderer));
|
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(mChunkManager.get());
|
||||||
mResourceSystem->addResourceManager(mTextureManager.get());
|
mResourceSystem->addResourceManager(mTextureManager.get());
|
||||||
|
|
|
@ -116,7 +116,7 @@ namespace Terrain
|
||||||
std::unique_ptr<TextureManager> mTextureManager;
|
std::unique_ptr<TextureManager> mTextureManager;
|
||||||
std::unique_ptr<ChunkManager> mChunkManager;
|
std::unique_ptr<ChunkManager> mChunkManager;
|
||||||
|
|
||||||
std::unique_ptr<MWRender::CellBorder> mCellBorder;
|
std::unique_ptr<CellBorder> mCellBorder;
|
||||||
|
|
||||||
bool mBorderVisible;
|
bool mBorderVisible;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue