forked from teamnwah/openmw-tes3coop
Merge pull request #139 from OpenMW/master
Add OpenMW commits up to 3 Feb 2017
This commit is contained in:
commit
63974af131
15 changed files with 67 additions and 18 deletions
|
@ -505,6 +505,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
|
|||
|
||||
std::string myguiResources = (mResDir / "mygui").string();
|
||||
osg::ref_ptr<osg::Group> guiRoot = new osg::Group;
|
||||
guiRoot->setName("GUI Root");
|
||||
guiRoot->setNodeMask(MWRender::Mask_GUI);
|
||||
rootNode->addChild(guiRoot);
|
||||
MWGui::WindowManager* window = new MWGui::WindowManager(mViewer, guiRoot, mResourceSystem.get(),
|
||||
|
@ -637,6 +638,7 @@ void OMW::Engine::go()
|
|||
return;
|
||||
|
||||
mViewer = new osgViewer::Viewer;
|
||||
mViewer->setReleaseContextAtEndOfFrameHint(false);
|
||||
|
||||
osg::ref_ptr<osgViewer::StatsHandler> statshandler = new osgViewer::StatsHandler;
|
||||
statshandler->setKeyEventTogglesOnScreenStats(osgGA::GUIEventAdapter::KEY_F3);
|
||||
|
|
|
@ -93,6 +93,7 @@ namespace MWRender
|
|||
mCamera->setViewport(0, 0, sizeX, sizeY);
|
||||
mCamera->setRenderOrder(osg::Camera::PRE_RENDER);
|
||||
mCamera->attach(osg::Camera::COLOR_BUFFER, mTexture);
|
||||
mCamera->setName("CharacterPreview");
|
||||
|
||||
mCamera->setNodeMask(Mask_RenderToTexture);
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ void Objects::insertBegin(const MWWorld::Ptr& ptr)
|
|||
if (found == mCellSceneNodes.end())
|
||||
{
|
||||
cellnode = new osg::Group;
|
||||
cellnode->setName("Cell Root");
|
||||
mRootNode->addChild(cellnode);
|
||||
mCellSceneNodes[ptr.getCell()] = cellnode;
|
||||
}
|
||||
|
|
|
@ -793,6 +793,7 @@ namespace MWRender
|
|||
{
|
||||
mPlayerNode = new SceneUtil::PositionAttitudeTransform;
|
||||
mPlayerNode->setNodeMask(Mask_Player);
|
||||
mPlayerNode->setName("Player Root");
|
||||
mSceneRoot->addChild(mPlayerNode);
|
||||
}
|
||||
|
||||
|
|
|
@ -1113,6 +1113,7 @@ SkyManager::SkyManager(osg::Group* parentNode, Resource::SceneManager* sceneMana
|
|||
, mSunEnabled(true)
|
||||
{
|
||||
osg::ref_ptr<CameraRelativeTransform> skyroot (new CameraRelativeTransform);
|
||||
skyroot->setName("Sky Root");
|
||||
// Assign empty program to specify we don't want shaders
|
||||
// The shaders generated by the SceneManager can't handle everything we need
|
||||
skyroot->getOrCreateStateSet()->setAttributeAndModes(new osg::Program(), osg::StateAttribute::OVERRIDE);
|
||||
|
|
|
@ -223,6 +223,7 @@ public:
|
|||
setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
|
||||
setReferenceFrame(osg::Camera::RELATIVE_RF);
|
||||
setSmallFeatureCullingPixelSize(Settings::Manager::getInt("small feature culling pixel size", "Water"));
|
||||
setName("RefractionCamera");
|
||||
|
||||
setCullMask(Mask_Effect|Mask_Scene|Mask_Terrain|Mask_Actor|Mask_ParticleSystem|Mask_Sky|Mask_Sun|Mask_Player|Mask_Lighting);
|
||||
setNodeMask(Mask_RenderToTexture);
|
||||
|
@ -305,6 +306,7 @@ public:
|
|||
setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
|
||||
setReferenceFrame(osg::Camera::RELATIVE_RF);
|
||||
setSmallFeatureCullingPixelSize(Settings::Manager::getInt("small feature culling pixel size", "Water"));
|
||||
setName("ReflectionCamera");
|
||||
|
||||
bool reflectActors = Settings::Manager::getBool("reflect actors", "Water");
|
||||
|
||||
|
@ -405,6 +407,7 @@ Water::Water(osg::Group *parent, osg::Group* sceneRoot, Resource::ResourceSystem
|
|||
ico->add(mWaterGeom);
|
||||
|
||||
mWaterNode = new osg::PositionAttitudeTransform;
|
||||
mWaterNode->setName("Water Root");
|
||||
mWaterNode->addChild(mWaterGeom);
|
||||
mWaterNode->addCullCallback(new FudgeCallback);
|
||||
|
||||
|
|
|
@ -179,6 +179,7 @@ namespace MWWorld
|
|||
, mMinCacheSize(0)
|
||||
, mMaxCacheSize(0)
|
||||
, mPreloadInstances(true)
|
||||
, mLastResourceCacheUpdate(0.0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -252,8 +253,12 @@ namespace MWWorld
|
|||
++it;
|
||||
}
|
||||
|
||||
// the resource cache is cleared from the worker thread so that we're not holding up the main thread with delete operations
|
||||
mWorkQueue->addWorkItem(new UpdateCacheItem(mResourceSystem, mTerrain, timestamp), true);
|
||||
if (timestamp - mLastResourceCacheUpdate > 1.0)
|
||||
{
|
||||
// the resource cache is cleared from the worker thread so that we're not holding up the main thread with delete operations
|
||||
mWorkQueue->addWorkItem(new UpdateCacheItem(mResourceSystem, mTerrain, timestamp), true);
|
||||
mLastResourceCacheUpdate = timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
void CellPreloader::setExpiryDelay(double expiryDelay)
|
||||
|
|
|
@ -61,6 +61,8 @@ namespace MWWorld
|
|||
unsigned int mMaxCacheSize;
|
||||
bool mPreloadInstances;
|
||||
|
||||
double mLastResourceCacheUpdate;
|
||||
|
||||
struct PreloadEntry
|
||||
{
|
||||
PreloadEntry(double timestamp, osg::ref_ptr<SceneUtil::WorkItem> workItem)
|
||||
|
|
|
@ -1597,12 +1597,9 @@ namespace NifOsg
|
|||
{
|
||||
const Nif::NiZBufferProperty* zprop = static_cast<const Nif::NiZBufferProperty*>(property);
|
||||
// VER_MW doesn't support a DepthFunction according to NifSkope
|
||||
static osg::ref_ptr<osg::Depth> depth;
|
||||
if (!depth)
|
||||
{
|
||||
depth = new osg::Depth;
|
||||
depth->setWriteMask((zprop->flags>>1)&1);
|
||||
}
|
||||
osg::ref_ptr<osg::Depth> depth = new osg::Depth;
|
||||
depth->setWriteMask((zprop->flags>>1)&1);
|
||||
depth = shareAttribute(depth);
|
||||
node->getOrCreateStateSet()->setAttributeAndModes(depth, osg::StateAttribute::ON);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -181,6 +181,7 @@ namespace Resource
|
|||
, mAutoUseNormalMaps(false)
|
||||
, mAutoUseSpecularMaps(false)
|
||||
, mInstanceCache(new MultiObjectCache)
|
||||
, mSharedStateManager(new osgDB::SharedStateManager)
|
||||
, mImageManager(imageManager)
|
||||
, mNifFileManager(nifFileManager)
|
||||
, mMinFilter(osg::Texture::LINEAR_MIPMAP_LINEAR)
|
||||
|
@ -392,7 +393,7 @@ namespace Resource
|
|||
|
||||
// share state
|
||||
mSharedStateMutex.lock();
|
||||
osgDB::Registry::instance()->getOrCreateSharedStateManager()->share(loaded.get());
|
||||
mSharedStateManager->share(loaded.get());
|
||||
mSharedStateMutex.unlock();
|
||||
|
||||
if (mIncrementalCompileOperation)
|
||||
|
@ -549,6 +550,10 @@ namespace Resource
|
|||
|
||||
void SceneManager::updateCache(double referenceTime)
|
||||
{
|
||||
mSharedStateMutex.lock();
|
||||
mSharedStateManager->prune();
|
||||
mSharedStateMutex.unlock();
|
||||
|
||||
ResourceManager::updateCache(referenceTime);
|
||||
|
||||
mInstanceCache->removeUnreferencedObjectsInCache();
|
||||
|
|
|
@ -22,6 +22,11 @@ namespace osgUtil
|
|||
class IncrementalCompileOperation;
|
||||
}
|
||||
|
||||
namespace osgDB
|
||||
{
|
||||
class SharedStateManager;
|
||||
}
|
||||
|
||||
namespace Shader
|
||||
{
|
||||
class ShaderManager;
|
||||
|
@ -147,6 +152,7 @@ namespace Resource
|
|||
|
||||
osg::ref_ptr<MultiObjectCache> mInstanceCache;
|
||||
|
||||
osg::ref_ptr<osgDB::SharedStateManager> mSharedStateManager;
|
||||
OpenThreads::Mutex mSharedStateMutex;
|
||||
|
||||
Resource::ImageManager* mImageManager;
|
||||
|
|
|
@ -271,7 +271,8 @@ void RigGeometry::update(osg::NodeVisitor* nv)
|
|||
const osg::Matrixf& boneMatrix = bone->mMatrixInSkeletonSpace;
|
||||
accumulateMatrix(invBindMatrix, boneMatrix, weight, resultMat);
|
||||
}
|
||||
resultMat = resultMat * mGeomToSkelMatrix;
|
||||
if (mGeomToSkelMatrix)
|
||||
resultMat *= (*mGeomToSkelMatrix);
|
||||
|
||||
for (std::vector<unsigned short>::const_iterator vertexIt = it->second.begin(); vertexIt != it->second.end(); ++vertexIt)
|
||||
{
|
||||
|
@ -316,7 +317,10 @@ void RigGeometry::updateBounds(osg::NodeVisitor *nv)
|
|||
{
|
||||
Bone* bone = it->first;
|
||||
osg::BoundingSpheref bs = it->second;
|
||||
transformBoundingSphere(bone->mMatrixInSkeletonSpace * mGeomToSkelMatrix, bs);
|
||||
if (mGeomToSkelMatrix)
|
||||
transformBoundingSphere(bone->mMatrixInSkeletonSpace * (*mGeomToSkelMatrix), bs);
|
||||
else
|
||||
transformBoundingSphere(bone->mMatrixInSkeletonSpace, bs);
|
||||
box.expandBy(bs);
|
||||
}
|
||||
|
||||
|
@ -332,19 +336,28 @@ void RigGeometry::updateBounds(osg::NodeVisitor *nv)
|
|||
|
||||
void RigGeometry::updateGeomToSkelMatrix(const osg::NodePath& nodePath)
|
||||
{
|
||||
mSkelToGeomPath.clear();
|
||||
bool foundSkel = false;
|
||||
osg::ref_ptr<osg::RefMatrix> geomToSkelMatrix;
|
||||
for (osg::NodePath::const_iterator it = nodePath.begin(); it != nodePath.end(); ++it)
|
||||
{
|
||||
osg::Node* node = *it;
|
||||
if (!foundSkel)
|
||||
{
|
||||
if (*it == mSkeleton)
|
||||
if (node == mSkeleton)
|
||||
foundSkel = true;
|
||||
}
|
||||
else
|
||||
mSkelToGeomPath.push_back(*it);
|
||||
{
|
||||
if (osg::Transform* trans = node->asTransform())
|
||||
{
|
||||
if (!geomToSkelMatrix)
|
||||
geomToSkelMatrix = new osg::RefMatrix;
|
||||
trans->computeWorldToLocalMatrix(*geomToSkelMatrix, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
mGeomToSkelMatrix = osg::computeWorldToLocal(mSkelToGeomPath);
|
||||
if (geomToSkelMatrix && !geomToSkelMatrix->isIdentity())
|
||||
mGeomToSkelMatrix = geomToSkelMatrix;
|
||||
}
|
||||
|
||||
void RigGeometry::setInfluenceMap(osg::ref_ptr<InfluenceMap> influenceMap)
|
||||
|
|
|
@ -56,8 +56,7 @@ namespace SceneUtil
|
|||
osg::ref_ptr<osg::Vec4Array> mSourceTangents;
|
||||
Skeleton* mSkeleton;
|
||||
|
||||
osg::NodePath mSkelToGeomPath;
|
||||
osg::Matrixf mGeomToSkelMatrix;
|
||||
osg::ref_ptr<osg::RefMatrix> mGeomToSkelMatrix;
|
||||
|
||||
osg::ref_ptr<InfluenceMap> mInfluenceMap;
|
||||
|
||||
|
|
|
@ -64,6 +64,15 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class CameraRelativeTransformSerializer : public osgDB::ObjectWrapper
|
||||
{
|
||||
public:
|
||||
CameraRelativeTransformSerializer()
|
||||
: osgDB::ObjectWrapper(createInstanceFunc<osg::Group>, "MWRender::CameraRelativeTransform", "osg::Object osg::Node osg::Group MWRender::CameraRelativeTransform")
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
osgDB::ObjectWrapper* makeDummySerializer(const std::string& classname)
|
||||
{
|
||||
return new osgDB::ObjectWrapper(createInstanceFunc<osg::DummyObject>, classname, "osg::Object");
|
||||
|
@ -80,17 +89,18 @@ void registerSerializers()
|
|||
osgDB::Registry::instance()->getObjectWrapperManager()->addWrapper(new FrameSwitchSerializer);
|
||||
osgDB::Registry::instance()->getObjectWrapperManager()->addWrapper(new RigGeometrySerializer);
|
||||
osgDB::Registry::instance()->getObjectWrapperManager()->addWrapper(new LightManagerSerializer);
|
||||
osgDB::Registry::instance()->getObjectWrapperManager()->addWrapper(new CameraRelativeTransformSerializer);
|
||||
|
||||
// ignore the below for now to avoid warning spam
|
||||
const char* ignore[] = {
|
||||
"MWRender::PtrHolder",
|
||||
"MWRender::CameraRelativeTransform",
|
||||
"Resource::TemplateRef",
|
||||
"SceneUtil::LightListCallback",
|
||||
"SceneUtil::LightManagerUpdateCallback",
|
||||
"SceneUtil::UpdateRigBounds",
|
||||
"SceneUtil::UpdateRigGeometry",
|
||||
"SceneUtil::LightSource",
|
||||
"SceneUtil::StateSetUpdater",
|
||||
"NifOsg::NodeUserData",
|
||||
"NifOsg::FlipController",
|
||||
"NifOsg::KeyframeController",
|
||||
|
@ -104,6 +114,8 @@ void registerSerializers()
|
|||
"NifOsg::UpdateMorphGeometry",
|
||||
"osgMyGUI::Drawable",
|
||||
"osg::DrawCallback",
|
||||
"osgOQ::ClearQueriesCallback",
|
||||
"osgOQ::RetrieveQueriesCallback",
|
||||
"osg::DummyObject"
|
||||
};
|
||||
for (size_t i=0; i<sizeof(ignore)/sizeof(ignore[0]); ++i)
|
||||
|
|
|
@ -18,6 +18,7 @@ World::World(osg::Group* parent, Resource::ResourceSystem* resourceSystem, osgUt
|
|||
mTerrainRoot = new osg::Group;
|
||||
mTerrainRoot->setNodeMask(nodeMask);
|
||||
mTerrainRoot->getOrCreateStateSet()->setRenderingHint(osg::StateSet::OPAQUE_BIN);
|
||||
mTerrainRoot->setName("Terrain Root");
|
||||
|
||||
mParent->addChild(mTerrainRoot);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue