From d06e69735694afdb96a68a9842260c6691cac35b Mon Sep 17 00:00:00 2001 From: elsid Date: Sat, 16 Oct 2021 00:22:40 +0200 Subject: [PATCH] Initialize RenderingManager fields before use PostProcessor is constructed before mNearClip, mViewDistance, mFieldOfView are initialized and the constructor calls updateProjectionMatrix that uses these fields. ==16218== Conditional jump or move depends on uninitialised value(s) ==16218== at 0x722EBE: min (stl_algobase.h:235) ==16218== by 0x722EBE: MWRender::RenderingManager::updateProjectionMatrix() (renderingmanager.cpp:1183) ==16218== by 0x7D022F: MWRender::PostProcessor::PostProcessor(MWRender::RenderingManager&, osgViewer::Viewer*, osg::Group*) (postprocessor.cpp:144) ==16218== by 0x728B41: MWRender::RenderingManager::RenderingManager(osgViewer::Viewer*, osg::ref_ptr, Resource::ResourceSystem*, SceneUtil::WorkQueue*, std::__cxx11::basic_string, std::allocator > const&, DetourNavigator::Navigator&) (renderingmanager.cpp:452) ==16218== by 0xBB5E65: MWWorld::World::World(osgViewer::Viewer*, osg::ref_ptr, Resource::ResourceSystem*, SceneUtil::WorkQueue*, Files::Collections const&, std::vector, std::allocator >, std::allocator, std::allocator > > > const&, std::vector, std::allocator >, std::allocator, std::allocator > > > const&, ToUTF8::Utf8Encoder*, int, std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&) (worldimp.cpp:190) ==16218== by 0xDEEA6F: OMW::Engine::prepareEngine(Settings::Manager&) (engine.cpp:789) ==16218== by 0xDF2068: OMW::Engine::go() (engine.cpp:959) ==16218== by 0xDE7B8F: runApplication(int, char**) (main.cpp:220) ==16218== by 0x1006593: wrapApplication(int (*)(int, char**), int, char**, std::__cxx11::basic_string, std::allocator > const&) (debugging.cpp:205) ==16218== by 0x7152C3: main (main.cpp:232) ==16218== ==17455== Conditional jump or move depends on uninitialised value(s) ==17455== at 0x4F8613F: osg::Matrixd::makeFrustum(double, double, double, double, double, double) (Matrix_implementation.cpp:916) ==17455== by 0x4EC0E11: osg::Camera::setProjectionMatrixAsPerspective(double, double, double, double) (Matrixd:580) ==17455== by 0x722DDA: MWRender::RenderingManager::updateProjectionMatrix() (renderingmanager.cpp:1167) ==17455== by 0x7D01EF: MWRender::PostProcessor::PostProcessor(MWRender::RenderingManager&, osgViewer::Viewer*, osg::Group*) (postprocessor.cpp:144) ==17455== by 0x728BA1: MWRender::RenderingManager::RenderingManager(osgViewer::Viewer*, osg::ref_ptr, Resource::ResourceSystem*, SceneUtil::WorkQueue*, std::__cxx11::basic_string, std::allocator > const&, DetourNavigator::Navigator&) (renderingmanager.cpp:453) ==17455== by 0xBB5E25: MWWorld::World::World(osgViewer::Viewer*, osg::ref_ptr, Resource::ResourceSystem*, SceneUtil::WorkQueue*, Files::Collections const&, std::vector, std::allocator >, std::allocator, std::allocator > > > const&, std::vector, std::allocator >, std::allocator, std::allocator > > > const&, ToUTF8::Utf8Encoder*, int, std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&) (worldimp.cpp:190) ==17455== by 0xDEEA3F: OMW::Engine::prepareEngine(Settings::Manager&) (engine.cpp:789) ==17455== by 0xDF2038: OMW::Engine::go() (engine.cpp:959) ==17455== by 0xDE7B5F: runApplication(int, char**) (main.cpp:220) ==17455== by 0x1006563: wrapApplication(int (*)(int, char**), int, char**, std::__cxx11::basic_string, std::allocator > const&) (debugging.cpp:205) ==17455== by 0x7152C3: main (main.cpp:232) ==17455== --- apps/openmw/mwrender/renderingmanager.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 120f97e892..14000273db 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -293,8 +293,13 @@ namespace MWRender , mNavigator(navigator) , mMinimumAmbientLuminance(0.f) , mNightEyeFactor(0.f) + // TODO: Near clip should not need to be bounded like this, but too small values break OSG shadow calculations CPU-side. + // See issue: #6072 + , mNearClip(std::max(0.005f, Settings::Manager::getFloat("near clip", "Camera"))) + , mViewDistance(Settings::Manager::getFloat("viewing distance", "Camera")) , mFieldOfViewOverridden(false) , mFieldOfViewOverride(0.f) + , mFieldOfView(std::min(std::max(1.f, Settings::Manager::getFloat("field of view", "Camera")), 179.f)) { bool reverseZ = SceneUtil::getReverseZ(); @@ -515,12 +520,6 @@ namespace MWRender NifOsg::Loader::setIntersectionDisabledNodeMask(Mask_Effect); Nif::NIFFile::setLoadUnsupportedFiles(Settings::Manager::getBool("load unsupported nif files", "Models")); - // TODO: Near clip should not need to be bounded like this, but too small values break OSG shadow calculations CPU-side. - // See issue: #6072 - mNearClip = std::max(0.005f, Settings::Manager::getFloat("near clip", "Camera")); - mViewDistance = Settings::Manager::getFloat("viewing distance", "Camera"); - float fov = Settings::Manager::getFloat("field of view", "Camera"); - mFieldOfView = std::min(std::max(1.f, fov), 179.f); float firstPersonFov = Settings::Manager::getFloat("first person field of view", "Camera"); mFirstPersonFieldOfView = std::min(std::max(1.f, firstPersonFov), 179.f); mStateUpdater->setFogEnd(mViewDistance);