mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 15:29:55 +00:00
Merge branch 'settings_values_navigator' into 'master'
Use settings values for Navigator settings (#6876) See merge request OpenMW/openmw!3468
This commit is contained in:
commit
01ee448c61
15 changed files with 67 additions and 63 deletions
|
@ -199,7 +199,7 @@ namespace NavMeshTool
|
|||
Settings::game().mActorCollisionShapeType,
|
||||
Settings::game().mDefaultActorPathfindHalfExtents,
|
||||
};
|
||||
const std::uint64_t maxDbFileSize = Settings::Manager::getUInt64("max navmeshdb file size", "Navigator");
|
||||
const std::uint64_t maxDbFileSize = Settings::navigator().mMaxNavmeshdbFileSize;
|
||||
const auto dbPath = Files::pathToUnicodeString(config.getUserDataPath() / "navmesh.db");
|
||||
|
||||
Log(Debug::Info) << "Using navmeshdb at " << dbPath;
|
||||
|
|
|
@ -23,7 +23,7 @@ add_openmw_dir (mwrender
|
|||
creatureanimation effectmanager util renderinginterface pathgrid rendermode weaponanimation screenshotmanager
|
||||
bulletdebugdraw globalmap characterpreview camera localmap water terrainstorage ripplesimulation
|
||||
renderbin actoranimation landmanager navmesh actorspaths recastmesh fogmanager objectpaging groundcover
|
||||
postprocessor pingpongcull luminancecalculator pingpongcanvas transparentpass navmeshmode precipitationocclusion ripples
|
||||
postprocessor pingpongcull luminancecalculator pingpongcanvas transparentpass precipitationocclusion ripples
|
||||
actorutil
|
||||
)
|
||||
|
||||
|
|
|
@ -55,12 +55,12 @@ namespace MWLua
|
|||
api["reloadLua"] = []() { MWBase::Environment::get().getLuaManager()->reloadAllScripts(); };
|
||||
|
||||
api["NAV_MESH_RENDER_MODE"]
|
||||
= LuaUtil::makeStrictReadOnly(context.mLua->tableFromPairs<std::string_view, MWRender::NavMeshMode>({
|
||||
{ "AreaType", MWRender::NavMeshMode::AreaType },
|
||||
{ "UpdateFrequency", MWRender::NavMeshMode::UpdateFrequency },
|
||||
= LuaUtil::makeStrictReadOnly(context.mLua->tableFromPairs<std::string_view, Settings::NavMeshRenderMode>({
|
||||
{ "AreaType", Settings::NavMeshRenderMode::AreaType },
|
||||
{ "UpdateFrequency", Settings::NavMeshRenderMode::UpdateFrequency },
|
||||
}));
|
||||
|
||||
api["setNavMeshRenderMode"] = [context](MWRender::NavMeshMode value) {
|
||||
api["setNavMeshRenderMode"] = [context](Settings::NavMeshRenderMode value) {
|
||||
context.mLuaManager->addAction(
|
||||
[value] { MWBase::Environment::get().getWorld()->getRenderingManager()->setNavMeshMode(value); });
|
||||
};
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace MWRender
|
|||
const osg::ref_ptr<osg::StateSet> mDebugDrawStateSet;
|
||||
const DetourNavigator::Settings mSettings;
|
||||
std::map<DetourNavigator::TilePosition, Tile> mTiles;
|
||||
NavMeshMode mMode;
|
||||
Settings::NavMeshRenderMode mMode;
|
||||
std::atomic_bool mAborted{ false };
|
||||
std::mutex mMutex;
|
||||
bool mStarted = false;
|
||||
|
@ -57,7 +57,7 @@ namespace MWRender
|
|||
std::weak_ptr<DetourNavigator::GuardedNavMeshCacheItem> navMesh,
|
||||
const osg::ref_ptr<osg::StateSet>& groupStateSet, const osg::ref_ptr<osg::StateSet>& debugDrawStateSet,
|
||||
const DetourNavigator::Settings& settings, const std::map<DetourNavigator::TilePosition, Tile>& tiles,
|
||||
NavMeshMode mode)
|
||||
Settings::NavMeshRenderMode mode)
|
||||
: mId(id)
|
||||
, mVersion(version)
|
||||
, mNavMesh(std::move(navMesh))
|
||||
|
@ -110,13 +110,13 @@ namespace MWRender
|
|||
|
||||
const unsigned char flags = SceneUtil::NavMeshTileDrawFlagsOffMeshConnections
|
||||
| SceneUtil::NavMeshTileDrawFlagsClosedList
|
||||
| (mMode == NavMeshMode::UpdateFrequency ? SceneUtil::NavMeshTileDrawFlagsHeat : 0);
|
||||
| (mMode == Settings::NavMeshRenderMode::UpdateFrequency ? SceneUtil::NavMeshTileDrawFlagsHeat : 0);
|
||||
|
||||
for (const auto& [position, version] : existingTiles)
|
||||
{
|
||||
const auto it = mTiles.find(position);
|
||||
if (it != mTiles.end() && it->second.mGroup != nullptr && it->second.mVersion == version
|
||||
&& mMode != NavMeshMode::UpdateFrequency)
|
||||
&& mMode != Settings::NavMeshRenderMode::UpdateFrequency)
|
||||
continue;
|
||||
|
||||
osg::ref_ptr<osg::Group> group;
|
||||
|
@ -163,7 +163,7 @@ namespace MWRender
|
|||
};
|
||||
|
||||
NavMesh::NavMesh(const osg::ref_ptr<osg::Group>& root, const osg::ref_ptr<SceneUtil::WorkQueue>& workQueue,
|
||||
bool enabled, NavMeshMode mode)
|
||||
bool enabled, Settings::NavMeshRenderMode mode)
|
||||
: mRootNode(root)
|
||||
, mWorkQueue(workQueue)
|
||||
, mGroupStateSet(SceneUtil::makeNavMeshTileStateSet())
|
||||
|
@ -310,7 +310,7 @@ namespace MWRender
|
|||
mEnabled = false;
|
||||
}
|
||||
|
||||
void NavMesh::setMode(NavMeshMode value)
|
||||
void NavMesh::setMode(Settings::NavMeshRenderMode value)
|
||||
{
|
||||
if (mMode == value)
|
||||
return;
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
#ifndef OPENMW_MWRENDER_NAVMESH_H
|
||||
#define OPENMW_MWRENDER_NAVMESH_H
|
||||
|
||||
#include "navmeshmode.hpp"
|
||||
|
||||
#include <components/detournavigator/tileposition.hpp>
|
||||
#include <components/detournavigator/version.hpp>
|
||||
#include <components/misc/guarded.hpp>
|
||||
#include <components/settings/navmeshrendermode.hpp>
|
||||
|
||||
#include <osg/ref_ptr>
|
||||
|
||||
|
@ -41,7 +40,7 @@ namespace MWRender
|
|||
{
|
||||
public:
|
||||
explicit NavMesh(const osg::ref_ptr<osg::Group>& root, const osg::ref_ptr<SceneUtil::WorkQueue>& workQueue,
|
||||
bool enabled, NavMeshMode mode);
|
||||
bool enabled, Settings::NavMeshRenderMode mode);
|
||||
~NavMesh();
|
||||
|
||||
bool toggle();
|
||||
|
@ -57,7 +56,7 @@ namespace MWRender
|
|||
|
||||
bool isEnabled() const { return mEnabled; }
|
||||
|
||||
void setMode(NavMeshMode value);
|
||||
void setMode(Settings::NavMeshRenderMode value);
|
||||
|
||||
private:
|
||||
struct Tile
|
||||
|
@ -75,7 +74,7 @@ namespace MWRender
|
|||
osg::ref_ptr<osg::StateSet> mGroupStateSet;
|
||||
osg::ref_ptr<osg::StateSet> mDebugDrawStateSet;
|
||||
bool mEnabled;
|
||||
NavMeshMode mMode;
|
||||
Settings::NavMeshRenderMode mMode;
|
||||
std::size_t mId;
|
||||
DetourNavigator::Version mVersion;
|
||||
std::map<DetourNavigator::TilePosition, Tile> mTiles;
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
#include "navmeshmode.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
namespace MWRender
|
||||
{
|
||||
NavMeshMode parseNavMeshMode(std::string_view value)
|
||||
{
|
||||
if (value == "area type")
|
||||
return NavMeshMode::AreaType;
|
||||
if (value == "update frequency")
|
||||
return NavMeshMode::UpdateFrequency;
|
||||
throw std::logic_error("Unsupported navigation mesh rendering mode: " + std::string(value));
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
#ifndef OPENMW_MWRENDER_NAVMESHMODE_H
|
||||
#define OPENMW_MWRENDER_NAVMESHMODE_H
|
||||
|
||||
#include <string_view>
|
||||
|
||||
namespace MWRender
|
||||
{
|
||||
enum class NavMeshMode
|
||||
{
|
||||
AreaType,
|
||||
UpdateFrequency,
|
||||
};
|
||||
|
||||
NavMeshMode parseNavMeshMode(std::string_view value);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -425,13 +425,10 @@ namespace MWRender
|
|||
// It is unnecessary to stop/start the viewer as no frames are being rendered yet.
|
||||
mResourceSystem->getSceneManager()->getShaderManager().setGlobalDefines(globalDefines);
|
||||
|
||||
mNavMesh = std::make_unique<NavMesh>(mRootNode, mWorkQueue,
|
||||
Settings::Manager::getBool("enable nav mesh render", "Navigator"),
|
||||
parseNavMeshMode(Settings::Manager::getString("nav mesh render mode", "Navigator")));
|
||||
mActorsPaths = std::make_unique<ActorsPaths>(
|
||||
mRootNode, Settings::Manager::getBool("enable agents paths render", "Navigator"));
|
||||
mRecastMesh = std::make_unique<RecastMesh>(
|
||||
mRootNode, Settings::Manager::getBool("enable recast mesh render", "Navigator"));
|
||||
mNavMesh = std::make_unique<NavMesh>(mRootNode, mWorkQueue, Settings::navigator().mEnableNavMeshRender,
|
||||
Settings::navigator().mNavMeshRenderMode);
|
||||
mActorsPaths = std::make_unique<ActorsPaths>(mRootNode, Settings::navigator().mEnableAgentsPathsRender);
|
||||
mRecastMesh = std::make_unique<RecastMesh>(mRootNode, Settings::navigator().mEnableRecastMeshRender);
|
||||
mPathgrid = std::make_unique<Pathgrid>(mRootNode);
|
||||
|
||||
mObjects = std::make_unique<Objects>(mResourceSystem, sceneRoot, unrefQueue);
|
||||
|
@ -1666,7 +1663,7 @@ namespace MWRender
|
|||
mObjectPaging->getPagedRefnums(activeGrid, out);
|
||||
}
|
||||
|
||||
void RenderingManager::setNavMeshMode(NavMeshMode value)
|
||||
void RenderingManager::setNavMeshMode(Settings::NavMeshRenderMode value)
|
||||
{
|
||||
mNavMesh->setMode(value);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
#include <osgUtil/IncrementalCompileOperation>
|
||||
|
||||
#include "navmeshmode.hpp"
|
||||
#include "objects.hpp"
|
||||
#include "renderinginterface.hpp"
|
||||
#include "rendermode.hpp"
|
||||
|
@ -275,7 +274,7 @@ namespace MWRender
|
|||
|
||||
void setScreenRes(int width, int height);
|
||||
|
||||
void setNavMeshMode(NavMeshMode value);
|
||||
void setNavMeshMode(Settings::NavMeshRenderMode value);
|
||||
|
||||
private:
|
||||
void updateTextureFiltering();
|
||||
|
|
|
@ -294,7 +294,7 @@ namespace MWWorld
|
|||
{
|
||||
mPhysics = std::make_unique<MWPhysics::PhysicsSystem>(mResourceSystem, rootNode);
|
||||
|
||||
if (Settings::Manager::getBool("enable", "Navigator"))
|
||||
if (Settings::navigator().mEnable)
|
||||
{
|
||||
auto navigatorSettings = DetourNavigator::makeSettingsFromSettingsManager();
|
||||
navigatorSettings.mRecast.mSwimHeightScale = mSwimHeightScale;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "components/settings/sanitizerimpl.hpp"
|
||||
#include "components/settings/settingvalue.hpp"
|
||||
#include <components/settings/navmeshrendermode.hpp>
|
||||
|
||||
#include <osg/Math>
|
||||
#include <osg/Vec2f>
|
||||
|
@ -52,8 +53,7 @@ namespace Settings
|
|||
SettingValue<std::string> mRecastMeshPathPrefix{ mIndex, "Navigator", "recast mesh path prefix" };
|
||||
SettingValue<std::string> mNavMeshPathPrefix{ mIndex, "Navigator", "nav mesh path prefix" };
|
||||
SettingValue<bool> mEnableNavMeshRender{ mIndex, "Navigator", "enable nav mesh render" };
|
||||
SettingValue<std::string> mNavMeshRenderMode{ mIndex, "Navigator", "nav mesh render mode",
|
||||
makeEnumSanitizerString({ "area type", "update frequency" }) };
|
||||
SettingValue<NavMeshRenderMode> mNavMeshRenderMode{ mIndex, "Navigator", "nav mesh render mode" };
|
||||
SettingValue<bool> mEnableAgentsPathsRender{ mIndex, "Navigator", "enable agents paths render" };
|
||||
SettingValue<bool> mEnableRecastMeshRender{ mIndex, "Navigator", "enable recast mesh render" };
|
||||
SettingValue<int> mMaxTilesNumber{ mIndex, "Navigator", "max tiles number", makeMaxSanitizerInt(0) };
|
||||
|
|
13
components/settings/navmeshrendermode.hpp
Normal file
13
components/settings/navmeshrendermode.hpp
Normal file
|
@ -0,0 +1,13 @@
|
|||
#ifndef OPENMW_COMPONENTS_SETTINGS_NAVMESHRENDERMODE_H
|
||||
#define OPENMW_COMPONENTS_SETTINGS_NAVMESHRENDERMODE_H
|
||||
|
||||
namespace Settings
|
||||
{
|
||||
enum class NavMeshRenderMode
|
||||
{
|
||||
AreaType,
|
||||
UpdateFrequency,
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -481,4 +481,14 @@ namespace Settings
|
|||
|
||||
throw std::runtime_error("Invalid gyroscope axis: " + std::string(value));
|
||||
}
|
||||
|
||||
NavMeshRenderMode parseNavMeshRenderMode(std::string_view value)
|
||||
{
|
||||
if (value == "area type")
|
||||
return NavMeshRenderMode::AreaType;
|
||||
if (value == "update frequency")
|
||||
return NavMeshRenderMode::UpdateFrequency;
|
||||
|
||||
throw std::invalid_argument("Invalid navigation mesh rendering mode: " + std::string(value));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "categories.hpp"
|
||||
#include "gyroscopeaxis.hpp"
|
||||
#include "navmeshrendermode.hpp"
|
||||
|
||||
#include "components/detournavigator/collisionshapetype.hpp"
|
||||
|
||||
|
@ -206,6 +207,14 @@ namespace Settings
|
|||
{
|
||||
return parseGyroscopeAxis(getString(setting, category));
|
||||
}
|
||||
|
||||
NavMeshRenderMode parseNavMeshRenderMode(std::string_view value);
|
||||
|
||||
template <>
|
||||
inline NavMeshRenderMode Manager::getImpl<NavMeshRenderMode>(std::string_view setting, std::string_view category)
|
||||
{
|
||||
return parseNavMeshRenderMode(getString(setting, category));
|
||||
}
|
||||
}
|
||||
|
||||
#endif // COMPONENTS_SETTINGS_H
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define OPENMW_COMPONENTS_SETTINGS_SETTINGVALUE_H
|
||||
|
||||
#include "gyroscopeaxis.hpp"
|
||||
#include "navmeshrendermode.hpp"
|
||||
#include "sanitizer.hpp"
|
||||
#include "settings.hpp"
|
||||
|
||||
|
@ -38,6 +39,7 @@ namespace Settings
|
|||
StringArray,
|
||||
MyGuiColour,
|
||||
GyroscopeAxis,
|
||||
NavMeshRenderMode,
|
||||
};
|
||||
|
||||
template <class T>
|
||||
|
@ -139,6 +141,12 @@ namespace Settings
|
|||
return SettingValueType::GyroscopeAxis;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline constexpr SettingValueType getSettingValueType<NavMeshRenderMode>()
|
||||
{
|
||||
return SettingValueType::NavMeshRenderMode;
|
||||
}
|
||||
|
||||
inline constexpr std::string_view getSettingValueTypeName(SettingValueType type)
|
||||
{
|
||||
switch (type)
|
||||
|
@ -175,6 +183,8 @@ namespace Settings
|
|||
return "colour";
|
||||
case SettingValueType::GyroscopeAxis:
|
||||
return "gyroscope axis";
|
||||
case SettingValueType::NavMeshRenderMode:
|
||||
return "navmesh render mode";
|
||||
}
|
||||
return "unsupported";
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue