From 08f06c6c2d6f89eeea5c85a6dc82ec92e5fcc802 Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 1 Mar 2016 16:57:11 +0100 Subject: [PATCH 01/18] Fix a crash that could occur with actors that define 'bip01 spine1' but do not define 'bip01 spine2' (Fixes #3223). --- apps/openmw/mwrender/weaponanimation.cpp | 25 +++++++++++++++--------- apps/openmw/mwrender/weaponanimation.hpp | 3 +++ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwrender/weaponanimation.cpp b/apps/openmw/mwrender/weaponanimation.cpp index 2627d3fc6..d5fb70d16 100644 --- a/apps/openmw/mwrender/weaponanimation.cpp +++ b/apps/openmw/mwrender/weaponanimation.cpp @@ -182,23 +182,30 @@ void WeaponAnimation::deleteControllers() void WeaponAnimation::configureControllers(float characterPitchRadians) { - if (!mSpineControllers[0]) - return; - if (mPitchFactor == 0.f || characterPitchRadians == 0.f) { - for (int i=0; i<2; ++i) - mSpineControllers[i]->setEnabled(false); + setControllerEnabled(false); return; } float pitch = characterPitchRadians * mPitchFactor; osg::Quat rotate (pitch/2, osg::Vec3f(-1,0,0)); + setControllerRotate(rotate); + setControllerEnabled(true); +} + +void WeaponAnimation::setControllerRotate(const osg::Quat& rotate) +{ for (int i=0; i<2; ++i) - { - mSpineControllers[i]->setRotate(rotate); - mSpineControllers[i]->setEnabled(true); - } + if (mSpineControllers[i]) + mSpineControllers[i]->setRotate(rotate); +} + +void WeaponAnimation::setControllerEnabled(bool enabled) +{ + for (int i=0; i<2; ++i) + if (mSpineControllers[i]) + mSpineControllers[i]->setEnabled(enabled); } } diff --git a/apps/openmw/mwrender/weaponanimation.hpp b/apps/openmw/mwrender/weaponanimation.hpp index 3bf0fb721..d50729c62 100644 --- a/apps/openmw/mwrender/weaponanimation.hpp +++ b/apps/openmw/mwrender/weaponanimation.hpp @@ -52,6 +52,9 @@ namespace MWRender osg::ref_ptr mSpineControllers[2]; + void setControllerRotate(const osg::Quat& rotate); + void setControllerEnabled(bool enabled); + virtual osg::Group* getArrowBone() = 0; virtual osg::Node* getWeaponNode() = 0; virtual Resource::ResourceSystem* getResourceSystem() = 0; From 64636bd85a7c7172f106dd4c0f11e79290aba75c Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 1 Mar 2016 17:05:02 +0100 Subject: [PATCH 02/18] Improve error reporting --- components/nifosg/nifloader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index ab6bfcff3..1300d592f 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -470,7 +470,7 @@ namespace NifOsg const Nif::NiTextureEffect* textureEffect = static_cast(nifNode); if (textureEffect->textureType != Nif::NiTextureEffect::Environment_Map) { - std::cerr << "Unhandled NiTextureEffect type " << textureEffect->textureType << std::endl; + std::cerr << "Unhandled NiTextureEffect type " << textureEffect->textureType << " in " << mFilename << std::endl; return; } @@ -487,7 +487,7 @@ namespace NifOsg texGen->setMode(osg::TexGen::SPHERE_MAP); break; default: - std::cerr << "Unhandled NiTextureEffect coordGenType " << textureEffect->coordGenType << std::endl; + std::cerr << "Unhandled NiTextureEffect coordGenType " << textureEffect->coordGenType << " in " << mFilename << std::endl; return; } From 30d06bfe0e9140796df9f205fd5f161e9b53865a Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 1 Mar 2016 17:27:54 +0100 Subject: [PATCH 03/18] Add comment --- components/nifosg/nifloader.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index 1300d592f..b7eb9d8a7 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -1377,6 +1377,8 @@ namespace NifOsg break; case Nif::NiTexturingProperty::GlossTexture: { + // Not used by the vanilla engine. MCP (Morrowind Code Patch) adds an option to use Gloss maps: + // "- Gloss map fix. Morrowind removed gloss map entries from model files after loading them. This stops Morrowind from removing them." std::cerr << "NiTexturingProperty::GlossTexture in " << mFilename << " not currently used." << std::endl; continue; } From 414c19f717e9e75d46cbd59d7130254c8dd10cd4 Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 1 Mar 2016 18:40:18 +0100 Subject: [PATCH 04/18] Fix detailMapUV bug --- files/shaders/objects_vertex.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/shaders/objects_vertex.glsl b/files/shaders/objects_vertex.glsl index b1004aad3..297941172 100644 --- a/files/shaders/objects_vertex.glsl +++ b/files/shaders/objects_vertex.glsl @@ -68,7 +68,7 @@ void main(void) #endif #if @detailMap - detailMapUV = (gl_TextureMatrix[@detailMap] * gl_MultiTexCoord@detailMap).xy; + detailMapUV = (gl_TextureMatrix[@detailMapUV] * gl_MultiTexCoord@detailMapUV).xy; #endif #if @emissiveMap From 6e7c6fdd7ee7672ee20d3d8374eecf17c5cf412a Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 1 Mar 2016 18:41:36 +0100 Subject: [PATCH 05/18] Implement NiTexturingProperty::DecalTexture --- components/nifosg/nifloader.cpp | 24 +++++++++++++++++++----- components/shader/shadervisitor.cpp | 4 ++-- files/shaders/objects_fragment.glsl | 10 ++++++++++ files/shaders/objects_vertex.glsl | 8 ++++++++ 4 files changed, 39 insertions(+), 7 deletions(-) diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index b7eb9d8a7..8ffb8d5de 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -1374,6 +1374,7 @@ namespace NifOsg case Nif::NiTexturingProperty::DarkTexture: case Nif::NiTexturingProperty::BumpTexture: case Nif::NiTexturingProperty::DetailTexture: + case Nif::NiTexturingProperty::DecalTexture: break; case Nif::NiTexturingProperty::GlossTexture: { @@ -1382,11 +1383,6 @@ namespace NifOsg std::cerr << "NiTexturingProperty::GlossTexture in " << mFilename << " not currently used." << std::endl; continue; } - case Nif::NiTexturingProperty::DecalTexture: - { - std::cerr << "NiTexturingProperty::DecalTexture in " << mFilename << " not currently used." << std::endl; - continue; - } default: { std::cerr << "Warning: unhandled texture stage " << i << " in " << mFilename << std::endl; @@ -1454,6 +1450,21 @@ namespace NifOsg // Set this texture to Off by default since we can't render it with the fixed-function pipeline stateset->setTextureMode(texUnit, GL_TEXTURE_2D, osg::StateAttribute::OFF); } + else if (i == Nif::NiTexturingProperty::DecalTexture) + { + osg::TexEnvCombine* texEnv = new osg::TexEnvCombine; + texEnv->setCombine_RGB(GL_INTERPOLATE); + texEnv->setSource0_RGB(GL_TEXTURE); + texEnv->setOperand0_RGB(GL_SRC_COLOR); + texEnv->setSource1_RGB(GL_PREVIOUS_ARB); + texEnv->setOperand1_RGB(GL_SRC_COLOR); + texEnv->setSource2_RGB(GL_TEXTURE); + texEnv->setOperand2_RGB(GL_SRC_ALPHA); + texEnv->setCombine_Alpha(GL_REPLACE); + texEnv->setSource0_Alpha(GL_PREVIOUS); + texEnv->setOperand0_Alpha(GL_SRC_ALPHA); + stateset->setTextureAttributeAndModes(texUnit, texEnv, osg::StateAttribute::ON); + } switch (i) { @@ -1472,6 +1483,9 @@ namespace NifOsg case Nif::NiTexturingProperty::DetailTexture: texture2d->setName("detailMap"); break; + case Nif::NiTexturingProperty::DecalTexture: + texture2d->setName("decalMap"); + break; default: break; } diff --git a/components/shader/shadervisitor.cpp b/components/shader/shadervisitor.cpp index b06ceafde..92bdac7b7 100644 --- a/components/shader/shadervisitor.cpp +++ b/components/shader/shadervisitor.cpp @@ -88,11 +88,11 @@ namespace Shader return newStateSet.get(); } - const char* defaultTextures[] = { "diffuseMap", "normalMap", "emissiveMap", "darkMap", "detailMap", "envMap", "specularMap" }; + const char* defaultTextures[] = { "diffuseMap", "normalMap", "emissiveMap", "darkMap", "detailMap", "envMap", "specularMap", "decalMap" }; bool isTextureNameRecognized(const std::string& name) { for (unsigned int i=0; i Date: Wed, 2 Mar 2016 13:20:23 +0100 Subject: [PATCH 06/18] Infinite loop fix --- apps/openmw/mwrender/animation.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 7f7183b9e..5cf502476 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -1363,6 +1363,7 @@ namespace MWRender foundKeyframeCtrl = true; break; } + cb = cb->getNestedCallback(); } if (foundKeyframeCtrl) From 563807ee5335c823d24fdc898ed439706bfa5b31 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 2 Mar 2016 13:33:31 +0100 Subject: [PATCH 07/18] Share the StateSet used to invert front face --- components/sceneutil/attach.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/components/sceneutil/attach.cpp b/components/sceneutil/attach.cpp index 38330901d..8ac0aa992 100644 --- a/components/sceneutil/attach.cpp +++ b/components/sceneutil/attach.cpp @@ -102,9 +102,15 @@ namespace SceneUtil // Need to invert culling because of the negative scale // Note: for absolute correctness we would need to check the current front face for every mesh then invert it // However MW isn't doing this either, so don't. Assuming all meshes are using backface culling is more efficient. - osg::FrontFace* frontFace = new osg::FrontFace; - frontFace->setMode(osg::FrontFace::CLOCKWISE); - trans->getOrCreateStateSet()->setAttributeAndModes(frontFace, osg::StateAttribute::ON); + static osg::ref_ptr frontFaceStateSet; + if (!frontFaceStateSet) + { + frontFaceStateSet = new osg::StateSet; + osg::FrontFace* frontFace = new osg::FrontFace; + frontFace->setMode(osg::FrontFace::CLOCKWISE); + frontFaceStateSet->setAttributeAndModes(frontFace, osg::StateAttribute::ON); + } + trans->setStateSet(frontFaceStateSet); } if (trans) From 3d6323f13a20ae5cba65814d859137ec8dd94005 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 2 Mar 2016 17:02:30 +0100 Subject: [PATCH 08/18] Force-enable hasWater() for exterior cells (Fixes #3222) --- apps/openmw/mwworld/worldimp.cpp | 2 +- components/esm/loadcell.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 2ab027cd6..0dbadca17 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -2039,7 +2039,7 @@ namespace MWWorld bool World::isUnderwater(const MWWorld::CellStore* cell, const osg::Vec3f &pos) const { - if (!(cell->getCell()->mData.mFlags & ESM::Cell::HasWater)) { + if (!(cell->getCell()->hasWater())) { return false; } return pos.z() < cell->getWaterLevel(); diff --git a/components/esm/loadcell.hpp b/components/esm/loadcell.hpp index f92e0b5b7..cab8cf65e 100644 --- a/components/esm/loadcell.hpp +++ b/components/esm/loadcell.hpp @@ -141,7 +141,7 @@ struct Cell bool hasWater() const { - return (mData.mFlags&HasWater) != 0; + return ((mData.mFlags&HasWater) != 0) || isExterior(); } // Restore the given reader to the stored position. Will try to open From 7fb6807e653a8d1258bb8104791ffbc29b17482a Mon Sep 17 00:00:00 2001 From: Aesylwinn Date: Wed, 2 Mar 2016 15:02:06 -0500 Subject: [PATCH 09/18] cell border markers --- apps/opencs/CMakeLists.txt | 2 +- apps/opencs/view/render/cell.cpp | 3 + apps/opencs/view/render/cell.hpp | 2 + apps/opencs/view/render/cellborder.cpp | 97 ++++++++++++++++++++++++++ apps/opencs/view/render/cellborder.hpp | 54 ++++++++++++++ 5 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 apps/opencs/view/render/cellborder.cpp create mode 100644 apps/opencs/view/render/cellborder.hpp diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 74f311c5f..f78c411d2 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -90,7 +90,7 @@ opencs_units (view/render opencs_units_noqt (view/render lighting lightingday lightingnight - lightingbright object cell terrainstorage tagbase cellarrow cellmarker + lightingbright object cell terrainstorage tagbase cellarrow cellmarker cellborder ) opencs_hdrs_noqt (view/render diff --git a/apps/opencs/view/render/cell.cpp b/apps/opencs/view/render/cell.cpp index 641aeb088..5348f4683 100644 --- a/apps/opencs/view/render/cell.cpp +++ b/apps/opencs/view/render/cell.cpp @@ -93,6 +93,9 @@ CSVRender::Cell::Cell (CSMWorld::Data& data, osg::Group* rootNode, const std::st mTerrain.reset(new Terrain::TerrainGrid(mCellNode, data.getResourceSystem().get(), NULL, new TerrainStorage(mData), Mask_Terrain)); mTerrain->loadCell(esmLand.mX, esmLand.mY); + + mCellBorder.reset(new CellBorder(mCellNode, mCoordinates)); + mCellBorder->buildShape(esmLand); } } } diff --git a/apps/opencs/view/render/cell.hpp b/apps/opencs/view/render/cell.hpp index 22f9872e3..54f5bea1e 100644 --- a/apps/opencs/view/render/cell.hpp +++ b/apps/opencs/view/render/cell.hpp @@ -16,6 +16,7 @@ #include "object.hpp" #include "cellarrow.hpp" #include "cellmarker.hpp" +#include "cellborder.hpp" class QModelIndex; @@ -44,6 +45,7 @@ namespace CSVRender CSMWorld::CellCoordinates mCoordinates; std::auto_ptr mCellArrows[4]; std::auto_ptr mCellMarker; + std::auto_ptr mCellBorder; bool mDeleted; /// Ignored if cell does not have an object with the given ID. diff --git a/apps/opencs/view/render/cellborder.cpp b/apps/opencs/view/render/cellborder.cpp new file mode 100644 index 000000000..fd0492e5d --- /dev/null +++ b/apps/opencs/view/render/cellborder.cpp @@ -0,0 +1,97 @@ +#include "cellborder.hpp" + +#include +#include +#include +#include +#include + +#include + +#include "mask.hpp" + +#include "../../model/world/cellcoordinates.hpp" + +const int CSVRender::CellBorder::CellSize = ESM::Land::REAL_SIZE; +const int CSVRender::CellBorder::VertexCount = (ESM::Land::LAND_SIZE * 4) - 3; + + +CSVRender::CellBorder::CellBorder(osg::Group* cellNode, const CSMWorld::CellCoordinates& coords) + : mParentNode(cellNode) +{ + mBaseNode = new osg::PositionAttitudeTransform(); + mBaseNode->setNodeMask(Mask_CellBorder); + mBaseNode->setPosition(osg::Vec3f(coords.getX() * CellSize, coords.getY() * CellSize, 10)); + + mParentNode->addChild(mBaseNode); +} + +CSVRender::CellBorder::~CellBorder() +{ + mParentNode->removeChild(mBaseNode); +} + +void CSVRender::CellBorder::buildShape(const ESM::Land& esmLand) +{ + const ESM::Land::LandData* landData = esmLand.getLandData(ESM::Land::DATA_VHGT); + + if (!landData) + return; + + osg::ref_ptr geometry = new osg::Geometry(); + + // Vertices + osg::ref_ptr vertices = new osg::Vec3Array(); + + int x = 0, y = 0; + for (; x < ESM::Land::LAND_SIZE; ++x) + vertices->push_back(osg::Vec3f(scaleToWorld(x), scaleToWorld(y), landData->mHeights[landIndex(x, y)])); + + x = ESM::Land::LAND_SIZE - 1; + for (; y < ESM::Land::LAND_SIZE; ++y) + vertices->push_back(osg::Vec3f(scaleToWorld(x), scaleToWorld(y), landData->mHeights[landIndex(x, y)])); + + y = ESM::Land::LAND_SIZE - 1; + for (; x >= 0; --x) + vertices->push_back(osg::Vec3f(scaleToWorld(x), scaleToWorld(y), landData->mHeights[landIndex(x, y)])); + + x = 0; + for (; y >= 0; --y) + vertices->push_back(osg::Vec3f(scaleToWorld(x), scaleToWorld(y), landData->mHeights[landIndex(x, y)])); + + geometry->setVertexArray(vertices); + + // Color + osg::ref_ptr colors = new osg::Vec4Array(); + colors->push_back(osg::Vec4f(0.f, 0.5f, 0.f, 1.f)); + + geometry->setColorArray(colors); + geometry->setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE_SET); + + // Primitive + osg::ref_ptr primitives = + new osg::DrawElementsUShort(osg::PrimitiveSet::LINE_STRIP, VertexCount+1); + + for (size_t i = 0; i < VertexCount; ++i) + primitives->setElement(i, i); + + primitives->setElement(VertexCount, 0); + + geometry->addPrimitiveSet(primitives); + geometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF); + + + osg::ref_ptr geode = new osg::Geode(); + geode->addDrawable(geometry); + mBaseNode->addChild(geode); +} + +size_t CSVRender::CellBorder::landIndex(int x, int y) +{ + return y * ESM::Land::LAND_SIZE + x; +} + +float CSVRender::CellBorder::scaleToWorld(int value) +{ + return (CellSize + 128) * (float)value / ESM::Land::LAND_SIZE; +} diff --git a/apps/opencs/view/render/cellborder.hpp b/apps/opencs/view/render/cellborder.hpp new file mode 100644 index 000000000..c91aa46c6 --- /dev/null +++ b/apps/opencs/view/render/cellborder.hpp @@ -0,0 +1,54 @@ +#ifndef OPENCS_VIEW_CELLBORDER_H +#define OPENCS_VIEW_CELLBORDER_H + +#include + +#include + +namespace osg +{ + class Group; + class PositionAttitudeTransform; +} + +namespace ESM +{ + struct Land; +} + +namespace CSMWorld +{ + class CellCoordinates; +} + +namespace CSVRender +{ + + class CellBorder + { + public: + + CellBorder(osg::Group* cellNode, const CSMWorld::CellCoordinates& coords); + ~CellBorder(); + + void buildShape(const ESM::Land& esmLand); + + private: + + static const int CellSize; + static const int VertexCount; + + size_t landIndex(int x, int y); + float scaleToWorld(int val); + + // unimplemented + CellBorder(const CellBorder&); + CellBorder& operator=(const CellBorder&); + + osg::Group* mParentNode; + osg::ref_ptr mBaseNode; + + }; +} + +#endif From fa1bd72bc0e13b094d3366d52ce9b518a32033c3 Mon Sep 17 00:00:00 2001 From: Aesylwinn Date: Wed, 2 Mar 2016 15:48:05 -0500 Subject: [PATCH 10/18] fix usage of deprecated function --- apps/opencs/view/render/cellborder.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/opencs/view/render/cellborder.cpp b/apps/opencs/view/render/cellborder.cpp index fd0492e5d..6073807ce 100644 --- a/apps/opencs/view/render/cellborder.cpp +++ b/apps/opencs/view/render/cellborder.cpp @@ -65,8 +65,7 @@ void CSVRender::CellBorder::buildShape(const ESM::Land& esmLand) osg::ref_ptr colors = new osg::Vec4Array(); colors->push_back(osg::Vec4f(0.f, 0.5f, 0.f, 1.f)); - geometry->setColorArray(colors); - geometry->setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE_SET); + geometry->setColorArray(colors, osg::Array::BIND_PER_PRIMITIVE_SET); // Primitive osg::ref_ptr primitives = From dd2fbfc0a2e5d09cd8e54d47ba1124f1a9bfbf9d Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 2 Mar 2016 21:57:25 +0100 Subject: [PATCH 11/18] Fix windows build --- components/nifosg/nifloader.cpp | 40 ++++++++++++++++----------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index 8ffb8d5de..705dbe83a 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -1433,16 +1433,16 @@ namespace NifOsg { osg::TexEnvCombine* texEnv = new osg::TexEnvCombine; texEnv->setScale_RGB(2.f); - texEnv->setCombine_Alpha(GL_MODULATE); - texEnv->setOperand0_Alpha(GL_SRC_ALPHA); - texEnv->setOperand1_Alpha(GL_SRC_ALPHA); - texEnv->setSource0_Alpha(GL_PREVIOUS_ARB); - texEnv->setSource1_Alpha(GL_TEXTURE); - texEnv->setCombine_RGB(GL_MODULATE); - texEnv->setOperand0_RGB(GL_SRC_COLOR); - texEnv->setOperand1_RGB(GL_SRC_COLOR); - texEnv->setSource0_RGB(GL_PREVIOUS_ARB); - texEnv->setSource1_RGB(GL_TEXTURE); + texEnv->setCombine_Alpha(osg::TexEnvCombine::MODULATE); + texEnv->setOperand0_Alpha(osg::TexEnvCombine::SRC_ALPHA); + texEnv->setOperand1_Alpha(osg::TexEnvCombine::SRC_ALPHA); + texEnv->setSource0_Alpha(osg::TexEnvCombine::PREVIOUS); + texEnv->setSource1_Alpha(osg::TexEnvCombine::TEXTURE); + texEnv->setCombine_RGB(osg::TexEnvCombine::MODULATE); + texEnv->setOperand0_RGB(osg::TexEnvCombine::SRC_COLOR); + texEnv->setOperand1_RGB(osg::TexEnvCombine::SRC_COLOR); + texEnv->setSource0_RGB(osg::TexEnvCombine::PREVIOUS); + texEnv->setSource1_RGB(osg::TexEnvCombine::TEXTURE); stateset->setTextureAttributeAndModes(texUnit, texEnv, osg::StateAttribute::ON); } else if (i == Nif::NiTexturingProperty::BumpTexture) @@ -1453,16 +1453,16 @@ namespace NifOsg else if (i == Nif::NiTexturingProperty::DecalTexture) { osg::TexEnvCombine* texEnv = new osg::TexEnvCombine; - texEnv->setCombine_RGB(GL_INTERPOLATE); - texEnv->setSource0_RGB(GL_TEXTURE); - texEnv->setOperand0_RGB(GL_SRC_COLOR); - texEnv->setSource1_RGB(GL_PREVIOUS_ARB); - texEnv->setOperand1_RGB(GL_SRC_COLOR); - texEnv->setSource2_RGB(GL_TEXTURE); - texEnv->setOperand2_RGB(GL_SRC_ALPHA); - texEnv->setCombine_Alpha(GL_REPLACE); - texEnv->setSource0_Alpha(GL_PREVIOUS); - texEnv->setOperand0_Alpha(GL_SRC_ALPHA); + texEnv->setCombine_RGB(osg::TexEnvCombine::INTERPOLATE); + texEnv->setSource0_RGB(osg::TexEnvCombine::TEXTURE); + texEnv->setOperand0_RGB(osg::TexEnvCombine::SRC_COLOR); + texEnv->setSource1_RGB(osg::TexEnvCombine::PREVIOUS); + texEnv->setOperand1_RGB(osg::TexEnvCombine::SRC_COLOR); + texEnv->setSource2_RGB(osg::TexEnvCombine::TEXTURE); + texEnv->setOperand2_RGB(osg::TexEnvCombine::SRC_ALPHA); + texEnv->setCombine_Alpha(osg::TexEnvCombine::REPLACE); + texEnv->setSource0_Alpha(osg::TexEnvCombine::PREVIOUS); + texEnv->setOperand0_Alpha(osg::TexEnvCombine::SRC_ALPHA); stateset->setTextureAttributeAndModes(texUnit, texEnv, osg::StateAttribute::ON); } From 2eaf96e3bfe7fd9052c8c0896bcf3f40cbcd2ce4 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 2 Mar 2016 21:58:11 +0100 Subject: [PATCH 12/18] Make ResourceManager destructor virtual --- components/resource/resourcemanager.cpp | 4 ++++ components/resource/resourcemanager.hpp | 1 + 2 files changed, 5 insertions(+) diff --git a/components/resource/resourcemanager.cpp b/components/resource/resourcemanager.cpp index 0a9784e6b..d19d9cf80 100644 --- a/components/resource/resourcemanager.cpp +++ b/components/resource/resourcemanager.cpp @@ -13,6 +13,10 @@ namespace Resource } + ResourceManager::~ResourceManager() + { + } + void ResourceManager::updateCache(double referenceTime) { mCache->updateTimeStampOfObjectsInCacheWithExternalReferences(referenceTime); diff --git a/components/resource/resourcemanager.hpp b/components/resource/resourcemanager.hpp index 34fce0145..b69256834 100644 --- a/components/resource/resourcemanager.hpp +++ b/components/resource/resourcemanager.hpp @@ -18,6 +18,7 @@ namespace Resource { public: ResourceManager(const VFS::Manager* vfs); + virtual ~ResourceManager(); /// Clear cache entries that have not been referenced for longer than expiryDelay. virtual void updateCache(double referenceTime); From 9d985d883b7abdbe31c17148955937a1912b6455 Mon Sep 17 00:00:00 2001 From: Aesylwinn Date: Wed, 2 Mar 2016 20:45:04 -0500 Subject: [PATCH 13/18] added grid icon --- apps/opencs/view/render/pagedworldspacewidget.cpp | 2 +- files/opencs/grid-view-small.png | Bin 0 -> 472 bytes files/opencs/grid-view.png | Bin 0 -> 210 bytes files/opencs/resources.qrc | 2 ++ 4 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 files/opencs/grid-view-small.png create mode 100644 files/opencs/grid-view.png diff --git a/apps/opencs/view/render/pagedworldspacewidget.cpp b/apps/opencs/view/render/pagedworldspacewidget.cpp index d71446d0b..60c5d1a23 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.cpp +++ b/apps/opencs/view/render/pagedworldspacewidget.cpp @@ -564,7 +564,7 @@ CSVWidget::SceneToolToggle *CSVRender::PagedWorldspaceWidget::makeControlVisibil mControlElements->addButton (":placeholder", Mask_CellMarker, ":placeholder", "Cell marker"); mControlElements->addButton (":placeholder", Mask_CellArrow, ":placeholder", "Cell arrows"); - mControlElements->addButton (":placeholder", Mask_CellBorder, ":placeholder", "Cell border"); + mControlElements->addButton (":scenetoolbar/grid", Mask_CellBorder, ":scenetoolbar/grid-small", "Cell border"); mControlElements->setSelectionMask (0xffffffff); diff --git a/files/opencs/grid-view-small.png b/files/opencs/grid-view-small.png new file mode 100644 index 0000000000000000000000000000000000000000..6a874f21b0601285bdb1834f5362f74f97f8974e GIT binary patch literal 472 zcmV;}0Vn>6P)LD;)H7tqmU*2g2SKQ&-84189VR>Aez_PF; zke>;oev0!FXf^85q0xA&?ca| z21&wq%tFOrg8Z>M?PlcbimFjaOy@_OG-zA$9o2lIC1LTXD#)3{p+z6P&Hat~Qvmsn z1fK{H-gf$Lr%M!cTXEq{cdIUMAF(X@vr+evd|j~!yU!oEy8DS5l!rvRXoQW^-hX{J z)UM`sG(+9|AGbu!`|7T`>cB5*&%5}S+J&_4SRRtA{Ug8(yjFWjPA`7rbl%n-(?wf- zj@wSip0K0ZBROICc$%=V5vo2hs?=jAgCp@r@M O0000PcU;ZX% ze0bRW|ETJ6A+~cOZ2SkV&%DilyRKA!&he_(cW(bTbpqMaFZ9-FR)jD!keQLB%#t9! tiJK9~zR_y3QOyjbV%80AhCe(3jGNC{Y^xHSFbOEc;OXk;vd$@?2>|IcL5lzY literal 0 HcmV?d00001 diff --git a/files/opencs/resources.qrc b/files/opencs/resources.qrc index 1bcd3ab4f..973f414fb 100644 --- a/files/opencs/resources.qrc +++ b/files/opencs/resources.qrc @@ -80,6 +80,8 @@ flying eye.png orbit2.png scene-play.png + grid-view.png + grid-view-small.png scene-view-references.png scene-view-terrain.png scene-view-water.png From bf9aa2e1317ec2b49ecb84b32924d0a1ba2397b2 Mon Sep 17 00:00:00 2001 From: pi03k Date: Wed, 27 Jan 2016 18:50:53 +0100 Subject: [PATCH 14/18] Extracted resizing of window's width to separate method --- apps/opencs/view/doc/view.cpp | 57 +++++++++++++++++++---------------- apps/opencs/view/doc/view.hpp | 2 +- 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 3491c9de2..234483744 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -570,32 +570,7 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin // mScrollbarOnly = windows["mainwindow-scrollbar"].toString() == "Scrollbar Only"; - QDesktopWidget *dw = QApplication::desktop(); - QRect rect; - if (windows["grow-limit"].isTrue()) - rect = dw->screenGeometry(this); - else - rect = dw->screenGeometry(dw->screen(dw->screenNumber(this))); - - if (!mScrollbarOnly && mScroll && mSubViews.size() > 1) - { - int newWidth = width()+minWidth; - int frameWidth = frameGeometry().width() - width(); - if (newWidth+frameWidth <= rect.width()) - { - resize(newWidth, height()); - // WARNING: below code assumes that new subviews are added to the right - if (x() > rect.width()-(newWidth+frameWidth)) - move(rect.width()-(newWidth+frameWidth), y()); // shift left to stay within the screen - } - else - { - // full width - resize(rect.width()-frameWidth, height()); - mSubViewWindow.setMinimumWidth(mSubViewWindow.width()+minWidth); - move(0, y()); - } - } + updateWidth(windows["grow-limit"].isTrue(), minWidth); mSubViewWindow.addDockWidget (Qt::TopDockWidgetArea, view); @@ -959,3 +934,33 @@ void CSVDoc::View::merge() { emit mergeDocument (mDocument); } + +void CSVDoc::View::updateWidth(bool isGrowLimit, int minSubViewWidth) +{ + QDesktopWidget *dw = QApplication::desktop(); + QRect rect; + if (isGrowLimit) + rect = dw->screenGeometry(this); + else + rect = dw->screenGeometry(dw->screen(dw->screenNumber(this))); + + if (!mScrollbarOnly && mScroll && mSubViews.size() > 1) + { + int newWidth = width()+minSubViewWidth; + int frameWidth = frameGeometry().width() - width(); + if (newWidth+frameWidth <= rect.width()) + { + resize(newWidth, height()); + // WARNING: below code assumes that new subviews are added to the right + if (x() > rect.width()-(newWidth+frameWidth)) + move(rect.width()-(newWidth+frameWidth), y()); // shift left to stay within the screen + } + else + { + // full width + resize(rect.width()-frameWidth, height()); + mSubViewWindow.setMinimumWidth(mSubViewWindow.width()+minSubViewWidth); + move(0, y()); + } + } +} diff --git a/apps/opencs/view/doc/view.hpp b/apps/opencs/view/doc/view.hpp index 7d5304269..4a620121e 100644 --- a/apps/opencs/view/doc/view.hpp +++ b/apps/opencs/view/doc/view.hpp @@ -95,7 +95,7 @@ namespace CSVDoc void resizeViewHeight (int height); void updateScrollbar(); - + void updateWidth(bool isGrowLimit, int minSubViewWidth); public: View (ViewManager& viewManager, CSMDoc::Document *document, int totalViews); From 9539925f3e8cd0465bf6ff552dca93655f694d18 Mon Sep 17 00:00:00 2001 From: pi03k Date: Mon, 1 Feb 2016 12:12:14 +0100 Subject: [PATCH 15/18] Fixed typo in updateSubViewIndices. Changed 0 to NULL for pointers. --- apps/opencs/view/doc/subview.cpp | 2 +- apps/opencs/view/doc/subview.hpp | 2 +- apps/opencs/view/doc/view.cpp | 10 +++++----- apps/opencs/view/doc/view.hpp | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/opencs/view/doc/subview.cpp b/apps/opencs/view/doc/subview.cpp index 67a8f8c70..82cbe835e 100644 --- a/apps/opencs/view/doc/subview.cpp +++ b/apps/opencs/view/doc/subview.cpp @@ -47,7 +47,7 @@ void CSVDoc::SubView::setUniversalId (const CSMWorld::UniversalId& id) void CSVDoc::SubView::closeEvent (QCloseEvent *event) { - emit updateSubViewIndicies (this); + emit updateSubViewIndices (this); } std::string CSVDoc::SubView::getTitle() const diff --git a/apps/opencs/view/doc/subview.hpp b/apps/opencs/view/doc/subview.hpp index 1c5f8a786..8402bf79a 100644 --- a/apps/opencs/view/doc/subview.hpp +++ b/apps/opencs/view/doc/subview.hpp @@ -64,7 +64,7 @@ namespace CSVDoc void updateTitle(); - void updateSubViewIndicies (SubView *view = 0); + void updateSubViewIndices (SubView *view = NULL); void universalIdChanged (const CSMWorld::UniversalId& universalId); diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 234483744..e606ff36d 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -343,7 +343,7 @@ void CSVDoc::View::updateTitle() setWindowTitle (QString::fromUtf8(stream.str().c_str())); } -void CSVDoc::View::updateSubViewIndicies(SubView *view) +void CSVDoc::View::updateSubViewIndices(SubView *view) { CSMPrefs::Category& windows = CSMPrefs::State::get()["Windows"]; @@ -574,7 +574,7 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin mSubViewWindow.addDockWidget (Qt::TopDockWidgetArea, view); - updateSubViewIndicies(); + updateSubViewIndices(); connect (view, SIGNAL (focusId (const CSMWorld::UniversalId&, const std::string&)), this, SLOT (addSubView (const CSMWorld::UniversalId&, const std::string&))); @@ -583,8 +583,8 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin connect (view, SIGNAL (updateTitle()), this, SLOT (updateTitle())); - connect (view, SIGNAL (updateSubViewIndicies (SubView *)), - this, SLOT (updateSubViewIndicies (SubView *))); + connect (view, SIGNAL (updateSubViewIndices (SubView *)), + this, SLOT (updateSubViewIndices (SubView *))); view->show(); @@ -606,7 +606,7 @@ void CSVDoc::View::moveScrollBarToEnd(int min, int max) void CSVDoc::View::settingChanged (const CSMPrefs::Setting *setting) { if (*setting=="Windows/hide-subview") - updateSubViewIndicies (0); + updateSubViewIndices (NULL); else if (*setting=="Windows/mainwindow-scrollbar") { if (setting->toString()!="Grow Only") diff --git a/apps/opencs/view/doc/view.hpp b/apps/opencs/view/doc/view.hpp index 4a620121e..835702e41 100644 --- a/apps/opencs/view/doc/view.hpp +++ b/apps/opencs/view/doc/view.hpp @@ -143,7 +143,7 @@ namespace CSVDoc void updateTitle(); // called when subviews are added or removed - void updateSubViewIndicies (SubView *view = 0); + void updateSubViewIndices (SubView *view = NULL); private slots: From 3bfab9c2c9068cccd13a9caab7c3ad1fa146be57 Mon Sep 17 00:00:00 2001 From: pi03k Date: Mon, 1 Feb 2016 12:39:24 +0100 Subject: [PATCH 16/18] extracted creation of scroll area to separate method --- apps/opencs/view/doc/view.cpp | 18 ++++++++++-------- apps/opencs/view/doc/view.hpp | 1 + 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index e606ff36d..ff5257486 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -419,10 +419,7 @@ CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int to } else { - mScroll = new QScrollArea(this); - mScroll->setWidgetResizable(true); - mScroll->setWidget(&mSubViewWindow); - setCentralWidget(mScroll); + createScrollArea(); } mOperations = new Operations; @@ -626,10 +623,7 @@ void CSVDoc::View::settingChanged (const CSMPrefs::Setting *setting) } else { - mScroll = new QScrollArea(this); - mScroll->setWidgetResizable(true); - mScroll->setWidget(&mSubViewWindow); - setCentralWidget(mScroll); + createScrollArea(); } } else if (mScroll) @@ -964,3 +958,11 @@ void CSVDoc::View::updateWidth(bool isGrowLimit, int minSubViewWidth) } } } + +void CSVDoc::View::createScrollArea() +{ + mScroll = new QScrollArea(this); + mScroll->setWidgetResizable(true); + mScroll->setWidget(&mSubViewWindow); + setCentralWidget(mScroll); +} diff --git a/apps/opencs/view/doc/view.hpp b/apps/opencs/view/doc/view.hpp index 835702e41..d95499191 100644 --- a/apps/opencs/view/doc/view.hpp +++ b/apps/opencs/view/doc/view.hpp @@ -96,6 +96,7 @@ namespace CSVDoc void updateScrollbar(); void updateWidth(bool isGrowLimit, int minSubViewWidth); + void createScrollArea(); public: View (ViewManager& viewManager, CSMDoc::Document *document, int totalViews); From 128508882a038ae54cc22569edd96e4088bc69ed Mon Sep 17 00:00:00 2001 From: pi03k Date: Wed, 3 Feb 2016 16:24:43 +0100 Subject: [PATCH 17/18] Changed some zeros to NULLs in view.cpp --- apps/opencs/view/doc/view.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index ff5257486..6f14e5a4d 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -373,7 +373,7 @@ void CSVDoc::View::updateSubViewIndices(SubView *view) else { delete subView->titleBarWidget(); - subView->setTitleBarWidget (0); + subView->setTitleBarWidget (NULL); } } } @@ -402,7 +402,7 @@ void CSVDoc::View::updateActions() CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int totalViews) : mViewManager (viewManager), mDocument (document), mViewIndex (totalViews-1), - mViewTotal (totalViews), mScroll(0), mScrollbarOnly(false) + mViewTotal (totalViews), mScroll(NULL), mScrollbarOnly(false) { CSMPrefs::Category& windows = CSMPrefs::State::get()["Windows"]; @@ -631,7 +631,7 @@ void CSVDoc::View::settingChanged (const CSMPrefs::Setting *setting) mScroll->takeWidget(); setCentralWidget (&mSubViewWindow); mScroll->deleteLater(); - mScroll = 0; + mScroll = NULL; } } } From 5e27abe874412f976f7a02e393cc57357381760c Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 4 Mar 2016 09:51:33 +0100 Subject: [PATCH 18/18] updated credits file --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 79cb87e64..6898c7a9a 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -94,6 +94,7 @@ Programmers Nolan Poe (nopoe) Paul Cercueil (pcercuei) Paul McElroy (Greendogo) + Pi03k Pieter van der Kloet (pvdk) pkubik Radu-Marius Popovici (rpopovici)