From 480302d634fa5bf418956be596e2738ea59a9a5f Mon Sep 17 00:00:00 2001 From: bzzt Date: Sat, 10 Aug 2019 13:37:00 +0000 Subject: [PATCH 01/44] terrainclusterculling --- components/terrain/chunkmanager.cpp | 3 +++ components/terrain/terraindrawable.cpp | 30 +++++++++++++++++++++++++- components/terrain/terraindrawable.hpp | 9 ++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/components/terrain/chunkmanager.cpp b/components/terrain/chunkmanager.cpp index 881397936..3c76945d3 100644 --- a/components/terrain/chunkmanager.cpp +++ b/components/terrain/chunkmanager.cpp @@ -3,6 +3,7 @@ #include #include +#include #include @@ -198,6 +199,8 @@ osg::ref_ptr ChunkManager::createChunk(float chunkSize, const osg::Ve for (unsigned int i=0; isetTexCoordArray(i, mBufferCache.getUVBuffer(numVerts)); + geometry->createClusterCullingCallback(); + if (useCompositeMap) { osg::ref_ptr compositeMap = new CompositeMap; diff --git a/components/terrain/terraindrawable.cpp b/components/terrain/terraindrawable.cpp index 151977cd4..c37074dac 100644 --- a/components/terrain/terraindrawable.cpp +++ b/components/terrain/terraindrawable.cpp @@ -1,5 +1,6 @@ #include "terraindrawable.hpp" +#include #include #include @@ -36,6 +37,23 @@ inline float distance(const osg::Vec3& coord,const osg::Matrix& matrix) return -((float)coord[0]*(float)matrix(0,2)+(float)coord[1]*(float)matrix(1,2)+(float)coord[2]*(float)matrix(2,2)+matrix(3,2)); } +//canot use ClusterCullingCallback::cull: viewpoint != eyepoint +// !osgfixpotential! +bool clusterCull(osg::ClusterCullingCallback* cb, const osg::Vec3f& eyePoint, bool shadowcam) +{ + float _deviation = cb->getDeviation(); + const osg::Vec3& _controlPoint = cb->getControlPoint(); + osg::Vec3 _normal = cb->getNormal(); + if (shadowcam) _normal = _normal * -1; //inverting for shadowcam frontfaceculing + float _radius = cb->getRadius(); + if (_deviation<=-1.0f) return false; + osg::Vec3 eye_cp = eyePoint - _controlPoint; + float radius = eye_cp.length(); + if (radius<_radius) return false; + float deviation = (eye_cp * _normal)/radius; + return deviation < _deviation; +} + void TerrainDrawable::cull(osgUtil::CullVisitor *cv) { const osg::BoundingBox& bb = getBoundingBox(); @@ -43,6 +61,11 @@ void TerrainDrawable::cull(osgUtil::CullVisitor *cv) if (_cullingActive && cv->isCulled(getBoundingBox())) return; + bool shadowcam = cv->getCurrentCamera()->getName() == "ShadowCamera"; + + if (cv->getCullingMode() & osg::CullStack::CLUSTER_CULLING && clusterCull(mClusterCullingCallback, cv->getEyePoint(), shadowcam)) + return; + osg::RefMatrix& matrix = *cv->getModelViewMatrix(); if (cv->getComputeNearFarMode() && bb.valid()) @@ -55,7 +78,7 @@ void TerrainDrawable::cull(osgUtil::CullVisitor *cv) if (osg::isNaN(depth)) return; - if (cv->getCurrentCamera()->getName() == "ShadowCamera") + if (shadowcam) { cv->addDrawableAndDepth(this, &matrix, depth); return; @@ -80,6 +103,11 @@ void TerrainDrawable::cull(osgUtil::CullVisitor *cv) cv->popStateSet(); } +void TerrainDrawable::createClusterCullingCallback() +{ + mClusterCullingCallback = new osg::ClusterCullingCallback(this); +} + void TerrainDrawable::setPasses(const TerrainDrawable::PassVector &passes) { mPasses = passes; diff --git a/components/terrain/terraindrawable.hpp b/components/terrain/terraindrawable.hpp index b77b6b784..516b1abdb 100644 --- a/components/terrain/terraindrawable.hpp +++ b/components/terrain/terraindrawable.hpp @@ -3,6 +3,11 @@ #include +namespace osg +{ + class ClusterCullingCallback; +} + namespace osgUtil { class CullVisitor; @@ -43,6 +48,8 @@ namespace Terrain void setLightListCallback(SceneUtil::LightListCallback* lightListCallback); + void createClusterCullingCallback(); + virtual void compileGLObjects(osg::RenderInfo& renderInfo) const; void setCompositeMap(CompositeMap* map) { mCompositeMap = map; } @@ -51,6 +58,8 @@ namespace Terrain private: PassVector mPasses; + osg::ref_ptr mClusterCullingCallback; + osg::ref_ptr mLightListCallback; osg::ref_ptr mCompositeMap; osg::ref_ptr mCompositeMapRenderer; From 8e741a0d0b30ac85e58311e0f4dfdf04438157eb Mon Sep 17 00:00:00 2001 From: Cody Date: Sat, 11 Apr 2020 23:01:16 -0700 Subject: [PATCH 02/44] fixed tab focus for pinned windows --- apps/openmw/mwgui/keyboardnavigation.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/openmw/mwgui/keyboardnavigation.cpp b/apps/openmw/mwgui/keyboardnavigation.cpp index 3f98b8607..d6922dc83 100644 --- a/apps/openmw/mwgui/keyboardnavigation.cpp +++ b/apps/openmw/mwgui/keyboardnavigation.cpp @@ -116,6 +116,13 @@ void KeyboardNavigation::onFrame() if (!mEnabled) return; + MWGui::GuiMode mode = MWBase::Environment::get().getWindowManager()->getMode(); + if (mode == GM_None) + { + MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(nullptr); + return; + } + MyGUI::Widget* focus = MyGUI::InputManager::getInstance().getKeyFocusWidget(); if (focus == mCurrentFocus) @@ -215,6 +222,10 @@ bool KeyboardNavigation::injectKeyPress(MyGUI::KeyCode key, unsigned int text, b bool KeyboardNavigation::switchFocus(int direction, bool wrap) { + MWGui::GuiMode mode = MWBase::Environment::get().getWindowManager()->getMode(); + if (mode == GM_None) + return false; + MyGUI::Widget* focus = MyGUI::InputManager::getInstance().getKeyFocusWidget(); bool isCycle = (direction == D_Prev || direction == D_Next); From a34fe1d9b288c4974e8fb7822f3bdfd4e6631915 Mon Sep 17 00:00:00 2001 From: Cody Date: Sun, 12 Apr 2020 10:18:07 -0700 Subject: [PATCH 03/44] proper game mode detection --- apps/openmw/mwgui/keyboardnavigation.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwgui/keyboardnavigation.cpp b/apps/openmw/mwgui/keyboardnavigation.cpp index d6922dc83..6dd66029b 100644 --- a/apps/openmw/mwgui/keyboardnavigation.cpp +++ b/apps/openmw/mwgui/keyboardnavigation.cpp @@ -116,8 +116,7 @@ void KeyboardNavigation::onFrame() if (!mEnabled) return; - MWGui::GuiMode mode = MWBase::Environment::get().getWindowManager()->getMode(); - if (mode == GM_None) + if (!MWBase::Environment::get().getWindowManager()->isGuiMode()) { MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(nullptr); return; @@ -222,8 +221,7 @@ bool KeyboardNavigation::injectKeyPress(MyGUI::KeyCode key, unsigned int text, b bool KeyboardNavigation::switchFocus(int direction, bool wrap) { - MWGui::GuiMode mode = MWBase::Environment::get().getWindowManager()->getMode(); - if (mode == GM_None) + if (!MWBase::Environment::get().getWindowManager()->isGuiMode()) return false; MyGUI::Widget* focus = MyGUI::InputManager::getInstance().getKeyFocusWidget(); From 4e22f03ece5d3e8d4a6f374720f00854cf63171b Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Mon, 13 Apr 2020 20:17:16 +0300 Subject: [PATCH 04/44] Revise esmtool cell reference output --- apps/esmtool/esmtool.cpp | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/apps/esmtool/esmtool.cpp b/apps/esmtool/esmtool.cpp index 4734e1c56..59095c1df 100644 --- a/apps/esmtool/esmtool.cpp +++ b/apps/esmtool/esmtool.cpp @@ -258,18 +258,37 @@ void loadCell(ESM::Cell &cell, ESM::ESMReader &esm, Arguments& info) if(quiet) continue; std::cout << " Refnum: " << ref.mRefNum.mIndex << std::endl; - std::cout << " ID: '" << ref.mRefID << "'\n"; - std::cout << " Owner: '" << ref.mOwner << "'\n"; - std::cout << " Global: '" << ref.mGlobalVariable << "'" << std::endl; - std::cout << " Faction: '" << ref.mFaction << "'" << std::endl; - std::cout << " Faction rank: '" << ref.mFactionRank << "'" << std::endl; - std::cout << " Enchantment charge: '" << ref.mEnchantmentCharge << "'\n"; - std::cout << " Uses/health: '" << ref.mChargeInt << "'\n"; - std::cout << " Gold value: '" << ref.mGoldValue << "'\n"; - std::cout << " Blocked: '" << static_cast(ref.mReferenceBlocked) << "'" << std::endl; + std::cout << " ID: " << ref.mRefID << std::endl; + std::cout << " Position: (" << ref.mPos.pos[0] << ", " << ref.mPos.pos[1] << ", " << ref.mPos.pos[2] << ")" << std::endl; + if (ref.mScale != 1.f) + std::cout << " Scale: " << ref.mScale << std::endl; + if (!ref.mOwner.empty()) + std::cout << " Owner: " << ref.mOwner << std::endl; + if (!ref.mGlobalVariable.empty()) + std::cout << " Global: " << ref.mGlobalVariable << std::endl; + if (!ref.mFaction.empty()) + std::cout << " Faction: " << ref.mFaction << std::endl; + if (!ref.mFaction.empty() || ref.mFactionRank != -2) + std::cout << " Faction rank: " << ref.mFactionRank << std::endl; + std::cout << " Enchantment charge: " << ref.mEnchantmentCharge << std::endl; + std::cout << " Uses/health: " << ref.mChargeInt << std::endl; + std::cout << " Gold value: " << ref.mGoldValue << std::endl; + std::cout << " Blocked: " << static_cast(ref.mReferenceBlocked) << std::endl; std::cout << " Deleted: " << deleted << std::endl; if (!ref.mKey.empty()) - std::cout << " Key: '" << ref.mKey << "'" << std::endl; + std::cout << " Key: " << ref.mKey << std::endl; + std::cout << " Lock level: " << ref.mLockLevel << std::endl; + if (!ref.mTrap.empty()) + std::cout << " Trap: " << ref.mTrap << std::endl; + if (!ref.mSoul.empty()) + std::cout << " Soul: " << ref.mSoul << std::endl; + if (ref.mTeleport) + { + std::cout << " Destination position: (" << ref.mDoorDest.pos[0] << ", " + << ref.mDoorDest.pos[1] << ", " << ref.mDoorDest.pos[2] << ")" << std::endl; + if (!ref.mDestCell.empty()) + std::cout << " Destination cell: " << ref.mDestCell << std::endl; + } } } From 5dc8da5f672f73a844864493d4938a7962a7275c Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Sun, 12 Apr 2020 14:40:06 +0300 Subject: [PATCH 05/44] Only disarm traps with keys when the door is locked (bug #5370) --- CHANGELOG.md | 1 + apps/openmw/mwclass/container.cpp | 5 ++--- apps/openmw/mwclass/door.cpp | 5 ++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 675766ad9..e49ba92ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Bug #5364: Script fails/stops if trying to startscript an unknown script Bug #5367: Selecting a spell on an enchanted item per hotkey always plays the equip sound Bug #5369: Spawnpoint in the Grazelands doesn't produce oversized creatures + Bug #5370: Opening an unlocked but trapped door uses the key Feature #5362: Show the soul gems' trapped soul in count dialog 0.46.0 diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index 3adeb19d9..b4b068c91 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -177,11 +177,10 @@ namespace MWClass } } - if ((isLocked || isTrapped) && hasKey) + if (isLocked && hasKey) { MWBase::Environment::get().getWindowManager ()->messageBox (keyName + " #{sKeyUsed}"); - if(isLocked) - ptr.getCellRef().unlock(); + ptr.getCellRef().unlock(); // using a key disarms the trap if(isTrapped) { diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 7d1c1d38a..19ba5351a 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -158,12 +158,11 @@ namespace MWClass } } - if ((isLocked || isTrapped) && hasKey) + if (isLocked && hasKey) { if(actor == MWMechanics::getPlayer()) MWBase::Environment::get().getWindowManager()->messageBox(keyName + " #{sKeyUsed}"); - if(isLocked) - ptr.getCellRef().unlock(); //Call the function here. because that makes sense. + ptr.getCellRef().unlock(); //Call the function here. because that makes sense. // using a key disarms the trap if(isTrapped) { From 36d82abafdf8022a3e51d7f62830687a6f87b821 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Mon, 13 Apr 2020 21:09:06 +0300 Subject: [PATCH 06/44] Make book layer have lower priority than the layer for other GUI windows --- files/mygui/openmw_layers.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/mygui/openmw_layers.xml b/files/mygui/openmw_layers.xml index 24595881a..a98efe07c 100644 --- a/files/mygui/openmw_layers.xml +++ b/files/mygui/openmw_layers.xml @@ -6,10 +6,10 @@ - + From 208a50340db5506dded60c05272ce9692773baa9 Mon Sep 17 00:00:00 2001 From: elsid Date: Mon, 13 Apr 2020 20:45:07 +0200 Subject: [PATCH 07/44] Specialize DetourNavigator::ObjectId ctor for pointers To fix msvc error: components\detournavigator\objectid.hpp(14,13): error C2440: 'reinterpret_cast': cannot convert from 'const T' to 'size_t' with [ T=unsigned long ] --- .../tilecachedrecastmeshmanager.cpp | 54 +++++++++---------- components/detournavigator/objectid.hpp | 2 +- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/apps/openmw_test_suite/detournavigator/tilecachedrecastmeshmanager.cpp b/apps/openmw_test_suite/detournavigator/tilecachedrecastmeshmanager.cpp index 5275d9119..e44ae4878 100644 --- a/apps/openmw_test_suite/detournavigator/tilecachedrecastmeshmanager.cpp +++ b/apps/openmw_test_suite/detournavigator/tilecachedrecastmeshmanager.cpp @@ -61,15 +61,15 @@ namespace { TileCachedRecastMeshManager manager(mSettings); const btBoxShape boxShape(btVector3(20, 20, 100)); - EXPECT_TRUE(manager.addObject(ObjectId(1ul), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground)); + EXPECT_TRUE(manager.addObject(ObjectId(&boxShape), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground)); } TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, add_object_for_existing_object_should_return_false) { TileCachedRecastMeshManager manager(mSettings); const btBoxShape boxShape(btVector3(20, 20, 100)); - manager.addObject(ObjectId(1ul), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); - EXPECT_FALSE(manager.addObject(ObjectId(1ul), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground)); + manager.addObject(ObjectId(&boxShape), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); + EXPECT_FALSE(manager.addObject(ObjectId(&boxShape), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground)); } TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, update_object_for_changed_object_should_return_changed_tiles) @@ -77,9 +77,9 @@ namespace TileCachedRecastMeshManager manager(mSettings); const btBoxShape boxShape(btVector3(20, 20, 100)); const btTransform transform(btMatrix3x3::getIdentity(), btVector3(getTileSize(mSettings) / mSettings.mRecastScaleFactor, 0, 0)); - manager.addObject(ObjectId(1ul), boxShape, transform, AreaType::AreaType_ground); + manager.addObject(ObjectId(&boxShape), boxShape, transform, AreaType::AreaType_ground); EXPECT_THAT( - manager.updateObject(ObjectId(1ul), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground), + manager.updateObject(ObjectId(&boxShape), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground), ElementsAre(TilePosition(-1, -1), TilePosition(-1, 0), TilePosition(0, -1), TilePosition(0, 0), TilePosition(1, -1), TilePosition(1, 0)) ); @@ -89,9 +89,9 @@ namespace { TileCachedRecastMeshManager manager(mSettings); const btBoxShape boxShape(btVector3(20, 20, 100)); - manager.addObject(ObjectId(1ul), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); + manager.addObject(ObjectId(&boxShape), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); EXPECT_EQ( - manager.updateObject(ObjectId(1ul), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground), + manager.updateObject(ObjectId(&boxShape), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground), std::vector() ); } @@ -100,7 +100,7 @@ namespace { TileCachedRecastMeshManager manager(mSettings); const btBoxShape boxShape(btVector3(20, 20, 100)); - manager.addObject(ObjectId(1ul), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); + manager.addObject(ObjectId(&boxShape), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); EXPECT_NE(manager.getMesh(TilePosition(-1, -1)), nullptr); EXPECT_NE(manager.getMesh(TilePosition(-1, 0)), nullptr); EXPECT_NE(manager.getMesh(TilePosition(0, -1)), nullptr); @@ -111,7 +111,7 @@ namespace { TileCachedRecastMeshManager manager(mSettings); const btBoxShape boxShape(btVector3(20, 20, 100)); - manager.addObject(ObjectId(1ul), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); + manager.addObject(ObjectId(&boxShape), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); EXPECT_EQ(manager.getMesh(TilePosition(1, 0)), nullptr); } @@ -121,13 +121,13 @@ namespace const btBoxShape boxShape(btVector3(20, 20, 100)); const btTransform transform(btMatrix3x3::getIdentity(), btVector3(getTileSize(mSettings) / mSettings.mRecastScaleFactor, 0, 0)); - manager.addObject(ObjectId(1ul), boxShape, transform, AreaType::AreaType_ground); + manager.addObject(ObjectId(&boxShape), boxShape, transform, AreaType::AreaType_ground); EXPECT_NE(manager.getMesh(TilePosition(0, -1)), nullptr); EXPECT_NE(manager.getMesh(TilePosition(0, 0)), nullptr); EXPECT_NE(manager.getMesh(TilePosition(1, 0)), nullptr); EXPECT_NE(manager.getMesh(TilePosition(1, -1)), nullptr); - manager.updateObject(ObjectId(1ul), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); + manager.updateObject(ObjectId(&boxShape), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); EXPECT_NE(manager.getMesh(TilePosition(-1, -1)), nullptr); EXPECT_NE(manager.getMesh(TilePosition(-1, 0)), nullptr); EXPECT_NE(manager.getMesh(TilePosition(0, -1)), nullptr); @@ -140,11 +140,11 @@ namespace const btBoxShape boxShape(btVector3(20, 20, 100)); const btTransform transform(btMatrix3x3::getIdentity(), btVector3(getTileSize(mSettings) / mSettings.mRecastScaleFactor, 0, 0)); - manager.addObject(ObjectId(1ul), boxShape, transform, AreaType::AreaType_ground); + manager.addObject(ObjectId(&boxShape), boxShape, transform, AreaType::AreaType_ground); EXPECT_EQ(manager.getMesh(TilePosition(-1, -1)), nullptr); EXPECT_EQ(manager.getMesh(TilePosition(-1, 0)), nullptr); - manager.updateObject(ObjectId(1ul), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); + manager.updateObject(ObjectId(&boxShape), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); EXPECT_EQ(manager.getMesh(TilePosition(1, 0)), nullptr); EXPECT_EQ(manager.getMesh(TilePosition(1, -1)), nullptr); } @@ -153,8 +153,8 @@ namespace { TileCachedRecastMeshManager manager(mSettings); const btBoxShape boxShape(btVector3(20, 20, 100)); - manager.addObject(ObjectId(1ul), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); - manager.removeObject(ObjectId(1ul)); + manager.addObject(ObjectId(&boxShape), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); + manager.removeObject(ObjectId(&boxShape)); EXPECT_EQ(manager.getMesh(TilePosition(-1, -1)), nullptr); EXPECT_EQ(manager.getMesh(TilePosition(-1, 0)), nullptr); EXPECT_EQ(manager.getMesh(TilePosition(0, -1)), nullptr); @@ -166,13 +166,13 @@ namespace TileCachedRecastMeshManager manager(mSettings); const btBoxShape boxShape(btVector3(20, 20, 100)); - manager.addObject(ObjectId(1ul), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); + manager.addObject(ObjectId(&boxShape), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); EXPECT_NE(manager.getMesh(TilePosition(-1, -1)), nullptr); EXPECT_NE(manager.getMesh(TilePosition(-1, 0)), nullptr); EXPECT_NE(manager.getMesh(TilePosition(0, -1)), nullptr); EXPECT_NE(manager.getMesh(TilePosition(0, 0)), nullptr); - manager.updateObject(ObjectId(1ul), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); + manager.updateObject(ObjectId(&boxShape), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); EXPECT_NE(manager.getMesh(TilePosition(-1, -1)), nullptr); EXPECT_NE(manager.getMesh(TilePosition(-1, 0)), nullptr); EXPECT_NE(manager.getMesh(TilePosition(0, -1)), nullptr); @@ -184,7 +184,7 @@ namespace TileCachedRecastMeshManager manager(mSettings); const auto initialRevision = manager.getRevision(); const btBoxShape boxShape(btVector3(20, 20, 100)); - manager.addObject(ObjectId(1ul), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); + manager.addObject(ObjectId(&boxShape), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); EXPECT_EQ(manager.getRevision(), initialRevision + 1); } @@ -192,9 +192,9 @@ namespace { TileCachedRecastMeshManager manager(mSettings); const btBoxShape boxShape(btVector3(20, 20, 100)); - manager.addObject(ObjectId(1ul), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); + manager.addObject(ObjectId(&boxShape), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); const auto beforeAddRevision = manager.getRevision(); - manager.addObject(ObjectId(1ul), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); + manager.addObject(ObjectId(&boxShape), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); EXPECT_EQ(manager.getRevision(), beforeAddRevision); } @@ -203,9 +203,9 @@ namespace TileCachedRecastMeshManager manager(mSettings); const btBoxShape boxShape(btVector3(20, 20, 100)); const btTransform transform(btMatrix3x3::getIdentity(), btVector3(getTileSize(mSettings) / mSettings.mRecastScaleFactor, 0, 0)); - manager.addObject(ObjectId(1ul), boxShape, transform, AreaType::AreaType_ground); + manager.addObject(ObjectId(&boxShape), boxShape, transform, AreaType::AreaType_ground); const auto beforeUpdateRevision = manager.getRevision(); - manager.updateObject(ObjectId(1ul), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); + manager.updateObject(ObjectId(&boxShape), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); EXPECT_EQ(manager.getRevision(), beforeUpdateRevision + 1); } @@ -213,9 +213,9 @@ namespace { TileCachedRecastMeshManager manager(mSettings); const btBoxShape boxShape(btVector3(20, 20, 100)); - manager.addObject(ObjectId(1ul), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); + manager.addObject(ObjectId(&boxShape), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); const auto beforeUpdateRevision = manager.getRevision(); - manager.updateObject(ObjectId(1ul), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); + manager.updateObject(ObjectId(&boxShape), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); EXPECT_EQ(manager.getRevision(), beforeUpdateRevision); } @@ -223,9 +223,9 @@ namespace { TileCachedRecastMeshManager manager(mSettings); const btBoxShape boxShape(btVector3(20, 20, 100)); - manager.addObject(ObjectId(1ul), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); + manager.addObject(ObjectId(&boxShape), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground); const auto beforeRemoveRevision = manager.getRevision(); - manager.removeObject(ObjectId(1ul)); + manager.removeObject(ObjectId(&boxShape)); EXPECT_EQ(manager.getRevision(), beforeRemoveRevision + 1); } @@ -233,7 +233,7 @@ namespace { TileCachedRecastMeshManager manager(mSettings); const auto beforeRemoveRevision = manager.getRevision(); - manager.removeObject(ObjectId(1ul)); + manager.removeObject(ObjectId(&manager)); EXPECT_EQ(manager.getRevision(), beforeRemoveRevision); } } diff --git a/components/detournavigator/objectid.hpp b/components/detournavigator/objectid.hpp index 3b56924b1..6ddcc9169 100644 --- a/components/detournavigator/objectid.hpp +++ b/components/detournavigator/objectid.hpp @@ -10,7 +10,7 @@ namespace DetourNavigator { public: template - explicit ObjectId(const T value) throw() + explicit ObjectId(T* value) throw() : mValue(reinterpret_cast(value)) { } From fbcc8ef046b8a2ad122fd4af895b29e590c5109f Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Tue, 14 Apr 2020 08:49:14 +0300 Subject: [PATCH 08/44] Reset dialogue history when the window can't track what closed it --- apps/openmw/mwgui/dialogue.cpp | 6 ++---- apps/openmw/mwgui/dialogue.hpp | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index bb3f3e4ba..bb40bea33 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -355,7 +355,6 @@ namespace MWGui { if (exit()) { - resetHistory(); MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Dialogue); } } @@ -476,8 +475,9 @@ namespace MWGui mDeleteLater.clear(); } - void DialogueWindow::resetHistory() + void DialogueWindow::onClose() { + // Reset history for (DialogueText* text : mHistoryContents) delete text; mHistoryContents.clear(); @@ -663,7 +663,6 @@ namespace MWGui void DialogueWindow::onGoodbyeActivated() { - resetHistory(); MWBase::Environment::get().getDialogueManager()->goodbyeSelected(); MWBase::Environment::get().getWindowManager()->removeGuiMode(MWGui::GM_Dialogue); resetReference(); @@ -718,7 +717,6 @@ namespace MWGui void DialogueWindow::onReferenceUnavailable() { - resetHistory(); MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Dialogue); } diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index 77c767ed8..2c3fb1a44 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -133,6 +133,8 @@ namespace MWGui void updateTopics(); + void onClose(); + protected: void updateTopicsPane(); bool isCompanion(const MWWorld::Ptr& actor); @@ -156,7 +158,6 @@ namespace MWGui void updateDisposition(); void restock(); void deleteLater(); - void resetHistory(); bool mIsCompanion; std::list mKeywords; From bbed9a70c5f6f1716e2d027bfd373d7027399462 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Tue, 14 Apr 2020 17:49:03 +0300 Subject: [PATCH 09/44] Ignore traps of initially unlocked refs with assigned keys --- components/esm/cellref.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/esm/cellref.cpp b/components/esm/cellref.cpp index 69841528f..ab6ba2754 100644 --- a/components/esm/cellref.cpp +++ b/components/esm/cellref.cpp @@ -130,7 +130,10 @@ void ESM::CellRef::loadData(ESMReader &esm, bool &isDeleted) } if (mLockLevel == 0 && !mKey.empty()) + { mLockLevel = UnbreakableLock; + mTrap.clear(); + } } void ESM::CellRef::save (ESMWriter &esm, bool wideRefNum, bool inInventory, bool isDeleted) const From ec7976522d63e285c95a318992736344bf4e2645 Mon Sep 17 00:00:00 2001 From: elsid Date: Wed, 15 Apr 2020 18:54:36 +0200 Subject: [PATCH 10/44] Fix issue number in changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 675766ad9..6eff7dee0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -223,7 +223,7 @@ Bug #5345: Dopey Necromancy does not work due to a missing quote Bug #5350: An attempt to launch magic bolt causes "AL error invalid value" error Bug #5352: Light source items' duration is decremented while they aren't visible - Feature #1774: Handle AvoidNode + Feature #1724: Handle AvoidNode Feature #2229: Improve pathfinding AI Feature #3025: Analogue gamepad movement controls Feature #3442: Default values for fallbacks from ini file From 6e2a651252727e655a8e0579948e39eb7241b11d Mon Sep 17 00:00:00 2001 From: Julien Valentin Date: Thu, 16 Apr 2020 02:48:42 +0200 Subject: [PATCH 11/44] fix particle alpha --- components/nifosg/nifloader.cpp | 8 -------- components/nifosg/particle.cpp | 3 +++ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index 5a9693740..07cbaee37 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -1809,14 +1809,6 @@ namespace NifOsg if (specFlags == 0) mat->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4f(0.f,0.f,0.f,0.f)); - // Particles don't have normals, so can't be diffuse lit. - if (particleMaterial) - { - // NB ignoring diffuse.a() - mat->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4f(0,0,0,1)); - mat->setColorMode(osg::Material::AMBIENT); - } - if (lightmode == 0) { osg::Vec4f diffuse = mat->getDiffuse(osg::Material::FRONT_AND_BACK); diff --git a/components/nifosg/particle.cpp b/components/nifosg/particle.cpp index c1ccede1a..2a79af1c8 100644 --- a/components/nifosg/particle.cpp +++ b/components/nifosg/particle.cpp @@ -159,8 +159,11 @@ void ParticleColorAffector::operate(osgParticle::Particle* particle, double /* d { float time = static_cast(particle->getAge()/particle->getLifeTime()); osg::Vec4f color = mData.interpKey(time); + float alpha = color.a(); + color.a() = 1.0f; particle->setColorRange(osgParticle::rangev4(color, color)); + particle->setAlphaRange(osgParticle::rangef(alpha, alpha)); } GravityAffector::GravityAffector(const Nif::NiGravity *gravity) From c3cc8ee1e17ff3b4faa2ec8b26831b90716c1fde Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Fri, 17 Apr 2020 14:08:29 +0300 Subject: [PATCH 12/44] Disable specular lighting for 4.0.0.2 and earlier files --- components/nifosg/nifloader.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index 5a9693740..74cdcefe3 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -1705,7 +1705,8 @@ namespace NifOsg { osg::StateSet* stateset = node->getOrCreateStateSet(); - int specFlags = 0; // Specular is disabled by default, even if there's a specular color in the NiMaterialProperty + // Specular lighting is enabled by default, but there's a quirk... + int specFlags = 1; osg::ref_ptr mat (new osg::Material); mat->setColorMode(hasVertexColors ? osg::Material::AMBIENT_AND_DIFFUSE : osg::Material::OFF); @@ -1723,6 +1724,7 @@ namespace NifOsg { case Nif::RC_NiSpecularProperty: { + // Specular property can turn specular lighting off. specFlags = property->flags; break; } @@ -1806,7 +1808,8 @@ namespace NifOsg } } - if (specFlags == 0) + // While NetImmerse and Gamebryo support specular lighting, Morrowind has its support disabled. + if (mVersion <= Nif::NIFFile::NIFVersion::VER_MW || specFlags == 0) mat->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4f(0.f,0.f,0.f,0.f)); // Particles don't have normals, so can't be diffuse lit. From 1cf20363868c88ff0df498330999f8cf884a50fd Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Sat, 18 Apr 2020 02:38:20 +0100 Subject: [PATCH 13/44] Don't add empty PrimitiveSets (prevent undefined behaviour) --- components/sceneutil/pathgridutil.cpp | 218 +++++++++++++------------- 1 file changed, 112 insertions(+), 106 deletions(-) diff --git a/components/sceneutil/pathgridutil.cpp b/components/sceneutil/pathgridutil.cpp index 58c5d8ad2..ed6894dfc 100644 --- a/components/sceneutil/pathgridutil.cpp +++ b/components/sceneutil/pathgridutil.cpp @@ -85,91 +85,95 @@ namespace SceneUtil osg::ref_ptr gridGeometry = new osg::Geometry(); - osg::ref_ptr vertices = new osg::Vec3Array(VertexCount); - osg::ref_ptr colors = new osg::Vec4Array(ColorCount); - osg::ref_ptr pointIndices = - new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLES, PointIndexCount); - osg::ref_ptr lineIndices = - new osg::DrawElementsUShort(osg::PrimitiveSet::LINES, EdgeIndexCount); - - // Add each point/node - for (unsigned short pointIndex = 0; pointIndex < PointCount; ++pointIndex) + if (PointIndexCount || EdgeIndexCount) { - const ESM::Pathgrid::Point& point = pathgrid.mPoints[pointIndex]; - osg::Vec3f position = osg::Vec3f(point.mX, point.mY, point.mZ); + osg::ref_ptr vertices = new osg::Vec3Array(VertexCount); + osg::ref_ptr colors = new osg::Vec4Array(ColorCount); + osg::ref_ptr pointIndices = + new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLES, PointIndexCount); + osg::ref_ptr lineIndices = + new osg::DrawElementsUShort(osg::PrimitiveSet::LINES, EdgeIndexCount); - unsigned short vertexOffset = pointIndex * DiamondTotalVertexCount; - unsigned short indexOffset = pointIndex * DiamondIndexCount; - - // Point - for (unsigned short i = 0; i < DiamondVertexCount; ++i) + // Add each point/node + for (unsigned short pointIndex = 0; pointIndex < PointCount; ++pointIndex) { - (*vertices)[vertexOffset + i] = position + DiamondPoints[i]; - (*colors)[vertexOffset + i] = DiamondColors[i]; + const ESM::Pathgrid::Point& point = pathgrid.mPoints[pointIndex]; + osg::Vec3f position = osg::Vec3f(point.mX, point.mY, point.mZ); + + unsigned short vertexOffset = pointIndex * DiamondTotalVertexCount; + unsigned short indexOffset = pointIndex * DiamondIndexCount; + + // Point + for (unsigned short i = 0; i < DiamondVertexCount; ++i) + { + (*vertices)[vertexOffset + i] = position + DiamondPoints[i]; + (*colors)[vertexOffset + i] = DiamondColors[i]; + } + + for (unsigned short i = 0; i < DiamondIndexCount; ++i) + { + pointIndices->setElement(indexOffset + i, vertexOffset + DiamondIndices[i]); + } + + // Connectors + vertexOffset += DiamondVertexCount; + for (unsigned short i = 0; i < DiamondConnectorVertexCount; ++i) + { + (*vertices)[vertexOffset + i] = position + DiamondPoints[DiamondConnectorVertices[i]]; + (*colors)[vertexOffset + i] = DiamondEdgeColor; + } } - for (unsigned short i = 0; i < DiamondIndexCount; ++i) + // Add edges + unsigned short lineIndex = 0; + + for (ESM::Pathgrid::EdgeList::const_iterator edge = pathgrid.mEdges.begin(); + edge != pathgrid.mEdges.end(); ++edge) { - pointIndices->setElement(indexOffset + i, vertexOffset + DiamondIndices[i]); + if (edge->mV0 == edge->mV1 || edge->mV0 < 0 || edge->mV0 >= PointCount || + edge->mV1 < 0 || edge->mV1 >= PointCount) + continue; + + const ESM::Pathgrid::Point& from = pathgrid.mPoints[edge->mV0]; + const ESM::Pathgrid::Point& to = pathgrid.mPoints[edge->mV1]; + + osg::Vec3f fromPos = osg::Vec3f(from.mX, from.mY, from.mZ); + osg::Vec3f toPos = osg::Vec3f(to.mX, to.mY, to.mZ); + osg::Vec3f dir = toPos - fromPos; + dir.normalize(); + + osg::Quat rot = osg::Quat(-osg::PI / 2, osg::Vec3(0, 0, 1)); + dir = rot * dir; + + unsigned short diamondIndex = 0; + if (dir.isNaN()) + diamondIndex = 0; + else if (dir.y() >= 0 && dir.x() > 0) + diamondIndex = 3; + else if (dir.x() <= 0 && dir.y() > 0) + diamondIndex = 1; + else if (dir.y() <= 0 && dir.x() < 0) + diamondIndex = 0; + else if (dir.x() >= 0 && dir.y() < 0) + diamondIndex = 2; + + unsigned short fromIndex = static_cast(edge->mV0); + unsigned short toIndex = static_cast(edge->mV1); + + lineIndices->setElement(lineIndex++, fromIndex * DiamondTotalVertexCount + DiamondVertexCount + diamondIndex); + lineIndices->setElement(lineIndex++, toIndex * DiamondTotalVertexCount + DiamondVertexCount + diamondIndex); } - // Connectors - vertexOffset += DiamondVertexCount; - for (unsigned short i = 0; i < DiamondConnectorVertexCount; ++i) - { - (*vertices)[vertexOffset + i] = position + DiamondPoints[DiamondConnectorVertices[i]]; - (*colors)[vertexOffset + i] = DiamondEdgeColor; - } + lineIndices->resize(lineIndex); + + gridGeometry->setVertexArray(vertices); + gridGeometry->setColorArray(colors, osg::Array::BIND_PER_VERTEX); + if (PointIndexCount) + gridGeometry->addPrimitiveSet(pointIndices); + if (EdgeIndexCount) + gridGeometry->addPrimitiveSet(lineIndices); + gridGeometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF); } - - // Add edges - unsigned short lineIndex = 0; - - for (ESM::Pathgrid::EdgeList::const_iterator edge = pathgrid.mEdges.begin(); - edge != pathgrid.mEdges.end(); ++edge) - { - if (edge->mV0 == edge->mV1 || edge->mV0 < 0 || edge->mV0 >= PointCount || - edge->mV1 < 0 || edge->mV1 >= PointCount) - continue; - - const ESM::Pathgrid::Point& from = pathgrid.mPoints[edge->mV0]; - const ESM::Pathgrid::Point& to = pathgrid.mPoints[edge->mV1]; - - osg::Vec3f fromPos = osg::Vec3f(from.mX, from.mY, from.mZ); - osg::Vec3f toPos = osg::Vec3f(to.mX, to.mY, to.mZ); - osg::Vec3f dir = toPos - fromPos; - dir.normalize(); - - osg::Quat rot = osg::Quat(-osg::PI / 2, osg::Vec3(0, 0, 1)); - dir = rot * dir; - - unsigned short diamondIndex = 0; - if (dir.isNaN()) - diamondIndex = 0; - else if (dir.y() >= 0 && dir.x() > 0) - diamondIndex = 3; - else if (dir.x() <= 0 && dir.y() > 0) - diamondIndex = 1; - else if (dir.y() <= 0 && dir.x() < 0) - diamondIndex = 0; - else if (dir.x() >= 0 && dir.y() < 0) - diamondIndex = 2; - - unsigned short fromIndex = static_cast(edge->mV0); - unsigned short toIndex = static_cast(edge->mV1); - - lineIndices->setElement(lineIndex++, fromIndex * DiamondTotalVertexCount + DiamondVertexCount + diamondIndex); - lineIndices->setElement(lineIndex++, toIndex * DiamondTotalVertexCount + DiamondVertexCount + diamondIndex); - } - - lineIndices->resize(lineIndex); - - gridGeometry->setVertexArray(vertices); - gridGeometry->setColorArray(colors, osg::Array::BIND_PER_VERTEX); - gridGeometry->addPrimitiveSet(pointIndices); - gridGeometry->addPrimitiveSet(lineIndices); - gridGeometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF); - return gridGeometry; } @@ -184,44 +188,46 @@ namespace SceneUtil osg::ref_ptr wireframeGeometry = new osg::Geometry(); - osg::ref_ptr vertices = new osg::Vec3Array(VertexCount); - osg::ref_ptr colors = new osg::Vec4Array(ColorCount); - osg::ref_ptr indices = - new osg::DrawElementsUShort(osg::PrimitiveSet::LINES, IndexCount); - - osg::Vec3f wireOffset = osg::Vec3f(0, 0, (1 - DiamondWireframeScalar) * DiamondHalfHeight); - - // Add each point/node - for (unsigned short it = 0; it < PointCount; ++it) + if (IndexCount) { - const ESM::Pathgrid::Point& point = pathgrid.mPoints[selected[it]]; - osg::Vec3f position = osg::Vec3f(point.mX, point.mY, point.mZ) + wireOffset; + osg::ref_ptr vertices = new osg::Vec3Array(VertexCount); + osg::ref_ptr colors = new osg::Vec4Array(ColorCount); + osg::ref_ptr indices = + new osg::DrawElementsUShort(osg::PrimitiveSet::LINES, IndexCount); - unsigned short vertexOffset = it * DiamondVertexCount; - unsigned short indexOffset = it * DiamondWireframeIndexCount; + osg::Vec3f wireOffset = osg::Vec3f(0, 0, (1 - DiamondWireframeScalar) * DiamondHalfHeight); - // Point - for (unsigned short i = 0; i < DiamondVertexCount; ++i) + // Add each point/node + for (unsigned short it = 0; it < PointCount; ++it) { - (*vertices)[vertexOffset + i] = position + DiamondPoints[i] * DiamondWireframeScalar; + const ESM::Pathgrid::Point& point = pathgrid.mPoints[selected[it]]; + osg::Vec3f position = osg::Vec3f(point.mX, point.mY, point.mZ) + wireOffset; - if (it == PointCount - 1) - (*colors)[vertexOffset + i] = DiamondFocusWireColor; - else - (*colors)[vertexOffset + i] = DiamondWireColor; + unsigned short vertexOffset = it * DiamondVertexCount; + unsigned short indexOffset = it * DiamondWireframeIndexCount; + + // Point + for (unsigned short i = 0; i < DiamondVertexCount; ++i) + { + (*vertices)[vertexOffset + i] = position + DiamondPoints[i] * DiamondWireframeScalar; + + if (it == PointCount - 1) + (*colors)[vertexOffset + i] = DiamondFocusWireColor; + else + (*colors)[vertexOffset + i] = DiamondWireColor; + } + + for (unsigned short i = 0; i < DiamondWireframeIndexCount; ++i) + { + indices->setElement(indexOffset + i, vertexOffset + DiamondWireframeIndices[i]); + } } - for (unsigned short i = 0; i < DiamondWireframeIndexCount; ++i) - { - indices->setElement(indexOffset + i, vertexOffset + DiamondWireframeIndices[i]); - } + wireframeGeometry->setVertexArray(vertices); + wireframeGeometry->setColorArray(colors, osg::Array::BIND_PER_VERTEX); + wireframeGeometry->addPrimitiveSet(indices); + wireframeGeometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF); } - - wireframeGeometry->setVertexArray(vertices); - wireframeGeometry->setColorArray(colors, osg::Array::BIND_PER_VERTEX); - wireframeGeometry->addPrimitiveSet(indices); - wireframeGeometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF); - return wireframeGeometry; } From bbf6b4e51779a4b7ff45318f199b8864e101b468 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Sat, 18 Apr 2020 12:30:01 +0300 Subject: [PATCH 14/44] Don't radialize underwater fog --- files/shaders/water_fragment.glsl | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/files/shaders/water_fragment.glsl b/files/shaders/water_fragment.glsl index 6e51a2082..86edd8698 100644 --- a/files/shaders/water_fragment.glsl +++ b/files/shaders/water_fragment.glsl @@ -203,17 +203,20 @@ void main(void) float ior = (cameraPos.z>0.0)?(1.333/1.0):(1.0/1.333); // air to water; water to air float fresnel = clamp(fresnel_dielectric(vVec, normal, ior), 0.0, 1.0); + float radialise = 1.0; + #if @radialFog float radialDepth = distance(position.xyz, cameraPos); - float radialize = radialDepth / linearDepth; -#else - float radialize = 1.0; + // TODO: Figure out how to properly radialise refraction depth and thus underwater fog + // while avoiding oddities when the water plane is close to the clipping plane + // radialise = radialDepth / linearDepth; #endif + vec2 screenCoordsOffset = normal.xy * REFL_BUMP; #if REFRACTION - float depthSample = linearizeDepth(texture2D(refractionDepthMap,screenCoords).x) * radialize; - float depthSampleDistorted = linearizeDepth(texture2D(refractionDepthMap,screenCoords-screenCoordsOffset).x) * radialize; - float surfaceDepth = linearizeDepth(gl_FragCoord.z) * radialize; + float depthSample = linearizeDepth(texture2D(refractionDepthMap,screenCoords).x) * radialise; + float depthSampleDistorted = linearizeDepth(texture2D(refractionDepthMap,screenCoords-screenCoordsOffset).x) * radialise; + float surfaceDepth = linearizeDepth(gl_FragCoord.z) * radialise; float realWaterDepth = depthSample - surfaceDepth; // undistorted water depth in view direction, independent of frustum screenCoordsOffset *= clamp(realWaterDepth / BUMP_SUPPRESS_DEPTH,0,1); #endif From 513ac8986d1f3f57d85c8fa4e2913c1160b5561b Mon Sep 17 00:00:00 2001 From: Frederic Chardon Date: Sat, 18 Apr 2020 20:54:21 +0000 Subject: [PATCH 15/44] Add link to opencs documentation on readthedocs, available through context menu. The documentation opens in default browser. There are 3 contexts: - global: opens the OpenMW CS User Manual main page - when a record is selected: opens the "Tables" page - when the filter field is selected: opens the "Record Filters" page There is also a link to the OpenCS tutorial in the help menu. --- CMakeLists.txt | 3 +++ apps/launcher/maindialog.cpp | 9 +++++++++ apps/launcher/maindialog.hpp | 1 + apps/opencs/model/prefs/state.cpp | 2 ++ apps/opencs/view/doc/view.cpp | 17 ++++++++++++++++ apps/opencs/view/doc/view.hpp | 4 ++++ apps/opencs/view/filter/editwidget.cpp | 27 ++++++++++++++++++++++++++ apps/opencs/view/filter/editwidget.hpp | 4 ++++ apps/opencs/view/world/table.cpp | 16 +++++++++++++++ apps/opencs/view/world/table.hpp | 3 +++ components/CMakeLists.txt | 2 +- components/misc/helpviewer.cpp | 12 ++++++++++++ components/misc/helpviewer.hpp | 7 +++++++ 13 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 components/misc/helpviewer.cpp create mode 100644 components/misc/helpviewer.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index b7329ea7c..23f894156 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,6 +63,8 @@ set(OPENMW_VERSION_COMMITDATE "") set(OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}") +set(OPENMW_DOC_BASEURL "https://openmw.readthedocs.io/en/master/") + set(GIT_CHECKOUT FALSE) if(EXISTS ${PROJECT_SOURCE_DIR}/.git) find_package(Git) @@ -605,6 +607,7 @@ endif() # Components add_subdirectory (components) +target_compile_definitions(components PRIVATE OPENMW_DOC_BASEURL="${OPENMW_DOC_BASEURL}") # Apps and tools if (BUILD_OPENMW) diff --git a/apps/launcher/maindialog.cpp b/apps/launcher/maindialog.cpp index f69213c4a..4a2e1ba0e 100644 --- a/apps/launcher/maindialog.cpp +++ b/apps/launcher/maindialog.cpp @@ -1,6 +1,7 @@ #include "maindialog.hpp" #include +#include #include #include @@ -54,12 +55,15 @@ Launcher::MainDialog::MainDialog(QWidget *parent) iconWidget->setCurrentRow(0); iconWidget->setFlow(QListView::LeftToRight); + QPushButton *helpButton = new QPushButton(tr("Help")); QPushButton *playButton = new QPushButton(tr("Play")); buttonBox->button(QDialogButtonBox::Close)->setText(tr("Close")); + buttonBox->addButton(helpButton, QDialogButtonBox::HelpRole); buttonBox->addButton(playButton, QDialogButtonBox::AcceptRole); connect(buttonBox, SIGNAL(rejected()), this, SLOT(close())); connect(buttonBox, SIGNAL(accepted()), this, SLOT(play())); + connect(buttonBox, SIGNAL(helpRequested()), this, SLOT(help())); // Remove what's this? button setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint); @@ -614,3 +618,8 @@ void Launcher::MainDialog::play() if (mGameInvoker->startProcess(QLatin1String("openmw"), true)) return qApp->quit(); } + +void Launcher::MainDialog::help() +{ + Misc::HelpViewer::openHelp("reference/index.html"); +} diff --git a/apps/launcher/maindialog.hpp b/apps/launcher/maindialog.hpp index 75fe5ab89..d87a43100 100644 --- a/apps/launcher/maindialog.hpp +++ b/apps/launcher/maindialog.hpp @@ -59,6 +59,7 @@ namespace Launcher public slots: void changePage(QListWidgetItem *current, QListWidgetItem *previous); void play(); + void help(); private slots: void wizardStarted(); diff --git a/apps/opencs/model/prefs/state.cpp b/apps/opencs/model/prefs/state.cpp index 89b5283a4..abd1ddfc8 100644 --- a/apps/opencs/model/prefs/state.cpp +++ b/apps/opencs/model/prefs/state.cpp @@ -271,6 +271,8 @@ void CSMPrefs::State::declare() declareShortcut ("document-file-newaddon", "New Addon", QKeySequence()); declareShortcut ("document-file-open", "Open", QKeySequence(Qt::ControlModifier | Qt::Key_O)); declareShortcut ("document-file-save", "Save", QKeySequence(Qt::ControlModifier | Qt::Key_S)); + declareShortcut ("document-help-help", "Help", QKeySequence(Qt::Key_F1)); + declareShortcut ("document-help-tutorial", "Tutorial", QKeySequence()); declareShortcut ("document-file-verify", "Verify", QKeySequence()); declareShortcut ("document-file-merge", "Merge", QKeySequence()); declareShortcut ("document-file-errorlog", "Open Load Error Log", QKeySequence()); diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index dd58cbabc..ce04f6ada 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -31,6 +31,7 @@ #include "../tools/subviews.hpp" +#include #include #include "viewmanager.hpp" @@ -315,6 +316,12 @@ void CSVDoc::View::setupHelpMenu() { QMenu *help = menuBar()->addMenu (tr ("Help")); + QAction* helpInfo = createMenuEntry("Help", ":/info.png", help, "document-help-help"); + connect (helpInfo, SIGNAL (triggered()), this, SLOT (openHelp())); + + QAction* tutorial = createMenuEntry("Tutorial", ":/info.png", help, "document-help-tutorial"); + connect (tutorial, SIGNAL (triggered()), this, SLOT (tutorial())); + QAction* about = createMenuEntry("About OpenMW-CS", ":./info.png", help, "document-help-about"); connect (about, SIGNAL (triggered()), this, SLOT (infoAbout())); @@ -708,6 +715,16 @@ void CSVDoc::View::save() mDocument->save(); } +void CSVDoc::View::openHelp() +{ + Misc::HelpViewer::openHelp("manuals/openmw-cs/index.html"); +} + +void CSVDoc::View::tutorial() +{ + Misc::HelpViewer::openHelp("manuals/openmw-cs/tour.html"); +} + void CSVDoc::View::infoAbout() { // Get current OpenMW version diff --git a/apps/opencs/view/doc/view.hpp b/apps/opencs/view/doc/view.hpp index 52057ab37..87c312412 100644 --- a/apps/opencs/view/doc/view.hpp +++ b/apps/opencs/view/doc/view.hpp @@ -169,6 +169,10 @@ namespace CSVDoc void exit(); + static void openHelp(); + + static void tutorial(); + void infoAbout(); void infoAboutQt(); diff --git a/apps/opencs/view/filter/editwidget.cpp b/apps/opencs/view/filter/editwidget.cpp index 600fa4f3b..6b585591f 100644 --- a/apps/opencs/view/filter/editwidget.cpp +++ b/apps/opencs/view/filter/editwidget.cpp @@ -1,12 +1,18 @@ #include "editwidget.hpp" #include +#include +#include +#include #include #include +#include + #include "../../model/world/data.hpp" #include "../../model/world/idtablebase.hpp" #include "../../model/world/columns.hpp" +#include "../../model/prefs/shortcut.hpp" CSVFilter::EditWidget::EditWidget (CSMWorld::Data& data, QWidget *parent) : QLineEdit (parent), mParser (data), mIsEmpty(true) @@ -29,6 +35,13 @@ CSVFilter::EditWidget::EditWidget (CSMWorld::Data& data, QWidget *parent) mStateColumnIndex = model->findColumnIndex(CSMWorld::Columns::ColumnId_Modification); mDescColumnIndex = model->findColumnIndex(CSMWorld::Columns::ColumnId_Description); + + mHelpAction = new QAction (tr ("Help"), this); + connect (mHelpAction, SIGNAL (triggered()), this, SLOT (openHelp())); + mHelpAction->setIcon(QIcon(":/info.png")); + addAction (mHelpAction); + auto* openHelpShortcut = new CSMPrefs::Shortcut("help", this); + openHelpShortcut->associateAction(mHelpAction); } void CSVFilter::EditWidget::textChanged (const QString& text) @@ -211,3 +224,17 @@ std::string CSVFilter::EditWidget::generateFilter (std::pair< std::string, std:: return ss.str(); } + +void CSVFilter::EditWidget::contextMenuEvent(QContextMenuEvent *event) +{ + QMenu *menu = createStandardContextMenu(); + menu->addAction(mHelpAction); + menu->exec(event->globalPos()); + delete menu; +} + +void CSVFilter::EditWidget::openHelp() +{ + Misc::HelpViewer::openHelp("manuals/openmw-cs/record-filters.html"); +} + diff --git a/apps/opencs/view/filter/editwidget.hpp b/apps/opencs/view/filter/editwidget.hpp index 51a36969a..b47a884a3 100644 --- a/apps/opencs/view/filter/editwidget.hpp +++ b/apps/opencs/view/filter/editwidget.hpp @@ -26,6 +26,7 @@ namespace CSVFilter bool mIsEmpty; int mStateColumnIndex; int mDescColumnIndex; + QAction *mHelpAction; public: @@ -40,6 +41,7 @@ namespace CSVFilter private: std::string generateFilter(std::pair >& seekedString) const; + void contextMenuEvent (QContextMenuEvent *event) override; private slots: @@ -51,6 +53,8 @@ namespace CSVFilter void filterRowsInserted (const QModelIndex& parent, int start, int end); + static void openHelp(); + }; } diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 11c2be5fc..e2bc87a72 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include "../../model/doc/document.hpp" @@ -155,6 +156,9 @@ void CSVWorld::Table::contextMenuEvent (QContextMenuEvent *event) } } + if (mHelpAction) + menu.addAction (mHelpAction); + menu.exec (event->globalPos()); } @@ -387,6 +391,13 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id, connect (mEditIdAction, SIGNAL (triggered()), this, SLOT (editCell())); addAction (mEditIdAction); + mHelpAction = new QAction (tr ("Help"), this); + connect (mHelpAction, SIGNAL (triggered()), this, SLOT (openHelp())); + mHelpAction->setIcon(QIcon(":/info.png")); + addAction (mHelpAction); + CSMPrefs::Shortcut* openHelpShortcut = new CSMPrefs::Shortcut("help", this); + openHelpShortcut->associateAction(mHelpAction); + connect (mProxyModel, SIGNAL (rowsRemoved (const QModelIndex&, int, int)), this, SLOT (tableSizeUpdate())); @@ -561,6 +572,11 @@ void CSVWorld::Table::editCell() emit editRequest(mEditIdAction->getCurrentId(), ""); } +void CSVWorld::Table::openHelp() +{ + Misc::HelpViewer::openHelp("manuals/openmw-cs/tables.html"); +} + void CSVWorld::Table::viewRecord() { if (!(mModel->getFeatures() & CSMWorld::IdTableBase::Feature_View)) diff --git a/apps/opencs/view/world/table.hpp b/apps/opencs/view/world/table.hpp index 02f9023e7..36c423b33 100644 --- a/apps/opencs/view/world/table.hpp +++ b/apps/opencs/view/world/table.hpp @@ -65,6 +65,7 @@ namespace CSVWorld QAction *mPreviewAction; QAction *mExtendedDeleteAction; QAction *mExtendedRevertAction; + QAction *mHelpAction; TableEditIdAction *mEditIdAction; CSMWorld::IdTableProxyModel *mProxyModel; CSMWorld::IdTableBase *mModel; @@ -128,6 +129,8 @@ namespace CSVWorld void editCell(); + static void openHelp(); + void editRecord(); void cloneRecord(); diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 8d644c6de..501960176 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -86,7 +86,7 @@ add_component_dir (esmterrain ) add_component_dir (misc - gcd constants utf8stream stringops resourcehelpers rng messageformatparser weakcache + gcd constants utf8stream stringops resourcehelpers rng messageformatparser weakcache helpviewer ) add_component_dir (debug diff --git a/components/misc/helpviewer.cpp b/components/misc/helpviewer.cpp new file mode 100644 index 000000000..0e6dadcaa --- /dev/null +++ b/components/misc/helpviewer.cpp @@ -0,0 +1,12 @@ +#include "helpviewer.hpp" + +#include +#include +#include + +void Misc::HelpViewer::openHelp(const char* url) +{ + QString link {OPENMW_DOC_BASEURL}; + link.append(url); + QDesktopServices::openUrl(QUrl(link)); +} diff --git a/components/misc/helpviewer.hpp b/components/misc/helpviewer.hpp new file mode 100644 index 000000000..7affb2c36 --- /dev/null +++ b/components/misc/helpviewer.hpp @@ -0,0 +1,7 @@ +#pragma once + +namespace Misc { + namespace HelpViewer { + void openHelp(const char* url); + } +} From 8c2f3ff00752af7b799f3d9229572343d8f8c0ed Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Sun, 19 Apr 2020 16:31:54 +0200 Subject: [PATCH 16/44] clean up code; purge const_cast --- apps/openmw/mwworld/esmstore.cpp | 4 ++-- components/esm/esmcommon.hpp | 2 ++ components/esm/esmreader.cpp | 3 +-- components/esm/esmreader.hpp | 8 +++++--- components/esm/loadcell.cpp | 4 ++-- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwworld/esmstore.cpp b/apps/openmw/mwworld/esmstore.cpp index d366a5a68..1f6ed5102 100644 --- a/apps/openmw/mwworld/esmstore.cpp +++ b/apps/openmw/mwworld/esmstore.cpp @@ -45,7 +45,7 @@ void ESMStore::load(ESM::ESMReader &esm, Loading::Listener* listener) const std::vector &masters = esm.getGameFiles(); std::vector *allPlugins = esm.getGlobalReaderList(); for (size_t j = 0; j < masters.size(); j++) { - ESM::Header::MasterData &mast = const_cast(masters[j]); + const ESM::Header::MasterData &mast = masters[j]; std::string fname = mast.name; int index = ~0; for (int i = 0; i < esm.getIndex(); i++) { @@ -63,7 +63,7 @@ void ESMStore::load(ESM::ESMReader &esm, Loading::Listener* listener) + ", but it has not been loaded yet. Please check your load order."; esm.fail(fstring); } - mast.index = index; + esm.addParentFileIndex(index); } // Loop through all records diff --git a/components/esm/esmcommon.hpp b/components/esm/esmcommon.hpp index 97ce88556..f7a8bf126 100644 --- a/components/esm/esmcommon.hpp +++ b/components/esm/esmcommon.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -126,6 +127,7 @@ struct ESM_Context // actually contribute to a specific cell. Therefore, we need to store the index // of the file belonging to this contest. See CellStore::(list/load)refs for details. int index; + std::vector parentFileIndices; // True if subName has been read but not used. bool subCached; diff --git a/components/esm/esmreader.cpp b/components/esm/esmreader.cpp index 92dbba167..1b6eca734 100644 --- a/components/esm/esmreader.cpp +++ b/components/esm/esmreader.cpp @@ -20,8 +20,7 @@ ESM_Context ESMReader::getContext() } ESMReader::ESMReader() - : mIdx(0) - , mRecordFlags(0) + : mRecordFlags(0) , mBuffer(50*1024) , mGlobalReaderList(nullptr) , mEncoder(nullptr) diff --git a/components/esm/esmreader.hpp b/components/esm/esmreader.hpp index 72a7b4790..761756e8f 100644 --- a/components/esm/esmreader.hpp +++ b/components/esm/esmreader.hpp @@ -79,13 +79,15 @@ public: // terrain palette, but ESMReader does not pass a reference to the correct plugin // to the individual load() methods. This hack allows to pass this reference // indirectly to the load() method. - int mIdx; - void setIndex(const int index) {mIdx = index; mCtx.index = index;} - int getIndex() {return mIdx;} + void setIndex(const int index) { mCtx.index = index;} + int getIndex() {return mCtx.index;} void setGlobalReaderList(std::vector *list) {mGlobalReaderList = list;} std::vector *getGlobalReaderList() {return mGlobalReaderList;} + void addParentFileIndex(int index) { mCtx.parentFileIndices.push_back(index); } + const std::vector& getParentFileIndices() const { return mCtx.parentFileIndices; } + /************************************************************************* * * Medium-level reading shortcuts diff --git a/components/esm/loadcell.cpp b/components/esm/loadcell.cpp index 5b259acef..f92a752a4 100644 --- a/components/esm/loadcell.cpp +++ b/components/esm/loadcell.cpp @@ -21,12 +21,12 @@ namespace // If we have an index value that does not make sense, assume that it was an addition // by the present plugin (but a faulty one) - if (local && local <= reader.getGameFiles().size()) + if (local && local <= reader.getParentFileIndices().size()) { // If the most significant 8 bits are used, then this reference already exists. // In this case, do not spawn a new reference, but overwrite the old one. refNum.mIndex &= 0x00ffffff; // delete old plugin ID - refNum.mContentFile = reader.getGameFiles()[local-1].index; + refNum.mContentFile = reader.getParentFileIndices()[local-1]; } else { From 91c2dea2a7a59c06e606990fea2188057aa9d2eb Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Sun, 19 Apr 2020 17:35:01 +0200 Subject: [PATCH 17/44] use OSG 3.6.5 from our PPA --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 383e30c61..5ce71a7b4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,7 @@ addons: # Audio, Video and Misc. deps libsdl2-dev, libqt5opengl5-dev, libopenal-dev, libunshield-dev, libtinyxml-dev, # The other ones from OpenMW ppa - libbullet-dev, libopenscenegraph-3.4-dev, libmygui-dev + libbullet-dev, libopenscenegraph-dev, libmygui-dev ] coverity_scan: # TODO: currently takes too long, disabled openmw/openmw-cs for now. project: From 0630cc482c4c32f78268a54cf9e0c5de02c67cfc Mon Sep 17 00:00:00 2001 From: fredzio Date: Sun, 19 Apr 2020 19:37:40 +0200 Subject: [PATCH 18/44] Compile helpviewer in components only when USE_QT is defined It fixes build of OpenMW alone (wihtout launcher or OpenCS) --- components/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 501960176..26cf38204 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -86,7 +86,7 @@ add_component_dir (esmterrain ) add_component_dir (misc - gcd constants utf8stream stringops resourcehelpers rng messageformatparser weakcache helpviewer + gcd constants utf8stream stringops resourcehelpers rng messageformatparser weakcache ) add_component_dir (debug @@ -196,6 +196,10 @@ if (USE_QT) processinvoker ) + add_component_dir (misc + helpviewer + ) + if (DESIRED_QT_VERSION MATCHES 4) include(${QT_USE_FILE}) QT4_WRAP_UI(ESM_UI_HDR ${ESM_UI}) From ddab86d94046eab0c0713371990deb04b3f423cc Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Sun, 16 Feb 2020 01:26:23 +0000 Subject: [PATCH 19/44] Use approximate comparison for floating point in test This fixes test suite on my machine --- .../detournavigator/navigator.cpp | 452 +++++++++--------- .../detournavigator/recastmeshbuilder.cpp | 9 +- 2 files changed, 234 insertions(+), 227 deletions(-) diff --git a/apps/openmw_test_suite/detournavigator/navigator.cpp b/apps/openmw_test_suite/detournavigator/navigator.cpp index df8be3781..51370c8e0 100644 --- a/apps/openmw_test_suite/detournavigator/navigator.cpp +++ b/apps/openmw_test_suite/detournavigator/navigator.cpp @@ -11,10 +11,16 @@ #include #include +#include #include #include +MATCHER_P3(Vec3fEq, x, y, z, "") +{ + return std::abs(arg.x() - x) < 1e-4 && std::abs(arg.y() - y) < 1e-4 && std::abs(arg.z() - z) < 1e-4; +} + namespace { using namespace testing; @@ -113,31 +119,31 @@ namespace EXPECT_EQ(mNavigator->findPath(mAgentHalfExtents, mStepSize, mStart, mEnd, Flag_walk, mOut), Status::Success); - EXPECT_EQ(mPath, std::deque({ - osg::Vec3f(-215, 215, 1.85963428020477294921875), - osg::Vec3f(-194.9653167724609375, 194.9653167724609375, -6.57602214813232421875), - osg::Vec3f(-174.930633544921875, 174.930633544921875, -15.01167774200439453125), - osg::Vec3f(-154.8959503173828125, 154.8959503173828125, -23.4473361968994140625), - osg::Vec3f(-134.86126708984375, 134.86126708984375, -31.8829936981201171875), - osg::Vec3f(-114.82657623291015625, 114.82657623291015625, -40.3186492919921875), - osg::Vec3f(-94.7918853759765625, 94.7918853759765625, -47.3990631103515625), - osg::Vec3f(-74.75719451904296875, 74.75719451904296875, -53.7258148193359375), - osg::Vec3f(-54.722499847412109375, 54.722499847412109375, -60.052555084228515625), - osg::Vec3f(-34.68780517578125, 34.68780517578125, -66.37931060791015625), - osg::Vec3f(-14.6531162261962890625, 14.6531162261962890625, -72.70604705810546875), - osg::Vec3f(5.3815765380859375, -5.3815765380859375, -75.35065460205078125), - osg::Vec3f(25.41626739501953125, -25.41626739501953125, -67.9694671630859375), - osg::Vec3f(45.450958251953125, -45.450958251953125, -60.5882568359375), - osg::Vec3f(65.48564910888671875, -65.48564910888671875, -53.20705413818359375), - osg::Vec3f(85.5203399658203125, -85.5203399658203125, -45.8258514404296875), - osg::Vec3f(105.55503082275390625, -105.55503082275390625, -38.44464874267578125), - osg::Vec3f(125.5897216796875, -125.5897216796875, -31.063449859619140625), - osg::Vec3f(145.6244049072265625, -145.6244049072265625, -23.6822509765625), - osg::Vec3f(165.659088134765625, -165.659088134765625, -16.3010501861572265625), - osg::Vec3f(185.6937713623046875, -185.6937713623046875, -8.91985416412353515625), - osg::Vec3f(205.7284698486328125, -205.7284698486328125, -1.5386505126953125), - osg::Vec3f(215, -215, 1.87718021869659423828125), - })) << mPath; + EXPECT_THAT(mPath, ElementsAre( + Vec3fEq(-215, 215, 1.85963428020477294921875), + Vec3fEq(-194.9653167724609375, 194.9653167724609375, -6.57602214813232421875), + Vec3fEq(-174.930633544921875, 174.930633544921875, -15.01167774200439453125), + Vec3fEq(-154.8959503173828125, 154.8959503173828125, -23.4473361968994140625), + Vec3fEq(-134.86126708984375, 134.86126708984375, -31.8829936981201171875), + Vec3fEq(-114.82657623291015625, 114.82657623291015625, -40.3186492919921875), + Vec3fEq(-94.7918853759765625, 94.7918853759765625, -47.3990631103515625), + Vec3fEq(-74.75719451904296875, 74.75719451904296875, -53.7258148193359375), + Vec3fEq(-54.722499847412109375, 54.722499847412109375, -60.052555084228515625), + Vec3fEq(-34.68780517578125, 34.68780517578125, -66.37931060791015625), + Vec3fEq(-14.6531162261962890625, 14.6531162261962890625, -72.70604705810546875), + Vec3fEq(5.3815765380859375, -5.3815765380859375, -75.35065460205078125), + Vec3fEq(25.41626739501953125, -25.41626739501953125, -67.9694671630859375), + Vec3fEq(45.450958251953125, -45.450958251953125, -60.5882568359375), + Vec3fEq(65.48564910888671875, -65.48564910888671875, -53.20705413818359375), + Vec3fEq(85.5203399658203125, -85.5203399658203125, -45.8258514404296875), + Vec3fEq(105.55503082275390625, -105.55503082275390625, -38.44464874267578125), + Vec3fEq(125.5897216796875, -125.5897216796875, -31.063449859619140625), + Vec3fEq(145.6244049072265625, -145.6244049072265625, -23.6822509765625), + Vec3fEq(165.659088134765625, -165.659088134765625, -16.3010501861572265625), + Vec3fEq(185.6937713623046875, -185.6937713623046875, -8.91985416412353515625), + Vec3fEq(205.7284698486328125, -205.7284698486328125, -1.5386505126953125), + Vec3fEq(215, -215, 1.87718021869659423828125) + )); } TEST_F(DetourNavigatorNavigatorTest, add_object_should_change_navmesh) @@ -163,31 +169,31 @@ namespace EXPECT_EQ(mNavigator->findPath(mAgentHalfExtents, mStepSize, mStart, mEnd, Flag_walk, mOut), Status::Success); - EXPECT_EQ(mPath, std::deque({ - osg::Vec3f(-215, 215, 1.85963428020477294921875), - osg::Vec3f(-194.9653167724609375, 194.9653167724609375, -6.57602214813232421875), - osg::Vec3f(-174.930633544921875, 174.930633544921875, -15.01167774200439453125), - osg::Vec3f(-154.8959503173828125, 154.8959503173828125, -23.4473361968994140625), - osg::Vec3f(-134.86126708984375, 134.86126708984375, -31.8829936981201171875), - osg::Vec3f(-114.82657623291015625, 114.82657623291015625, -40.3186492919921875), - osg::Vec3f(-94.7918853759765625, 94.7918853759765625, -47.3990631103515625), - osg::Vec3f(-74.75719451904296875, 74.75719451904296875, -53.7258148193359375), - osg::Vec3f(-54.722499847412109375, 54.722499847412109375, -60.052555084228515625), - osg::Vec3f(-34.68780517578125, 34.68780517578125, -66.37931060791015625), - osg::Vec3f(-14.6531162261962890625, 14.6531162261962890625, -72.70604705810546875), - osg::Vec3f(5.3815765380859375, -5.3815765380859375, -75.35065460205078125), - osg::Vec3f(25.41626739501953125, -25.41626739501953125, -67.9694671630859375), - osg::Vec3f(45.450958251953125, -45.450958251953125, -60.5882568359375), - osg::Vec3f(65.48564910888671875, -65.48564910888671875, -53.20705413818359375), - osg::Vec3f(85.5203399658203125, -85.5203399658203125, -45.8258514404296875), - osg::Vec3f(105.55503082275390625, -105.55503082275390625, -38.44464874267578125), - osg::Vec3f(125.5897216796875, -125.5897216796875, -31.063449859619140625), - osg::Vec3f(145.6244049072265625, -145.6244049072265625, -23.6822509765625), - osg::Vec3f(165.659088134765625, -165.659088134765625, -16.3010501861572265625), - osg::Vec3f(185.6937713623046875, -185.6937713623046875, -8.91985416412353515625), - osg::Vec3f(205.7284698486328125, -205.7284698486328125, -1.5386505126953125), - osg::Vec3f(215, -215, 1.87718021869659423828125), - })) << mPath; + EXPECT_THAT(mPath, ElementsAre( + Vec3fEq(-215, 215, 1.85963428020477294921875), + Vec3fEq(-194.9653167724609375, 194.9653167724609375, -6.57602214813232421875), + Vec3fEq(-174.930633544921875, 174.930633544921875, -15.01167774200439453125), + Vec3fEq(-154.8959503173828125, 154.8959503173828125, -23.4473361968994140625), + Vec3fEq(-134.86126708984375, 134.86126708984375, -31.8829936981201171875), + Vec3fEq(-114.82657623291015625, 114.82657623291015625, -40.3186492919921875), + Vec3fEq(-94.7918853759765625, 94.7918853759765625, -47.3990631103515625), + Vec3fEq(-74.75719451904296875, 74.75719451904296875, -53.7258148193359375), + Vec3fEq(-54.722499847412109375, 54.722499847412109375, -60.052555084228515625), + Vec3fEq(-34.68780517578125, 34.68780517578125, -66.37931060791015625), + Vec3fEq(-14.6531162261962890625, 14.6531162261962890625, -72.70604705810546875), + Vec3fEq(5.3815765380859375, -5.3815765380859375, -75.35065460205078125), + Vec3fEq(25.41626739501953125, -25.41626739501953125, -67.9694671630859375), + Vec3fEq(45.450958251953125, -45.450958251953125, -60.5882568359375), + Vec3fEq(65.48564910888671875, -65.48564910888671875, -53.20705413818359375), + Vec3fEq(85.5203399658203125, -85.5203399658203125, -45.8258514404296875), + Vec3fEq(105.55503082275390625, -105.55503082275390625, -38.44464874267578125), + Vec3fEq(125.5897216796875, -125.5897216796875, -31.063449859619140625), + Vec3fEq(145.6244049072265625, -145.6244049072265625, -23.6822509765625), + Vec3fEq(165.659088134765625, -165.659088134765625, -16.3010501861572265625), + Vec3fEq(185.6937713623046875, -185.6937713623046875, -8.91985416412353515625), + Vec3fEq(205.7284698486328125, -205.7284698486328125, -1.5386505126953125), + Vec3fEq(215, -215, 1.87718021869659423828125) + )); mNavigator->addObject(ObjectId(&compoundShape), compoundShape, btTransform::getIdentity()); mNavigator->update(mPlayerPosition); @@ -197,31 +203,31 @@ namespace mOut = std::back_inserter(mPath); EXPECT_EQ(mNavigator->findPath(mAgentHalfExtents, mStepSize, mStart, mEnd, Flag_walk, mOut), Status::Success); - EXPECT_EQ(mPath, std::deque({ - osg::Vec3f(-215, 215, 1.87826788425445556640625), - osg::Vec3f(-199.7968292236328125, 191.09100341796875, -3.54876613616943359375), - osg::Vec3f(-184.5936431884765625, 167.1819915771484375, -8.97847843170166015625), - osg::Vec3f(-169.3904571533203125, 143.2729949951171875, -14.408184051513671875), - osg::Vec3f(-154.1872711181640625, 119.36397552490234375, -19.837890625), - osg::Vec3f(-138.9840850830078125, 95.45496368408203125, -25.2675991058349609375), - osg::Vec3f(-123.78090667724609375, 71.54595184326171875, -30.6973056793212890625), - osg::Vec3f(-108.57772064208984375, 47.636936187744140625, -36.12701416015625), - osg::Vec3f(-93.3745269775390625, 23.7279262542724609375, -40.754688262939453125), - osg::Vec3f(-78.17134857177734375, -0.18108306825160980224609375, -37.128787994384765625), - osg::Vec3f(-62.968158721923828125, -24.0900936126708984375, -33.50289154052734375), - osg::Vec3f(-47.764972686767578125, -47.999103546142578125, -30.797946929931640625), - osg::Vec3f(-23.852447509765625, -63.196765899658203125, -33.97112274169921875), - osg::Vec3f(0.0600789971649646759033203125, -78.39443206787109375, -37.14543914794921875), - osg::Vec3f(23.97260284423828125, -93.5920867919921875, -40.774089813232421875), - osg::Vec3f(47.885128021240234375, -108.78974151611328125, -36.05129241943359375), - osg::Vec3f(71.7976531982421875, -123.98740386962890625, -30.6235561370849609375), - osg::Vec3f(95.71018218994140625, -139.18505859375, -25.1958255767822265625), - osg::Vec3f(119.6226959228515625, -154.382720947265625, -19.7680912017822265625), - osg::Vec3f(143.53521728515625, -169.58038330078125, -14.34035205841064453125), - osg::Vec3f(167.4477386474609375, -184.778045654296875, -8.9126186370849609375), - osg::Vec3f(191.360260009765625, -199.9757080078125, -3.4848802089691162109375), - osg::Vec3f(215, -215, 1.87826788425445556640625), - })) << mPath; + EXPECT_THAT(mPath, ElementsAre( + Vec3fEq(-215, 215, 1.87826788425445556640625), + Vec3fEq(-199.7968292236328125, 191.09100341796875, -3.54876613616943359375), + Vec3fEq(-184.5936431884765625, 167.1819915771484375, -8.97847843170166015625), + Vec3fEq(-169.3904571533203125, 143.2729949951171875, -14.408184051513671875), + Vec3fEq(-154.1872711181640625, 119.36397552490234375, -19.837890625), + Vec3fEq(-138.9840850830078125, 95.45496368408203125, -25.2675991058349609375), + Vec3fEq(-123.78090667724609375, 71.54595184326171875, -30.6973056793212890625), + Vec3fEq(-108.57772064208984375, 47.636936187744140625, -36.12701416015625), + Vec3fEq(-93.3745269775390625, 23.7279262542724609375, -40.754688262939453125), + Vec3fEq(-78.17134857177734375, -0.18108306825160980224609375, -37.128787994384765625), + Vec3fEq(-62.968158721923828125, -24.0900936126708984375, -33.50289154052734375), + Vec3fEq(-47.764972686767578125, -47.999103546142578125, -30.797946929931640625), + Vec3fEq(-23.852447509765625, -63.196765899658203125, -33.97112274169921875), + Vec3fEq(0.0600789971649646759033203125, -78.39443206787109375, -37.14543914794921875), + Vec3fEq(23.97260284423828125, -93.5920867919921875, -40.774089813232421875), + Vec3fEq(47.885128021240234375, -108.78974151611328125, -36.05129241943359375), + Vec3fEq(71.7976531982421875, -123.98740386962890625, -30.6235561370849609375), + Vec3fEq(95.71018218994140625, -139.18505859375, -25.1958255767822265625), + Vec3fEq(119.6226959228515625, -154.382720947265625, -19.7680912017822265625), + Vec3fEq(143.53521728515625, -169.58038330078125, -14.34035205841064453125), + Vec3fEq(167.4477386474609375, -184.778045654296875, -8.9126186370849609375), + Vec3fEq(191.360260009765625, -199.9757080078125, -3.4848802089691162109375), + Vec3fEq(215, -215, 1.87826788425445556640625) + )); } TEST_F(DetourNavigatorNavigatorTest, update_changed_object_should_change_navmesh) @@ -248,31 +254,31 @@ namespace EXPECT_EQ(mNavigator->findPath(mAgentHalfExtents, mStepSize, mStart, mEnd, Flag_walk, mOut), Status::Success); - EXPECT_EQ(mPath, std::deque({ - osg::Vec3f(-215, 215, 1.87826788425445556640625), - osg::Vec3f(-199.7968292236328125, 191.09100341796875, -3.54876613616943359375), - osg::Vec3f(-184.5936431884765625, 167.1819915771484375, -8.97847843170166015625), - osg::Vec3f(-169.3904571533203125, 143.2729949951171875, -14.408184051513671875), - osg::Vec3f(-154.1872711181640625, 119.36397552490234375, -19.837890625), - osg::Vec3f(-138.9840850830078125, 95.45496368408203125, -25.2675991058349609375), - osg::Vec3f(-123.78090667724609375, 71.54595184326171875, -30.6973056793212890625), - osg::Vec3f(-108.57772064208984375, 47.636936187744140625, -36.12701416015625), - osg::Vec3f(-93.3745269775390625, 23.7279262542724609375, -40.754688262939453125), - osg::Vec3f(-78.17134857177734375, -0.18108306825160980224609375, -37.128787994384765625), - osg::Vec3f(-62.968158721923828125, -24.0900936126708984375, -33.50289154052734375), - osg::Vec3f(-47.764972686767578125, -47.999103546142578125, -30.797946929931640625), - osg::Vec3f(-23.852447509765625, -63.196765899658203125, -33.97112274169921875), - osg::Vec3f(0.0600789971649646759033203125, -78.39443206787109375, -37.14543914794921875), - osg::Vec3f(23.97260284423828125, -93.5920867919921875, -40.774089813232421875), - osg::Vec3f(47.885128021240234375, -108.78974151611328125, -36.05129241943359375), - osg::Vec3f(71.7976531982421875, -123.98740386962890625, -30.6235561370849609375), - osg::Vec3f(95.71018218994140625, -139.18505859375, -25.1958255767822265625), - osg::Vec3f(119.6226959228515625, -154.382720947265625, -19.7680912017822265625), - osg::Vec3f(143.53521728515625, -169.58038330078125, -14.34035205841064453125), - osg::Vec3f(167.4477386474609375, -184.778045654296875, -8.9126186370849609375), - osg::Vec3f(191.360260009765625, -199.9757080078125, -3.4848802089691162109375), - osg::Vec3f(215, -215, 1.87826788425445556640625), - })) << mPath; + EXPECT_THAT(mPath, ElementsAre( + Vec3fEq(-215, 215, 1.87826788425445556640625), + Vec3fEq(-199.7968292236328125, 191.09100341796875, -3.54876613616943359375), + Vec3fEq(-184.5936431884765625, 167.1819915771484375, -8.97847843170166015625), + Vec3fEq(-169.3904571533203125, 143.2729949951171875, -14.408184051513671875), + Vec3fEq(-154.1872711181640625, 119.36397552490234375, -19.837890625), + Vec3fEq(-138.9840850830078125, 95.45496368408203125, -25.2675991058349609375), + Vec3fEq(-123.78090667724609375, 71.54595184326171875, -30.6973056793212890625), + Vec3fEq(-108.57772064208984375, 47.636936187744140625, -36.12701416015625), + Vec3fEq(-93.3745269775390625, 23.7279262542724609375, -40.754688262939453125), + Vec3fEq(-78.17134857177734375, -0.18108306825160980224609375, -37.128787994384765625), + Vec3fEq(-62.968158721923828125, -24.0900936126708984375, -33.50289154052734375), + Vec3fEq(-47.764972686767578125, -47.999103546142578125, -30.797946929931640625), + Vec3fEq(-23.852447509765625, -63.196765899658203125, -33.97112274169921875), + Vec3fEq(0.0600789971649646759033203125, -78.39443206787109375, -37.14543914794921875), + Vec3fEq(23.97260284423828125, -93.5920867919921875, -40.774089813232421875), + Vec3fEq(47.885128021240234375, -108.78974151611328125, -36.05129241943359375), + Vec3fEq(71.7976531982421875, -123.98740386962890625, -30.6235561370849609375), + Vec3fEq(95.71018218994140625, -139.18505859375, -25.1958255767822265625), + Vec3fEq(119.6226959228515625, -154.382720947265625, -19.7680912017822265625), + Vec3fEq(143.53521728515625, -169.58038330078125, -14.34035205841064453125), + Vec3fEq(167.4477386474609375, -184.778045654296875, -8.9126186370849609375), + Vec3fEq(191.360260009765625, -199.9757080078125, -3.4848802089691162109375), + Vec3fEq(215, -215, 1.87826788425445556640625) + )); compoundShape.updateChildTransform(0, btTransform(btMatrix3x3::getIdentity(), btVector3(1000, 0, 0))); @@ -284,31 +290,31 @@ namespace mOut = std::back_inserter(mPath); EXPECT_EQ(mNavigator->findPath(mAgentHalfExtents, mStepSize, mStart, mEnd, Flag_walk, mOut), Status::Success); - EXPECT_EQ(mPath, std::deque({ - osg::Vec3f(-215, 215, 1.85963428020477294921875), - osg::Vec3f(-194.9653167724609375, 194.9653167724609375, -6.57602214813232421875), - osg::Vec3f(-174.930633544921875, 174.930633544921875, -15.01167774200439453125), - osg::Vec3f(-154.8959503173828125, 154.8959503173828125, -23.4473361968994140625), - osg::Vec3f(-134.86126708984375, 134.86126708984375, -31.8829936981201171875), - osg::Vec3f(-114.82657623291015625, 114.82657623291015625, -40.3186492919921875), - osg::Vec3f(-94.7918853759765625, 94.7918853759765625, -47.3990631103515625), - osg::Vec3f(-74.75719451904296875, 74.75719451904296875, -53.7258148193359375), - osg::Vec3f(-54.722499847412109375, 54.722499847412109375, -60.052555084228515625), - osg::Vec3f(-34.68780517578125, 34.68780517578125, -66.37931060791015625), - osg::Vec3f(-14.6531162261962890625, 14.6531162261962890625, -72.70604705810546875), - osg::Vec3f(5.3815765380859375, -5.3815765380859375, -75.35065460205078125), - osg::Vec3f(25.41626739501953125, -25.41626739501953125, -67.9694671630859375), - osg::Vec3f(45.450958251953125, -45.450958251953125, -60.5882568359375), - osg::Vec3f(65.48564910888671875, -65.48564910888671875, -53.20705413818359375), - osg::Vec3f(85.5203399658203125, -85.5203399658203125, -45.8258514404296875), - osg::Vec3f(105.55503082275390625, -105.55503082275390625, -38.44464874267578125), - osg::Vec3f(125.5897216796875, -125.5897216796875, -31.063449859619140625), - osg::Vec3f(145.6244049072265625, -145.6244049072265625, -23.6822509765625), - osg::Vec3f(165.659088134765625, -165.659088134765625, -16.3010501861572265625), - osg::Vec3f(185.6937713623046875, -185.6937713623046875, -8.91985416412353515625), - osg::Vec3f(205.7284698486328125, -205.7284698486328125, -1.5386505126953125), - osg::Vec3f(215, -215, 1.87718021869659423828125), - })) << mPath; + EXPECT_THAT(mPath, ElementsAre( + Vec3fEq(-215, 215, 1.85963428020477294921875), + Vec3fEq(-194.9653167724609375, 194.9653167724609375, -6.57602214813232421875), + Vec3fEq(-174.930633544921875, 174.930633544921875, -15.01167774200439453125), + Vec3fEq(-154.8959503173828125, 154.8959503173828125, -23.4473361968994140625), + Vec3fEq(-134.86126708984375, 134.86126708984375, -31.8829936981201171875), + Vec3fEq(-114.82657623291015625, 114.82657623291015625, -40.3186492919921875), + Vec3fEq(-94.7918853759765625, 94.7918853759765625, -47.3990631103515625), + Vec3fEq(-74.75719451904296875, 74.75719451904296875, -53.7258148193359375), + Vec3fEq(-54.722499847412109375, 54.722499847412109375, -60.052555084228515625), + Vec3fEq(-34.68780517578125, 34.68780517578125, -66.37931060791015625), + Vec3fEq(-14.6531162261962890625, 14.6531162261962890625, -72.70604705810546875), + Vec3fEq(5.3815765380859375, -5.3815765380859375, -75.35065460205078125), + Vec3fEq(25.41626739501953125, -25.41626739501953125, -67.9694671630859375), + Vec3fEq(45.450958251953125, -45.450958251953125, -60.5882568359375), + Vec3fEq(65.48564910888671875, -65.48564910888671875, -53.20705413818359375), + Vec3fEq(85.5203399658203125, -85.5203399658203125, -45.8258514404296875), + Vec3fEq(105.55503082275390625, -105.55503082275390625, -38.44464874267578125), + Vec3fEq(125.5897216796875, -125.5897216796875, -31.063449859619140625), + Vec3fEq(145.6244049072265625, -145.6244049072265625, -23.6822509765625), + Vec3fEq(165.659088134765625, -165.659088134765625, -16.3010501861572265625), + Vec3fEq(185.6937713623046875, -185.6937713623046875, -8.91985416412353515625), + Vec3fEq(205.7284698486328125, -205.7284698486328125, -1.5386505126953125), + Vec3fEq(215, -215, 1.87718021869659423828125) + )); } TEST_F(DetourNavigatorNavigatorTest, for_overlapping_heightfields_should_use_higher) @@ -341,31 +347,31 @@ namespace EXPECT_EQ(mNavigator->findPath(mAgentHalfExtents, mStepSize, mStart, mEnd, Flag_walk, mOut), Status::Success); - EXPECT_EQ(mPath, std::deque({ - osg::Vec3f(-215, 215, 1.96328866481781005859375), - osg::Vec3f(-194.9653167724609375, 194.9653167724609375, -0.242215454578399658203125), - osg::Vec3f(-174.930633544921875, 174.930633544921875, -2.447719097137451171875), - osg::Vec3f(-154.8959503173828125, 154.8959503173828125, -4.65322399139404296875), - osg::Vec3f(-134.86126708984375, 134.86126708984375, -6.858726978302001953125), - osg::Vec3f(-114.82657623291015625, 114.82657623291015625, -9.06423282623291015625), - osg::Vec3f(-94.7918853759765625, 94.7918853759765625, -11.26973628997802734375), - osg::Vec3f(-74.75719451904296875, 74.75719451904296875, -13.26497173309326171875), - osg::Vec3f(-54.722499847412109375, 54.722499847412109375, -15.24860477447509765625), - osg::Vec3f(-34.68780517578125, 34.68780517578125, -17.23223876953125), - osg::Vec3f(-14.6531162261962890625, 14.6531162261962890625, -19.215869903564453125), - osg::Vec3f(5.3815765380859375, -5.3815765380859375, -20.1338443756103515625), - osg::Vec3f(25.41626739501953125, -25.41626739501953125, -18.1502132415771484375), - osg::Vec3f(45.450958251953125, -45.450958251953125, -16.1665802001953125), - osg::Vec3f(65.48564910888671875, -65.48564910888671875, -14.18294620513916015625), - osg::Vec3f(85.5203399658203125, -85.5203399658203125, -12.199314117431640625), - osg::Vec3f(105.55503082275390625, -105.55503082275390625, -10.08488368988037109375), - osg::Vec3f(125.5897216796875, -125.5897216796875, -7.87938022613525390625), - osg::Vec3f(145.6244049072265625, -145.6244049072265625, -5.673875331878662109375), - osg::Vec3f(165.659088134765625, -165.659088134765625, -3.468370914459228515625), - osg::Vec3f(185.6937713623046875, -185.6937713623046875, -1.26286637783050537109375), - osg::Vec3f(205.7284698486328125, -205.7284698486328125, 0.942641556262969970703125), - osg::Vec3f(215, -215, 1.96328866481781005859375), - })) << mPath; + EXPECT_THAT(mPath, ElementsAre( + Vec3fEq(-215, 215, 1.96328866481781005859375), + Vec3fEq(-194.9653167724609375, 194.9653167724609375, -0.242215454578399658203125), + Vec3fEq(-174.930633544921875, 174.930633544921875, -2.447719097137451171875), + Vec3fEq(-154.8959503173828125, 154.8959503173828125, -4.65322399139404296875), + Vec3fEq(-134.86126708984375, 134.86126708984375, -6.858726978302001953125), + Vec3fEq(-114.82657623291015625, 114.82657623291015625, -9.06423282623291015625), + Vec3fEq(-94.7918853759765625, 94.7918853759765625, -11.26973628997802734375), + Vec3fEq(-74.75719451904296875, 74.75719451904296875, -13.26497173309326171875), + Vec3fEq(-54.722499847412109375, 54.722499847412109375, -15.24860477447509765625), + Vec3fEq(-34.68780517578125, 34.68780517578125, -17.23223876953125), + Vec3fEq(-14.6531162261962890625, 14.6531162261962890625, -19.215869903564453125), + Vec3fEq(5.3815765380859375, -5.3815765380859375, -20.1338443756103515625), + Vec3fEq(25.41626739501953125, -25.41626739501953125, -18.1502132415771484375), + Vec3fEq(45.450958251953125, -45.450958251953125, -16.1665802001953125), + Vec3fEq(65.48564910888671875, -65.48564910888671875, -14.18294620513916015625), + Vec3fEq(85.5203399658203125, -85.5203399658203125, -12.199314117431640625), + Vec3fEq(105.55503082275390625, -105.55503082275390625, -10.08488368988037109375), + Vec3fEq(125.5897216796875, -125.5897216796875, -7.87938022613525390625), + Vec3fEq(145.6244049072265625, -145.6244049072265625, -5.673875331878662109375), + Vec3fEq(165.659088134765625, -165.659088134765625, -3.468370914459228515625), + Vec3fEq(185.6937713623046875, -185.6937713623046875, -1.26286637783050537109375), + Vec3fEq(205.7284698486328125, -205.7284698486328125, 0.942641556262969970703125), + Vec3fEq(215, -215, 1.96328866481781005859375) + )); } TEST_F(DetourNavigatorNavigatorTest, path_should_be_around_avoid_shape) @@ -397,32 +403,32 @@ namespace EXPECT_EQ(mNavigator->findPath(mAgentHalfExtents, mStepSize, mStart, mEnd, Flag_walk, mOut), Status::Success); - EXPECT_EQ(mPath, std::deque({ - osg::Vec3f(-215, 215, 1.9393787384033203125), - osg::Vec3f(-200.8159637451171875, 190.47265625, -0.639537751674652099609375), - osg::Vec3f(-186.6319427490234375, 165.9453125, -3.2184507846832275390625), - osg::Vec3f(-172.447906494140625, 141.41796875, -5.797363758087158203125), - osg::Vec3f(-158.263885498046875, 116.8906097412109375, -8.37627696990966796875), - osg::Vec3f(-144.079864501953125, 92.3632659912109375, -10.9551906585693359375), - osg::Vec3f(-129.89581298828125, 67.83591461181640625, -13.53410625457763671875), - osg::Vec3f(-115.7117919921875, 43.308563232421875, -16.1130199432373046875), - osg::Vec3f(-101.5277557373046875, 18.7812137603759765625, -18.6919345855712890625), - osg::Vec3f(-87.34372711181640625, -5.7461376190185546875, -20.4680538177490234375), - osg::Vec3f(-67.02922821044921875, -25.4970550537109375, -20.514247894287109375), - osg::Vec3f(-46.714717864990234375, -45.2479705810546875, -20.560443878173828125), - osg::Vec3f(-26.40021514892578125, -64.99889373779296875, -20.6066417694091796875), - osg::Vec3f(-6.085712432861328125, -84.74980926513671875, -20.652835845947265625), - osg::Vec3f(14.22879505157470703125, -104.50072479248046875, -18.151397705078125), - osg::Vec3f(39.05098724365234375, -118.16222381591796875, -15.66748714447021484375), - osg::Vec3f(63.87317657470703125, -131.82373046875, -13.18358135223388671875), - osg::Vec3f(88.69537353515625, -145.4852142333984375, -10.699672698974609375), - osg::Vec3f(113.51757049560546875, -159.146697998046875, -8.21576786041259765625), - osg::Vec3f(138.3397674560546875, -172.808197021484375, -5.731859683990478515625), - osg::Vec3f(163.1619720458984375, -186.469696044921875, -3.2479507923126220703125), - osg::Vec3f(187.984161376953125, -200.1311798095703125, -0.764044821262359619140625), - osg::Vec3f(212.8063507080078125, -213.7926788330078125, 1.719865322113037109375), - osg::Vec3f(215, -215, 1.9393787384033203125), - })) << mPath; + EXPECT_THAT(mPath, ElementsAre( + Vec3fEq(-215, 215, 1.9393787384033203125), + Vec3fEq(-200.8159637451171875, 190.47265625, -0.639537751674652099609375), + Vec3fEq(-186.6319427490234375, 165.9453125, -3.2184507846832275390625), + Vec3fEq(-172.447906494140625, 141.41796875, -5.797363758087158203125), + Vec3fEq(-158.263885498046875, 116.8906097412109375, -8.37627696990966796875), + Vec3fEq(-144.079864501953125, 92.3632659912109375, -10.9551906585693359375), + Vec3fEq(-129.89581298828125, 67.83591461181640625, -13.53410625457763671875), + Vec3fEq(-115.7117919921875, 43.308563232421875, -16.1130199432373046875), + Vec3fEq(-101.5277557373046875, 18.7812137603759765625, -18.6919345855712890625), + Vec3fEq(-87.34372711181640625, -5.7461376190185546875, -20.4680538177490234375), + Vec3fEq(-67.02922821044921875, -25.4970550537109375, -20.514247894287109375), + Vec3fEq(-46.714717864990234375, -45.2479705810546875, -20.560443878173828125), + Vec3fEq(-26.40021514892578125, -64.99889373779296875, -20.6066417694091796875), + Vec3fEq(-6.085712432861328125, -84.74980926513671875, -20.652835845947265625), + Vec3fEq(14.22879505157470703125, -104.50072479248046875, -18.151397705078125), + Vec3fEq(39.05098724365234375, -118.16222381591796875, -15.66748714447021484375), + Vec3fEq(63.87317657470703125, -131.82373046875, -13.18358135223388671875), + Vec3fEq(88.69537353515625, -145.4852142333984375, -10.699672698974609375), + Vec3fEq(113.51757049560546875, -159.146697998046875, -8.21576786041259765625), + Vec3fEq(138.3397674560546875, -172.808197021484375, -5.731859683990478515625), + Vec3fEq(163.1619720458984375, -186.469696044921875, -3.2479507923126220703125), + Vec3fEq(187.984161376953125, -200.1311798095703125, -0.764044821262359619140625), + Vec3fEq(212.8063507080078125, -213.7926788330078125, 1.719865322113037109375), + Vec3fEq(215, -215, 1.9393787384033203125) + )); } TEST_F(DetourNavigatorNavigatorTest, path_should_be_over_water_ground_lower_than_water_with_only_swim_flag) @@ -590,26 +596,26 @@ namespace EXPECT_EQ(mNavigator->findPath(mAgentHalfExtents, mStepSize, mStart, mEnd, Flag_walk, mOut), Status::Success); - EXPECT_EQ(mPath, std::deque({ - osg::Vec3f(0, 215, -94.75363922119140625), - osg::Vec3f(9.8083515167236328125, 188.4185333251953125, -105.199951171875), - osg::Vec3f(19.6167049407958984375, 161.837066650390625, -114.25495147705078125), - osg::Vec3f(29.42505645751953125, 135.255615234375, -123.309967041015625), - osg::Vec3f(39.23340606689453125, 108.674163818359375, -132.3649749755859375), - osg::Vec3f(49.04175567626953125, 82.09270477294921875, -137.2874755859375), - osg::Vec3f(58.8501129150390625, 55.5112457275390625, -139.2451171875), - osg::Vec3f(68.6584625244140625, 28.9297885894775390625, -141.2027740478515625), - osg::Vec3f(78.4668121337890625, 2.3483295440673828125, -143.1604156494140625), - osg::Vec3f(88.27516937255859375, -24.233127593994140625, -141.3894805908203125), - osg::Vec3f(83.73651885986328125, -52.2005767822265625, -142.3761444091796875), - osg::Vec3f(79.19786834716796875, -80.16802978515625, -143.114837646484375), - osg::Vec3f(64.8477935791015625, -104.598602294921875, -137.840911865234375), - osg::Vec3f(50.497714996337890625, -129.0291748046875, -131.45831298828125), - osg::Vec3f(36.147632598876953125, -153.459747314453125, -121.42321014404296875), - osg::Vec3f(21.7975559234619140625, -177.8903350830078125, -111.38811492919921875), - osg::Vec3f(7.44747829437255859375, -202.3209075927734375, -101.19382476806640625), - osg::Vec3f(0, -215, -94.75363922119140625), - })) << mPath; + EXPECT_THAT(mPath, ElementsAre( + Vec3fEq(0, 215, -94.75363922119140625), + Vec3fEq(9.8083515167236328125, 188.4185333251953125, -105.199951171875), + Vec3fEq(19.6167049407958984375, 161.837066650390625, -114.25495147705078125), + Vec3fEq(29.42505645751953125, 135.255615234375, -123.309967041015625), + Vec3fEq(39.23340606689453125, 108.674163818359375, -132.3649749755859375), + Vec3fEq(49.04175567626953125, 82.09270477294921875, -137.2874755859375), + Vec3fEq(58.8501129150390625, 55.5112457275390625, -139.2451171875), + Vec3fEq(68.6584625244140625, 28.9297885894775390625, -141.2027740478515625), + Vec3fEq(78.4668121337890625, 2.3483295440673828125, -143.1604156494140625), + Vec3fEq(88.27516937255859375, -24.233127593994140625, -141.3894805908203125), + Vec3fEq(83.73651885986328125, -52.2005767822265625, -142.3761444091796875), + Vec3fEq(79.19786834716796875, -80.16802978515625, -143.114837646484375), + Vec3fEq(64.8477935791015625, -104.598602294921875, -137.840911865234375), + Vec3fEq(50.497714996337890625, -129.0291748046875, -131.45831298828125), + Vec3fEq(36.147632598876953125, -153.459747314453125, -121.42321014404296875), + Vec3fEq(21.7975559234619140625, -177.8903350830078125, -111.38811492919921875), + Vec3fEq(7.44747829437255859375, -202.3209075927734375, -101.19382476806640625), + Vec3fEq(0, -215, -94.75363922119140625) + )); } TEST_F(DetourNavigatorNavigatorTest, update_remove_and_update_then_find_path_should_return_path) @@ -639,31 +645,31 @@ namespace EXPECT_EQ(mNavigator->findPath(mAgentHalfExtents, mStepSize, mStart, mEnd, Flag_walk, mOut), Status::Success); - EXPECT_EQ(mPath, std::deque({ - osg::Vec3f(-215, 215, 1.85963428020477294921875), - osg::Vec3f(-194.9653167724609375, 194.9653167724609375, -6.57602214813232421875), - osg::Vec3f(-174.930633544921875, 174.930633544921875, -15.01167774200439453125), - osg::Vec3f(-154.8959503173828125, 154.8959503173828125, -23.4473361968994140625), - osg::Vec3f(-134.86126708984375, 134.86126708984375, -31.8829936981201171875), - osg::Vec3f(-114.82657623291015625, 114.82657623291015625, -40.3186492919921875), - osg::Vec3f(-94.7918853759765625, 94.7918853759765625, -47.3990631103515625), - osg::Vec3f(-74.75719451904296875, 74.75719451904296875, -53.7258148193359375), - osg::Vec3f(-54.722499847412109375, 54.722499847412109375, -60.052555084228515625), - osg::Vec3f(-34.68780517578125, 34.68780517578125, -66.37931060791015625), - osg::Vec3f(-14.6531162261962890625, 14.6531162261962890625, -72.70604705810546875), - osg::Vec3f(5.3815765380859375, -5.3815765380859375, -75.35065460205078125), - osg::Vec3f(25.41626739501953125, -25.41626739501953125, -67.9694671630859375), - osg::Vec3f(45.450958251953125, -45.450958251953125, -60.5882568359375), - osg::Vec3f(65.48564910888671875, -65.48564910888671875, -53.20705413818359375), - osg::Vec3f(85.5203399658203125, -85.5203399658203125, -45.8258514404296875), - osg::Vec3f(105.55503082275390625, -105.55503082275390625, -38.44464874267578125), - osg::Vec3f(125.5897216796875, -125.5897216796875, -31.063449859619140625), - osg::Vec3f(145.6244049072265625, -145.6244049072265625, -23.6822509765625), - osg::Vec3f(165.659088134765625, -165.659088134765625, -16.3010501861572265625), - osg::Vec3f(185.6937713623046875, -185.6937713623046875, -8.91985416412353515625), - osg::Vec3f(205.7284698486328125, -205.7284698486328125, -1.5386505126953125), - osg::Vec3f(215, -215, 1.87718021869659423828125), - })) << mPath; + EXPECT_THAT(mPath, ElementsAre( + Vec3fEq(-215, 215, 1.85963428020477294921875), + Vec3fEq(-194.9653167724609375, 194.9653167724609375, -6.57602214813232421875), + Vec3fEq(-174.930633544921875, 174.930633544921875, -15.01167774200439453125), + Vec3fEq(-154.8959503173828125, 154.8959503173828125, -23.4473361968994140625), + Vec3fEq(-134.86126708984375, 134.86126708984375, -31.8829936981201171875), + Vec3fEq(-114.82657623291015625, 114.82657623291015625, -40.3186492919921875), + Vec3fEq(-94.7918853759765625, 94.7918853759765625, -47.3990631103515625), + Vec3fEq(-74.75719451904296875, 74.75719451904296875, -53.7258148193359375), + Vec3fEq(-54.722499847412109375, 54.722499847412109375, -60.052555084228515625), + Vec3fEq(-34.68780517578125, 34.68780517578125, -66.37931060791015625), + Vec3fEq(-14.6531162261962890625, 14.6531162261962890625, -72.70604705810546875), + Vec3fEq(5.3815765380859375, -5.3815765380859375, -75.35065460205078125), + Vec3fEq(25.41626739501953125, -25.41626739501953125, -67.9694671630859375), + Vec3fEq(45.450958251953125, -45.450958251953125, -60.5882568359375), + Vec3fEq(65.48564910888671875, -65.48564910888671875, -53.20705413818359375), + Vec3fEq(85.5203399658203125, -85.5203399658203125, -45.8258514404296875), + Vec3fEq(105.55503082275390625, -105.55503082275390625, -38.44464874267578125), + Vec3fEq(125.5897216796875, -125.5897216796875, -31.063449859619140625), + Vec3fEq(145.6244049072265625, -145.6244049072265625, -23.6822509765625), + Vec3fEq(165.659088134765625, -165.659088134765625, -16.3010501861572265625), + Vec3fEq(185.6937713623046875, -185.6937713623046875, -8.91985416412353515625), + Vec3fEq(205.7284698486328125, -205.7284698486328125, -1.5386505126953125), + Vec3fEq(215, -215, 1.87718021869659423828125) + )); } TEST_F(DetourNavigatorNavigatorTest, update_then_find_random_point_around_circle_should_return_position) @@ -687,10 +693,10 @@ namespace const auto result = mNavigator->findRandomPointAroundCircle(mAgentHalfExtents, mStart, 100.0, Flag_walk); - ASSERT_EQ(result, boost::optional(osg::Vec3f(-209.95985412597656, 129.89768981933594, -0.26253718137741089))); + ASSERT_THAT(result, Optional(Vec3fEq(-209.95985412597656, 129.89768981933594, -0.26253718137741089))); const auto distance = (*result - mStart).length(); - EXPECT_EQ(distance, 85.260780334472656) << distance; + EXPECT_FLOAT_EQ(distance, 85.260780334472656); } } diff --git a/apps/openmw_test_suite/detournavigator/recastmeshbuilder.cpp b/apps/openmw_test_suite/detournavigator/recastmeshbuilder.cpp index af6797cf0..6c474765d 100644 --- a/apps/openmw_test_suite/detournavigator/recastmeshbuilder.cpp +++ b/apps/openmw_test_suite/detournavigator/recastmeshbuilder.cpp @@ -12,6 +12,7 @@ #include #include +#include namespace DetourNavigator { @@ -312,11 +313,11 @@ namespace AreaType_ground ); const auto recastMesh = builder.create(mGeneration, mRevision); - EXPECT_EQ(recastMesh->getVertices(), std::vector({ + EXPECT_THAT(recastMesh->getVertices(), Pointwise(FloatNear(1e-5), std::vector({ 0, -0.70710659027099609375, -3.535533905029296875, 0, 0.707107067108154296875, -3.535533905029296875, 0, 2.384185791015625e-07, -4.24264049530029296875, - })); + }))); EXPECT_EQ(recastMesh->getIndices(), std::vector({0, 1, 2})); EXPECT_EQ(recastMesh->getAreaTypes(), std::vector({AreaType_ground})); } @@ -337,11 +338,11 @@ namespace AreaType_ground ); const auto recastMesh = builder.create(mGeneration, mRevision); - EXPECT_EQ(recastMesh->getVertices(), std::vector({ + EXPECT_THAT(recastMesh->getVertices(), Pointwise(FloatNear(1e-5), std::vector({ -3.535533905029296875, -0.70710659027099609375, 0, -3.535533905029296875, 0.707107067108154296875, 0, -4.24264049530029296875, 2.384185791015625e-07, 0, - })); + }))); EXPECT_EQ(recastMesh->getIndices(), std::vector({0, 1, 2})); EXPECT_EQ(recastMesh->getAreaTypes(), std::vector({AreaType_ground})); } From 8a8107e837f215bbdca1d0ef33ac828d35a43267 Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Mon, 20 Apr 2020 18:47:14 +0200 Subject: [PATCH 20/44] as it says; revert vismask and uncomplicate openmw --- apps/opencs/CMakeLists.txt | 4 ++ apps/opencs/view/render/brushdraw.cpp | 6 +-- apps/opencs/view/render/cell.cpp | 22 ++++---- apps/opencs/view/render/cellarrow.cpp | 7 +-- apps/opencs/view/render/cellborder.cpp | 5 +- apps/opencs/view/render/cellmarker.cpp | 4 +- apps/opencs/view/render/cellwater.cpp | 4 +- apps/opencs/view/render/instancemode.cpp | 50 +++++++++--------- .../view/render/instanceselectionmode.cpp | 8 ++- apps/opencs/view/render/mask.hpp | 35 +++++++++++++ apps/opencs/view/render/object.cpp | 8 +-- .../view/render/pagedworldspacewidget.cpp | 17 +++--- apps/opencs/view/render/pathgrid.cpp | 5 +- apps/opencs/view/render/pathgridmode.cpp | 22 ++++---- .../view/render/pathgridselectionmode.cpp | 6 +-- apps/opencs/view/render/scenewidget.cpp | 14 ++--- apps/opencs/view/render/selectionmode.hpp | 2 + apps/opencs/view/render/tagbase.cpp | 4 +- apps/opencs/view/render/tagbase.hpp | 8 +-- apps/opencs/view/render/terrainshapemode.cpp | 4 +- .../opencs/view/render/terraintexturemode.cpp | 4 +- .../view/render/unpagedworldspacewidget.cpp | 5 +- apps/opencs/view/render/worldspacewidget.cpp | 13 +++-- apps/opencs/view/render/worldspacewidget.hpp | 1 + apps/openmw/CMakeLists.txt | 2 +- apps/openmw/engine.cpp | 5 +- apps/openmw/mwclass/activator.cpp | 4 +- apps/openmw/mwclass/door.cpp | 4 +- apps/openmw/mwclass/static.cpp | 4 +- apps/openmw/mwgui/loadingscreen.cpp | 7 +-- apps/openmw/mwgui/windowmanagerimp.cpp | 7 +-- apps/openmw/mwmechanics/actors.cpp | 11 ++-- apps/openmw/mwrender/actoranimation.cpp | 7 +-- apps/openmw/mwrender/actorspaths.cpp | 4 +- apps/openmw/mwrender/animation.cpp | 10 ++-- apps/openmw/mwrender/bulletdebugdraw.cpp | 4 +- apps/openmw/mwrender/characterpreview.cpp | 12 ++--- apps/openmw/mwrender/effectmanager.cpp | 4 +- apps/openmw/mwrender/globalmap.cpp | 7 +-- apps/openmw/mwrender/localmap.cpp | 11 ++-- apps/openmw/mwrender/navmesh.cpp | 4 +- apps/openmw/mwrender/npcanimation.cpp | 4 +- apps/openmw/mwrender/objects.cpp | 9 ++-- apps/openmw/mwrender/pathgrid.cpp | 5 +- apps/openmw/mwrender/recastmesh.cpp | 7 +-- apps/openmw/mwrender/renderingmanager.cpp | 52 ++++++++++--------- apps/openmw/mwrender/ripplesimulation.cpp | 5 +- apps/openmw/mwrender/sky.cpp | 24 ++++----- .../openmw/mwrender}/vismask.hpp | 22 ++------ apps/openmw/mwrender/water.cpp | 28 +++++----- apps/openmw/mwworld/projectilemanager.cpp | 6 +-- apps/openmw/mwworld/worldimp.cpp | 4 +- components/CMakeLists.txt | 2 +- components/nifosg/controller.cpp | 3 +- components/nifosg/nifloader.cpp | 7 ++- components/resource/stats.cpp | 5 +- components/sceneutil/lightutil.cpp | 11 ++-- components/sceneutil/lightutil.hpp | 4 +- components/sceneutil/optimizer.hpp | 4 +- components/sceneutil/shadow.cpp | 3 +- components/terrain/cellborder.cpp | 9 ++-- components/terrain/cellborder.hpp | 3 +- components/terrain/quadtreeworld.cpp | 7 ++- components/terrain/quadtreeworld.hpp | 2 +- components/terrain/terraingrid.cpp | 4 +- components/terrain/terraingrid.hpp | 2 +- components/terrain/world.cpp | 11 ++-- components/terrain/world.hpp | 2 +- 68 files changed, 320 insertions(+), 290 deletions(-) create mode 100644 apps/opencs/view/render/mask.hpp rename {components/sceneutil => apps/openmw/mwrender}/vismask.hpp (82%) diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 6d0f2ad9f..5dc2fb26f 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -97,6 +97,10 @@ opencs_units_noqt (view/render cellarrow cellmarker cellborder pathgrid ) +opencs_hdrs_noqt (view/render + mask + ) + opencs_units (view/tools reportsubview reporttable searchsubview searchbox merge diff --git a/apps/opencs/view/render/brushdraw.cpp b/apps/opencs/view/render/brushdraw.cpp index 992540851..255a13a12 100644 --- a/apps/opencs/view/render/brushdraw.cpp +++ b/apps/opencs/view/render/brushdraw.cpp @@ -8,10 +8,9 @@ #include -#include - #include "../../model/world/cellcoordinates.hpp" #include "../widget/brushshapes.hpp" +#include "mask.hpp" CSVRender::BrushDraw::BrushDraw(osg::ref_ptr parentNode, bool textureMode) : mParentNode(parentNode), mTextureMode(textureMode) @@ -46,7 +45,7 @@ float CSVRender::BrushDraw::getIntersectionHeight (const osg::Vec3d& point) intersector->setIntersectionLimit(osgUtil::LineSegmentIntersector::NO_LIMIT); osgUtil::IntersectionVisitor visitor(intersector); - visitor.setTraversalMask(SceneUtil::Mask_Terrain); + visitor.setTraversalMask(Mask_Terrain); mParentNode->accept(visitor); @@ -258,7 +257,6 @@ void CSVRender::BrushDraw::update(osg::Vec3d point, int brushSize, CSVWidget::Br { if (mBrushDrawNode->containsNode(mGeometry)) mBrushDrawNode->removeChild(mGeometry); - mBrushDrawNode->setNodeMask (SceneUtil::Mask_GUI); float radius = (mLandSizeFactor * brushSize) / 2; osg::Vec3d snapToGridPoint = point; if (mTextureMode) diff --git a/apps/opencs/view/render/cell.cpp b/apps/opencs/view/render/cell.cpp index 48659865a..056c50e45 100644 --- a/apps/opencs/view/render/cell.cpp +++ b/apps/opencs/view/render/cell.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include "../../model/world/idtable.hpp" @@ -22,6 +21,7 @@ #include "cellborder.hpp" #include "cellarrow.hpp" #include "cellmarker.hpp" +#include "mask.hpp" #include "pathgrid.hpp" #include "terrainstorage.hpp" #include "object.hpp" @@ -92,7 +92,7 @@ bool CSVRender::Cell::addObjects (int start, int end) std::unique_ptr object (new Object (mData, mCellNode, id, false)); - if (mSubModeElementMask & SceneUtil::Mask_EditorReference) + if (mSubModeElementMask & Mask_Reference) object->setSubMode (mSubMode); mObjects.insert (std::make_pair (id, object.release())); @@ -134,7 +134,7 @@ void CSVRender::Cell::updateLand() else { mTerrain.reset(new Terrain::TerrainGrid(mCellNode, mCellNode, - mData.getResourceSystem().get(), mTerrainStorage)); + mData.getResourceSystem().get(), mTerrainStorage, Mask_Terrain)); } mTerrain->loadCell(esmLand.mX, esmLand.mY); @@ -434,7 +434,7 @@ void CSVRender::Cell::reloadAssets() void CSVRender::Cell::setSelection (int elementMask, Selection mode) { - if (elementMask & SceneUtil::Mask_EditorReference) + if (elementMask & Mask_Reference) { for (std::map::const_iterator iter (mObjects.begin()); iter!=mObjects.end(); ++iter) @@ -451,7 +451,7 @@ void CSVRender::Cell::setSelection (int elementMask, Selection mode) iter->second->setSelected (selected); } } - if (mPathgrid && elementMask & SceneUtil::Mask_Pathgrid) + if (mPathgrid && elementMask & Mask_Pathgrid) { // Only one pathgrid may be selected, so some operations will only have an effect // if the pathgrid is already focused @@ -546,12 +546,12 @@ std::vector > CSVRender::Cell::getSelection (un { std::vector > result; - if (elementMask & SceneUtil::Mask_EditorReference) + if (elementMask & Mask_Reference) for (std::map::const_iterator iter (mObjects.begin()); iter!=mObjects.end(); ++iter) if (iter->second->getSelected()) result.push_back (iter->second->getTag()); - if (mPathgrid && elementMask & SceneUtil::Mask_Pathgrid) + if (mPathgrid && elementMask & Mask_Pathgrid) if (mPathgrid->isSelected()) result.push_back(mPathgrid->getTag()); @@ -562,7 +562,7 @@ std::vector > CSVRender::Cell::getEdited (unsig { std::vector > result; - if (elementMask & SceneUtil::Mask_EditorReference) + if (elementMask & Mask_Reference) for (std::map::const_iterator iter (mObjects.begin()); iter!=mObjects.end(); ++iter) if (iter->second->isEdited()) @@ -576,7 +576,7 @@ void CSVRender::Cell::setSubMode (int subMode, unsigned int elementMask) mSubMode = subMode; mSubModeElementMask = elementMask; - if (elementMask & SceneUtil::Mask_EditorReference) + if (elementMask & Mask_Reference) for (std::map::const_iterator iter (mObjects.begin()); iter!=mObjects.end(); ++iter) iter->second->setSubMode (subMode); @@ -584,10 +584,10 @@ void CSVRender::Cell::setSubMode (int subMode, unsigned int elementMask) void CSVRender::Cell::reset (unsigned int elementMask) { - if (elementMask & SceneUtil::Mask_EditorReference) + if (elementMask & Mask_Reference) for (std::map::const_iterator iter (mObjects.begin()); iter!=mObjects.end(); ++iter) iter->second->reset(); - if (mPathgrid && elementMask & SceneUtil::Mask_Pathgrid) + if (mPathgrid && elementMask & Mask_Pathgrid) mPathgrid->resetIndicators(); } diff --git a/apps/opencs/view/render/cellarrow.cpp b/apps/opencs/view/render/cellarrow.cpp index 3fb4f711d..b6fee1545 100644 --- a/apps/opencs/view/render/cellarrow.cpp +++ b/apps/opencs/view/render/cellarrow.cpp @@ -11,10 +11,11 @@ #include "../../model/prefs/shortcutmanager.hpp" #include -#include + +#include "mask.hpp" CSVRender::CellArrowTag::CellArrowTag (CellArrow *arrow) -: TagBase (SceneUtil::Mask_EditorCellArrow), mArrow (arrow) +: TagBase (Mask_CellArrow), mArrow (arrow) {} CSVRender::CellArrow *CSVRender::CellArrowTag::getCellArrow() const @@ -174,7 +175,7 @@ CSVRender::CellArrow::CellArrow (osg::Group *cellNode, Direction direction, mParentNode->addChild (mBaseNode); - mBaseNode->setNodeMask (SceneUtil::Mask_EditorCellArrow); + mBaseNode->setNodeMask (Mask_CellArrow); adjustTransform(); buildShape(); diff --git a/apps/opencs/view/render/cellborder.cpp b/apps/opencs/view/render/cellborder.cpp index 0789ee22a..6073807ce 100644 --- a/apps/opencs/view/render/cellborder.cpp +++ b/apps/opencs/view/render/cellborder.cpp @@ -7,7 +7,8 @@ #include #include -#include + +#include "mask.hpp" #include "../../model/world/cellcoordinates.hpp" @@ -19,7 +20,7 @@ CSVRender::CellBorder::CellBorder(osg::Group* cellNode, const CSMWorld::CellCoor : mParentNode(cellNode) { mBaseNode = new osg::PositionAttitudeTransform(); - mBaseNode->setNodeMask(SceneUtil::Mask_EditorCellBorder); + mBaseNode->setNodeMask(Mask_CellBorder); mBaseNode->setPosition(osg::Vec3f(coords.getX() * CellSize, coords.getY() * CellSize, 10)); mParentNode->addChild(mBaseNode); diff --git a/apps/opencs/view/render/cellmarker.cpp b/apps/opencs/view/render/cellmarker.cpp index e629aa827..3de96ab02 100644 --- a/apps/opencs/view/render/cellmarker.cpp +++ b/apps/opencs/view/render/cellmarker.cpp @@ -8,7 +8,7 @@ #include CSVRender::CellMarkerTag::CellMarkerTag(CellMarker *marker) -: TagBase(SceneUtil::Mask_EditorCellMarker), mMarker(marker) +: TagBase(Mask_CellMarker), mMarker(marker) {} CSVRender::CellMarker *CSVRender::CellMarkerTag::getCellMarker() const @@ -79,7 +79,7 @@ CSVRender::CellMarker::CellMarker( mMarkerNode->getOrCreateStateSet()->setAttribute(mat); mMarkerNode->setUserData(new CellMarkerTag(this)); - mMarkerNode->setNodeMask(SceneUtil::Mask_EditorCellMarker); + mMarkerNode->setNodeMask(Mask_CellMarker); mCellNode->addChild(mMarkerNode); diff --git a/apps/opencs/view/render/cellwater.cpp b/apps/opencs/view/render/cellwater.cpp index 8edbc1cd1..435178860 100644 --- a/apps/opencs/view/render/cellwater.cpp +++ b/apps/opencs/view/render/cellwater.cpp @@ -11,12 +11,12 @@ #include #include #include -#include #include "../../model/world/cell.hpp" #include "../../model/world/cellcoordinates.hpp" #include "../../model/world/data.hpp" +#include "mask.hpp" namespace CSVRender { @@ -38,7 +38,7 @@ namespace CSVRender mWaterTransform->setPosition(osg::Vec3f(cellCoords.getX() * CellSize + CellSize / 2.f, cellCoords.getY() * CellSize + CellSize / 2.f, 0)); - mWaterTransform->setNodeMask(SceneUtil::Mask_Water); + mWaterTransform->setNodeMask(Mask_Water); mParentNode->addChild(mWaterTransform); mWaterNode = new osg::Geode(); diff --git a/apps/opencs/view/render/instancemode.cpp b/apps/opencs/view/render/instancemode.cpp index 0d221beb1..987dea437 100644 --- a/apps/opencs/view/render/instancemode.cpp +++ b/apps/opencs/view/render/instancemode.cpp @@ -21,7 +21,7 @@ #include "../widget/scenetoolbar.hpp" #include "../widget/scenetoolmode.hpp" -#include +#include "mask.hpp" #include "object.hpp" #include "worldspacewidget.hpp" @@ -97,7 +97,7 @@ osg::Vec3f CSVRender::InstanceMode::getScreenCoords(const osg::Vec3f& pos) } CSVRender::InstanceMode::InstanceMode (WorldspaceWidget *worldspaceWidget, osg::ref_ptr parentNode, QWidget *parent) -: EditMode (worldspaceWidget, QIcon (":scenetoolbar/editing-instance"), SceneUtil::Mask_EditorReference | SceneUtil::Mask_Terrain, "Instance editing", +: EditMode (worldspaceWidget, QIcon (":scenetoolbar/editing-instance"), Mask_Reference | Mask_Terrain, "Instance editing", parent), mSubMode (0), mSubModeId ("move"), mSelectionMode (0), mDragMode (DragMode_None), mDragAxis (-1), mLocked (false), mUnitScaleDist(1), mParentNode (parentNode) { @@ -157,13 +157,13 @@ void CSVRender::InstanceMode::activate (CSVWidget::SceneToolbar *toolbar) std::string subMode = mSubMode->getCurrentId(); - getWorldspaceWidget().setSubMode (getSubModeFromId (subMode), SceneUtil::Mask_EditorReference); + getWorldspaceWidget().setSubMode (getSubModeFromId (subMode), Mask_Reference); } void CSVRender::InstanceMode::deactivate (CSVWidget::SceneToolbar *toolbar) { mDragMode = DragMode_None; - getWorldspaceWidget().reset (SceneUtil::Mask_EditorReference); + getWorldspaceWidget().reset (Mask_Reference); if (mSelectionMode) { @@ -216,7 +216,7 @@ void CSVRender::InstanceMode::secondaryEditPressed (const WorldspaceHitResult& h void CSVRender::InstanceMode::primarySelectPressed (const WorldspaceHitResult& hit) { - getWorldspaceWidget().clearSelection (SceneUtil::Mask_EditorReference); + getWorldspaceWidget().clearSelection (Mask_Reference); if (hit.tag) { @@ -251,13 +251,13 @@ bool CSVRender::InstanceMode::primaryEditStartDrag (const QPoint& pos) WorldspaceHitResult hit = getWorldspaceWidget().mousePick (pos, getWorldspaceWidget().getInteractionMask()); - std::vector > selection = getWorldspaceWidget().getSelection (SceneUtil::Mask_EditorReference); + std::vector > selection = getWorldspaceWidget().getSelection (Mask_Reference); if (selection.empty()) { // Only change selection at the start of drag if no object is already selected if (hit.tag && CSMPrefs::get()["3D Scene Input"]["context-select"].isTrue()) { - getWorldspaceWidget().clearSelection (SceneUtil::Mask_EditorReference); + getWorldspaceWidget().clearSelection (Mask_Reference); if (CSVRender::ObjectTag *objectTag = dynamic_cast (hit.tag.get())) { CSVRender::Object* object = objectTag->mObject; @@ -265,7 +265,7 @@ bool CSVRender::InstanceMode::primaryEditStartDrag (const QPoint& pos) } } - selection = getWorldspaceWidget().getSelection (SceneUtil::Mask_EditorReference); + selection = getWorldspaceWidget().getSelection (Mask_Reference); if (selection.empty()) return false; } @@ -291,7 +291,7 @@ bool CSVRender::InstanceMode::primaryEditStartDrag (const QPoint& pos) mDragMode = DragMode_Scale; // Calculate scale factor - std::vector > editedSelection = getWorldspaceWidget().getEdited (SceneUtil::Mask_EditorReference); + std::vector > editedSelection = getWorldspaceWidget().getEdited (Mask_Reference); osg::Vec3f center = getScreenCoords(getSelectionCenter(editedSelection)); int widgetHeight = getWorldspaceWidget().height(); @@ -327,7 +327,7 @@ void CSVRender::InstanceMode::drag (const QPoint& pos, int diffX, int diffY, dou osg::Vec3f offset; osg::Quat rotation; - std::vector > selection = getWorldspaceWidget().getEdited (SceneUtil::Mask_EditorReference); + std::vector > selection = getWorldspaceWidget().getEdited (Mask_Reference); if (mDragMode == DragMode_Move) { @@ -484,7 +484,7 @@ void CSVRender::InstanceMode::drag (const QPoint& pos, int diffX, int diffY, dou void CSVRender::InstanceMode::dragCompleted(const QPoint& pos) { std::vector > selection = - getWorldspaceWidget().getEdited (SceneUtil::Mask_EditorReference); + getWorldspaceWidget().getEdited (Mask_Reference); QUndoStack& undoStack = getWorldspaceWidget().getDocument().getUndoStack(); @@ -516,7 +516,7 @@ void CSVRender::InstanceMode::dragCompleted(const QPoint& pos) void CSVRender::InstanceMode::dragAborted() { - getWorldspaceWidget().reset (SceneUtil::Mask_EditorReference); + getWorldspaceWidget().reset (Mask_Reference); mDragMode = DragMode_None; } @@ -535,7 +535,7 @@ void CSVRender::InstanceMode::dragWheel (int diff, double speedFactor) offset *= diff * speedFactor; std::vector > selection = - getWorldspaceWidget().getEdited (SceneUtil::Mask_EditorReference); + getWorldspaceWidget().getEdited (Mask_Reference); for (std::vector >::iterator iter (selection.begin()); iter!=selection.end(); ++iter) @@ -677,12 +677,12 @@ void CSVRender::InstanceMode::subModeChanged (const std::string& id) { mSubModeId = id; getWorldspaceWidget().abortDrag(); - getWorldspaceWidget().setSubMode (getSubModeFromId (id), SceneUtil::Mask_EditorReference); + getWorldspaceWidget().setSubMode (getSubModeFromId (id), Mask_Reference); } void CSVRender::InstanceMode::deleteSelectedInstances(bool active) { - std::vector > selection = getWorldspaceWidget().getSelection (SceneUtil::Mask_EditorReference); + std::vector > selection = getWorldspaceWidget().getSelection (Mask_Reference); if (selection.empty()) return; CSMDoc::Document& document = getWorldspaceWidget().getDocument(); @@ -695,7 +695,7 @@ void CSVRender::InstanceMode::deleteSelectedInstances(bool active) if (CSVRender::ObjectTag *objectTag = dynamic_cast (tag.get())) macro.push(new CSMWorld::DeleteCommand(referencesTable, objectTag->mObject->getReferenceId())); - getWorldspaceWidget().clearSelection (SceneUtil::Mask_EditorReference); + getWorldspaceWidget().clearSelection (Mask_Reference); } void CSVRender::InstanceMode::dropInstance(DropMode dropMode, CSVRender::Object* object, float objectHeight) @@ -713,9 +713,9 @@ void CSVRender::InstanceMode::dropInstance(DropMode dropMode, CSVRender::Object* osgUtil::IntersectionVisitor visitor(intersector); if (dropMode == TerrainSep) - visitor.setTraversalMask(SceneUtil::Mask_Terrain); + visitor.setTraversalMask(Mask_Terrain); if (dropMode == CollisionSep) - visitor.setTraversalMask(SceneUtil::Mask_Terrain | SceneUtil::Mask_EditorReference); + visitor.setTraversalMask(Mask_Terrain | Mask_Reference); mParentNode->accept(visitor); @@ -745,9 +745,9 @@ float CSVRender::InstanceMode::getDropHeight(DropMode dropMode, CSVRender::Objec osgUtil::IntersectionVisitor visitor(intersector); if (dropMode == Terrain) - visitor.setTraversalMask(SceneUtil::Mask_Terrain); + visitor.setTraversalMask(Mask_Terrain); if (dropMode == Collision) - visitor.setTraversalMask(SceneUtil::Mask_Terrain | SceneUtil::Mask_EditorReference); + visitor.setTraversalMask(Mask_Terrain | Mask_Reference); mParentNode->accept(visitor); @@ -784,7 +784,7 @@ void CSVRender::InstanceMode::dropSelectedInstancesToTerrainSeparately() void CSVRender::InstanceMode::handleDropMethod(DropMode dropMode, QString commandMsg) { - std::vector > selection = getWorldspaceWidget().getSelection (SceneUtil::Mask_EditorReference); + std::vector > selection = getWorldspaceWidget().getSelection (Mask_Reference); if (selection.empty()) return; @@ -841,7 +841,7 @@ void CSVRender::InstanceMode::handleDropMethod(DropMode dropMode, QString comman CSVRender::DropObjectDataHandler::DropObjectDataHandler(WorldspaceWidget* worldspacewidget) : mWorldspaceWidget(worldspacewidget) { - std::vector > selection = mWorldspaceWidget->getSelection (SceneUtil::Mask_EditorReference); + std::vector > selection = mWorldspaceWidget->getSelection (Mask_Reference); for(osg::ref_ptr tag: selection) { if (CSVRender::ObjectTag *objectTag = dynamic_cast (tag.get())) @@ -850,7 +850,7 @@ CSVRender::DropObjectDataHandler::DropObjectDataHandler(WorldspaceWidget* worlds osg::ref_ptr objectNodeWithoutGUI = objectTag->mObject->getBaseNode(); osg::ComputeBoundsVisitor computeBounds; - computeBounds.setTraversalMask(SceneUtil::Mask_EditorReference); + computeBounds.setTraversalMask(Mask_Reference); objectNodeWithoutGUI->accept(computeBounds); osg::BoundingBox bounds = computeBounds.getBoundingBox(); float boundingBoxOffset = 0.0f; @@ -860,14 +860,14 @@ CSVRender::DropObjectDataHandler::DropObjectDataHandler(WorldspaceWidget* worlds mObjectHeights.emplace_back(boundingBoxOffset); mOldMasks.emplace_back(objectNodeWithGUI->getNodeMask()); - objectNodeWithGUI->setNodeMask(SceneUtil::Mask_Disabled); + objectNodeWithGUI->setNodeMask(0); } } } CSVRender::DropObjectDataHandler::~DropObjectDataHandler() { - std::vector > selection = mWorldspaceWidget->getSelection (SceneUtil::Mask_EditorReference); + std::vector > selection = mWorldspaceWidget->getSelection (Mask_Reference); int counter = 0; for(osg::ref_ptr tag: selection) { diff --git a/apps/opencs/view/render/instanceselectionmode.cpp b/apps/opencs/view/render/instanceselectionmode.cpp index 470f34e5d..bf8ede0eb 100644 --- a/apps/opencs/view/render/instanceselectionmode.cpp +++ b/apps/opencs/view/render/instanceselectionmode.cpp @@ -6,15 +6,13 @@ #include "../../model/world/idtable.hpp" #include "../../model/world/commands.hpp" -#include - #include "worldspacewidget.hpp" #include "object.hpp" namespace CSVRender { InstanceSelectionMode::InstanceSelectionMode(CSVWidget::SceneToolbar* parent, WorldspaceWidget& worldspaceWidget) - : SelectionMode(parent, worldspaceWidget, SceneUtil::Mask_EditorReference) + : SelectionMode(parent, worldspaceWidget, Mask_Reference) { mSelectSame = new QAction("Extend selection to instances with same object ID", this); mDeleteSelection = new QAction("Delete selected instances", this); @@ -38,12 +36,12 @@ namespace CSVRender void InstanceSelectionMode::selectSame() { - getWorldspaceWidget().selectAllWithSameParentId(SceneUtil::Mask_EditorReference); + getWorldspaceWidget().selectAllWithSameParentId(Mask_Reference); } void InstanceSelectionMode::deleteSelection() { - std::vector > selection = getWorldspaceWidget().getSelection(SceneUtil::Mask_EditorReference); + std::vector > selection = getWorldspaceWidget().getSelection(Mask_Reference); CSMWorld::IdTable& referencesTable = dynamic_cast( *getWorldspaceWidget().getDocument().getData().getTableModel(CSMWorld::UniversalId::Type_References)); diff --git a/apps/opencs/view/render/mask.hpp b/apps/opencs/view/render/mask.hpp new file mode 100644 index 000000000..55b7c823f --- /dev/null +++ b/apps/opencs/view/render/mask.hpp @@ -0,0 +1,35 @@ +#ifndef CSV_RENDER_ELEMENTS_H +#define CSV_RENDER_ELEMENTS_H + +namespace CSVRender +{ + + /// Node masks used on the OSG scene graph in OpenMW-CS. + /// @note See the respective file in OpenMW (apps/openmw/mwrender/vismask.hpp) + /// for general usage hints about node masks. + /// @copydoc MWRender::VisMask + enum Mask + { + // internal use within NifLoader, do not change + Mask_UpdateVisitor = 0x1, + + // elements that are part of the actual scene + Mask_Reference = 0x2, + Mask_Pathgrid = 0x4, + Mask_Water = 0x8, + Mask_Fog = 0x10, + Mask_Terrain = 0x20, + + // used within models + Mask_ParticleSystem = 0x100, + + Mask_Lighting = 0x200, + + // control elements + Mask_CellMarker = 0x10000, + Mask_CellArrow = 0x20000, + Mask_CellBorder = 0x40000 + }; +} + +#endif diff --git a/apps/opencs/view/render/object.cpp b/apps/opencs/view/render/object.cpp index 6b33cdeb2..f9d2c8872 100644 --- a/apps/opencs/view/render/object.cpp +++ b/apps/opencs/view/render/object.cpp @@ -29,9 +29,9 @@ #include #include #include -#include #include "actor.hpp" +#include "mask.hpp" const float CSVRender::Object::MarkerShaftWidth = 30; @@ -58,7 +58,7 @@ namespace CSVRender::ObjectTag::ObjectTag (Object* object) -: TagBase (SceneUtil::Mask_EditorReference), mObject (object) +: TagBase (Mask_Reference), mObject (object) {} QString CSVRender::ObjectTag::getToolTip (bool hideBasics) const @@ -140,7 +140,7 @@ void CSVRender::Object::update() if (light) { bool isExterior = false; // FIXME - SceneUtil::addLight(mBaseNode, light, isExterior); + SceneUtil::addLight(mBaseNode, light, Mask_ParticleSystem, Mask_Lighting, isExterior); } } @@ -429,7 +429,7 @@ CSVRender::Object::Object (CSMWorld::Data& data, osg::Group* parentNode, parentNode->addChild (mRootNode); - mRootNode->setNodeMask(SceneUtil::Mask_EditorReference); + mRootNode->setNodeMask(Mask_Reference); if (referenceable) { diff --git a/apps/opencs/view/render/pagedworldspacewidget.cpp b/apps/opencs/view/render/pagedworldspacewidget.cpp index 8fafa8459..b5d9234e4 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.cpp +++ b/apps/opencs/view/render/pagedworldspacewidget.cpp @@ -21,6 +21,7 @@ #include "../widget/scenetooltoggle2.hpp" #include "editmode.hpp" +#include "mask.hpp" #include "cameracontroller.hpp" #include "cellarrow.hpp" #include "terraintexturemode.hpp" @@ -126,8 +127,8 @@ void CSVRender::PagedWorldspaceWidget::addVisibilitySelectorButtons ( CSVWidget::SceneToolToggle2 *tool) { WorldspaceWidget::addVisibilitySelectorButtons (tool); - tool->addButton (Button_Terrain, SceneUtil::Mask_Terrain, "Terrain"); - //tool->addButton (Button_Fog, Mask_Fog, "Fog", "", true); + tool->addButton (Button_Terrain, Mask_Terrain, "Terrain"); + tool->addButton (Button_Fog, Mask_Fog, "Fog", "", true); } void CSVRender::PagedWorldspaceWidget::addEditModeSelectorButtons ( @@ -141,16 +142,16 @@ void CSVRender::PagedWorldspaceWidget::addEditModeSelectorButtons ( tool->addButton ( new TerrainTextureMode (this, mRootNode, tool), "terrain-texture"); tool->addButton ( - new EditMode (this, QIcon (":placeholder"), SceneUtil::Mask_EditorReference, "Terrain vertex paint editing"), + new EditMode (this, QIcon (":placeholder"), Mask_Reference, "Terrain vertex paint editing"), "terrain-vertex"); tool->addButton ( - new EditMode (this, QIcon (":placeholder"), SceneUtil::Mask_EditorReference, "Terrain movement"), + new EditMode (this, QIcon (":placeholder"), Mask_Reference, "Terrain movement"), "terrain-move"); } void CSVRender::PagedWorldspaceWidget::handleInteractionPress (const WorldspaceHitResult& hit, InteractionType type) { - if (hit.tag && hit.tag->getMask()==SceneUtil::Mask_EditorCellArrow) + if (hit.tag && hit.tag->getMask()==Mask_CellArrow) { if (CellArrowTag *cellArrowTag = dynamic_cast (hit.tag.get())) { @@ -873,9 +874,9 @@ CSVWidget::SceneToolToggle2 *CSVRender::PagedWorldspaceWidget::makeControlVisibi mControlElements = new CSVWidget::SceneToolToggle2 (parent, "Controls & Guides Visibility", ":scenetoolbar/scene-view-marker-c", ":scenetoolbar/scene-view-marker-"); - mControlElements->addButton (1, SceneUtil::Mask_EditorCellMarker, "Cell Marker"); - mControlElements->addButton (2, SceneUtil::Mask_EditorCellArrow, "Cell Arrows"); - mControlElements->addButton (4, SceneUtil::Mask_EditorCellBorder, "Cell Border"); + mControlElements->addButton (1, Mask_CellMarker, "Cell Marker"); + mControlElements->addButton (2, Mask_CellArrow, "Cell Arrows"); + mControlElements->addButton (4, Mask_CellBorder, "Cell Border"); mControlElements->setSelectionMask (0xffffffff); diff --git a/apps/opencs/view/render/pathgrid.cpp b/apps/opencs/view/render/pathgrid.cpp index b2714014b..d8acfe2e1 100644 --- a/apps/opencs/view/render/pathgrid.cpp +++ b/apps/opencs/view/render/pathgrid.cpp @@ -10,7 +10,6 @@ #include #include -#include #include "../../model/world/cell.hpp" #include "../../model/world/commands.hpp" @@ -32,7 +31,7 @@ namespace CSVRender }; PathgridTag::PathgridTag(Pathgrid* pathgrid) - : TagBase(SceneUtil::Mask_Pathgrid), mPathgrid(pathgrid) + : TagBase(Mask_Pathgrid), mPathgrid(pathgrid) { } @@ -71,7 +70,7 @@ namespace CSVRender mBaseNode->setPosition(osg::Vec3f(mCoords.getX() * CoordScalar, mCoords.getY() * CoordScalar, 0.f)); mBaseNode->setUserData(mTag); mBaseNode->setUpdateCallback(new PathgridNodeCallback()); - mBaseNode->setNodeMask(SceneUtil::Mask_Pathgrid); + mBaseNode->setNodeMask(Mask_Pathgrid); mParent->addChild(mBaseNode); mPathgridGeode = new osg::Geode(); diff --git a/apps/opencs/view/render/pathgridmode.cpp b/apps/opencs/view/render/pathgridmode.cpp index 33c1b8b42..8863ad235 100644 --- a/apps/opencs/view/render/pathgridmode.cpp +++ b/apps/opencs/view/render/pathgridmode.cpp @@ -4,7 +4,6 @@ #include #include -#include #include "../../model/prefs/state.hpp" @@ -16,6 +15,7 @@ #include "../widget/scenetoolbar.hpp" #include "cell.hpp" +#include "mask.hpp" #include "pathgrid.hpp" #include "pathgridselectionmode.hpp" #include "worldspacewidget.hpp" @@ -23,7 +23,7 @@ namespace CSVRender { PathgridMode::PathgridMode(WorldspaceWidget* worldspaceWidget, QWidget* parent) - : EditMode(worldspaceWidget, QIcon(":placeholder"), SceneUtil::Mask_Pathgrid | SceneUtil::Mask_Terrain | SceneUtil::Mask_EditorReference, + : EditMode(worldspaceWidget, QIcon(":placeholder"), Mask_Pathgrid | Mask_Terrain | Mask_Reference, getTooltip(), parent) , mDragMode(DragMode_None) , mFromNode(0) @@ -110,7 +110,7 @@ namespace CSVRender void PathgridMode::primarySelectPressed(const WorldspaceHitResult& hit) { - getWorldspaceWidget().clearSelection(SceneUtil::Mask_Pathgrid); + getWorldspaceWidget().clearSelection(Mask_Pathgrid); if (hit.tag) { @@ -131,7 +131,7 @@ namespace CSVRender { if (tag->getPathgrid()->getId() != mLastId) { - getWorldspaceWidget().clearSelection(SceneUtil::Mask_Pathgrid); + getWorldspaceWidget().clearSelection(Mask_Pathgrid); mLastId = tag->getPathgrid()->getId(); } @@ -142,12 +142,12 @@ namespace CSVRender } } - getWorldspaceWidget().clearSelection(SceneUtil::Mask_Pathgrid); + getWorldspaceWidget().clearSelection(Mask_Pathgrid); } bool PathgridMode::primaryEditStartDrag(const QPoint& pos) { - std::vector > selection = getWorldspaceWidget().getSelection (SceneUtil::Mask_Pathgrid); + std::vector > selection = getWorldspaceWidget().getSelection (Mask_Pathgrid); if (CSMPrefs::get()["3D Scene Input"]["context-select"].isTrue()) { @@ -156,7 +156,7 @@ namespace CSVRender if (dynamic_cast(hit.tag.get())) { primarySelectPressed(hit); - selection = getWorldspaceWidget().getSelection (SceneUtil::Mask_Pathgrid); + selection = getWorldspaceWidget().getSelection (Mask_Pathgrid); } } @@ -192,7 +192,7 @@ namespace CSVRender { if (mDragMode == DragMode_Move) { - std::vector > selection = getWorldspaceWidget().getSelection(SceneUtil::Mask_Pathgrid); + std::vector > selection = getWorldspaceWidget().getSelection(Mask_Pathgrid); for (std::vector >::iterator it = selection.begin(); it != selection.end(); ++it) { @@ -233,7 +233,7 @@ namespace CSVRender { if (mDragMode == DragMode_Move) { - std::vector > selection = getWorldspaceWidget().getSelection (SceneUtil::Mask_Pathgrid); + std::vector > selection = getWorldspaceWidget().getSelection (Mask_Pathgrid); for (std::vector >::iterator it = selection.begin(); it != selection.end(); ++it) { if (PathgridTag* tag = dynamic_cast(it->get())) @@ -272,11 +272,11 @@ namespace CSVRender } mDragMode = DragMode_None; - getWorldspaceWidget().reset(SceneUtil::Mask_Pathgrid); + getWorldspaceWidget().reset(Mask_Pathgrid); } void PathgridMode::dragAborted() { - getWorldspaceWidget().reset(SceneUtil::Mask_Pathgrid); + getWorldspaceWidget().reset(Mask_Pathgrid); } } diff --git a/apps/opencs/view/render/pathgridselectionmode.cpp b/apps/opencs/view/render/pathgridselectionmode.cpp index 43050d52a..db41faf50 100644 --- a/apps/opencs/view/render/pathgridselectionmode.cpp +++ b/apps/opencs/view/render/pathgridselectionmode.cpp @@ -13,7 +13,7 @@ namespace CSVRender { PathgridSelectionMode::PathgridSelectionMode(CSVWidget::SceneToolbar* parent, WorldspaceWidget& worldspaceWidget) - : SelectionMode(parent, worldspaceWidget, SceneUtil::Mask_Pathgrid) + : SelectionMode(parent, worldspaceWidget, Mask_Pathgrid) { mRemoveSelectedNodes = new QAction("Remove selected nodes", this); mRemoveSelectedEdges = new QAction("Remove edges between selected nodes", this); @@ -37,7 +37,7 @@ namespace CSVRender void PathgridSelectionMode::removeSelectedNodes() { - std::vector > selection = getWorldspaceWidget().getSelection (SceneUtil::Mask_Pathgrid); + std::vector > selection = getWorldspaceWidget().getSelection (Mask_Pathgrid); for (std::vector >::iterator it = selection.begin(); it != selection.end(); ++it) { @@ -54,7 +54,7 @@ namespace CSVRender void PathgridSelectionMode::removeSelectedEdges() { - std::vector > selection = getWorldspaceWidget().getSelection (SceneUtil::Mask_Pathgrid); + std::vector > selection = getWorldspaceWidget().getSelection (Mask_Pathgrid); for (std::vector >::iterator it = selection.begin(); it != selection.end(); ++it) { diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index cd671f875..ed232722d 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include "../widget/scenetoolmode.hpp" @@ -26,6 +25,7 @@ #include "../../model/prefs/shortcuteventhandler.hpp" #include "lighting.hpp" +#include "mask.hpp" #include "cameracontroller.hpp" namespace CSVRender @@ -71,7 +71,7 @@ RenderWidget::RenderWidget(QWidget *parent, Qt::WindowFlags f) SceneUtil::LightManager* lightMgr = new SceneUtil::LightManager; lightMgr->setStartLight(1); - lightMgr->setLightingMask(SceneUtil::Mask_Lighting); + lightMgr->setLightingMask(Mask_Lighting); mRootNode = lightMgr; mView->getCamera()->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON); @@ -88,7 +88,7 @@ RenderWidget::RenderWidget(QWidget *parent, Qt::WindowFlags f) // Add ability to signal osg to show its statistics for debugging purposes mView->addEventHandler(new osgViewer::StatsHandler); - mView->getCamera()->setCullMask(~(SceneUtil::Mask_UpdateVisitor)); + mView->getCamera()->setCullMask(~(Mask_UpdateVisitor)); viewer.addView(mView); viewer.setDone(false); @@ -122,7 +122,7 @@ void RenderWidget::flagAsModified() void RenderWidget::setVisibilityMask(int mask) { - mView->getCamera()->setCullMask(mask | SceneUtil::Mask_ParticleSystem | SceneUtil::Mask_Lighting); + mView->getCamera()->setCullMask(mask | Mask_ParticleSystem | Mask_Lighting); } osg::Camera *RenderWidget::getCamera() @@ -212,7 +212,7 @@ SceneWidget::SceneWidget(std::shared_ptr resourceSyste mOrbitCamControl = new OrbitCameraController(this); mCurrentCamControl = mFreeCamControl; - mOrbitCamControl->setPickingMask(SceneUtil::Mask_EditorReference | SceneUtil::Mask_Terrain); + mOrbitCamControl->setPickingMask(Mask_Reference | Mask_Terrain); mOrbitCamControl->setConstRoll( CSMPrefs::get()["3D Scene Input"]["navi-orbit-const-roll"].isTrue() ); @@ -221,7 +221,7 @@ SceneWidget::SceneWidget(std::shared_ptr resourceSyste setLighting(&mLightingDay); - mResourceSystem->getSceneManager()->setParticleSystemMask(SceneUtil::Mask_ParticleSystem); + mResourceSystem->getSceneManager()->setParticleSystemMask(Mask_ParticleSystem); // Recieve mouse move event even if mouse button is not pressed setMouseTracking(true); @@ -350,7 +350,7 @@ void SceneWidget::update(double dt) } else { - mCurrentCamControl->setup(mRootNode, SceneUtil::Mask_EditorReference | SceneUtil::Mask_Terrain, CameraController::WorldUp); + mCurrentCamControl->setup(mRootNode, Mask_Reference | Mask_Terrain, CameraController::WorldUp); mCamPositionSet = true; } } diff --git a/apps/opencs/view/render/selectionmode.hpp b/apps/opencs/view/render/selectionmode.hpp index 18c751290..f28888bfd 100644 --- a/apps/opencs/view/render/selectionmode.hpp +++ b/apps/opencs/view/render/selectionmode.hpp @@ -3,6 +3,8 @@ #include "../widget/scenetoolmode.hpp" +#include "mask.hpp" + class QAction; namespace CSVRender diff --git a/apps/opencs/view/render/tagbase.cpp b/apps/opencs/view/render/tagbase.cpp index bdd648102..3ddd68690 100644 --- a/apps/opencs/view/render/tagbase.cpp +++ b/apps/opencs/view/render/tagbase.cpp @@ -1,9 +1,9 @@ #include "tagbase.hpp" -CSVRender::TagBase::TagBase (SceneUtil::VisMask mask) : mMask (mask) {} +CSVRender::TagBase::TagBase (Mask mask) : mMask (mask) {} -SceneUtil::VisMask CSVRender::TagBase::getMask() const +CSVRender::Mask CSVRender::TagBase::getMask() const { return mMask; } diff --git a/apps/opencs/view/render/tagbase.hpp b/apps/opencs/view/render/tagbase.hpp index 6a0bc4aef..d1ecd2cfd 100644 --- a/apps/opencs/view/render/tagbase.hpp +++ b/apps/opencs/view/render/tagbase.hpp @@ -5,19 +5,19 @@ #include -#include +#include "mask.hpp" namespace CSVRender { class TagBase : public osg::Referenced { - SceneUtil::VisMask mMask; + Mask mMask; public: - TagBase (SceneUtil::VisMask mask); + TagBase (Mask mask); - SceneUtil::VisMask getMask() const; + Mask getMask() const; virtual QString getToolTip (bool hideBasics) const; diff --git a/apps/opencs/view/render/terrainshapemode.cpp b/apps/opencs/view/render/terrainshapemode.cpp index 6df5ee836..5664378ca 100644 --- a/apps/opencs/view/render/terrainshapemode.cpp +++ b/apps/opencs/view/render/terrainshapemode.cpp @@ -17,7 +17,6 @@ #include #include -#include #include "../widget/brushshapes.hpp" #include "../widget/modebutton.hpp" @@ -40,12 +39,13 @@ #include "brushdraw.hpp" #include "editmode.hpp" #include "pagedworldspacewidget.hpp" +#include "mask.hpp" #include "tagbase.hpp" #include "terrainselection.hpp" #include "worldspacewidget.hpp" CSVRender::TerrainShapeMode::TerrainShapeMode (WorldspaceWidget *worldspaceWidget, osg::Group* parentNode, QWidget *parent) -: EditMode (worldspaceWidget, QIcon {":scenetoolbar/editing-terrain-shape"}, SceneUtil::Mask_Terrain | SceneUtil::Mask_EditorReference, "Terrain land editing", parent), +: EditMode (worldspaceWidget, QIcon {":scenetoolbar/editing-terrain-shape"}, Mask_Terrain | Mask_Reference, "Terrain land editing", parent), mParentNode(parentNode) { } diff --git a/apps/opencs/view/render/terraintexturemode.cpp b/apps/opencs/view/render/terraintexturemode.cpp index d4656b578..ae5711881 100644 --- a/apps/opencs/view/render/terraintexturemode.cpp +++ b/apps/opencs/view/render/terraintexturemode.cpp @@ -13,7 +13,6 @@ #include #include -#include #include "../widget/modebutton.hpp" #include "../widget/scenetoolbar.hpp" @@ -37,11 +36,12 @@ #include "brushdraw.hpp" #include "editmode.hpp" #include "pagedworldspacewidget.hpp" +#include "mask.hpp" #include "object.hpp" // Something small needed regarding pointers from here () #include "worldspacewidget.hpp" CSVRender::TerrainTextureMode::TerrainTextureMode (WorldspaceWidget *worldspaceWidget, osg::Group* parentNode, QWidget *parent) -: EditMode (worldspaceWidget, QIcon {":scenetoolbar/editing-terrain-texture"}, SceneUtil::Mask_Terrain | SceneUtil::Mask_EditorReference, "Terrain texture editing", parent), +: EditMode (worldspaceWidget, QIcon {":scenetoolbar/editing-terrain-texture"}, Mask_Terrain | Mask_Reference, "Terrain texture editing", parent), mBrushTexture("L0#0"), mBrushSize(1), mBrushShape(CSVWidget::BrushShape_Point), diff --git a/apps/opencs/view/render/unpagedworldspacewidget.cpp b/apps/opencs/view/render/unpagedworldspacewidget.cpp index 5f5441b83..b1088aa60 100644 --- a/apps/opencs/view/render/unpagedworldspacewidget.cpp +++ b/apps/opencs/view/render/unpagedworldspacewidget.cpp @@ -16,6 +16,7 @@ #include "../widget/scenetooltoggle2.hpp" #include "cameracontroller.hpp" +#include "mask.hpp" #include "tagbase.hpp" void CSVRender::UnpagedWorldspaceWidget::update() @@ -303,8 +304,8 @@ void CSVRender::UnpagedWorldspaceWidget::addVisibilitySelectorButtons ( CSVWidget::SceneToolToggle2 *tool) { WorldspaceWidget::addVisibilitySelectorButtons (tool); - tool->addButton (Button_Terrain, SceneUtil::Mask_Terrain, "Terrain", "", true); - //tool->addButton (Button_Fog, Mask_Fog, "Fog"); + tool->addButton (Button_Terrain, Mask_Terrain, "Terrain", "", true); + tool->addButton (Button_Fog, Mask_Fog, "Fog"); } std::string CSVRender::UnpagedWorldspaceWidget::getStartupInstruction() diff --git a/apps/opencs/view/render/worldspacewidget.cpp b/apps/opencs/view/render/worldspacewidget.cpp index 4755de97b..8e54b9a81 100644 --- a/apps/opencs/view/render/worldspacewidget.cpp +++ b/apps/opencs/view/render/worldspacewidget.cpp @@ -26,9 +26,8 @@ #include "../widget/scenetooltoggle2.hpp" #include "../widget/scenetoolrun.hpp" -#include - #include "object.hpp" +#include "mask.hpp" #include "instancemode.hpp" #include "pathgridmode.hpp" #include "cameracontroller.hpp" @@ -139,7 +138,7 @@ void CSVRender::WorldspaceWidget::settingChanged (const CSMPrefs::Setting *setti { float alpha = setting->toDouble(); // getSelection is virtual, thus this can not be called from the constructor - auto selection = getSelection(SceneUtil::Mask_EditorReference); + auto selection = getSelection(Mask_Reference); for (osg::ref_ptr tag : selection) { if (auto objTag = dynamic_cast(tag.get())) @@ -346,7 +345,7 @@ unsigned int CSVRender::WorldspaceWidget::getVisibilityMask() const void CSVRender::WorldspaceWidget::setInteractionMask (unsigned int mask) { - mInteractionMask = mask | SceneUtil::Mask_EditorCellMarker | SceneUtil::Mask_EditorCellArrow; + mInteractionMask = mask | Mask_CellMarker | Mask_CellArrow; } unsigned int CSVRender::WorldspaceWidget::getInteractionMask() const @@ -362,9 +361,9 @@ void CSVRender::WorldspaceWidget::setEditLock (bool locked) void CSVRender::WorldspaceWidget::addVisibilitySelectorButtons ( CSVWidget::SceneToolToggle2 *tool) { - tool->addButton (Button_Reference, SceneUtil::Mask_EditorReference, "Instances"); - tool->addButton (Button_Water, SceneUtil::Mask_Water, "Water"); - tool->addButton (Button_Pathgrid, SceneUtil::Mask_Pathgrid, "Pathgrid"); + tool->addButton (Button_Reference, Mask_Reference, "Instances"); + tool->addButton (Button_Water, Mask_Water, "Water"); + tool->addButton (Button_Pathgrid, Mask_Pathgrid, "Pathgrid"); } void CSVRender::WorldspaceWidget::addEditModeSelectorButtons (CSVWidget::SceneToolMode *tool) diff --git a/apps/opencs/view/render/worldspacewidget.hpp b/apps/opencs/view/render/worldspacewidget.hpp index 5ac63c673..a80032b82 100644 --- a/apps/opencs/view/render/worldspacewidget.hpp +++ b/apps/opencs/view/render/worldspacewidget.hpp @@ -8,6 +8,7 @@ #include "../../model/world/tablemimedata.hpp" #include "scenewidget.hpp" +#include "mask.hpp" namespace CSMPrefs { diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 4a375b8e9..57262f964 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -18,7 +18,7 @@ set(GAME_HEADER source_group(game FILES ${GAME} ${GAME_HEADER}) add_openmw_dir (mwrender - actors objects renderingmanager animation rotatecontroller sky npcanimation + actors objects renderingmanager animation rotatecontroller sky npcanimation vismask creatureanimation effectmanager util renderinginterface pathgrid rendermode weaponanimation bulletdebugdraw globalmap characterpreview camera localmap water terrainstorage ripplesimulation renderbin actoranimation landmanager navmesh actorspaths recastmesh diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index ec8c1e305..4a66f3a7a 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -26,7 +26,6 @@ #include -#include #include #include @@ -48,6 +47,8 @@ #include "mwworld/player.hpp" #include "mwworld/worldimp.hpp" +#include "mwrender/vismask.hpp" + #include "mwclass/classes.hpp" #include "mwdialogue/dialoguemanagerimp.hpp" @@ -537,7 +538,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings) std::string myguiResources = (mResDir / "mygui").string(); osg::ref_ptr guiRoot = new osg::Group; guiRoot->setName("GUI Root"); - guiRoot->setNodeMask(SceneUtil::Mask_GUI); + guiRoot->setNodeMask(MWRender::Mask_GUI); rootNode->addChild(guiRoot); MWGui::WindowManager* window = new MWGui::WindowManager(mViewer, guiRoot, mResourceSystem.get(), mWorkQueue.get(), mCfgMgr.getLogPath().string() + std::string("/"), myguiResources, diff --git a/apps/openmw/mwclass/activator.cpp b/apps/openmw/mwclass/activator.cpp index 3f4e13c1c..c54b1c369 100644 --- a/apps/openmw/mwclass/activator.cpp +++ b/apps/openmw/mwclass/activator.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include "../mwbase/environment.hpp" #include "../mwbase/windowmanager.hpp" @@ -20,6 +19,7 @@ #include "../mwrender/objects.hpp" #include "../mwrender/renderinginterface.hpp" +#include "../mwrender/vismask.hpp" #include "../mwgui/tooltips.hpp" @@ -34,7 +34,7 @@ namespace MWClass if (!model.empty()) { renderingInterface.getObjects().insertModel(ptr, model, true); - ptr.getRefData().getBaseNode()->setNodeMask(SceneUtil::Mask_Static); + ptr.getRefData().getBaseNode()->setNodeMask(MWRender::Mask_Static); } } diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 7d1c1d38a..56712a815 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -26,6 +25,7 @@ #include "../mwrender/objects.hpp" #include "../mwrender/renderinginterface.hpp" #include "../mwrender/animation.hpp" +#include "../mwrender/vismask.hpp" #include "../mwmechanics/actorutil.hpp" @@ -58,7 +58,7 @@ namespace MWClass if (!model.empty()) { renderingInterface.getObjects().insertModel(ptr, model, true); - ptr.getRefData().getBaseNode()->setNodeMask(SceneUtil::Mask_Static); + ptr.getRefData().getBaseNode()->setNodeMask(MWRender::Mask_Static); } } diff --git a/apps/openmw/mwclass/static.cpp b/apps/openmw/mwclass/static.cpp index 2cb00c497..5551b3d73 100644 --- a/apps/openmw/mwclass/static.cpp +++ b/apps/openmw/mwclass/static.cpp @@ -2,7 +2,6 @@ #include #include -#include #include "../mwworld/ptr.hpp" #include "../mwphysics/physicssystem.hpp" @@ -10,6 +9,7 @@ #include "../mwrender/objects.hpp" #include "../mwrender/renderinginterface.hpp" +#include "../mwrender/vismask.hpp" namespace MWClass { @@ -19,7 +19,7 @@ namespace MWClass if (!model.empty()) { renderingInterface.getObjects().insertModel(ptr, model); - ptr.getRefData().getBaseNode()->setNodeMask(SceneUtil::Mask_Static); + ptr.getRefData().getBaseNode()->setNodeMask(MWRender::Mask_Static); } } diff --git a/apps/openmw/mwgui/loadingscreen.cpp b/apps/openmw/mwgui/loadingscreen.cpp index ddaa9063a..54382ab4d 100644 --- a/apps/openmw/mwgui/loadingscreen.cpp +++ b/apps/openmw/mwgui/loadingscreen.cpp @@ -14,13 +14,14 @@ #include #include #include -#include #include "../mwbase/environment.hpp" #include "../mwbase/statemanager.hpp" #include "../mwbase/windowmanager.hpp" #include "../mwbase/inputmanager.hpp" +#include "../mwrender/vismask.hpp" + #include "backgroundimage.hpp" namespace MWGui @@ -334,8 +335,8 @@ namespace MWGui // Turn off rendering except the GUI int oldUpdateMask = mViewer->getUpdateVisitor()->getTraversalMask(); int oldCullMask = mViewer->getCamera()->getCullMask(); - mViewer->getUpdateVisitor()->setTraversalMask(SceneUtil::Mask_GUI|SceneUtil::Mask_PreCompile); - mViewer->getCamera()->setCullMask(SceneUtil::Mask_GUI|SceneUtil::Mask_PreCompile); + mViewer->getUpdateVisitor()->setTraversalMask(MWRender::Mask_GUI|MWRender::Mask_PreCompile); + mViewer->getCamera()->setCullMask(MWRender::Mask_GUI|MWRender::Mask_PreCompile); MWBase::Environment::get().getInputManager()->update(0, true, true); diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 4f36032e1..d10270d77 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -30,7 +30,6 @@ #include #include -#include #include #include @@ -51,6 +50,8 @@ #include "../mwbase/soundmanager.hpp" #include "../mwbase/world.hpp" +#include "../mwrender/vismask.hpp" + #include "../mwworld/class.hpp" #include "../mwworld/player.hpp" #include "../mwworld/cellstore.hpp" @@ -1878,8 +1879,8 @@ namespace MWGui // Turn off all rendering except for the GUI int oldUpdateMask = mViewer->getUpdateVisitor()->getTraversalMask(); int oldCullMask = mViewer->getCamera()->getCullMask(); - mViewer->getUpdateVisitor()->setTraversalMask(SceneUtil::Mask_GUI); - mViewer->getCamera()->setCullMask(SceneUtil::Mask_GUI); + mViewer->getUpdateVisitor()->setTraversalMask(MWRender::Mask_GUI); + mViewer->getCamera()->setCullMask(MWRender::Mask_GUI); MyGUI::IntSize screenSize = MyGUI::RenderManager::getInstance().getViewSize(); sizeVideo(screenSize.width, screenSize.height); diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index e81c9a119..726b2a31f 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -4,7 +4,6 @@ #include #include -#include #include #include #include @@ -25,6 +24,8 @@ #include "../mwmechanics/aibreathe.hpp" +#include "../mwrender/vismask.hpp" + #include "spellcasting.hpp" #include "steering.hpp" #include "npcstats.hpp" @@ -1422,11 +1423,11 @@ namespace MWMechanics const float dist = (player.getRefData().getPosition().asVec3() - ptr.getRefData().getPosition().asVec3()).length(); if (dist > mActorsProcessingRange) { - ptr.getRefData().getBaseNode()->setNodeMask(SceneUtil::Mask_Disabled); + ptr.getRefData().getBaseNode()->setNodeMask(0); return; } else - ptr.getRefData().getBaseNode()->setNodeMask(SceneUtil::Mask_Actor); + ptr.getRefData().getBaseNode()->setNodeMask(MWRender::Mask_Actor); // Fade away actors on large distance (>90% of actor's processing distance) float visibilityRatio = 1.0; @@ -1750,12 +1751,12 @@ namespace MWMechanics if (!inRange) { - iter->first.getRefData().getBaseNode()->setNodeMask(SceneUtil::Mask_Disabled); + iter->first.getRefData().getBaseNode()->setNodeMask(0); world->setActorCollisionMode(iter->first, false, false); continue; } else if (!isPlayer) - iter->first.getRefData().getBaseNode()->setNodeMask(SceneUtil::Mask_Actor); + iter->first.getRefData().getBaseNode()->setNodeMask(MWRender::Mask_Actor); const bool isDead = iter->first.getClass().getCreatureStats(iter->first).isDead(); if (!isDead && iter->first.getClass().getCreatureStats(iter->first).isParalyzed()) diff --git a/apps/openmw/mwrender/actoranimation.cpp b/apps/openmw/mwrender/actoranimation.cpp index 1c54f0684..fcffe220b 100644 --- a/apps/openmw/mwrender/actoranimation.cpp +++ b/apps/openmw/mwrender/actoranimation.cpp @@ -15,7 +15,6 @@ #include #include #include -#include #include @@ -32,6 +31,8 @@ #include "../mwmechanics/actorutil.hpp" #include "../mwmechanics/weapontype.hpp" +#include "vismask.hpp" + namespace MWRender { @@ -366,7 +367,7 @@ void ActorAnimation::updateHolsteredWeapon(bool showHolsteredWeapons) // Otherwise add the enchanted glow to it. if (!showHolsteredWeapons) { - weaponNode->setNodeMask(SceneUtil::Mask_Disabled); + weaponNode->setNodeMask(0); } else { @@ -540,7 +541,7 @@ void ActorAnimation::addHiddenItemLight(const MWWorld::ConstPtr& item, const ESM bool exterior = mPtr.isInCell() && mPtr.getCell()->getCell()->isExterior(); osg::Vec4f ambient(1,1,1,1); - osg::ref_ptr lightSource = SceneUtil::createLightSource(esmLight, exterior, ambient); + osg::ref_ptr lightSource = SceneUtil::createLightSource(esmLight, Mask_Lighting, exterior, ambient); mInsert->addChild(lightSource); diff --git a/apps/openmw/mwrender/actorspaths.cpp b/apps/openmw/mwrender/actorspaths.cpp index ec90949bc..35b255355 100644 --- a/apps/openmw/mwrender/actorspaths.cpp +++ b/apps/openmw/mwrender/actorspaths.cpp @@ -1,7 +1,7 @@ #include "actorspaths.hpp" +#include "vismask.hpp" #include -#include #include @@ -43,7 +43,7 @@ namespace MWRender const auto newGroup = SceneUtil::createAgentPathGroup(path, halfExtents, start, end, settings); if (newGroup) { - newGroup->setNodeMask(SceneUtil::Mask_Debug); + newGroup->setNodeMask(Mask_Debug); mRootNode->addChild(newGroup); mGroups[actor] = newGroup; } diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 0f7548f05..3505ea261 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -45,6 +44,7 @@ #include "../mwmechanics/character.hpp" // FIXME: for MWMechanics::Priority +#include "vismask.hpp" #include "util.hpp" #include "rotatecontroller.hpp" @@ -578,7 +578,7 @@ namespace MWRender else { // Hide effect immediately - node->setNodeMask(SceneUtil::Mask_Disabled); + node->setNodeMask(0); mFinished = true; } } @@ -1595,7 +1595,7 @@ namespace MWRender { bool exterior = mPtr.isInCell() && mPtr.getCell()->getCell()->isExterior(); - SceneUtil::addLight(parent, esmLight, exterior); + SceneUtil::addLight(parent, esmLight, Mask_ParticleSystem, Mask_Lighting, exterior); } void Animation::addEffect (const std::string& model, int effectId, bool loop, const std::string& bonename, const std::string& texture) @@ -1647,7 +1647,7 @@ namespace MWRender // FreezeOnCull doesn't work so well with effect particles, that tend to have moving emitters SceneUtil::DisableFreezeOnCullVisitor disableFreezeOnCullVisitor; node->accept(disableFreezeOnCullVisitor); - node->setNodeMask(SceneUtil::Mask_Effect); + node->setNodeMask(Mask_Effect); params.mMaxControllerLength = findMaxLengthVisitor.getMaxLength(); params.mLoop = loop; @@ -1806,7 +1806,7 @@ namespace MWRender SceneUtil::configureLight(light, radius, isExterior); mGlowLight = new SceneUtil::LightSource; - mGlowLight->setNodeMask(SceneUtil::Mask_Lighting); + mGlowLight->setNodeMask(Mask_Lighting); mInsert->addChild(mGlowLight); mGlowLight->setLight(light); } diff --git a/apps/openmw/mwrender/bulletdebugdraw.cpp b/apps/openmw/mwrender/bulletdebugdraw.cpp index 9883d9fe3..4cf76e473 100644 --- a/apps/openmw/mwrender/bulletdebugdraw.cpp +++ b/apps/openmw/mwrender/bulletdebugdraw.cpp @@ -7,7 +7,7 @@ #include -#include +#include "vismask.hpp" namespace { @@ -34,7 +34,7 @@ void DebugDrawer::createGeometry() if (!mGeometry) { mGeometry = new osg::Geometry; - mGeometry->setNodeMask(SceneUtil::Mask_Debug); + mGeometry->setNodeMask(Mask_Debug); mVertices = new osg::Vec3Array; diff --git a/apps/openmw/mwrender/characterpreview.cpp b/apps/openmw/mwrender/characterpreview.cpp index c74c70b55..b2552e598 100644 --- a/apps/openmw/mwrender/characterpreview.cpp +++ b/apps/openmw/mwrender/characterpreview.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -28,6 +27,7 @@ #include "../mwmechanics/weapontype.hpp" #include "npcanimation.hpp" +#include "vismask.hpp" namespace MWRender { @@ -61,7 +61,7 @@ namespace MWRender } else { - node->setNodeMask(SceneUtil::Mask_Disabled); + node->setNodeMask(0); } } @@ -138,9 +138,9 @@ namespace MWRender mCamera->attach(osg::Camera::COLOR_BUFFER, mTexture); mCamera->setName("CharacterPreview"); mCamera->setComputeNearFarMode(osg::Camera::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES); - mCamera->setCullMask(~(SceneUtil::Mask_UpdateVisitor)); + mCamera->setCullMask(~(Mask_UpdateVisitor)); - mCamera->setNodeMask(SceneUtil::Mask_RenderToTexture); + mCamera->setNodeMask(Mask_RenderToTexture); osg::ref_ptr lightManager = new SceneUtil::LightManager; lightManager->setStartLight(1); @@ -255,7 +255,7 @@ namespace MWRender void CharacterPreview::redraw() { - mCamera->setNodeMask(SceneUtil::Mask_RenderToTexture); + mCamera->setNodeMask(Mask_RenderToTexture); mDrawOnceCallback->redrawNextFrame(); } @@ -364,7 +364,7 @@ namespace MWRender visitor.setTraversalNumber(mDrawOnceCallback->getLastRenderedFrame()); osg::Node::NodeMask nodeMask = mCamera->getNodeMask(); - mCamera->setNodeMask(SceneUtil::Mask_Default); + mCamera->setNodeMask(~0); mCamera->accept(visitor); mCamera->setNodeMask(nodeMask); diff --git a/apps/openmw/mwrender/effectmanager.cpp b/apps/openmw/mwrender/effectmanager.cpp index 450cb20f5..3e785a769 100644 --- a/apps/openmw/mwrender/effectmanager.cpp +++ b/apps/openmw/mwrender/effectmanager.cpp @@ -6,9 +6,9 @@ #include #include -#include #include "animation.hpp" +#include "vismask.hpp" #include "util.hpp" namespace MWRender @@ -29,7 +29,7 @@ void EffectManager::addEffect(const std::string &model, const std::string& textu { osg::ref_ptr node = mResourceSystem->getSceneManager()->getInstance(model); - node->setNodeMask(SceneUtil::Mask_Effect); + node->setNodeMask(Mask_Effect); Effect effect; effect.mAnimTime.reset(new EffectAnimationTime); diff --git a/apps/openmw/mwrender/globalmap.cpp b/apps/openmw/mwrender/globalmap.cpp index d51791da6..afa83a1d7 100644 --- a/apps/openmw/mwrender/globalmap.cpp +++ b/apps/openmw/mwrender/globalmap.cpp @@ -16,7 +16,6 @@ #include #include -#include #include @@ -25,6 +24,8 @@ #include "../mwworld/esmstore.hpp" +#include "vismask.hpp" + namespace { @@ -75,7 +76,7 @@ namespace { if (mParent->copyResult(static_cast(node), nv->getTraversalNumber())) { - node->setNodeMask(SceneUtil::Mask_Disabled); + node->setNodeMask(0); mParent->markForRemoval(static_cast(node)); } return; @@ -287,7 +288,7 @@ namespace MWRender float srcLeft, float srcTop, float srcRight, float srcBottom) { osg::ref_ptr camera (new osg::Camera); - camera->setNodeMask(SceneUtil::Mask_RenderToTexture); + camera->setNodeMask(Mask_RenderToTexture); camera->setReferenceFrame(osg::Camera::ABSOLUTE_RF); camera->setViewMatrix(osg::Matrix::identity()); camera->setProjectionMatrix(osg::Matrix::identity()); diff --git a/apps/openmw/mwrender/localmap.cpp b/apps/openmw/mwrender/localmap.cpp index 7bd202e7e..f4a54eb98 100644 --- a/apps/openmw/mwrender/localmap.cpp +++ b/apps/openmw/mwrender/localmap.cpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #include "../mwbase/environment.hpp" @@ -26,6 +25,8 @@ #include "../mwworld/cellstore.hpp" +#include "vismask.hpp" + namespace { @@ -41,7 +42,7 @@ namespace virtual void operator()(osg::Node* node, osg::NodeVisitor*) { if (mRendered) - node->setNodeMask(SceneUtil::Mask_Disabled); + node->setNodeMask(0); if (!mRendered) { @@ -177,8 +178,8 @@ osg::ref_ptr LocalMap::createOrthographicCamera(float x, float y, f camera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); camera->setRenderOrder(osg::Camera::PRE_RENDER); - camera->setCullMask(SceneUtil::Mask_Scene | SceneUtil::Mask_SimpleWater | SceneUtil::Mask_Terrain | SceneUtil::Mask_Object | SceneUtil::Mask_Static); - camera->setNodeMask(SceneUtil::Mask_RenderToTexture); + camera->setCullMask(Mask_Scene | Mask_SimpleWater | Mask_Terrain | Mask_Object | Mask_Static); + camera->setNodeMask(Mask_RenderToTexture); osg::ref_ptr stateset = new osg::StateSet; stateset->setAttribute(new osg::PolygonMode(osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::FILL), osg::StateAttribute::OVERRIDE); @@ -375,7 +376,7 @@ void LocalMap::requestExteriorMap(const MWWorld::CellStore* cell) void LocalMap::requestInteriorMap(const MWWorld::CellStore* cell) { osg::ComputeBoundsVisitor computeBoundsVisitor; - computeBoundsVisitor.setTraversalMask(SceneUtil::Mask_Scene | SceneUtil::Mask_Terrain | SceneUtil::Mask_Object | SceneUtil::Mask_Static); + computeBoundsVisitor.setTraversalMask(Mask_Scene | Mask_Terrain | Mask_Object | Mask_Static); mSceneRoot->accept(computeBoundsVisitor); osg::BoundingBox bounds = computeBoundsVisitor.getBoundingBox(); diff --git a/apps/openmw/mwrender/navmesh.cpp b/apps/openmw/mwrender/navmesh.cpp index 7aade0c23..791c41a1a 100644 --- a/apps/openmw/mwrender/navmesh.cpp +++ b/apps/openmw/mwrender/navmesh.cpp @@ -1,7 +1,7 @@ #include "navmesh.hpp" +#include "vismask.hpp" #include -#include #include @@ -45,7 +45,7 @@ namespace MWRender mGroup = SceneUtil::createNavMeshGroup(navMesh, settings); if (mGroup) { - mGroup->setNodeMask(SceneUtil::Mask_Debug); + mGroup->setNodeMask(Mask_Debug); mRootNode->addChild(mGroup); } } diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 261723db5..a797a9876 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #include @@ -44,6 +43,7 @@ #include "camera.hpp" #include "rotatecontroller.hpp" #include "renderbin.hpp" +#include "vismask.hpp" namespace { @@ -538,7 +538,7 @@ void NpcAnimation::updateNpcBase() addAnimSource(smodel, smodel); - mObjectRoot->setNodeMask(SceneUtil::Mask_FirstPerson); + mObjectRoot->setNodeMask(Mask_FirstPerson); mObjectRoot->addCullCallback(new OverrideFieldOfViewCallback(mFirstPersonFieldOfView)); } diff --git a/apps/openmw/mwrender/objects.cpp b/apps/openmw/mwrender/objects.cpp index 83fd807dc..ec1c4397b 100644 --- a/apps/openmw/mwrender/objects.cpp +++ b/apps/openmw/mwrender/objects.cpp @@ -5,7 +5,6 @@ #include #include -#include #include "../mwworld/ptr.hpp" #include "../mwworld/class.hpp" @@ -13,6 +12,8 @@ #include "animation.hpp" #include "npcanimation.hpp" #include "creatureanimation.hpp" +#include "vismask.hpp" + namespace MWRender { @@ -70,7 +71,7 @@ void Objects::insertBegin(const MWWorld::Ptr& ptr) void Objects::insertModel(const MWWorld::Ptr &ptr, const std::string &mesh, bool animated, bool allowLight) { insertBegin(ptr); - ptr.getRefData().getBaseNode()->setNodeMask(SceneUtil::Mask_Object); + ptr.getRefData().getBaseNode()->setNodeMask(Mask_Object); osg::ref_ptr anim (new ObjectAnimation(ptr, mesh, mResourceSystem, animated, allowLight)); @@ -80,7 +81,7 @@ void Objects::insertModel(const MWWorld::Ptr &ptr, const std::string &mesh, bool void Objects::insertCreature(const MWWorld::Ptr &ptr, const std::string &mesh, bool weaponsShields) { insertBegin(ptr); - ptr.getRefData().getBaseNode()->setNodeMask(SceneUtil::Mask_Actor); + ptr.getRefData().getBaseNode()->setNodeMask(Mask_Actor); // CreatureAnimation osg::ref_ptr anim; @@ -97,7 +98,7 @@ void Objects::insertCreature(const MWWorld::Ptr &ptr, const std::string &mesh, b void Objects::insertNPC(const MWWorld::Ptr &ptr) { insertBegin(ptr); - ptr.getRefData().getBaseNode()->setNodeMask(SceneUtil::Mask_Actor); + ptr.getRefData().getBaseNode()->setNodeMask(Mask_Actor); osg::ref_ptr anim (new NpcAnimation(ptr, osg::ref_ptr(ptr.getRefData().getBaseNode()), mResourceSystem)); diff --git a/apps/openmw/mwrender/pathgrid.cpp b/apps/openmw/mwrender/pathgrid.cpp index a2c5a1f46..797794457 100644 --- a/apps/openmw/mwrender/pathgrid.cpp +++ b/apps/openmw/mwrender/pathgrid.cpp @@ -8,7 +8,6 @@ #include #include -#include #include "../mwbase/world.hpp" // these includes can be removed once the static-hack is gone #include "../mwbase/environment.hpp" @@ -18,6 +17,8 @@ #include "../mwmechanics/pathfinding.hpp" #include "../mwmechanics/coordinateconverter.hpp" +#include "vismask.hpp" + namespace MWRender { @@ -72,7 +73,7 @@ void Pathgrid::togglePathgrid() { // add path grid meshes to already loaded cells mPathGridRoot = new osg::Group; - mPathGridRoot->setNodeMask(SceneUtil::Mask_Pathgrid); + mPathGridRoot->setNodeMask(Mask_Debug); mRootNode->addChild(mPathGridRoot); for(const MWWorld::CellStore* cell : mActiveCells) diff --git a/apps/openmw/mwrender/recastmesh.cpp b/apps/openmw/mwrender/recastmesh.cpp index 5aec174df..d07e7d37b 100644 --- a/apps/openmw/mwrender/recastmesh.cpp +++ b/apps/openmw/mwrender/recastmesh.cpp @@ -1,11 +1,12 @@ #include "recastmesh.hpp" -#include #include #include #include +#include "vismask.hpp" + namespace MWRender { RecastMesh::RecastMesh(const osg::ref_ptr& root, bool enabled) @@ -49,7 +50,7 @@ namespace MWRender || it->second.mRevision != tile->second->getRevision()) { const auto group = SceneUtil::createRecastMeshGroup(*tile->second, settings); - group->setNodeMask(SceneUtil::Mask_Debug); + group->setNodeMask(Mask_Debug); mRootNode->removeChild(it->second.mValue); mRootNode->addChild(group); it->second.mValue = group; @@ -66,7 +67,7 @@ namespace MWRender if (mGroups.count(tile.first)) continue; const auto group = SceneUtil::createRecastMeshGroup(*tile.second, settings); - group->setNodeMask(SceneUtil::Mask_Debug); + group->setNodeMask(Mask_Debug); mGroups.emplace(tile.first, Group {tile.second->getGeneration(), tile.second->getRevision(), group}); mRootNode->addChild(group); } diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 23a47438a..648660669 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -40,7 +40,6 @@ #include #include #include -#include #include #include @@ -59,6 +58,7 @@ #include "sky.hpp" #include "effectmanager.hpp" #include "npcanimation.hpp" +#include "vismask.hpp" #include "pathgrid.hpp" #include "camera.hpp" #include "water.hpp" @@ -216,7 +216,7 @@ namespace MWRender , mFieldOfViewOverride(0.f) , mBorders(false) { - resourceSystem->getSceneManager()->setParticleSystemMask(SceneUtil::Mask_ParticleSystem); + resourceSystem->getSceneManager()->setParticleSystemMask(MWRender::Mask_ParticleSystem); resourceSystem->getSceneManager()->setShaderPath(resourcePath + "/shaders"); // Shadows and radial fog have problems with fixed-function mode bool forceShaders = Settings::Manager::getBool("radial fog", "Shaders") || Settings::Manager::getBool("force shaders", "Shaders") || Settings::Manager::getBool("enable shadows", "Shadows"); @@ -230,21 +230,21 @@ namespace MWRender resourceSystem->getSceneManager()->setSpecularMapPattern(Settings::Manager::getString("specular map pattern", "Shaders")); osg::ref_ptr sceneRoot = new SceneUtil::LightManager; - sceneRoot->setLightingMask(SceneUtil::Mask_Lighting); + sceneRoot->setLightingMask(Mask_Lighting); mSceneRoot = sceneRoot; sceneRoot->setStartLight(1); - int shadowCastingTraversalMask = SceneUtil::Mask_Scene; + int shadowCastingTraversalMask = Mask_Scene; if (Settings::Manager::getBool("actor shadows", "Shadows")) - shadowCastingTraversalMask |= SceneUtil::Mask_Actor; + shadowCastingTraversalMask |= Mask_Actor; if (Settings::Manager::getBool("player shadows", "Shadows")) - shadowCastingTraversalMask |= SceneUtil::Mask_Player; + shadowCastingTraversalMask |= Mask_Player; if (Settings::Manager::getBool("terrain shadows", "Shadows")) - shadowCastingTraversalMask |= SceneUtil::Mask_Terrain; + shadowCastingTraversalMask |= Mask_Terrain; int indoorShadowCastingTraversalMask = shadowCastingTraversalMask; if (Settings::Manager::getBool("object shadows", "Shadows")) - shadowCastingTraversalMask |= (SceneUtil::Mask_Object|SceneUtil::Mask_Static); + shadowCastingTraversalMask |= (Mask_Object|Mask_Static); mShadowManager.reset(new SceneUtil::ShadowManager(sceneRoot, mRootNode, shadowCastingTraversalMask, indoorShadowCastingTraversalMask, mResourceSystem->getSceneManager()->getShaderManager())); @@ -311,10 +311,11 @@ namespace MWRender float maxCompGeometrySize = Settings::Manager::getFloat("max composite geometry size", "Terrain"); maxCompGeometrySize = std::max(maxCompGeometrySize, 1.f); mTerrain.reset(new Terrain::QuadTreeWorld( - sceneRoot, mRootNode, mResourceSystem, mTerrainStorage, compMapResolution, compMapLevel, lodFactor, vertexLodMod, maxCompGeometrySize)); + sceneRoot, mRootNode, mResourceSystem, mTerrainStorage, Mask_Terrain, Mask_PreCompile, Mask_Debug, + compMapResolution, compMapLevel, lodFactor, vertexLodMod, maxCompGeometrySize)); } else - mTerrain.reset(new Terrain::TerrainGrid(sceneRoot, mRootNode, mResourceSystem, mTerrainStorage)); + mTerrain.reset(new Terrain::TerrainGrid(sceneRoot, mRootNode, mResourceSystem, mTerrainStorage, Mask_Terrain, Mask_PreCompile, Mask_Debug)); mTerrain->setTargetFrameRate(Settings::Manager::getFloat("target framerate", "Cells")); mTerrain->setWorkQueue(mWorkQueue.get()); @@ -324,7 +325,7 @@ namespace MWRender mViewer->setLightingMode(osgViewer::View::NO_LIGHT); osg::ref_ptr source = new osg::LightSource; - source->setNodeMask(SceneUtil::Mask_Lighting); + source->setNodeMask(Mask_Lighting); mSunLight = new osg::Light; source->setLight(mSunLight); mSunLight->setDiffuse(osg::Vec4f(0,0,0,1)); @@ -343,7 +344,7 @@ namespace MWRender defaultMat->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4f(0.f, 0.f, 0.f, 0.f)); sceneRoot->getOrCreateStateSet()->setAttribute(defaultMat); - sceneRoot->setNodeMask(SceneUtil::Mask_Scene); + sceneRoot->setNodeMask(Mask_Scene); sceneRoot->setName("Scene Root"); mSky.reset(new SkyManager(sceneRoot, resourceSystem->getSceneManager())); @@ -371,7 +372,7 @@ namespace MWRender mViewer->getCamera()->setComputeNearFarMode(osg::Camera::DO_NOT_COMPUTE_NEAR_FAR); mViewer->getCamera()->setCullingMode(cullingMode); - mViewer->getCamera()->setCullMask(~(SceneUtil::Mask_UpdateVisitor|SceneUtil::Mask_SimpleWater)); + mViewer->getCamera()->setCullMask(~(Mask_UpdateVisitor|Mask_SimpleWater)); mNearClip = Settings::Manager::getFloat("near clip", "Camera"); mViewDistance = Settings::Manager::getFloat("viewing distance", "Camera"); @@ -573,12 +574,12 @@ namespace MWRender else if (mode == Render_Scene) { int mask = mViewer->getCamera()->getCullMask(); - bool enabled = mask & SceneUtil::Mask_Scene; + bool enabled = mask&Mask_Scene; enabled = !enabled; if (enabled) - mask |= SceneUtil::Mask_Scene; + mask |= Mask_Scene; else - mask &= ~SceneUtil::Mask_Scene; + mask &= ~Mask_Scene; mViewer->getCamera()->setCullMask(mask); return enabled; } @@ -851,7 +852,7 @@ namespace MWRender int maskBackup = mPlayerAnimation->getObjectRoot()->getNodeMask(); if (mCamera->isFirstPerson()) - mPlayerAnimation->getObjectRoot()->setNodeMask(SceneUtil::Mask_Disabled); + mPlayerAnimation->getObjectRoot()->setNodeMask(0); for (int i = 0; i < 6; ++i) // for each cubemap side { @@ -925,7 +926,7 @@ namespace MWRender void RenderingManager::renderCameraToImage(osg::Camera *camera, osg::Image *image, int w, int h) { - camera->setNodeMask(SceneUtil::Mask_RenderToTexture); + camera->setNodeMask(Mask_RenderToTexture); camera->attach(osg::Camera::COLOR_BUFFER, image); camera->setRenderOrder(osg::Camera::PRE_RENDER); camera->setReferenceFrame(osg::Camera::ABSOLUTE_RF); @@ -978,7 +979,7 @@ namespace MWRender rttCamera->addChild(mWater->getReflectionCamera()); rttCamera->addChild(mWater->getRefractionCamera()); - rttCamera->setCullMask(mViewer->getCamera()->getCullMask() & (~SceneUtil::Mask_GUI)); + rttCamera->setCullMask(mViewer->getCamera()->getCullMask() & (~Mask_GUI)); rttCamera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -991,7 +992,7 @@ namespace MWRender return osg::Vec4f(); osg::ComputeBoundsVisitor computeBoundsVisitor; - computeBoundsVisitor.setTraversalMask(~(SceneUtil::Mask_ParticleSystem|SceneUtil::Mask_Effect)); + computeBoundsVisitor.setTraversalMask(~(Mask_ParticleSystem|Mask_Effect)); ptr.getRefData().getBaseNode()->accept(computeBoundsVisitor); osg::Matrix viewProj = mViewer->getCamera()->getViewMatrix() * mViewer->getCamera()->getProjectionMatrix(); @@ -1063,11 +1064,12 @@ namespace MWRender mIntersectionVisitor->setTraversalNumber(mViewer->getFrameStamp()->getFrameNumber()); mIntersectionVisitor->setIntersector(intersector); - int mask = ~(SceneUtil::Mask_RenderToTexture|SceneUtil::Mask_Sky|SceneUtil::Mask_Pathgrid|SceneUtil::Mask_Debug|SceneUtil::Mask_Effect|SceneUtil::Mask_Water|SceneUtil::Mask_SimpleWater); + int mask = ~0; + mask &= ~(Mask_RenderToTexture|Mask_Sky|Mask_Debug|Mask_Effect|Mask_Water|Mask_SimpleWater); if (ignorePlayer) - mask &= ~(SceneUtil::Mask_Player); + mask &= ~(Mask_Player); if (ignoreActors) - mask &= ~(SceneUtil::Mask_Actor|SceneUtil::Mask_Player); + mask &= ~(Mask_Actor|Mask_Player); mIntersectionVisitor->setTraversalMask(mask); return mIntersectionVisitor; @@ -1148,7 +1150,7 @@ namespace MWRender if (!mPlayerNode) { mPlayerNode = new SceneUtil::PositionAttitudeTransform; - mPlayerNode->setNodeMask(SceneUtil::Mask_Player); + mPlayerNode->setNodeMask(Mask_Player); mPlayerNode->setName("Player Root"); mSceneRoot->addChild(mPlayerNode); } @@ -1392,7 +1394,7 @@ namespace MWRender osg::ref_ptr node = mResourceSystem->getSceneManager()->getTemplate(modelName); osg::ComputeBoundsVisitor computeBoundsVisitor; - computeBoundsVisitor.setTraversalMask(~(SceneUtil::Mask_ParticleSystem|SceneUtil::Mask_Effect)); + computeBoundsVisitor.setTraversalMask(~(MWRender::Mask_ParticleSystem|MWRender::Mask_Effect)); const_cast(node.get())->accept(computeBoundsVisitor); osg::BoundingBox bounds = computeBoundsVisitor.getBoundingBox(); diff --git a/apps/openmw/mwrender/ripplesimulation.cpp b/apps/openmw/mwrender/ripplesimulation.cpp index 6597dde24..f7feb267a 100644 --- a/apps/openmw/mwrender/ripplesimulation.cpp +++ b/apps/openmw/mwrender/ripplesimulation.cpp @@ -16,7 +16,8 @@ #include #include #include -#include + +#include "vismask.hpp" #include "../mwbase/world.hpp" #include "../mwbase/environment.hpp" @@ -103,7 +104,7 @@ RippleSimulation::RippleSimulation(osg::Group *parent, Resource::ResourceSystem* mParticleNode->setName("Ripple Root"); mParticleNode->addChild(updater); mParticleNode->addChild(mParticleSystem); - mParticleNode->setNodeMask(SceneUtil::Mask_Water); + mParticleNode->setNodeMask(Mask_Water); createWaterRippleStateSet(resourceSystem, mParticleNode); diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index 592cd75bf..10fc630bd 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -43,12 +43,12 @@ #include #include #include -#include #include #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" +#include "vismask.hpp" #include "renderbin.hpp" namespace @@ -454,7 +454,7 @@ public: void setVisible(bool visible) { - mTransform->setNodeMask(visible ? mVisibleMask : SceneUtil::Mask_Disabled); + mTransform->setNodeMask(visible ? mVisibleMask : 0); } protected: @@ -470,7 +470,7 @@ class Sun : public CelestialBody { public: Sun(osg::Group* parentNode, Resource::ImageManager& imageManager) - : CelestialBody(parentNode, 1.0f, 1, SceneUtil::Mask_Sun) + : CelestialBody(parentNode, 1.0f, 1, Mask_Sun) , mUpdater(new Updater) { mTransform->addUpdateCallback(mUpdater); @@ -655,7 +655,7 @@ private: camera->setProjectionMatrix(osg::Matrix::identity()); camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF); // add to skyRoot instead? camera->setViewMatrix(osg::Matrix::identity()); - camera->setClearMask(SceneUtil::Mask_Disabled); + camera->setClearMask(0); camera->setRenderOrder(osg::Camera::NESTED_RENDER); camera->setAllowEventFocus(false); @@ -1145,7 +1145,7 @@ SkyManager::SkyManager(osg::Group* parentNode, Resource::SceneManager* sceneMana skyroot->getOrCreateStateSet()->setAttributeAndModes(new osg::Program(), osg::StateAttribute::OVERRIDE|osg::StateAttribute::PROTECTED|osg::StateAttribute::ON); SceneUtil::ShadowManager::disableShadowsForStateSet(skyroot->getOrCreateStateSet()); - skyroot->setNodeMask(SceneUtil::Mask_Sky); + skyroot->setNodeMask(Mask_Sky); parentNode->addChild(skyroot); mRootNode = skyroot; @@ -1177,7 +1177,7 @@ void SkyManager::create() mAtmosphereDay->addUpdateCallback(mAtmosphereUpdater); mAtmosphereNightNode = new osg::PositionAttitudeTransform; - mAtmosphereNightNode->setNodeMask(SceneUtil::Mask_Disabled); + mAtmosphereNightNode->setNodeMask(0); mEarlyRenderBinRoot->addChild(mAtmosphereNightNode); osg::ref_ptr atmosphereNight; @@ -1210,7 +1210,7 @@ void SkyManager::create() mCloudUpdater2 = new CloudUpdater; mCloudUpdater2->setOpacity(0.f); mCloudMesh2->addUpdateCallback(mCloudUpdater2); - mCloudMesh2->setNodeMask(SceneUtil::Mask_Disabled); + mCloudMesh2->setNodeMask(0); osg::ref_ptr depth = new osg::Depth; depth->setWriteMask(false); @@ -1533,7 +1533,7 @@ void SkyManager::createRain() mRainFader = new RainFader(&mWeatherAlpha); mRainNode->addUpdateCallback(mRainFader); mRainNode->addCullCallback(mUnderwaterSwitch); - mRainNode->setNodeMask(SceneUtil::Mask_WeatherParticles); + mRainNode->setNodeMask(Mask_WeatherParticles); mRootNode->addChild(mRainNode); } @@ -1636,7 +1636,7 @@ void SkyManager::setEnabled(bool enabled) if (enabled && !mCreated) create(); - mRootNode->setNodeMask(enabled ? SceneUtil::Mask_Sky : SceneUtil::Mask_Disabled); + mRootNode->setNodeMask(enabled ? Mask_Sky : 0); mEnabled = enabled; } @@ -1729,7 +1729,7 @@ void SkyManager::setWeather(const WeatherResult& weather) { mParticleNode = new osg::PositionAttitudeTransform; mParticleNode->addCullCallback(mUnderwaterSwitch); - mParticleNode->setNodeMask(SceneUtil::Mask_WeatherParticles); + mParticleNode->setNodeMask(Mask_WeatherParticles); mRootNode->addChild(mParticleNode); } @@ -1799,7 +1799,7 @@ void SkyManager::setWeather(const WeatherResult& weather) mCloudUpdater->setOpacity((1.f-mCloudBlendFactor)); mCloudUpdater2->setOpacity(mCloudBlendFactor); - mCloudMesh2->setNodeMask(mCloudBlendFactor > 0.f ? SceneUtil::Mask_Default : SceneUtil::Mask_Disabled); + mCloudMesh2->setNodeMask(mCloudBlendFactor > 0.f ? ~0 : 0); } if (mCloudColour != weather.mFogColor) @@ -1844,7 +1844,7 @@ void SkyManager::setWeather(const WeatherResult& weather) mAtmosphereNightUpdater->setFade(mStarsOpacity); } - mAtmosphereNightNode->setNodeMask(weather.mNight ? SceneUtil::Mask_Default : SceneUtil::Mask_Disabled); + mAtmosphereNightNode->setNodeMask(weather.mNight ? ~0 : 0); if (mRainFader) mRainFader->setAlpha(weather.mEffectFade * 0.6); // * Rain_Threshold? diff --git a/components/sceneutil/vismask.hpp b/apps/openmw/mwrender/vismask.hpp similarity index 82% rename from components/sceneutil/vismask.hpp rename to apps/openmw/mwrender/vismask.hpp index e9c35922c..f9f9dc74c 100644 --- a/components/sceneutil/vismask.hpp +++ b/apps/openmw/mwrender/vismask.hpp @@ -1,7 +1,7 @@ -#ifndef OPENMW_COMPONENTS_SCENEUTIL_VISMASK_H -#define OPENMW_COMPONENTS_SCENEUTIL_VISMASK_H +#ifndef OPENMW_MWRENDER_VISMASK_H +#define OPENMW_MWRENDER_VISMASK_H -namespace SceneUtil +namespace MWRender { /// Node masks used for controlling visibility of game objects. @@ -21,8 +21,6 @@ namespace SceneUtil /// compatibility if the enumeration values were to be changed. Feel free to change them when it makes sense. enum VisMask { - Mask_Disabled = 0, // For hidden nodes - Mask_UpdateVisitor = 0x1, // reserved for separating UpdateVisitors from CullVisitors // child of Scene @@ -55,19 +53,7 @@ namespace SceneUtil Mask_PreCompile = (1<<18), // Set on a camera's cull mask to enable the LightManager - Mask_Lighting = (1<<19), - - // For pathgrid nodes debugging - Mask_Pathgrid = (1<<20), - - // Editor control elements - Mask_EditorCellMarker = (1<<21), - Mask_EditorCellArrow = (1<<22), - Mask_EditorCellBorder = (1<<23), - Mask_EditorReference = (1<<24), - - // Default mask for OSG nodes - Mask_Default = 0xffffffff + Mask_Lighting = (1<<19) }; } diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index 2b307055d..6d230d36e 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -27,7 +27,6 @@ #include #include -#include #include @@ -41,6 +40,7 @@ #include "../mwworld/cellstore.hpp" +#include "vismask.hpp" #include "ripplesimulation.hpp" #include "renderbin.hpp" #include "util.hpp" @@ -243,8 +243,8 @@ public: setName("RefractionCamera"); setCullCallback(new InheritViewPointCallback); - setCullMask(SceneUtil::Mask_Effect|SceneUtil::Mask_Scene|SceneUtil::Mask_Object|SceneUtil::Mask_Static|SceneUtil::Mask_Terrain|SceneUtil::Mask_Actor|SceneUtil::Mask_ParticleSystem|SceneUtil::Mask_Sky|SceneUtil::Mask_Sun|SceneUtil::Mask_Player|SceneUtil::Mask_Lighting); - setNodeMask(SceneUtil::Mask_RenderToTexture); + setCullMask(Mask_Effect|Mask_Scene|Mask_Object|Mask_Static|Mask_Terrain|Mask_Actor|Mask_ParticleSystem|Mask_Sky|Mask_Sun|Mask_Player|Mask_Lighting); + setNodeMask(Mask_RenderToTexture); setViewport(0, 0, rttSize, rttSize); // No need for Update traversal since the scene is already updated as part of the main scene graph @@ -337,7 +337,7 @@ public: setCullCallback(new InheritViewPointCallback); setInterior(isInterior); - setNodeMask(SceneUtil::Mask_RenderToTexture); + setNodeMask(Mask_RenderToTexture); unsigned int rttSize = Settings::Manager::getInt("rtt size", "Water"); setViewport(0, 0, rttSize, rttSize); @@ -372,11 +372,11 @@ public: int reflectionDetail = Settings::Manager::getInt("reflection detail", "Water"); reflectionDetail = std::min(4, std::max(isInterior ? 2 : 0, reflectionDetail)); unsigned int extraMask = 0; - if(reflectionDetail >= 1) extraMask |= SceneUtil::Mask_Terrain; - if(reflectionDetail >= 2) extraMask |= SceneUtil::Mask_Static; - if(reflectionDetail >= 3) extraMask |= SceneUtil::Mask_Effect|SceneUtil::Mask_ParticleSystem|SceneUtil::Mask_Object; - if(reflectionDetail >= 4) extraMask |= SceneUtil::Mask_Player|SceneUtil::Mask_Actor; - setCullMask(SceneUtil::Mask_Scene|SceneUtil::Mask_Sky|SceneUtil::Mask_Lighting|extraMask); + if(reflectionDetail >= 1) extraMask |= Mask_Terrain; + if(reflectionDetail >= 2) extraMask |= Mask_Static; + if(reflectionDetail >= 3) extraMask |= Mask_Effect|Mask_ParticleSystem|Mask_Object; + if(reflectionDetail >= 4) extraMask |= Mask_Player|Mask_Actor; + setCullMask(Mask_Scene|Mask_Sky|Mask_Lighting|extraMask); } void setWaterLevel(float waterLevel) @@ -441,7 +441,7 @@ Water::Water(osg::Group *parent, osg::Group* sceneRoot, Resource::ResourceSystem mWaterGeom = SceneUtil::createWaterGeometry(Constants::CellSizeInUnits*150, 40, 900); mWaterGeom->setDrawCallback(new DepthClampCallback); - mWaterGeom->setNodeMask(SceneUtil::Mask_Water); + mWaterGeom->setNodeMask(Mask_Water); mWaterNode = new osg::PositionAttitudeTransform; mWaterNode->setName("Water Root"); @@ -451,7 +451,7 @@ Water::Water(osg::Group *parent, osg::Group* sceneRoot, Resource::ResourceSystem // simple water fallback for the local map osg::ref_ptr geom2 (osg::clone(mWaterGeom.get(), osg::CopyOp::DEEP_COPY_NODES)); createSimpleWaterStateSet(geom2, Fallback::Map::getFloat("Water_Map_Alpha")); - geom2->setNodeMask(SceneUtil::Mask_SimpleWater); + geom2->setNodeMask(Mask_SimpleWater); mWaterNode->addChild(geom2); mSceneRoot->addChild(mWaterNode); @@ -706,11 +706,11 @@ void Water::update(float dt) void Water::updateVisible() { bool visible = mEnabled && mToggled; - mWaterNode->setNodeMask(visible ? SceneUtil::Mask_Default : SceneUtil::Mask_Disabled); + mWaterNode->setNodeMask(visible ? ~0 : 0); if (mRefraction) - mRefraction->setNodeMask(visible ? SceneUtil::Mask_RenderToTexture : SceneUtil::Mask_Disabled); + mRefraction->setNodeMask(visible ? Mask_RenderToTexture : 0); if (mReflection) - mReflection->setNodeMask(visible ? SceneUtil::Mask_RenderToTexture : SceneUtil::Mask_Disabled); + mReflection->setNodeMask(visible ? Mask_RenderToTexture : 0); } bool Water::toggle() diff --git a/apps/openmw/mwworld/projectilemanager.cpp b/apps/openmw/mwworld/projectilemanager.cpp index c34c9c77f..38458fdb9 100644 --- a/apps/openmw/mwworld/projectilemanager.cpp +++ b/apps/openmw/mwworld/projectilemanager.cpp @@ -16,7 +16,6 @@ #include #include -#include #include #include "../mwworld/manualref.hpp" @@ -36,6 +35,7 @@ #include "../mwmechanics/weapontype.hpp" #include "../mwrender/animation.hpp" +#include "../mwrender/vismask.hpp" #include "../mwrender/renderingmanager.hpp" #include "../mwrender/util.hpp" @@ -188,7 +188,7 @@ namespace MWWorld bool rotate, bool createLight, osg::Vec4 lightDiffuseColor, std::string texture) { state.mNode = new osg::PositionAttitudeTransform; - state.mNode->setNodeMask(SceneUtil::Mask_Effect); + state.mNode->setNodeMask(MWRender::Mask_Effect); state.mNode->setPosition(pos); state.mNode->setAttitude(orient); @@ -228,7 +228,7 @@ namespace MWWorld projectileLight->setPosition(osg::Vec4(pos, 1.0)); SceneUtil::LightSource* projectileLightSource = new SceneUtil::LightSource; - projectileLightSource->setNodeMask(SceneUtil::Mask_Lighting); + projectileLightSource->setNodeMask(MWRender::Mask_Lighting); projectileLightSource->setRadius(66.f); state.mNode->addChild(projectileLightSource); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 8598b9b04..49b55f2a9 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -23,7 +23,6 @@ #include #include -#include #include #include @@ -47,6 +46,7 @@ #include "../mwrender/npcanimation.hpp" #include "../mwrender/renderingmanager.hpp" #include "../mwrender/camera.hpp" +#include "../mwrender/vismask.hpp" #include "../mwscript/globalscripts.hpp" @@ -2273,7 +2273,7 @@ namespace MWWorld { // Adjust position so the location we wanted ends up in the middle of the object bounding box osg::ComputeBoundsVisitor computeBounds; - computeBounds.setTraversalMask(~SceneUtil::Mask_ParticleSystem); + computeBounds.setTraversalMask(~MWRender::Mask_ParticleSystem); dropped.getRefData().getBaseNode()->accept(computeBounds); osg::BoundingBox bounds = computeBounds.getBoundingBox(); if (bounds.valid()) diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 26cf38204..06c777c02 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -51,7 +51,7 @@ add_component_dir (shader add_component_dir (sceneutil clone attach visitor util statesetupdater controller skeleton riggeometry morphgeometry lightcontroller lightmanager lightutil positionattitudetransform workqueue unrefqueue pathgridutil waterutil writescene serialize optimizer - actorutil detourdebugdraw navmesh agentpath shadow mwshadowtechnique vismask recastmesh + actorutil detourdebugdraw navmesh agentpath shadow mwshadowtechnique recastmesh ) add_component_dir (nif diff --git a/components/nifosg/controller.cpp b/components/nifosg/controller.cpp index 934e9b565..1842e0017 100644 --- a/components/nifosg/controller.cpp +++ b/components/nifosg/controller.cpp @@ -10,7 +10,6 @@ #include #include -#include #include "userdata.hpp" @@ -305,7 +304,7 @@ void VisController::operator() (osg::Node* node, osg::NodeVisitor* nv) { bool vis = calculate(getInputValue(nv)); // Leave 0x1 enabled for UpdateVisitor, so we can make ourselves visible again in the future from this update callback - node->setNodeMask(vis ? SceneUtil::Mask_Default : SceneUtil::Mask_UpdateVisitor); + node->setNodeMask(vis ? ~0 : 0x1); } traverse(node, nv); } diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index 74cdcefe3..dc624315c 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -16,7 +16,6 @@ #include #include #include -#include // particle #include @@ -178,7 +177,7 @@ namespace NifOsg void setEnabled(bool enabled) { - setNodeMask(enabled ? SceneUtil::Mask_Default : SceneUtil::Mask_Effect); + setNodeMask(enabled ? ~0 : 0); } }; @@ -573,7 +572,7 @@ namespace NifOsg { skipMeshes = true; // Leave mask for UpdateVisitor enabled - node->setNodeMask(SceneUtil::Mask_UpdateVisitor); + node->setNodeMask(0x1); } // We can skip creating meshes for hidden nodes if they don't have a VisController that @@ -588,7 +587,7 @@ namespace NifOsg skipMeshes = true; // skip child meshes, but still create the child node hierarchy for animating collision shapes // now hide this node, but leave the mask for UpdateVisitor enabled so that KeyframeController works - node->setNodeMask(SceneUtil::Mask_UpdateVisitor); + node->setNodeMask(0x1); } if ((skipMeshes || hasMarkers) && isAnimated) // make sure the empty node is not optimized away so the physicssystem can find it. diff --git a/components/resource/stats.cpp b/components/resource/stats.cpp index 1535bdbf6..51497cd27 100644 --- a/components/resource/stats.cpp +++ b/components/resource/stats.cpp @@ -12,7 +12,6 @@ #include #include -#include namespace Resource { @@ -104,14 +103,14 @@ void StatsHandler::toggle(osgViewer::ViewerBase *viewer) if (!_statsType) { - _camera->setNodeMask(SceneUtil::Mask_Disabled); + _camera->setNodeMask(0); _switch->setAllChildrenOff(); viewer->getViewerStats()->collectStats("resource", false); } else { - _camera->setNodeMask(SceneUtil::Mask_Default); + _camera->setNodeMask(0xffffffff); _switch->setSingleChildOn(_resourceStatsChildNum); viewer->getViewerStats()->collectStats("resource", true); diff --git a/components/sceneutil/lightutil.cpp b/components/sceneutil/lightutil.cpp index c90fa8923..e9be05908 100644 --- a/components/sceneutil/lightutil.cpp +++ b/components/sceneutil/lightutil.cpp @@ -11,7 +11,6 @@ #include "lightcontroller.hpp" #include "util.hpp" #include "visitor.hpp" -#include "vismask.hpp" #include "positionattitudetransform.hpp" namespace SceneUtil @@ -59,7 +58,7 @@ namespace SceneUtil light->setQuadraticAttenuation(quadraticAttenuation); } - void addLight (osg::Group* node, const ESM::Light* esmLight, bool isExterior) + void addLight (osg::Group* node, const ESM::Light* esmLight, unsigned int partsysMask, unsigned int lightMask, bool isExterior) { SceneUtil::FindByNameVisitor visitor("AttachLight"); node->accept(visitor); @@ -72,7 +71,7 @@ namespace SceneUtil else { osg::ComputeBoundsVisitor computeBound; - computeBound.setTraversalMask(~SceneUtil::Mask_ParticleSystem); + computeBound.setTraversalMask(~partsysMask); // We want the bounds of all children of the node, ignoring the node's local transformation // So do a traverse(), not accept() computeBound.traverse(*node); @@ -86,15 +85,15 @@ namespace SceneUtil attachTo = trans; } - osg::ref_ptr lightSource = createLightSource(esmLight, isExterior); + osg::ref_ptr lightSource = createLightSource(esmLight, lightMask, isExterior); attachTo->addChild(lightSource); } - osg::ref_ptr createLightSource(const ESM::Light* esmLight, bool isExterior, const osg::Vec4f& ambient) + osg::ref_ptr createLightSource(const ESM::Light* esmLight, unsigned int lightMask, bool isExterior, const osg::Vec4f& ambient) { osg::ref_ptr lightSource (new SceneUtil::LightSource); osg::ref_ptr light (new osg::Light); - lightSource->setNodeMask(SceneUtil::Mask_Lighting); + lightSource->setNodeMask(lightMask); float radius = esmLight->mData.mRadius; lightSource->setRadius(radius); diff --git a/components/sceneutil/lightutil.hpp b/components/sceneutil/lightutil.hpp index f72cf9f19..7096c38b2 100644 --- a/components/sceneutil/lightutil.hpp +++ b/components/sceneutil/lightutil.hpp @@ -32,14 +32,14 @@ namespace SceneUtil /// @param partsysMask Node mask to ignore when computing the sub graph's bounding box. /// @param lightMask Mask to assign to the newly created LightSource. /// @param isExterior Is the light outside? May be used for deciding which attenuation settings to use. - void addLight (osg::Group* node, const ESM::Light* esmLight, bool isExterior); + void addLight (osg::Group* node, const ESM::Light* esmLight, unsigned int partsysMask, unsigned int lightMask, bool isExterior); /// @brief Convert an ESM::Light to a SceneUtil::LightSource, and return it. /// @param esmLight The light definition coming from the game files containing radius, color, flicker, etc. /// @param lightMask Mask to assign to the newly created LightSource. /// @param isExterior Is the light outside? May be used for deciding which attenuation settings to use. /// @param ambient Ambient component of the light. - osg::ref_ptr createLightSource (const ESM::Light* esmLight, bool isExterior, const osg::Vec4f& ambient=osg::Vec4f(0,0,0,1)); + osg::ref_ptr createLightSource (const ESM::Light* esmLight, unsigned int lightMask, bool isExterior, const osg::Vec4f& ambient=osg::Vec4f(0,0,0,1)); } diff --git a/components/sceneutil/optimizer.hpp b/components/sceneutil/optimizer.hpp index 9b3dc47f9..9974e7097 100644 --- a/components/sceneutil/optimizer.hpp +++ b/components/sceneutil/optimizer.hpp @@ -22,8 +22,6 @@ #include #include -#include - //#include #include @@ -44,7 +42,7 @@ class BaseOptimizerVisitor : public osg::NodeVisitor _optimizer(optimizer), _operationType(operation) { - setNodeMaskOverride(SceneUtil::Mask_Default); + setNodeMaskOverride(0xffffffff); } inline bool isOperationPermissibleForObject(const osg::StateSet* object) const; diff --git a/components/sceneutil/shadow.cpp b/components/sceneutil/shadow.cpp index 035c19a5f..6b88adaab 100644 --- a/components/sceneutil/shadow.cpp +++ b/components/sceneutil/shadow.cpp @@ -2,7 +2,6 @@ #include -#include #include namespace SceneUtil @@ -22,7 +21,7 @@ namespace SceneUtil mShadowTechnique->enableShadows(); mShadowSettings->setLightNum(0); - mShadowSettings->setReceivesShadowTraversalMask(SceneUtil::Mask_Default); + mShadowSettings->setReceivesShadowTraversalMask(~0u); int numberOfShadowMapsPerLight = Settings::Manager::getInt("number of shadow maps", "Shadows"); numberOfShadowMapsPerLight = std::max(1, std::min(numberOfShadowMapsPerLight, 8)); diff --git a/components/terrain/cellborder.cpp b/components/terrain/cellborder.cpp index d6ecd5b5a..6eabadf92 100644 --- a/components/terrain/cellborder.cpp +++ b/components/terrain/cellborder.cpp @@ -4,17 +4,16 @@ #include #include -#include - #include "world.hpp" #include "../esm/loadland.hpp" namespace Terrain { -CellBorder::CellBorder(Terrain::World *world, osg::Group *root): +CellBorder::CellBorder(Terrain::World *world, osg::Group *root, int borderMask): mWorld(world), - mRoot(root) + mRoot(root), + mBorderMask(borderMask) { } @@ -70,7 +69,7 @@ void CellBorder::createCellBorderGeometry(int x, int y) polygonmode->setMode(osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::LINE); stateSet->setAttributeAndModes(polygonmode,osg::StateAttribute::ON); - borderGeode->setNodeMask(SceneUtil::Mask_Debug); + borderGeode->setNodeMask(mBorderMask); mRoot->addChild(borderGeode); diff --git a/components/terrain/cellborder.hpp b/components/terrain/cellborder.hpp index 49759671f..908cdea09 100644 --- a/components/terrain/cellborder.hpp +++ b/components/terrain/cellborder.hpp @@ -16,7 +16,7 @@ namespace Terrain public: typedef std::map, osg::ref_ptr > CellGrid; - CellBorder(Terrain::World *world, osg::Group *root); + CellBorder(Terrain::World *world, osg::Group *root, int borderMask); void createCellBorderGeometry(int x, int y); void destroyCellBorderGeometry(int x, int y); @@ -31,6 +31,7 @@ namespace Terrain osg::Group *mRoot; CellGrid mCellBorderNodes; + int mBorderMask; }; } diff --git a/components/terrain/quadtreeworld.cpp b/components/terrain/quadtreeworld.cpp index 05f33078f..396ac1138 100644 --- a/components/terrain/quadtreeworld.cpp +++ b/components/terrain/quadtreeworld.cpp @@ -6,7 +6,6 @@ #include #include -#include #include "quadtreenode.hpp" #include "storage.hpp" @@ -217,8 +216,8 @@ private: osg::ref_ptr mRootNode; }; -QuadTreeWorld::QuadTreeWorld(osg::Group *parent, osg::Group *compileRoot, Resource::ResourceSystem *resourceSystem, Storage *storage, int compMapResolution, float compMapLevel, float lodFactor, int vertexLodMod, float maxCompGeometrySize) - : TerrainGrid(parent, compileRoot, resourceSystem, storage) +QuadTreeWorld::QuadTreeWorld(osg::Group *parent, osg::Group *compileRoot, Resource::ResourceSystem *resourceSystem, Storage *storage, int nodeMask, int preCompileMask, int borderMask, int compMapResolution, float compMapLevel, float lodFactor, int vertexLodMod, float maxCompGeometrySize) + : TerrainGrid(parent, compileRoot, resourceSystem, storage, nodeMask, preCompileMask, borderMask) , mViewDataMap(new ViewDataMap) , mQuadTreeBuilt(false) , mLodFactor(lodFactor) @@ -425,7 +424,7 @@ void QuadTreeWorld::enable(bool enabled) } if (mRootNode) - mRootNode->setNodeMask(enabled ? SceneUtil::Mask_Default : SceneUtil::Mask_Disabled); + mRootNode->setNodeMask(enabled ? ~0 : 0); } void QuadTreeWorld::cacheCell(View *view, int x, int y) diff --git a/components/terrain/quadtreeworld.hpp b/components/terrain/quadtreeworld.hpp index 2bfd9f896..bcb671ee1 100644 --- a/components/terrain/quadtreeworld.hpp +++ b/components/terrain/quadtreeworld.hpp @@ -21,7 +21,7 @@ namespace Terrain class QuadTreeWorld : public TerrainGrid // note: derived from TerrainGrid is only to render default cells (see loadCell) { public: - QuadTreeWorld(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, Storage* storage, int compMapResolution, float comMapLevel, float lodFactor, int vertexLodMod, float maxCompGeometrySize); + QuadTreeWorld(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, Storage* storage, int nodeMask, int preCompileMask, int borderMask, int compMapResolution, float comMapLevel, float lodFactor, int vertexLodMod, float maxCompGeometrySize); ~QuadTreeWorld(); diff --git a/components/terrain/terraingrid.cpp b/components/terrain/terraingrid.cpp index f7a7644fd..7310846c2 100644 --- a/components/terrain/terraingrid.cpp +++ b/components/terrain/terraingrid.cpp @@ -18,8 +18,8 @@ public: virtual void reset() {} }; -TerrainGrid::TerrainGrid(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, Storage* storage) - : Terrain::World(parent, compileRoot, resourceSystem, storage) +TerrainGrid::TerrainGrid(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, Storage* storage, int nodeMask, int preCompileMask, int borderMask) + : Terrain::World(parent, compileRoot, resourceSystem, storage, nodeMask, preCompileMask, borderMask) , mNumSplits(4) { } diff --git a/components/terrain/terraingrid.hpp b/components/terrain/terraingrid.hpp index 3764eb986..eb30fb97d 100644 --- a/components/terrain/terraingrid.hpp +++ b/components/terrain/terraingrid.hpp @@ -14,7 +14,7 @@ namespace Terrain class TerrainGrid : public Terrain::World { public: - TerrainGrid(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, Storage* storage); + TerrainGrid(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, Storage* storage, int nodeMask, int preCompileMask=~0, int borderMask=0); ~TerrainGrid(); virtual void cacheCell(View* view, int x, int y); diff --git a/components/terrain/world.cpp b/components/terrain/world.cpp index 010ae9568..da3bdb5c2 100644 --- a/components/terrain/world.cpp +++ b/components/terrain/world.cpp @@ -5,7 +5,6 @@ #include #include -#include #include "storage.hpp" #include "texturemanager.hpp" @@ -15,14 +14,14 @@ namespace Terrain { -World::World(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, Storage* storage) +World::World(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, Storage* storage, int nodeMask, int preCompileMask, int borderMask) : mStorage(storage) , mParent(parent) , mResourceSystem(resourceSystem) , mBorderVisible(false) { mTerrainRoot = new osg::Group; - mTerrainRoot->setNodeMask(SceneUtil::Mask_Terrain); + mTerrainRoot->setNodeMask(nodeMask); mTerrainRoot->getOrCreateStateSet()->setRenderingHint(osg::StateSet::OPAQUE_BIN); osg::ref_ptr material (new osg::Material); material->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE); @@ -35,8 +34,8 @@ World::World(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSyst compositeCam->setProjectionMatrix(osg::Matrix::identity()); compositeCam->setViewMatrix(osg::Matrix::identity()); compositeCam->setReferenceFrame(osg::Camera::ABSOLUTE_RF); - compositeCam->setClearMask(SceneUtil::Mask_Disabled); - compositeCam->setNodeMask(SceneUtil::Mask_PreCompile); + compositeCam->setClearMask(0); + compositeCam->setNodeMask(preCompileMask); mCompositeMapCamera = compositeCam; compileRoot->addChild(compositeCam); @@ -48,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 CellBorder(this,mTerrainRoot.get())); + mCellBorder.reset(new CellBorder(this,mTerrainRoot.get(),borderMask)); mResourceSystem->addResourceManager(mChunkManager.get()); mResourceSystem->addResourceManager(mTextureManager.get()); diff --git a/components/terrain/world.hpp b/components/terrain/world.hpp index 8929e0f6b..0402b8197 100644 --- a/components/terrain/world.hpp +++ b/components/terrain/world.hpp @@ -63,7 +63,7 @@ namespace Terrain /// @param storage Storage instance to get terrain data from (heights, normals, colors, textures..) /// @param nodeMask mask for the terrain root /// @param preCompileMask mask for pre compiling textures - World(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, Storage* storage); + World(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, Storage* storage, int nodeMask, int preCompileMask, int borderMask); virtual ~World(); /// Set a WorkQueue to delete objects in the background thread. From dab09180ae2b3971d667f5ae92233592a8c9e19d Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Mon, 20 Apr 2020 22:09:09 +0300 Subject: [PATCH 21/44] Make sure non-carriable light sources can't be picked up --- apps/openmw/mwgui/inventorywindow.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index 6041838f5..d11ee4f0c 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -732,7 +732,8 @@ namespace MWGui && (type != typeid(ESM::Potion).name())) return; - if (object.getClass().getName(object) == "") // objects without name presented to user can never be picked up + // An object that can be picked up must have a tooltip. + if (!object.getClass().hasToolTip(object)) return; int count = object.getRefData().getCount(); From 886fd5efc94e92290cd1967082882fbb71e12d99 Mon Sep 17 00:00:00 2001 From: Julien Valentin Date: Thu, 16 Apr 2020 02:55:47 +0200 Subject: [PATCH 22/44] enable particle shading and force particle normal to (0.3,0.3,0.3) and update changelog --- CHANGELOG.md | 2 ++ components/nifosg/nifloader.cpp | 2 ++ components/nifosg/particle.cpp | 27 +++++++++++++++++++++++++++ components/nifosg/particle.hpp | 3 +++ 4 files changed, 34 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6eff7dee0..d975eb4cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ 0.47.0 ------ + Bug #3676: NiParticleColorModifier isn't applied properly + Bug #4949: Incorrect particle lighting when force shaders = true Bug #5358: ForceGreeting always resets the dialogue window completely Bug #5363: Enchantment autocalc not always 0/1 Bug #5364: Script fails/stops if trying to startscript an unknown script diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index 07cbaee37..801427b92 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -1078,6 +1078,8 @@ namespace NifOsg trans->addChild(toAttach); parentNode->addChild(trans); } + // create partsys stateset in order to pass in ShaderVisitor like all other Drawables + partsys->getOrCreateStateSet(); } void triCommonToGeometry(osg::Geometry *geometry, const std::vector& vertices, const std::vector& normals, const std::vector>& uvlist, const std::vector& colors, const std::vector& boundTextures, const std::string& name) diff --git a/components/nifosg/particle.cpp b/components/nifosg/particle.cpp index 2a79af1c8..1b1e469bc 100644 --- a/components/nifosg/particle.cpp +++ b/components/nifosg/particle.cpp @@ -2,6 +2,7 @@ #include +#include #include #include @@ -19,12 +20,19 @@ ParticleSystem::ParticleSystem() : osgParticle::ParticleSystem() , mQuota(std::numeric_limits::max()) { + mNormalArray = new osg::Vec3Array(1); + mNormalArray->setBinding(osg::Array::BIND_OVERALL); + (*mNormalArray.get())[0] = osg::Vec3(0.3, 0.3, 0.3); } ParticleSystem::ParticleSystem(const ParticleSystem ©, const osg::CopyOp ©op) : osgParticle::ParticleSystem(copy, copyop) , mQuota(copy.mQuota) { + mNormalArray = new osg::Vec3Array(1); + mNormalArray->setBinding(osg::Array::BIND_OVERALL); + (*mNormalArray.get())[0] = osg::Vec3(0.3, 0.3, 0.3); + // For some reason the osgParticle constructor doesn't copy the particles for (int i=0;iassignNormalArrayDispatcher(); + state.getCurrentVertexArrayState()->setNormalArray(state, mNormalArray); + } + else + { + state.getAttributeDispatchers().activateNormalArray(mNormalArray); + } +#else + state.Normal(0.3, 0.3, 0.3); +#endif + osgParticle::ParticleSystem::drawImplementation(renderInfo); +} + void InverseWorldMatrix::operator()(osg::Node *node, osg::NodeVisitor *nv) { if (nv && nv->getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR) diff --git a/components/nifosg/particle.hpp b/components/nifosg/particle.hpp index e159914c7..d71cbb9f5 100644 --- a/components/nifosg/particle.hpp +++ b/components/nifosg/particle.hpp @@ -36,8 +36,11 @@ namespace NifOsg void setQuota(int quota); + virtual void drawImplementation(osg::RenderInfo& renderInfo) const; + private: int mQuota; + osg::ref_ptr mNormalArray; }; // HACK: Particle doesn't allow setting the initial age, but we need this for loading the particle system state From af335d71271891c1964c3ae6b6a3e263b9b274c5 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Mon, 20 Apr 2020 23:51:00 +0300 Subject: [PATCH 23/44] Fix changelog particle lighting entry --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d975eb4cb..1043ca0cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ 0.47.0 ------ + Bug #1952: Incorrect particle lighting Bug #3676: NiParticleColorModifier isn't applied properly - Bug #4949: Incorrect particle lighting when force shaders = true Bug #5358: ForceGreeting always resets the dialogue window completely Bug #5363: Enchantment autocalc not always 0/1 Bug #5364: Script fails/stops if trying to startscript an unknown script From 673184369158bb901c1572ac538bf51ff9a82216 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Tue, 21 Apr 2020 09:32:34 +0300 Subject: [PATCH 24/44] Consider the first person movement sneaking if it's actually sneaking --- apps/openmw/mwmechanics/character.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 0c13c2740..b5addea70 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -615,7 +615,9 @@ void CharacterController::refreshMovementAnims(const std::string& weapShortGroup // The first person anims don't have any velocity to calculate a speed multiplier from. // We use the third person velocities instead. // FIXME: should be pulled from the actual animation, but it is not presently loaded. - mMovementAnimSpeed = (isSneaking() ? 33.5452f : (isRunning() ? 222.857f : 154.064f)); + bool sneaking = mMovementState == CharState_SneakForward || mMovementState == CharState_SneakBack + || mMovementState == CharState_SneakLeft || mMovementState == CharState_SneakRight; + mMovementAnimSpeed = (sneaking ? 33.5452f : (isRunning() ? 222.857f : 154.064f)); mMovementAnimationControlled = false; } } From ade265ec6b8cef1d40a5a1d064f21d7d50356c6c Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Tue, 21 Apr 2020 23:44:55 +0200 Subject: [PATCH 25/44] give shared windows runners a try --- .gitlab-ci.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 79eb6795f..dfeb37a75 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -42,10 +42,7 @@ MacOS: Windows: tags: - - win10 - - msvc2017 - except: - - branches # because our CI VMs are not public, MRs can't use them and timeout + - windows stage: build allow_failure: true script: From 0021dabd8e4d62462c91052e001ad95135d89f6a Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Wed, 22 Apr 2020 00:22:48 +0200 Subject: [PATCH 26/44] powershell hell --- .gitlab-ci.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dfeb37a75..b466d011b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,8 +3,9 @@ stages: Debian: tags: - - docker - - linux +# - docker +# - linux + - none_remove_me image: gcc cache: key: apt-cache @@ -46,7 +47,14 @@ Windows: stage: build allow_failure: true script: - # - env # turn on for debugging + - Set-Variable -Name "time" -Value (date -Format "%H:%m") + - echo ${time} + - echo "started by ${GITLAB_USER_NAME}" + - (New-Object System.Net.WebClient).DownloadFile(http://repo.msys2.org/distrib/x86_64/msys2-x86_64-20190524.exe, $PSScriptRoot\msys2.exe) + - $result = Start-Process -Wait -FilePath '$PSScriptRoot\msys2.exe' -ArgumentList '/S' -PassThru + - echo ${result} + - bash + - env # turn on for debugging - sh %CI_PROJECT_DIR%/CI/before_script.msvc.sh -c Release -p x64 -v 2017 -V - SET msBuildLocation="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe" - call %msBuildLocation% MSVC2017_64\OpenMW.sln /t:Build /p:Configuration=Release /m:%NUMBER_OF_PROCESSORS% From b38459e50558af6af0fc0335344e1d251bb8d7ad Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Wed, 22 Apr 2020 00:30:08 +0200 Subject: [PATCH 27/44] powershell hell 2 --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b466d011b..8a5740de8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -50,7 +50,7 @@ Windows: - Set-Variable -Name "time" -Value (date -Format "%H:%m") - echo ${time} - echo "started by ${GITLAB_USER_NAME}" - - (New-Object System.Net.WebClient).DownloadFile(http://repo.msys2.org/distrib/x86_64/msys2-x86_64-20190524.exe, $PSScriptRoot\msys2.exe) + - (New-Object System.Net.WebClient).DownloadFile('http://repo.msys2.org/distrib/x86_64/msys2-x86_64-20190524.exe', '$PSScriptRoot\msys2.exe') - $result = Start-Process -Wait -FilePath '$PSScriptRoot\msys2.exe' -ArgumentList '/S' -PassThru - echo ${result} - bash From 9106e3646cb49bdb3d285e563b687856171fecf1 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Wed, 22 Apr 2020 01:39:51 +0300 Subject: [PATCH 28/44] Fix outdated bug tracker links --- CONTRIBUTING.md | 2 +- apps/wizard/conclusionpage.cpp | 2 +- components/crashcatcher/crashcatcher.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 73ec986b5..264db49cc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -21,7 +21,7 @@ Pull Request Guidelines To facilitate the review process, your pull request description should include the following, if applicable: -* A link back to the bug report or forum discussion that prompted the change. Note: when linking bugs, use the syntax ```[Bug #xyz](https://bugs.openmw.org/issues/#xyz)``` to create a clickable link. Writing only 'Bug #xyz' will unfortunately create a link to the Github pull request with that number instead. +* A link back to the bug report or forum discussion that prompted the change. Note: when linking bugs, use the syntax ```[Bug #xyz](https://gitlab.com/OpenMW/openmw/issues/#xyz)``` to create a clickable link. Writing only 'Bug #xyz' will unfortunately create a link to the Github pull request with that number instead. * Summary of the changes made * Reasoning / motivation behind the change * What testing you have carried out to verify the change diff --git a/apps/wizard/conclusionpage.cpp b/apps/wizard/conclusionpage.cpp index f6a6015b8..b1341374d 100644 --- a/apps/wizard/conclusionpage.cpp +++ b/apps/wizard/conclusionpage.cpp @@ -44,7 +44,7 @@ void Wizard::ConclusionPage::initializePage() } else { textLabel->setText(tr("

