mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-13 00:44:56 +00:00
Merge branch 'recast_log_level' into 'master'
Support max log level for Recast via env variable See merge request OpenMW/openmw!4596
This commit is contained in:
commit
57fb334a6e
@ -225,7 +225,8 @@ namespace NavMeshTool
|
|||||||
Resource::SceneManager sceneManager(&vfs, &imageManager, &nifFileManager, &bgsmFileManager, expiryDelay);
|
Resource::SceneManager sceneManager(&vfs, &imageManager, &nifFileManager, &bgsmFileManager, expiryDelay);
|
||||||
Resource::BulletShapeManager bulletShapeManager(&vfs, &sceneManager, &nifFileManager, expiryDelay);
|
Resource::BulletShapeManager bulletShapeManager(&vfs, &sceneManager, &nifFileManager, expiryDelay);
|
||||||
DetourNavigator::RecastGlobalAllocator::init();
|
DetourNavigator::RecastGlobalAllocator::init();
|
||||||
DetourNavigator::Settings navigatorSettings = DetourNavigator::makeSettingsFromSettingsManager();
|
DetourNavigator::Settings navigatorSettings
|
||||||
|
= DetourNavigator::makeSettingsFromSettingsManager(Debug::getRecastMaxLogLevel());
|
||||||
navigatorSettings.mRecast.mSwimHeightScale
|
navigatorSettings.mRecast.mSwimHeightScale
|
||||||
= EsmLoader::getGameSetting(esmData.mGameSettings, "fSwimHeightScale").getFloat();
|
= EsmLoader::getGameSetting(esmData.mGameSettings, "fSwimHeightScale").getFloat();
|
||||||
|
|
||||||
|
@ -847,7 +847,7 @@ void OMW::Engine::prepareEngine()
|
|||||||
}
|
}
|
||||||
listener->loadingOff();
|
listener->loadingOff();
|
||||||
|
|
||||||
mWorld->init(mViewer, std::move(rootNode), mWorkQueue.get(), *mUnrefQueue);
|
mWorld->init(mMaxRecastLogLevel, mViewer, std::move(rootNode), mWorkQueue.get(), *mUnrefQueue);
|
||||||
mEnvironment.setWorldScene(mWorld->getWorldScene());
|
mEnvironment.setWorldScene(mWorld->getWorldScene());
|
||||||
mWorld->setupPlayer();
|
mWorld->setupPlayer();
|
||||||
mWorld->setRandomSeed(mRandomSeed);
|
mWorld->setRandomSeed(mRandomSeed);
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
#include <components/compiler/extensions.hpp>
|
#include <components/compiler/extensions.hpp>
|
||||||
|
#include <components/debug/debuglog.hpp>
|
||||||
#include <components/esm/refid.hpp>
|
#include <components/esm/refid.hpp>
|
||||||
#include <components/files/collections.hpp>
|
#include <components/files/collections.hpp>
|
||||||
#include <components/settings/settings.hpp>
|
#include <components/settings/settings.hpp>
|
||||||
@ -172,6 +173,7 @@ namespace OMW
|
|||||||
bool mGrab;
|
bool mGrab;
|
||||||
|
|
||||||
unsigned int mRandomSeed;
|
unsigned int mRandomSeed;
|
||||||
|
Debug::Level mMaxRecastLogLevel = Debug::Error;
|
||||||
|
|
||||||
Compiler::Extensions mExtensions;
|
Compiler::Extensions mExtensions;
|
||||||
std::unique_ptr<Compiler::Context> mScriptContext;
|
std::unique_ptr<Compiler::Context> mScriptContext;
|
||||||
@ -180,6 +182,9 @@ namespace OMW
|
|||||||
Translation::Storage mTranslationDataStorage;
|
Translation::Storage mTranslationDataStorage;
|
||||||
bool mNewGame;
|
bool mNewGame;
|
||||||
|
|
||||||
|
Files::ConfigurationManager& mCfgMgr;
|
||||||
|
int mGlMaxTextureImageUnits;
|
||||||
|
|
||||||
// not implemented
|
// not implemented
|
||||||
Engine(const Engine&);
|
Engine(const Engine&);
|
||||||
Engine& operator=(const Engine&);
|
Engine& operator=(const Engine&);
|
||||||
@ -256,9 +261,7 @@ namespace OMW
|
|||||||
|
|
||||||
void setRandomSeed(unsigned int seed);
|
void setRandomSeed(unsigned int seed);
|
||||||
|
|
||||||
private:
|
void setRecastMaxLogLevel(Debug::Level value) { mMaxRecastLogLevel = value; }
|
||||||
Files::ConfigurationManager& mCfgMgr;
|
|
||||||
int mGlMaxTextureImageUnits;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,6 +220,8 @@ int runApplication(int argc, char* argv[])
|
|||||||
Files::ConfigurationManager cfgMgr;
|
Files::ConfigurationManager cfgMgr;
|
||||||
std::unique_ptr<OMW::Engine> engine = std::make_unique<OMW::Engine>(cfgMgr);
|
std::unique_ptr<OMW::Engine> engine = std::make_unique<OMW::Engine>(cfgMgr);
|
||||||
|
|
||||||
|
engine->setRecastMaxLogLevel(Debug::getRecastMaxLogLevel());
|
||||||
|
|
||||||
if (parseOptions(argc, argv, *engine, cfgMgr))
|
if (parseOptions(argc, argv, *engine, cfgMgr))
|
||||||
{
|
{
|
||||||
if (!Misc::checkRequiredOSGPluginsArePresent())
|
if (!Misc::checkRequiredOSGPluginsArePresent())
|
||||||
|
@ -290,14 +290,14 @@ namespace MWWorld
|
|||||||
mSwimHeightScale = mStore.get<ESM::GameSetting>().find("fSwimHeightScale")->mValue.getFloat();
|
mSwimHeightScale = mStore.get<ESM::GameSetting>().find("fSwimHeightScale")->mValue.getFloat();
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::init(osgViewer::Viewer* viewer, osg::ref_ptr<osg::Group> rootNode, SceneUtil::WorkQueue* workQueue,
|
void World::init(Debug::Level maxRecastLogLevel, osgViewer::Viewer* viewer, osg::ref_ptr<osg::Group> rootNode,
|
||||||
SceneUtil::UnrefQueue& unrefQueue)
|
SceneUtil::WorkQueue* workQueue, SceneUtil::UnrefQueue& unrefQueue)
|
||||||
{
|
{
|
||||||
mPhysics = std::make_unique<MWPhysics::PhysicsSystem>(mResourceSystem, rootNode);
|
mPhysics = std::make_unique<MWPhysics::PhysicsSystem>(mResourceSystem, rootNode);
|
||||||
|
|
||||||
if (Settings::navigator().mEnable)
|
if (Settings::navigator().mEnable)
|
||||||
{
|
{
|
||||||
auto navigatorSettings = DetourNavigator::makeSettingsFromSettingsManager();
|
auto navigatorSettings = DetourNavigator::makeSettingsFromSettingsManager(maxRecastLogLevel);
|
||||||
navigatorSettings.mRecast.mSwimHeightScale = mSwimHeightScale;
|
navigatorSettings.mRecast.mSwimHeightScale = mSwimHeightScale;
|
||||||
mNavigator = DetourNavigator::makeNavigator(navigatorSettings, mUserDataPath);
|
mNavigator = DetourNavigator::makeNavigator(navigatorSettings, mUserDataPath);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <osg/Timer>
|
#include <osg/Timer>
|
||||||
#include <osg/ref_ptr>
|
#include <osg/ref_ptr>
|
||||||
|
|
||||||
|
#include <components/debug/debuglog.hpp>
|
||||||
#include <components/esm3/readerscache.hpp>
|
#include <components/esm3/readerscache.hpp>
|
||||||
#include <components/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
#include <components/settings/settings.hpp>
|
#include <components/settings/settings.hpp>
|
||||||
@ -201,8 +202,8 @@ namespace MWWorld
|
|||||||
Loading::Listener* listener);
|
Loading::Listener* listener);
|
||||||
|
|
||||||
// Must be called after `loadData`.
|
// Must be called after `loadData`.
|
||||||
void init(osgViewer::Viewer* viewer, osg::ref_ptr<osg::Group> rootNode, SceneUtil::WorkQueue* workQueue,
|
void init(Debug::Level maxRecastLogLevel, osgViewer::Viewer* viewer, osg::ref_ptr<osg::Group> rootNode,
|
||||||
SceneUtil::UnrefQueue& unrefQueue);
|
SceneUtil::WorkQueue* workQueue, SceneUtil::UnrefQueue& unrefQueue);
|
||||||
|
|
||||||
virtual ~World();
|
virtual ~World();
|
||||||
|
|
||||||
|
@ -324,6 +324,22 @@ namespace Debug
|
|||||||
First mFirst;
|
First mFirst;
|
||||||
Second mSecond;
|
Second mSecond;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Level toLevel(std::string_view value)
|
||||||
|
{
|
||||||
|
if (value == "ERROR")
|
||||||
|
return Error;
|
||||||
|
if (value == "WARNING")
|
||||||
|
return Warning;
|
||||||
|
if (value == "INFO")
|
||||||
|
return Info;
|
||||||
|
if (value == "VERBOSE")
|
||||||
|
return Verbose;
|
||||||
|
if (value == "DEBUG")
|
||||||
|
return Debug;
|
||||||
|
|
||||||
|
return Verbose;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -359,23 +375,19 @@ namespace Debug
|
|||||||
Level getDebugLevel()
|
Level getDebugLevel()
|
||||||
{
|
{
|
||||||
if (const char* env = getenv("OPENMW_DEBUG_LEVEL"))
|
if (const char* env = getenv("OPENMW_DEBUG_LEVEL"))
|
||||||
{
|
return toLevel(env);
|
||||||
const std::string_view value(env);
|
|
||||||
if (value == "ERROR")
|
|
||||||
return Error;
|
|
||||||
if (value == "WARNING")
|
|
||||||
return Warning;
|
|
||||||
if (value == "INFO")
|
|
||||||
return Info;
|
|
||||||
if (value == "VERBOSE")
|
|
||||||
return Verbose;
|
|
||||||
if (value == "DEBUG")
|
|
||||||
return Debug;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Verbose;
|
return Verbose;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Level getRecastMaxLogLevel()
|
||||||
|
{
|
||||||
|
if (const char* env = getenv("OPENMW_RECAST_MAX_LOG_LEVEL"))
|
||||||
|
return toLevel(env);
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
|
||||||
void setupLogging(const std::filesystem::path& logDir, std::string_view appName)
|
void setupLogging(const std::filesystem::path& logDir, std::string_view appName)
|
||||||
{
|
{
|
||||||
Log::sMinDebugLevel = getDebugLevel();
|
Log::sMinDebugLevel = getDebugLevel();
|
||||||
|
@ -36,6 +36,8 @@ namespace Debug
|
|||||||
|
|
||||||
Level getDebugLevel();
|
Level getDebugLevel();
|
||||||
|
|
||||||
|
Level getRecastMaxLogLevel();
|
||||||
|
|
||||||
// Redirect cout and cerr to the log file
|
// Redirect cout and cerr to the log file
|
||||||
void setupLogging(const std::filesystem::path& logDir, std::string_view appName);
|
void setupLogging(const std::filesystem::path& logDir, std::string_view appName);
|
||||||
|
|
||||||
|
@ -523,7 +523,7 @@ namespace DetourNavigator
|
|||||||
std::unique_ptr<PreparedNavMeshData> prepareNavMeshTileData(const RecastMesh& recastMesh, ESM::RefId worldspace,
|
std::unique_ptr<PreparedNavMeshData> prepareNavMeshTileData(const RecastMesh& recastMesh, ESM::RefId worldspace,
|
||||||
const TilePosition& tilePosition, const AgentBounds& agentBounds, const RecastSettings& settings)
|
const TilePosition& tilePosition, const AgentBounds& agentBounds, const RecastSettings& settings)
|
||||||
{
|
{
|
||||||
RecastContext context(worldspace, tilePosition, agentBounds);
|
RecastContext context(worldspace, tilePosition, agentBounds, settings.mMaxLogLevel);
|
||||||
|
|
||||||
const auto [minZ, maxZ] = getBoundsByZ(recastMesh, agentBounds.mHalfExtents.z(), settings);
|
const auto [minZ, maxZ] = getBoundsByZ(recastMesh, agentBounds.mHalfExtents.z(), settings);
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "recastcontext.hpp"
|
#include "recastcontext.hpp"
|
||||||
#include "debug.hpp"
|
#include "debug.hpp"
|
||||||
|
|
||||||
#include "components/debug/debuglog.hpp"
|
#include <components/debug/debuglog.hpp>
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
@ -33,15 +33,20 @@ namespace DetourNavigator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RecastContext::RecastContext(
|
RecastContext::RecastContext(ESM::RefId worldspace, const TilePosition& tilePosition,
|
||||||
ESM::RefId worldspace, const TilePosition& tilePosition, const AgentBounds& agentBounds)
|
const AgentBounds& agentBounds, Debug::Level maxLogLevel)
|
||||||
: mPrefix(formatPrefix(worldspace, tilePosition, agentBounds))
|
: mMaxLogLevel(maxLogLevel)
|
||||||
|
, mPrefix(formatPrefix(worldspace, tilePosition, agentBounds))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void RecastContext::doLog(const rcLogCategory category, const char* msg, const int len)
|
void RecastContext::doLog(const rcLogCategory category, const char* msg, const int len)
|
||||||
{
|
{
|
||||||
if (len > 0)
|
if (msg == nullptr || len <= 0)
|
||||||
Log(getLogLevel(category)) << mPrefix << std::string_view(msg, static_cast<std::size_t>(len));
|
return;
|
||||||
|
const Debug::Level level = getLogLevel(category);
|
||||||
|
if (level > mMaxLogLevel)
|
||||||
|
return;
|
||||||
|
Log(level) << mPrefix << std::string_view(msg, static_cast<std::size_t>(len));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "tileposition.hpp"
|
#include "tileposition.hpp"
|
||||||
|
|
||||||
|
#include <components/debug/debuglog.hpp>
|
||||||
#include <components/esm/refid.hpp>
|
#include <components/esm/refid.hpp>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -16,11 +17,13 @@ namespace DetourNavigator
|
|||||||
class RecastContext final : public rcContext
|
class RecastContext final : public rcContext
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit RecastContext(ESM::RefId worldspace, const TilePosition& tilePosition, const AgentBounds& agentBounds);
|
explicit RecastContext(ESM::RefId worldspace, const TilePosition& tilePosition, const AgentBounds& agentBounds,
|
||||||
|
Debug::Level maxLogLevel);
|
||||||
|
|
||||||
const std::string& getPrefix() const { return mPrefix; }
|
const std::string& getPrefix() const { return mPrefix; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Debug::Level mMaxLogLevel;
|
||||||
std::string mPrefix;
|
std::string mPrefix;
|
||||||
|
|
||||||
void doLog(rcLogCategory category, const char* msg, int len) override;
|
void doLog(rcLogCategory category, const char* msg, int len) override;
|
||||||
|
@ -44,7 +44,7 @@ namespace DetourNavigator
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
RecastSettings makeRecastSettingsFromSettingsManager()
|
RecastSettings makeRecastSettingsFromSettingsManager(Debug::Level maxLogLevel)
|
||||||
{
|
{
|
||||||
RecastSettings result;
|
RecastSettings result;
|
||||||
|
|
||||||
@ -63,6 +63,7 @@ namespace DetourNavigator
|
|||||||
result.mRegionMergeArea = ::Settings::navigator().mRegionMergeArea;
|
result.mRegionMergeArea = ::Settings::navigator().mRegionMergeArea;
|
||||||
result.mRegionMinArea = ::Settings::navigator().mRegionMinArea;
|
result.mRegionMinArea = ::Settings::navigator().mRegionMinArea;
|
||||||
result.mTileSize = ::Settings::navigator().mTileSize;
|
result.mTileSize = ::Settings::navigator().mTileSize;
|
||||||
|
result.mMaxLogLevel = maxLogLevel;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -80,11 +81,11 @@ namespace DetourNavigator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings makeSettingsFromSettingsManager()
|
Settings makeSettingsFromSettingsManager(Debug::Level maxLogLevel)
|
||||||
{
|
{
|
||||||
Settings result;
|
Settings result;
|
||||||
|
|
||||||
result.mRecast = makeRecastSettingsFromSettingsManager();
|
result.mRecast = makeRecastSettingsFromSettingsManager(maxLogLevel);
|
||||||
result.mDetour = makeDetourSettingsFromSettingsManager();
|
result.mDetour = makeDetourSettingsFromSettingsManager();
|
||||||
|
|
||||||
const NavMeshLimits limits = getNavMeshTileLimits(result.mDetour);
|
const NavMeshLimits limits = getNavMeshTileLimits(result.mDetour);
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_SETTINGS_H
|
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_SETTINGS_H
|
||||||
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_SETTINGS_H
|
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_SETTINGS_H
|
||||||
|
|
||||||
|
#include <components/debug/debuglog.hpp>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -23,6 +25,7 @@ namespace DetourNavigator
|
|||||||
int mRegionMergeArea = 0;
|
int mRegionMergeArea = 0;
|
||||||
int mRegionMinArea = 0;
|
int mRegionMinArea = 0;
|
||||||
int mTileSize = 0;
|
int mTileSize = 0;
|
||||||
|
Debug::Level mMaxLogLevel = Debug::Error;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DetourSettings
|
struct DetourSettings
|
||||||
@ -55,7 +58,7 @@ namespace DetourNavigator
|
|||||||
|
|
||||||
inline constexpr std::int64_t navMeshFormatVersion = 2;
|
inline constexpr std::int64_t navMeshFormatVersion = 2;
|
||||||
|
|
||||||
Settings makeSettingsFromSettingsManager();
|
Settings makeSettingsFromSettingsManager(Debug::Level maxLogLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user