The OpenMW Wizard failed to install Morrowind on your computer.

\

Please report any bugs you might have encountered to our \ - bug tracker.
Make sure to include the installation log.


")); + bug tracker.
Make sure to include the installation log.


")); } } diff --git a/components/crashcatcher/crashcatcher.cpp b/components/crashcatcher/crashcatcher.cpp index 80d2102b8..006ab2d88 100644 --- a/components/crashcatcher/crashcatcher.cpp +++ b/components/crashcatcher/crashcatcher.cpp @@ -412,7 +412,7 @@ static void crash_handler(const char *logfile) if(logfile) { - std::string message = "OpenMW has encountered a fatal error.\nCrash log saved to '" + std::string(logfile) + "'.\n Please report this to https://bugs.openmw.org !"; + std::string message = "OpenMW has encountered a fatal error.\nCrash log saved to '" + std::string(logfile) + "'.\n Please report this to https://gitlab.com/OpenMW/openmw/issues !"; SDL_ShowSimpleMessageBox(0, "Fatal Error", message.c_str(), nullptr); } From 6f1767c37408adc0ac4ceaeb3f7be8e489a8ffb5 Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Wed, 22 Apr 2020 10:36:11 +0200 Subject: [PATCH 29/44] just get the thing working and leave it up to someone with more win10 knowledge than myself :) --- .gitlab-ci.yml | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8a5740de8..514bac1ad 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,9 +3,8 @@ stages: Debian: tags: -# - docker -# - linux - - none_remove_me + - docker + - linux image: gcc cache: key: apt-cache @@ -24,6 +23,7 @@ Debian: artifacts: paths: - build/artifacts/ + MacOS: tags: - macos @@ -50,15 +50,14 @@ Windows: - Set-Variable -Name "time" -Value (date -Format "%H:%m") - echo ${time} - echo "started by ${GITLAB_USER_NAME}" - - (New-Object System.Net.WebClient).DownloadFile('http://repo.msys2.org/distrib/x86_64/msys2-x86_64-20190524.exe', '$PSScriptRoot\msys2.exe') - - $result = Start-Process -Wait -FilePath '$PSScriptRoot\msys2.exe' -ArgumentList '/S' -PassThru - - echo ${result} - - bash - - env # turn on for debugging - - sh %CI_PROJECT_DIR%/CI/before_script.msvc.sh -c Release -p x64 -v 2017 -V - - SET msBuildLocation="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe" - - call %msBuildLocation% MSVC2017_64\OpenMW.sln /t:Build /p:Configuration=Release /m:%NUMBER_OF_PROCESSORS% - - 7z a OpenMW_MSVC2017_64_%CI_BUILD_REF_NAME%_%CI_BUILD_ID%.zip %CI_PROJECT_DIR%\MSVC2017_64\Release\ +# TODO: to anyone wanting to do further work here, we need to figure out how to get the below working +# TODO: on gitlab's new shared windows runners. They currently don't have bash or anything else installed +# TODO: it is currently just a bare windows 10 with powershell. +# - env # turn on for debugging +# - sh %CI_PROJECT_DIR%/CI/before_script.msvc.sh -c Release -p x64 -v 2017 -V +# - SET msBuildLocation="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe" +# - call %msBuildLocation% MSVC2017_64\OpenMW.sln /t:Build /p:Configuration=Release /m:%NUMBER_OF_PROCESSORS% +# - 7z a OpenMW_MSVC2017_64_%CI_BUILD_REF_NAME%_%CI_BUILD_ID%.zip %CI_PROJECT_DIR%\MSVC2017_64\Release\ cache: paths: - deps From 68549828b49e7473a294df068dce94e3957977c8 Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Wed, 22 Apr 2020 13:34:19 +0200 Subject: [PATCH 30/44] create static functions to set/get hidden node mask; compromise on magic numbers to make things easier to understand --- apps/opencs/view/render/mask.hpp | 3 --- apps/opencs/view/render/scenewidget.cpp | 2 -- apps/openmw/mwrender/renderingmanager.cpp | 3 +++ components/nifosg/controller.cpp | 8 +++++--- components/nifosg/controller.hpp | 3 ++- components/nifosg/nifloader.cpp | 19 ++++++++++++++----- components/nifosg/nifloader.hpp | 7 ++++++- 7 files changed, 30 insertions(+), 15 deletions(-) diff --git a/apps/opencs/view/render/mask.hpp b/apps/opencs/view/render/mask.hpp index 55b7c823f..deeab4996 100644 --- a/apps/opencs/view/render/mask.hpp +++ b/apps/opencs/view/render/mask.hpp @@ -10,9 +10,6 @@ namespace CSVRender /// @copydoc MWRender::VisMask enum Mask { - // internal use within NifLoader, do not change - Mask_UpdateVisitor = 0x1, - // elements that are part of the actual scene Mask_Reference = 0x2, Mask_Pathgrid = 0x4, diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index ed232722d..e50d7b2cd 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -88,8 +88,6 @@ RenderWidget::RenderWidget(QWidget *parent, Qt::WindowFlags f) // Add ability to signal osg to show its statistics for debugging purposes mView->addEventHandler(new osgViewer::StatsHandler); - mView->getCamera()->setCullMask(~(Mask_UpdateVisitor)); - viewer.addView(mView); viewer.setDone(false); viewer.realize(); diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 648660669..9a68b15fa 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -20,6 +20,8 @@ #include +#include + #include #include @@ -373,6 +375,7 @@ namespace MWRender mViewer->getCamera()->setCullingMode(cullingMode); mViewer->getCamera()->setCullMask(~(Mask_UpdateVisitor|Mask_SimpleWater)); + NifOsg::Loader::setHiddenNodeMask(Mask_UpdateVisitor); mNearClip = Settings::Manager::getFloat("near clip", "Camera"); mViewDistance = Settings::Manager::getFloat("viewing distance", "Camera"); diff --git a/components/nifosg/controller.cpp b/components/nifosg/controller.cpp index 1842e0017..100aa234a 100644 --- a/components/nifosg/controller.cpp +++ b/components/nifosg/controller.cpp @@ -269,12 +269,14 @@ void UVController::apply(osg::StateSet* stateset, osg::NodeVisitor* nv) } } -VisController::VisController(const Nif::NiVisData *data) +VisController::VisController(const Nif::NiVisData *data, unsigned int mask) : mData(data->mVis) + , mMask(mask) { } VisController::VisController() + : mMask(0) { } @@ -282,6 +284,7 @@ VisController::VisController(const VisController ©, const osg::CopyOp ©o : osg::NodeCallback(copy, copyop) , Controller(copy) , mData(copy.mData) + , mMask(copy.mMask) { } @@ -303,8 +306,7 @@ void VisController::operator() (osg::Node* node, osg::NodeVisitor* nv) if (hasInput()) { bool vis = calculate(getInputValue(nv)); - // Leave 0x1 enabled for UpdateVisitor, so we can make ourselves visible again in the future from this update callback - node->setNodeMask(vis ? ~0 : 0x1); + node->setNodeMask(vis ? ~0 : mMask); } traverse(node, nv); } diff --git a/components/nifosg/controller.hpp b/components/nifosg/controller.hpp index c9bda2e62..ad6ee4d87 100644 --- a/components/nifosg/controller.hpp +++ b/components/nifosg/controller.hpp @@ -234,11 +234,12 @@ namespace NifOsg { private: std::vector mData; + unsigned int mMask; bool calculate(float time) const; public: - VisController(const Nif::NiVisData *data); + VisController(const Nif::NiVisData *data, unsigned int mask); VisController(); VisController(const VisController& copy, const osg::CopyOp& copyop); diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index af8431da7..7d62d1ef1 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -193,6 +193,17 @@ namespace NifOsg return sShowMarkers; } + unsigned int Loader::sHiddenNodeMask = 0; + + void Loader::setHiddenNodeMask(unsigned int mask) + { + sHiddenNodeMask = mask; + } + unsigned int Loader::getHiddenNodeMask() + { + return sHiddenNodeMask; + } + class LoaderImpl { public: @@ -571,8 +582,7 @@ namespace NifOsg if (nifNode->recType == Nif::RC_RootCollisionNode) { skipMeshes = true; - // Leave mask for UpdateVisitor enabled - node->setNodeMask(0x1); + node->setNodeMask(Loader::getHiddenNodeMask()); } // We can skip creating meshes for hidden nodes if they don't have a VisController that @@ -586,8 +596,7 @@ namespace NifOsg if (!hasVisController) skipMeshes = true; // skip child meshes, but still create the child node hierarchy for animating collision shapes - // now hide this node, but leave the mask for UpdateVisitor enabled so that KeyframeController works - node->setNodeMask(0x1); + node->setNodeMask(Loader::getHiddenNodeMask()); } if ((skipMeshes || hasMarkers) && isAnimated) // make sure the empty node is not optimized away so the physicssystem can find it. @@ -753,7 +762,7 @@ namespace NifOsg { if (visctrl->data.empty()) return; - osg::ref_ptr callback(new VisController(visctrl->data.getPtr())); + osg::ref_ptr callback(new VisController(visctrl->data.getPtr(), Loader::getHiddenNodeMask())); setupController(visctrl, callback, animflags); node->addUpdateCallback(callback); } diff --git a/components/nifosg/nifloader.hpp b/components/nifosg/nifloader.hpp index d2d5e7b2d..6168bb474 100644 --- a/components/nifosg/nifloader.hpp +++ b/components/nifosg/nifloader.hpp @@ -74,8 +74,13 @@ namespace NifOsg static bool getShowMarkers(); - private: + /// Set the mask to use for hidden nodes. The default is 0, i.e. updates to those nodes can no longer happen. + /// If you need to run animations or physics for hidden nodes, you may want to set this to a non-zero mask and remove exactly that mask from the camera's cull mask. + static void setHiddenNodeMask(unsigned int mask); + static unsigned int getHiddenNodeMask(); + private: + static unsigned int sHiddenNodeMask; static bool sShowMarkers; }; From 40766d746c670a598bacbe26e149a105108f72d3 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Wed, 22 Apr 2020 16:06:42 +0300 Subject: [PATCH 31/44] Pick the correct aggressive actor in fight distance bias calculation --- apps/openmw/mwmechanics/combat.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/combat.cpp b/apps/openmw/mwmechanics/combat.cpp index 978ca61bd..9f5446c11 100644 --- a/apps/openmw/mwmechanics/combat.cpp +++ b/apps/openmw/mwmechanics/combat.cpp @@ -467,7 +467,7 @@ namespace MWMechanics osg::Vec3f pos1 (actor1.getRefData().getPosition().asVec3()); osg::Vec3f pos2 (actor2.getRefData().getPosition().asVec3()); - float d = getAggroDistance(actor2, pos1, pos2); + float d = getAggroDistance(actor1, pos1, pos2); static const int iFightDistanceBase = MWBase::Environment::get().getWorld()->getStore().get().find( "iFightDistanceBase")->mValue.getInteger(); From 6316227594ff8168fe033279d5b6b6aa91d93380 Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Wed, 22 Apr 2020 15:57:24 +0200 Subject: [PATCH 32/44] hpp not cpp; review --- apps/openmw/mwrender/renderingmanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 9a68b15fa..481ea9982 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -20,7 +20,7 @@ #include -#include +#include #include From 1cd4b9ee6861a46d034d9bcd7a0ce6a4312c0d32 Mon Sep 17 00:00:00 2001 From: bzzt Date: Wed, 20 Feb 2019 13:37:00 +0000 Subject: [PATCH 33/44] fixes shadows on savegame screenshot --- apps/openmw/mwrender/renderingmanager.cpp | 62 ++++++++++++++++++++--- apps/openmw/mwrender/renderingmanager.hpp | 3 +- apps/openmw/mwworld/worldimp.cpp | 2 +- 3 files changed, 58 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 648660669..fac6fcff2 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -744,17 +744,19 @@ namespace MWRender class NotifyDrawCompletedCallback : public osg::Camera::DrawCallback { public: - NotifyDrawCompletedCallback() - : mDone(false) + NotifyDrawCompletedCallback(unsigned int frame) + : mDone(false), mFrame(frame) { } virtual void operator () (osg::RenderInfo& renderInfo) const { - mMutex.lock(); - mDone = true; - mMutex.unlock(); - mCondition.signal(); + OpenThreads::ScopedLock lock(mMutex); + if (renderInfo.getState()->getFrameStamp()->getFrameNumber() >= mFrame) + { + mDone = true; + mCondition.signal(); + } } void waitTillDone() @@ -769,6 +771,7 @@ namespace MWRender mutable OpenThreads::Condition mCondition; mutable OpenThreads::Mutex mMutex; mutable bool mDone; + unsigned int mFrame; }; bool RenderingManager::screenshot360(osg::Image* image, std::string settingStr) @@ -948,7 +951,7 @@ namespace MWRender mRootNode->addChild(camera); // The draw needs to complete before we can copy back our image. - osg::ref_ptr callback (new NotifyDrawCompletedCallback); + osg::ref_ptr callback (new NotifyDrawCompletedCallback(0)); camera->setFinalDrawCallback(callback); MWBase::Environment::get().getWindowManager()->getLoadingScreen()->loadingOn(false); @@ -967,6 +970,51 @@ namespace MWRender mRootNode->removeChild(camera); } + class ReadImageFromFramebufferCallback : public osg::Drawable::DrawCallback + { + public: + ReadImageFromFramebufferCallback(osg::Image* image, int width, int height) + : mWidth(width), mHeight(height), mImage(image) + { + } + virtual void drawImplementation(osg::RenderInfo& renderInfo,const osg::Drawable* /*drawable*/) const + { + int screenW = renderInfo.getCurrentCamera()->getViewport()->width(); + int screenH = renderInfo.getCurrentCamera()->getViewport()->height(); + double imageaspect = (double)mWidth/(double)mHeight; + int leftPadding = std::max(0, static_cast(screenW - screenH * imageaspect) / 2); + int topPadding = std::max(0, static_cast(screenH - screenW / imageaspect) / 2); + int width = screenW - leftPadding*2; + int height = screenH - topPadding*2; + mImage->readPixels(leftPadding, topPadding, width, height, GL_RGB, GL_UNSIGNED_BYTE); + mImage->scaleImage(mWidth, mHeight, 1); + } + private: + int mWidth; + int mHeight; + osg::ref_ptr mImage; + }; + + void RenderingManager::screenshotScreen(osg::Image* image, int w, int h) + { + osg::Camera* camera = mViewer->getCamera(); + osg::ref_ptr tempDrw = new osg::Drawable; + tempDrw->setDrawCallback(new ReadImageFromFramebufferCallback(image, w, h)); + tempDrw->setCullingActive(false); + tempDrw->getOrCreateStateSet()->setRenderBinDetails(100, "RenderBin", osg::StateSet::USE_RENDERBIN_DETAILS); // so its after all scene bins but before POST_RENDER gui camera + camera->addChild(tempDrw); + osg::ref_ptr callback (new NotifyDrawCompletedCallback(mViewer->getFrameStamp()->getFrameNumber())); + camera->setFinalDrawCallback(callback); + mViewer->eventTraversal(); + mViewer->updateTraversal(); + mViewer->renderingTraversals(); + callback->waitTillDone(); + // now that we've "used up" the current frame, get a fresh framenumber for the next frame() following after the screenshot is completed + mViewer->advance(mViewer->getFrameStamp()->getSimulationTime()); + camera->removeChild(tempDrw); + camera->setFinalDrawCallback(nullptr); + } + void RenderingManager::screenshot(osg::Image *image, int w, int h, osg::Matrixd cameraTransform) { osg::ref_ptr rttCamera (new osg::Camera); diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index d4b0b1840..2efe10cf9 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -144,7 +144,8 @@ namespace MWRender void setWaterHeight(float level); /// Take a screenshot of w*h onto the given image, not including the GUI. - void screenshot(osg::Image* image, int w, int h, osg::Matrixd cameraTransform=osg::Matrixd()); + void screenshotScreen(osg::Image* image, int w, int h); // copie directly from framebuffer and scale to given size + void screenshot(osg::Image* image, int w, int h, osg::Matrixd cameraTransform=osg::Matrixd()); // make a new render at given size bool screenshot360(osg::Image* image, std::string settingStr); struct RayResult diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 49b55f2a9..73be0e6f4 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -2554,7 +2554,7 @@ namespace MWWorld void World::screenshot(osg::Image* image, int w, int h) { - mRendering->screenshot(image, w, h); + mRendering->screenshotScreen(image, w, h); } bool World::screenshot360(osg::Image* image, std::string settingStr) From c359406473bb45cf79c58f625cac5c0ff7a78418 Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Wed, 22 Apr 2020 20:29:50 +0200 Subject: [PATCH 34/44] taking anyoldname3 review comments to heart; typo fixes plus rebase --- apps/openmw/mwrender/renderingmanager.cpp | 4 ++-- apps/openmw/mwrender/renderingmanager.hpp | 2 +- apps/openmw/mwworld/worldimp.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index fac6fcff2..f5053cca9 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -995,7 +995,7 @@ namespace MWRender osg::ref_ptr mImage; }; - void RenderingManager::screenshotScreen(osg::Image* image, int w, int h) + void RenderingManager::screenshotFramebuffer(osg::Image* image, int w, int h) { osg::Camera* camera = mViewer->getCamera(); osg::ref_ptr tempDrw = new osg::Drawable; @@ -1009,7 +1009,7 @@ namespace MWRender mViewer->updateTraversal(); mViewer->renderingTraversals(); callback->waitTillDone(); - // now that we've "used up" the current frame, get a fresh framenumber for the next frame() following after the screenshot is completed + // now that we've "used up" the current frame, get a fresh frame number for the next frame() following after the screenshot is completed mViewer->advance(mViewer->getFrameStamp()->getSimulationTime()); camera->removeChild(tempDrw); camera->setFinalDrawCallback(nullptr); diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index 2efe10cf9..09cff26f1 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -144,8 +144,8 @@ namespace MWRender void setWaterHeight(float level); /// Take a screenshot of w*h onto the given image, not including the GUI. - void screenshotScreen(osg::Image* image, int w, int h); // copie directly from framebuffer and scale to given size void screenshot(osg::Image* image, int w, int h, osg::Matrixd cameraTransform=osg::Matrixd()); // make a new render at given size + void screenshotFramebuffer(osg::Image* image, int w, int h); // copy directly from framebuffer and scale to given size bool screenshot360(osg::Image* image, std::string settingStr); struct RayResult diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 73be0e6f4..ce06d887c 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -2554,7 +2554,7 @@ namespace MWWorld void World::screenshot(osg::Image* image, int w, int h) { - mRendering->screenshotScreen(image, w, h); + mRendering->screenshotFramebuffer(image, w, h); } bool World::screenshot360(osg::Image* image, std::string settingStr) From ed20d869b4e8a8283bd726b82da2ca6a074c8afc Mon Sep 17 00:00:00 2001 From: bzzt Date: Thu, 13 Jun 2019 13:37:00 +0000 Subject: [PATCH 35/44] waterculling for both terrain --- apps/openmw/mwrender/renderingmanager.cpp | 8 ++++-- apps/openmw/mwrender/water.cpp | 28 ++++++++++++++++++ apps/openmw/mwrender/water.hpp | 4 +++ components/terrain/quadtreeworld.cpp | 35 +++++++++++++++++++++++ components/terrain/terraingrid.cpp | 11 +++++++ components/terrain/terraingrid.hpp | 3 +- components/terrain/world.cpp | 8 ++++++ components/terrain/world.hpp | 35 +++++++++++++++++++++++ 8 files changed, 129 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 31af55a44..c966a5d67 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -282,8 +282,6 @@ namespace MWRender mEffectManager.reset(new EffectManager(sceneRoot, mResourceSystem)); - mWater.reset(new Water(mRootNode, sceneRoot, mResourceSystem, mViewer->getIncrementalCompileOperation(), resourcePath)); - DLLandFogStart = Settings::Manager::getFloat("distant land fog start", "Fog"); DLLandFogEnd = Settings::Manager::getFloat("distant land fog end", "Fog"); DLUnderwaterFogStart = Settings::Manager::getFloat("distant underwater fog start", "Fog"); @@ -322,6 +320,9 @@ namespace MWRender mTerrain->setTargetFrameRate(Settings::Manager::getFloat("target framerate", "Cells")); mTerrain->setWorkQueue(mWorkQueue.get()); + // water goes after terrain for correct waterculling order + mWater.reset(new Water(mRootNode, sceneRoot, mResourceSystem, mViewer->getIncrementalCompileOperation(), resourcePath)); + mCamera.reset(new Camera(mViewer->getCamera())); mViewer->setLightingMode(osgViewer::View::NO_LIGHT); @@ -541,6 +542,8 @@ namespace MWRender void RenderingManager::enableTerrain(bool enable) { + if (!enable) + mWater->setCullCallback(nullptr); mTerrain->enable(enable); } @@ -740,6 +743,7 @@ namespace MWRender void RenderingManager::setWaterHeight(float height) { + mWater->setCullCallback(mTerrain->getHeightCullCallback(height, Mask_Water)); mWater->setHeight(height); mSky->setWaterHeight(height); } diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index 6d230d36e..c9d16b728 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -436,6 +436,7 @@ Water::Water(osg::Group *parent, osg::Group* sceneRoot, Resource::ResourceSystem , mToggled(true) , mTop(0) , mInterior(false) + , mCullCallback(nullptr) { mSimulation.reset(new RippleSimulation(mSceneRoot, resourceSystem)); @@ -466,6 +467,29 @@ Water::Water(osg::Group *parent, osg::Group* sceneRoot, Resource::ResourceSystem ico->add(mWaterNode); } +void Water::setCullCallback(osg::Callback* callback) +{ + if (mCullCallback) + { + mWaterNode->removeCullCallback(mCullCallback); + if (mReflection) + mReflection->removeCullCallback(mCullCallback); + if (mRefraction) + mRefraction->removeCullCallback(mCullCallback); + } + + mCullCallback = callback; + + if (callback) + { + mWaterNode->addCullCallback(callback); + if (mReflection) + mReflection->addCullCallback(callback); + if (mRefraction) + mRefraction->addCullCallback(callback); + } +} + osg::Uniform *Water::getRainIntensityUniform() { return mRainIntensityUniform.get(); @@ -491,6 +515,8 @@ void Water::updateWaterMaterial() mReflection = new Reflection(mInterior); mReflection->setWaterLevel(mTop); mReflection->setScene(mSceneRoot); + if (mCullCallback) + mReflection->addCullCallback(mCullCallback); mParent->addChild(mReflection); if (Settings::Manager::getBool("refraction", "Water")) @@ -498,6 +524,8 @@ void Water::updateWaterMaterial() mRefraction = new Refraction; mRefraction->setWaterLevel(mTop); mRefraction->setScene(mSceneRoot); + if (mCullCallback) + mRefraction->addCullCallback(mCullCallback); mParent->addChild(mRefraction); } diff --git a/apps/openmw/mwrender/water.hpp b/apps/openmw/mwrender/water.hpp index 5d99413c6..3787ef426 100644 --- a/apps/openmw/mwrender/water.hpp +++ b/apps/openmw/mwrender/water.hpp @@ -71,6 +71,8 @@ namespace MWRender float mTop; bool mInterior; + osg::Callback* mCullCallback; + osg::Vec3f getSceneNodeCoordinates(int gridX, int gridY); void updateVisible(); @@ -88,6 +90,8 @@ namespace MWRender const std::string& resourcePath); ~Water(); + void setCullCallback(osg::Callback* callback); + void listAssetsToPreload(std::vector& textures); void setEnabled(bool enabled); diff --git a/components/terrain/quadtreeworld.cpp b/components/terrain/quadtreeworld.cpp index 396ac1138..1d968ddc4 100644 --- a/components/terrain/quadtreeworld.cpp +++ b/components/terrain/quadtreeworld.cpp @@ -307,6 +307,38 @@ void loadRenderingNode(ViewData::Entry& entry, ViewData* vd, int vertexLodMod, C entry.mRenderingNode = chunkManager->getChunk(entry.mNode->getSize(), entry.mNode->getCenter(), ourLod, entry.mLodFlags); } +void updateWaterCullingView(HeightCullCallback* callback, ViewData* vd, osgUtil::CullVisitor* cv, float cellworldsize, bool outofworld) +{ + if (!(cv->getTraversalMask() & callback->getCullMask())) + return; + float lowZ = FLT_MAX; + float highZ = callback->getHighZ(); + if (cv->getEyePoint().z() <= highZ || outofworld) + { + callback->setLowZ(-FLT_MAX); + return; + } + cv->pushCurrentMask(); + for (unsigned int i=0; igetNumEntries(); ++i) + { + ViewData::Entry& entry = vd->getEntry(i); + osg::BoundingBox bb = static_cast(entry.mRenderingNode->asGroup()->getChild(0))->getBoundingBox(); + float minZ = bb._min.z(); + if (minZ > highZ) + continue; + osg::Vec3f ofs (entry.mNode->getCenter().x()*cellworldsize, entry.mNode->getCenter().y()*cellworldsize, 0.f); + bb._min += ofs; bb._max += ofs; + bb._min.z() = highZ; + bb._max.z() = highZ; + if (cv->isCulled(bb)) + continue; + lowZ = minZ; + break; + } + callback->setLowZ(lowZ); + cv->popCurrentMask(); +} + void QuadTreeWorld::accept(osg::NodeVisitor &nv) { bool isCullVisitor = nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR; @@ -384,6 +416,9 @@ void QuadTreeWorld::accept(osg::NodeVisitor &nv) entry.mRenderingNode->accept(nv); } + if (isCullVisitor) + updateWaterCullingView(mHeightCullCallback, vd, static_cast(&nv), mStorage->getCellWorldSize(), !mGrid.empty()); + if (!isCullVisitor) vd->clear(); // we can't reuse intersection views in the next frame because they only contain what is touched by the intersection ray. diff --git a/components/terrain/terraingrid.cpp b/components/terrain/terraingrid.cpp index 7310846c2..a0e5e4718 100644 --- a/components/terrain/terraingrid.cpp +++ b/components/terrain/terraingrid.cpp @@ -3,6 +3,7 @@ #include #include +#include #include "chunkmanager.hpp" #include "compositemaprenderer.hpp" @@ -80,6 +81,7 @@ void TerrainGrid::loadCell(int x, int y) mTerrainRoot->addChild(terrainNode); mGrid[std::make_pair(x,y)] = terrainNode; + updateWaterCulling(); } void TerrainGrid::unloadCell(int x, int y) @@ -94,6 +96,15 @@ void TerrainGrid::unloadCell(int x, int y) mTerrainRoot->removeChild(terrainNode); mGrid.erase(it); + updateWaterCulling(); +} + +void TerrainGrid::updateWaterCulling() +{ + osg::ComputeBoundsVisitor computeBoundsVisitor; + mTerrainRoot->accept(computeBoundsVisitor); + float lowZ = computeBoundsVisitor.getBoundingBox()._min.z(); + mHeightCullCallback->setLowZ(lowZ); } View *TerrainGrid::createView() diff --git a/components/terrain/terraingrid.hpp b/components/terrain/terraingrid.hpp index eb30fb97d..e633a258f 100644 --- a/components/terrain/terraingrid.hpp +++ b/components/terrain/terraingrid.hpp @@ -27,8 +27,9 @@ namespace Terrain View* createView(); - private: + protected: osg::ref_ptr buildTerrain (osg::Group* parent, float chunkSize, const osg::Vec2f& chunkCenter); + void updateWaterCulling(); // split each ESM::Cell into mNumSplits*mNumSplits terrain chunks unsigned int mNumSplits; diff --git a/components/terrain/world.cpp b/components/terrain/world.cpp index da3bdb5c2..2d53f4090 100644 --- a/components/terrain/world.cpp +++ b/components/terrain/world.cpp @@ -19,6 +19,7 @@ World::World(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSyst , mParent(parent) , mResourceSystem(resourceSystem) , mBorderVisible(false) + , mHeightCullCallback(new HeightCullCallback) { mTerrainRoot = new osg::Group; mTerrainRoot->setNodeMask(nodeMask); @@ -120,4 +121,11 @@ void World::clearAssociatedCaches() mChunkManager->clearCache(); } +osg::Callback* World::getHeightCullCallback(float highz, unsigned int mask) +{ + mHeightCullCallback->setHighZ(highz); + mHeightCullCallback->setCullMask(mask); + return mHeightCullCallback; +} + } diff --git a/components/terrain/world.hpp b/components/terrain/world.hpp index 0402b8197..92eb69b80 100644 --- a/components/terrain/world.hpp +++ b/components/terrain/world.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -39,6 +40,37 @@ namespace Terrain class ChunkManager; class CompositeMapRenderer; +class HeightCullCallback : public osg::NodeCallback +{ +public: + HeightCullCallback() : mLowZ(-FLT_MAX), mHighZ(FLT_MAX), mMask(~0) {} + + void setLowZ(float z) + { + mLowZ = z; + } + float getLowZ() const { return mLowZ; } + + void setHighZ(float highZ) + { + mHighZ = highZ; + } + float getHighZ() const { return mHighZ; } + + void setCullMask(unsigned int mask) { mMask = mask; } + unsigned int getCullMask() const { return mMask; } + + virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) + { + if (mLowZ <= mHighZ) + traverse(node, nv); + } +private: + float mLowZ; + float mHighZ; + unsigned int mMask; +}; + /** * @brief A View is a collection of rendering objects that are visible from a given camera/intersection. * The base View class is part of the interface for usage in conjunction with preload feature. @@ -116,6 +148,8 @@ namespace Terrain Storage* getStorage() { return mStorage; } + osg::Callback* getHeightCullCallback(float highz, unsigned int mask); + protected: Storage* mStorage; @@ -135,6 +169,7 @@ namespace Terrain bool mBorderVisible; std::set> mLoadedCells; + osg::ref_ptr mHeightCullCallback; }; } From 407fbe320ef2ae7104e8c13a2156f055c41e23ed Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Thu, 23 Apr 2020 10:10:50 +0200 Subject: [PATCH 36/44] cleanup and use C++ version of FLT_MAX --- components/terrain/quadtreeworld.cpp | 5 +++-- components/terrain/world.hpp | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/components/terrain/quadtreeworld.cpp b/components/terrain/quadtreeworld.cpp index 1d968ddc4..56fa8b7f3 100644 --- a/components/terrain/quadtreeworld.cpp +++ b/components/terrain/quadtreeworld.cpp @@ -2,6 +2,7 @@ #include +#include #include #include @@ -311,11 +312,11 @@ void updateWaterCullingView(HeightCullCallback* callback, ViewData* vd, osgUtil: { if (!(cv->getTraversalMask() & callback->getCullMask())) return; - float lowZ = FLT_MAX; + float lowZ = std::numeric_limits::max(); float highZ = callback->getHighZ(); if (cv->getEyePoint().z() <= highZ || outofworld) { - callback->setLowZ(-FLT_MAX); + callback->setLowZ(-std::numeric_limits::max()); return; } cv->pushCurrentMask(); diff --git a/components/terrain/world.hpp b/components/terrain/world.hpp index 92eb69b80..fb6c45967 100644 --- a/components/terrain/world.hpp +++ b/components/terrain/world.hpp @@ -7,9 +7,9 @@ #include #include +#include #include #include -#include #include "defs.hpp" #include "cellborder.hpp" @@ -43,7 +43,7 @@ namespace Terrain class HeightCullCallback : public osg::NodeCallback { public: - HeightCullCallback() : mLowZ(-FLT_MAX), mHighZ(FLT_MAX), mMask(~0) {} + HeightCullCallback() : mLowZ(-std::numeric_limits::max()), mHighZ(std::numeric_limits::max()), mMask(~0) {} void setLowZ(float z) { From 48713915cb21b86f515fd5d1e95808d8ad56bf17 Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Thu, 23 Apr 2020 11:12:10 +0200 Subject: [PATCH 37/44] re-use bzzts waterplane overlay for debug; makes it easier to test. To use this, set the env OPENMW_WATER_CULLING_DEBUG=1; You will see blue rectangles corresponding to water outlines. Once there are no more outlines, water is culled. You can further see this by pressing F3 3 times to check the the amount of quads. Before culling it should be around 1600, after culling it should drop to 0. --- components/terrain/chunkmanager.cpp | 2 ++ components/terrain/quadtreeworld.cpp | 34 ++++++++++++++++++++++---- components/terrain/terraindrawable.cpp | 29 ++++++++++++++++++++++ components/terrain/terraindrawable.hpp | 8 ++++-- 4 files changed, 66 insertions(+), 7 deletions(-) diff --git a/components/terrain/chunkmanager.cpp b/components/terrain/chunkmanager.cpp index 3c76945d3..95c1ca491 100644 --- a/components/terrain/chunkmanager.cpp +++ b/components/terrain/chunkmanager.cpp @@ -227,6 +227,8 @@ osg::ref_ptr ChunkManager::createChunk(float chunkSize, const osg::Ve transform->addChild(geometry); transform->getBound(); + geometry->setupWaterBoundingBox(-1, chunkSize * mStorage->getCellWorldSize() / numVerts); + if (mSceneManager->getIncrementalCompileOperation()) { mSceneManager->getIncrementalCompileOperation()->add(geometry); diff --git a/components/terrain/quadtreeworld.cpp b/components/terrain/quadtreeworld.cpp index 56fa8b7f3..ae3656fd2 100644 --- a/components/terrain/quadtreeworld.cpp +++ b/components/terrain/quadtreeworld.cpp @@ -1,6 +1,8 @@ #include "quadtreeworld.hpp" #include +#include +#include #include #include @@ -13,6 +15,7 @@ #include "viewdata.hpp" #include "chunkmanager.hpp" #include "compositemaprenderer.hpp" +#include "terraindrawable.hpp" namespace { @@ -323,9 +326,8 @@ void updateWaterCullingView(HeightCullCallback* callback, ViewData* vd, osgUtil: for (unsigned int i=0; igetNumEntries(); ++i) { ViewData::Entry& entry = vd->getEntry(i); - osg::BoundingBox bb = static_cast(entry.mRenderingNode->asGroup()->getChild(0))->getBoundingBox(); - float minZ = bb._min.z(); - if (minZ > highZ) + osg::BoundingBox bb = static_cast(entry.mRenderingNode->asGroup()->getChild(0))->getWaterBoundingBox(); + if (!bb.valid()) continue; osg::Vec3f ofs (entry.mNode->getCenter().x()*cellworldsize, entry.mNode->getCenter().y()*cellworldsize, 0.f); bb._min += ofs; bb._max += ofs; @@ -333,8 +335,30 @@ void updateWaterCullingView(HeightCullCallback* callback, ViewData* vd, osgUtil: bb._max.z() = highZ; if (cv->isCulled(bb)) continue; - lowZ = minZ; - break; + lowZ = bb._min.z(); + + static bool debug = getenv("OPENMW_WATER_CULLING_DEBUG") != nullptr; + if (!debug) + break; + osg::Box* b = new osg::Box; + b->set(bb.center(), bb._max - bb.center()); + osg::ShapeDrawable* drw = new osg::ShapeDrawable(b); + static osg::ref_ptr stateset = nullptr; + if (!stateset) + { + stateset = new osg::StateSet; + stateset->setMode(GL_CULL_FACE, osg::StateAttribute::OFF); + stateset->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF); + stateset->setAttributeAndModes(new osg::PolygonMode(osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::LINE), osg::StateAttribute::ON); + osg::Material* m = new osg::Material; + m->setEmission(osg::Material::FRONT_AND_BACK, osg::Vec4f(0,0,1,1)); + m->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4f(0,0,0,1)); + m->setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4f(0,0,0,1)); + stateset->setAttributeAndModes(m, osg::StateAttribute::ON); + stateset->setRenderBinDetails(100,"RenderBin"); + } + drw->setStateSet(stateset); + drw->accept(*cv); } callback->setLowZ(lowZ); cv->popCurrentMask(); diff --git a/components/terrain/terraindrawable.cpp b/components/terrain/terraindrawable.cpp index c37074dac..9593687cf 100644 --- a/components/terrain/terraindrawable.cpp +++ b/components/terrain/terraindrawable.cpp @@ -10,6 +10,16 @@ namespace Terrain { +TerrainDrawable::TerrainDrawable() +{ + +} + +TerrainDrawable::~TerrainDrawable() +{ + +} + TerrainDrawable::TerrainDrawable(const TerrainDrawable ©, const osg::CopyOp ©op) : osg::Geometry(copy, copyop) , mPasses(copy.mPasses) @@ -118,6 +128,25 @@ void TerrainDrawable::setLightListCallback(SceneUtil::LightListCallback *lightLi mLightListCallback = lightListCallback; } +void TerrainDrawable::setupWaterBoundingBox(float waterheight, float margin) +{ + osg::Vec3Array* vertices = static_cast(getVertexArray()); + for (unsigned int i=0; isize(); ++i) + { + const osg::Vec3f& vertex = (*vertices)[i]; + if (vertex.z() <= waterheight) + mWaterBoundingBox.expandBy(vertex); + } + if (mWaterBoundingBox.valid()) + { + const osg::BoundingBox& bb = getBoundingBox(); + mWaterBoundingBox.xMin() = std::max(bb.xMin(), mWaterBoundingBox.xMin() - margin); + mWaterBoundingBox.yMin() = std::max(bb.yMin(), mWaterBoundingBox.yMin() - margin); + mWaterBoundingBox.xMax() = std::min(bb.xMax(), mWaterBoundingBox.xMax() + margin); + mWaterBoundingBox.xMax() = std::min(bb.xMax(), mWaterBoundingBox.xMax() + margin); + } +} + void TerrainDrawable::compileGLObjects(osg::RenderInfo &renderInfo) const { for (PassVector::const_iterator it = mPasses.begin(); it != mPasses.end(); ++it) diff --git a/components/terrain/terraindrawable.hpp b/components/terrain/terraindrawable.hpp index 516b1abdb..a84200f66 100644 --- a/components/terrain/terraindrawable.hpp +++ b/components/terrain/terraindrawable.hpp @@ -36,8 +36,8 @@ namespace Terrain virtual const char* className() const { return "TerrainDrawable"; } virtual const char* libraryName() const { return "Terrain"; } - TerrainDrawable() = default; - ~TerrainDrawable() = default; + TerrainDrawable(); + ~TerrainDrawable(); // has to be defined in the cpp file because we only forward declared some members. TerrainDrawable(const TerrainDrawable& copy, const osg::CopyOp& copyop); virtual void accept(osg::NodeVisitor &nv); @@ -52,10 +52,14 @@ namespace Terrain virtual void compileGLObjects(osg::RenderInfo& renderInfo) const; + void setupWaterBoundingBox(float waterheight, float margin); + const osg::BoundingBox& getWaterBoundingBox() const { return mWaterBoundingBox; } + void setCompositeMap(CompositeMap* map) { mCompositeMap = map; } void setCompositeMapRenderer(CompositeMapRenderer* renderer) { mCompositeMapRenderer = renderer; } private: + osg::BoundingBox mWaterBoundingBox; PassVector mPasses; osg::ref_ptr mClusterCullingCallback; From 89ff1974ee180fb27ab61da4c9ea78bb082f6061 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Thu, 23 Apr 2020 13:14:48 +0300 Subject: [PATCH 38/44] Remove issue that hasn't been solved properly --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1043ca0cf..93681ef21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -165,7 +165,6 @@ Bug #5099: Non-swimming enemies will enter water if player is water walking Bug #5103: Sneaking state behavior is still inconsistent Bug #5104: Black Dart's enchantment doesn't trigger at low Enchant levels - Bug #5105: NPCs start combat with werewolves from any distance Bug #5106: Still can jump even when encumbered Bug #5110: ModRegion with a redundant numerical argument breaks script execution Bug #5112: Insufficient magicka for current spell not reflected on HUD icon From 756ec7117b4d6b8362ac22415c2e57ddc59c3e80 Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Thu, 23 Apr 2020 17:40:10 +0200 Subject: [PATCH 39/44] make mGrid (and friends) private again, create accessor method to return bool of mGrid.empty() --- components/terrain/quadtreeworld.cpp | 2 +- components/terrain/terraingrid.hpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/components/terrain/quadtreeworld.cpp b/components/terrain/quadtreeworld.cpp index ae3656fd2..0140ade49 100644 --- a/components/terrain/quadtreeworld.cpp +++ b/components/terrain/quadtreeworld.cpp @@ -442,7 +442,7 @@ void QuadTreeWorld::accept(osg::NodeVisitor &nv) } if (isCullVisitor) - updateWaterCullingView(mHeightCullCallback, vd, static_cast(&nv), mStorage->getCellWorldSize(), !mGrid.empty()); + updateWaterCullingView(mHeightCullCallback, vd, static_cast(&nv), mStorage->getCellWorldSize(), !isGridEmpty()); if (!isCullVisitor) vd->clear(); // we can't reuse intersection views in the next frame because they only contain what is touched by the intersection ray. diff --git a/components/terrain/terraingrid.hpp b/components/terrain/terraingrid.hpp index e633a258f..cb37ca296 100644 --- a/components/terrain/terraingrid.hpp +++ b/components/terrain/terraingrid.hpp @@ -28,6 +28,9 @@ namespace Terrain View* createView(); protected: + bool isGridEmpty() { return mGrid.empty(); } + + private: osg::ref_ptr buildTerrain (osg::Group* parent, float chunkSize, const osg::Vec2f& chunkCenter); void updateWaterCulling(); From 7aaec5e989f58327e30741e016d0d7d9ad5fd0b8 Mon Sep 17 00:00:00 2001 From: elsid Date: Thu, 23 Apr 2020 19:16:32 +0200 Subject: [PATCH 40/44] Log shader template name on parse error --- components/shader/shadermanager.cpp | 42 +++++++++++++++-------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/components/shader/shadermanager.cpp b/components/shader/shadermanager.cpp index 0a7345b97..c2126275f 100644 --- a/components/shader/shadermanager.cpp +++ b/components/shader/shadermanager.cpp @@ -58,7 +58,7 @@ namespace Shader return true; } - bool parseIncludes(boost::filesystem::path shaderPath, std::string& source) + bool parseIncludes(boost::filesystem::path shaderPath, std::string& source, const std::string& shaderTemplate) { Misc::StringUtils::replaceAll(source, "\r\n", "\n"); @@ -70,13 +70,13 @@ namespace Shader size_t start = source.find('"', foundPos); if (start == std::string::npos || start == source.size()-1) { - Log(Debug::Error) << "Invalid #include"; + Log(Debug::Error) << "Shader " << shaderTemplate << " error: Invalid #include"; return false; } size_t end = source.find('"', start+1); if (end == std::string::npos) { - Log(Debug::Error) << "Invalid #include"; + Log(Debug::Error) << "Shader " << shaderTemplate << " error: Invalid #include"; return false; } std::string includeFilename = source.substr(start+1, end-(start+1)); @@ -85,7 +85,7 @@ namespace Shader includeFstream.open(includePath); if (includeFstream.fail()) { - Log(Debug::Error) << "Failed to open " << includePath.string(); + Log(Debug::Error) << "Shader " << shaderTemplate << " error: Failed to open include " << includePath.string(); return false; } @@ -120,14 +120,14 @@ namespace Shader if (includedFiles.insert(includePath).second == false) { - Log(Debug::Error) << "Detected cyclic #includes"; + Log(Debug::Error) << "Shader " << shaderTemplate << " error: Detected cyclic #includes"; return false; } } return true; } - bool parseFors(std::string& source) + bool parseFors(std::string& source, const std::string& shaderTemplate) { const char escapeCharacter = '$'; size_t foundPos = 0; @@ -136,13 +136,13 @@ namespace Shader size_t endPos = source.find_first_of(" \n\r()[].;,", foundPos); if (endPos == std::string::npos) { - Log(Debug::Error) << "Unexpected EOF"; + Log(Debug::Error) << "Shader " << shaderTemplate << " error: Unexpected EOF"; return false; } std::string command = source.substr(foundPos + 1, endPos - (foundPos + 1)); if (command != "foreach") { - Log(Debug::Error) << "Unknown shader directive: $" << command; + Log(Debug::Error) << "Shader " << shaderTemplate << " error: Unknown shader directive: $" << command; return false; } @@ -150,7 +150,7 @@ namespace Shader size_t iterNameEnd = source.find_first_of(" \n\r()[].;,", iterNameStart); if (iterNameEnd == std::string::npos) { - Log(Debug::Error) << "Unexpected EOF"; + Log(Debug::Error) << "Shader " << shaderTemplate << " error: Unexpected EOF"; return false; } std::string iteratorName = "$" + source.substr(iterNameStart, iterNameEnd - iterNameStart); @@ -159,7 +159,7 @@ namespace Shader size_t listEnd = source.find_first_of("\n\r", listStart); if (listEnd == std::string::npos) { - Log(Debug::Error) << "Unexpected EOF"; + Log(Debug::Error) << "Shader " << shaderTemplate << " error: Unexpected EOF"; return false; } std::string list = source.substr(listStart, listEnd - listStart); @@ -171,13 +171,13 @@ namespace Shader size_t contentEnd = source.find("$endforeach", contentStart); if (contentEnd == std::string::npos) { - Log(Debug::Error) << "Unexpected EOF"; + Log(Debug::Error) << "Shader " << shaderTemplate << " error: Unexpected EOF"; return false; } std::string content = source.substr(contentStart, contentEnd - contentStart); size_t overallEnd = contentEnd + std::string("$endforeach").length(); - + size_t lineDirectivePosition = source.rfind("#line", overallEnd); int lineNumber; if (lineDirectivePosition != std::string::npos) @@ -210,7 +210,8 @@ namespace Shader return true; } - bool parseDefines(std::string& source, const ShaderManager::DefineMap& defines, const ShaderManager::DefineMap& globalDefines) + bool parseDefines(std::string& source, const ShaderManager::DefineMap& defines, + const ShaderManager::DefineMap& globalDefines, const std::string& shaderTemplate) { const char escapeCharacter = '@'; size_t foundPos = 0; @@ -220,7 +221,7 @@ namespace Shader size_t endPos = source.find_first_of(" \n\r()[].;,", foundPos); if (endPos == std::string::npos) { - Log(Debug::Error) << "Unexpected EOF"; + Log(Debug::Error) << "Shader " << shaderTemplate << " error: Unexpected EOF"; return false; } std::string define = source.substr(foundPos+1, endPos - (foundPos+1)); @@ -233,7 +234,7 @@ namespace Shader size_t iterNameEnd = source.find_first_of(" \n\r()[].;,", iterNameStart); if (iterNameEnd == std::string::npos) { - Log(Debug::Error) << "Unexpected EOF"; + Log(Debug::Error) << "Shader " << shaderTemplate << " error: Unexpected EOF"; return false; } forIterators.push_back(source.substr(iterNameStart, iterNameEnd - iterNameStart)); @@ -243,7 +244,7 @@ namespace Shader source.replace(foundPos, 1, "$"); if (forIterators.empty()) { - Log(Debug::Error) << "endforeach without foreach"; + Log(Debug::Error) << "Shader " << shaderTemplate << " error: endforeach without foreach"; return false; } else @@ -263,7 +264,7 @@ namespace Shader } else { - Log(Debug::Error) << "Undefined " << define; + Log(Debug::Error) << "Shader " << shaderTemplate << " error: Undefined " << define; return false; } } @@ -291,7 +292,8 @@ namespace Shader // parse includes std::string source = buffer.str(); - if (!addLineDirectivesAfterConditionalBlocks(source) || !parseIncludes(boost::filesystem::path(mPath), source)) + if (!addLineDirectivesAfterConditionalBlocks(source) + || !parseIncludes(boost::filesystem::path(mPath), source, shaderTemplate)) return nullptr; templateIt = mShaderTemplates.insert(std::make_pair(shaderTemplate, source)).first; @@ -301,7 +303,7 @@ namespace Shader if (shaderIt == mShaders.end()) { std::string shaderSource = templateIt->second; - if (!parseDefines(shaderSource, defines, mGlobalDefines) || !parseFors(shaderSource)) + if (!parseDefines(shaderSource, defines, mGlobalDefines, shaderTemplate) || !parseFors(shaderSource, shaderTemplate)) { // Add to the cache anyway to avoid logging the same error over and over. mShaders.insert(std::make_pair(std::make_pair(shaderTemplate, defines), nullptr)); @@ -350,7 +352,7 @@ namespace Shader // I'm not sure how to handle a shader that was already broken as there's no way to get a potential replacement to the nodes that need it. continue; std::string shaderSource = mShaderTemplates[templateId]; - if (!parseDefines(shaderSource, defines, mGlobalDefines) || !parseFors(shaderSource)) + if (!parseDefines(shaderSource, defines, mGlobalDefines, templateId) || !parseFors(shaderSource, templateId)) // We just broke the shader and there's no way to force existing objects back to fixed-function mode as we would when creating the shader. // If we put a nullptr in the shader map, we just lose the ability to put a working one in later. continue; From ed970f4d17d0803e31092e055d753dc2010ddbfe Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Fri, 24 Apr 2020 06:26:08 +0000 Subject: [PATCH 41/44] Apply suggestion to components/terrain/terraingrid.hpp --- components/terrain/terraingrid.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/terrain/terraingrid.hpp b/components/terrain/terraingrid.hpp index cb37ca296..8b36448c1 100644 --- a/components/terrain/terraingrid.hpp +++ b/components/terrain/terraingrid.hpp @@ -28,7 +28,7 @@ namespace Terrain View* createView(); protected: - bool isGridEmpty() { return mGrid.empty(); } + bool isGridEmpty() const { return mGrid.empty(); } private: osg::ref_ptr buildTerrain (osg::Group* parent, float chunkSize, const osg::Vec2f& chunkCenter); From 847cd41b010af8b7c5e48301e46fb527b0a0b6f9 Mon Sep 17 00:00:00 2001 From: elsid Date: Sat, 4 Apr 2020 01:16:55 +0200 Subject: [PATCH 42/44] Update recastnavigation to 57610fa6ef31b39020231906f8c5d40eaa8294ae --- extern/recastnavigation/.id | 2 +- extern/recastnavigation/Recast/Source/RecastContour.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extern/recastnavigation/.id b/extern/recastnavigation/.id index f15ce513c..81e564671 100644 --- a/extern/recastnavigation/.id +++ b/extern/recastnavigation/.id @@ -1 +1 @@ -c40188c796f089f89a42e0b939d934178dbcfc5c +57610fa6ef31b39020231906f8c5d40eaa8294ae diff --git a/extern/recastnavigation/Recast/Source/RecastContour.cpp b/extern/recastnavigation/Recast/Source/RecastContour.cpp index 277ab0150..6574c11b6 100644 --- a/extern/recastnavigation/Recast/Source/RecastContour.cpp +++ b/extern/recastnavigation/Recast/Source/RecastContour.cpp @@ -1009,7 +1009,7 @@ bool rcBuildContours(rcContext* ctx, rcCompactHeightfield& chf, if (cset.nconts > 0) { // Calculate winding of all polygons. - rcScopedDelete winding((char*)rcAlloc(sizeof(char)*cset.nconts, RC_ALLOC_TEMP)); + rcScopedDelete winding((signed char*)rcAlloc(sizeof(signed char)*cset.nconts, RC_ALLOC_TEMP)); if (!winding) { ctx->log(RC_LOG_ERROR, "rcBuildContours: Out of memory 'hole' (%d).", cset.nconts); From 975e4f99084a36d7d3c636cb5520c326b425cf0c Mon Sep 17 00:00:00 2001 From: elsid Date: Sat, 25 Apr 2020 01:26:06 +0200 Subject: [PATCH 43/44] Fix warning -Wrange-loop-construct apps/openmw/mwgui/loadingscreen.cpp:81:36: warning: loop variable 'extension' of type 'const std::__cxx11::basic_string' creates a copy from type 'const std::__cxx11::basic_string' [-Wrange-loop-construct] for(auto const extension: supported_extensions) ^ apps/openmw/mwgui/loadingscreen.cpp:81:25: note: use reference type 'const std::__cxx11::basic_string &' to prevent copying for(auto const extension: supported_extensions) ^~~~~~~~~~~~~~~~~~~~~ & --- apps/openmw/mwgui/loadingscreen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/loadingscreen.cpp b/apps/openmw/mwgui/loadingscreen.cpp index 54382ab4d..7ab39915f 100644 --- a/apps/openmw/mwgui/loadingscreen.cpp +++ b/apps/openmw/mwgui/loadingscreen.cpp @@ -78,7 +78,7 @@ namespace MWGui size_t pos = name.find_last_of('.'); if (pos != std::string::npos) { - for(auto const extension: supported_extensions) + for(auto const& extension: supported_extensions) { if (name.compare(pos, name.size() - pos, extension) == 0) { From ffacc30597ee38d6f4fb00154b1f325400e30c84 Mon Sep 17 00:00:00 2001 From: elsid Date: Sat, 25 Apr 2020 01:29:43 +0200 Subject: [PATCH 44/44] Use std::array for a list of extensions This list doesn't change and the size is known at compile time. --- apps/openmw/mwgui/loadingscreen.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/loadingscreen.cpp b/apps/openmw/mwgui/loadingscreen.cpp index 7ab39915f..093a2f34c 100644 --- a/apps/openmw/mwgui/loadingscreen.cpp +++ b/apps/openmw/mwgui/loadingscreen.cpp @@ -1,5 +1,7 @@ #include "loadingscreen.hpp" +#include + #include #include @@ -67,7 +69,7 @@ namespace MWGui mVFS->normalizeFilename(pattern); /* priority given to the left */ - std::list supported_extensions = {".tga", ".dds", ".ktx", ".png", ".bmp", ".jpeg", ".jpg"}; + const std::array supported_extensions {{".tga", ".dds", ".ktx", ".png", ".bmp", ".jpeg", ".jpg"}}; auto found = index.lower_bound(pattern); while (found != index.end())