Commit Graph

793 Commits (master)

Author SHA1 Message Date
Bo Svensson 1960e976e2
refactors stringops.hpp (#3192)
With this PR we refactor `StringUtils::replaceAll` to accept `string_view` as suggested in a code comment. In addition, while we are touching this rebuild happy file, we slim it down a bit by moving a few sparingly used functions elsewhere.
3 years ago
Bo Svensson 5debd6e25a
removes two dummy serialisers (#3212)
This PR removes dummy serialisers for `StateSetUpdater`, `NodeCallback` and the respective `META` macros that trigger serialisation requirement here.

`StateSetUpdater` and `NodeCallback` are just base classes that can not be used on their own, so there is no need to incorporate them into serialisation. These changes might have minor effects on derived classes that forget to override `className()`, `libraryName()` through `META`, but it makes hardly a difference to now serialise such classes as a dysfunctional `osg::Callback` instead of a dysfunctional `SceneUtil::NodeCallback`.
3 years ago
Bo Svensson 1979ee1491
refactors hashed std::map (#3199)
We currently apply a strange algorithm to `LightManager::mStateSetCache`. For some reason this algorithm inserts hashed keys into `std::map` in a way that fails to handle hash collisions and exhibits worse lookup complexity than `std::unordered_map`. With this PR we just use `std::unordered_map` here.
3 years ago
Evil Eye a9106f4d7c Rotate torches by 90 degrees 3 years ago
Bo Svensson b9911da4c7
applies lightMask (#3201)
With this PR we apply `lightMask` to a `Transform` node we create specifically for a light. This mask will allow us to stop traversing such nodes sooner and avoid costly processing associated with `Transform` nodes in the cull visitor.
3 years ago
Bo Svensson 356e9d7cf0
refactors osg::Callback virtual inheritance (#3200)
With this PR we refactor `SceneUtil::KeyframeController` not to require `virtual osg::Callback` inheritance. I suppose such `virtual` overhead is not justified here because it negatively impacts many other classes we derive from `osg::Callback`.
3 years ago
Bret Curtis ac02753da7
Merge pull request #3190 from akortunov/master
Fix showscenegraph warnings
3 years ago
Bo Svensson 7f9beac3a7
refactors a case insensitive map (#3184)
This PR aims to spark the retirement of a questionable pattern I have found all over our code base. I will illustrate how this pattern encourages code duplication, lacks type safety, requires documentation and can be prone to bugs.
```
std::map<std::string, Object> mMap; // Stored in all lowercase for a case-insensitive lookup

std::string lowerKey = Misc::StringUtils::lowerCase(key);
mMap.emplace(lowerKey, object);

std::string lowerKey = Misc::StringUtils::lowerCase(key);
mMap.find(lowerKey);

mMap.find(key); // Not found. Oops!
```
An alternative approach produces no such issues.
```
std::unordered_map<std::string, Object, Misc::StringUtils::CiHash, Misc::StringUtils::CiEqual> mMap;

mMap.emplace(key, object);

mMap.find(key);
```
Of course, such an alternative will work for a `map` as well, but an `unordered_map` is generally preferable over a `map` with these changes because we have moved `lowerCase` into the comparison operator. 

In this PR I have refactored `Animation::mNodeMap` accordingly. I have reviewed and adapted all direct and indirect usage of `Animation::mNodeMap` to ensure we do not change behaviour with this PR.
3 years ago
Andrei Kortunov 566380c0d6 Fix showscenegraph warnings 3 years ago
Bo Svensson c9c8d02332
fixes a crash (#3183)
This PR fixes a crash caused by the improperly ensured lifetime of RigGeometry::mSourceGeometry. mSourceGeometry was not adequate to ensure mSourceGeometry would outlive mGeometry because we extend mGeometrys lifetime beyond this lifetime by passing mGeometry to the draw traversal instead of this.
In addition,

We add important comments.
We detect and prevent generally unsafe operations in high level code.
We add a sprinkling of const to help clarify intentions.
3 years ago
Bo Svensson a854a6e04a
removes UnrefQueue (#3181)
Currently, we use an `UnrefQueue` which supposedly aims to transfer destruction costs to another thread. The implications of this unusual pattern can not be well understood because some allocators might free resources more efficiently if they are freed by the same thread that allocated them. In addition, `UnrefQueue` complicates the validation of thread safety in our engine. Lastly, our current usage of `UnrefQueue` triggers `ref()`, `unref()` atomic operations as objects are passed into the queue. These operations could be more expensive than the actual destruction.

With this PR we thus remove `UnrefQueue`. We can expect these changes to have a minor impact at most because we free most resources elsewhere in `ResourceSystem::updateCache`.
3 years ago
elsid 562590720b
Remove ShadowsBin prototype on MWShadowTechnique destruction
To prevent crash:
==7733==ERROR: AddressSanitizer: heap-use-after-free on address 0x6040000ca1b0 at pc 0x55fcfa8d1ee3 bp 0x7ffd1c464e00 sp 0x7ffd1c464df0
READ of size 4 at 0x6040000ca1b0 thread T0
    #0 0x55fcfa8d1ee2 in std::less<unsigned int>::operator()(unsigned int const&, unsigned int const&) const /usr/include/c++/11.1.0/bits/stl_function.h:386
    #1 0x55fcfa8d1ee2 in std::_Rb_tree<unsigned int, std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> >, std::_Select1st<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >::_M_lower_bound(std::_Rb_tree_node<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >*, std::_Rb_tree_node_base*, unsigned int const&) /usr/include/c++/11.1.0/bits/stl_tree.h:1903
    #2 0x55fcfa8ca76e in std::_Rb_tree<unsigned int, std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> >, std::_Select1st<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >::lower_bound(unsigned int const&) /usr/include/c++/11.1.0/bits/stl_tree.h:1270
    #3 0x55fcfa8ca76e in std::map<unsigned int, osg::ref_ptr<osg::ContextData>, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >::lower_bound(unsigned int const&) /usr/include/c++/11.1.0/bits/stl_map.h:1259
    #4 0x55fcfa8ca76e in std::map<unsigned int, osg::ref_ptr<osg::ContextData>, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >::operator[](unsigned int const&) /usr/include/c++/11.1.0/bits/stl_map.h:497
    #5 0x55fcfa8ca76e in osg::getOrCreateContextData(unsigned int) /home/elsid/dev/OpenSceneGraph/src/osg/ContextData.cpp:142
    #6 0x55fcfab6848a in GLShaderManager* osg::get<GLShaderManager>(unsigned int) /home/elsid/dev/OpenSceneGraph/include/osg/ContextData:154
    #7 0x55fcfab6848a in osg::Shader::PerContextShader::~PerContextShader() /home/elsid/dev/OpenSceneGraph/src/osg/Shader.cpp:540
    #8 0x55fcfab68dc6 in osg::Shader::PerContextShader::~PerContextShader() /home/elsid/dev/OpenSceneGraph/src/osg/Shader.cpp:541
    #9 0x55fcfab4a3f3 in osg::Referenced::signalObserversAndDelete(bool, bool) const /home/elsid/dev/OpenSceneGraph/src/osg/Referenced.cpp:292
    #10 0x55fcfab6d0ce in osg::Referenced::unref() const /home/elsid/dev/OpenSceneGraph/include/osg/Referenced:201
    #11 0x55fcfab6d0ce in osg::ref_ptr<osg::Shader::PerContextShader>::~ref_ptr() /home/elsid/dev/OpenSceneGraph/include/osg/ref_ptr:44
    #12 0x55fcfab6d0ce in void std::_Destroy<osg::ref_ptr<osg::Shader::PerContextShader> >(osg::ref_ptr<osg::Shader::PerContextShader>*) /usr/include/c++/11.1.0/bits/stl_construct.h:140
    #13 0x55fcfab6d0ce in void std::_Destroy_aux<false>::__destroy<osg::ref_ptr<osg::Shader::PerContextShader>*>(osg::ref_ptr<osg::Shader::PerContextShader>*, osg::ref_ptr<osg::Shader::PerContextShader>*) /usr/include/c++/11.1.0/bits/stl_construct.h:152
    #14 0x55fcfab6d0ce in void std::_Destroy<osg::ref_ptr<osg::Shader::PerContextShader>*>(osg::ref_ptr<osg::Shader::PerContextShader>*, osg::ref_ptr<osg::Shader::PerContextShader>*) /usr/include/c++/11.1.0/bits/stl_construct.h:185
    #15 0x55fcfab6d0ce in void std::_Destroy<osg::ref_ptr<osg::Shader::PerContextShader>*, osg::ref_ptr<osg::Shader::PerContextShader> >(osg::ref_ptr<osg::Shader::PerContextShader>*, osg::ref_ptr<osg::Shader::PerContextShader>*, std::allocator<osg::ref_ptr<osg::Shader::PerContextShader> >&) /usr/include/c++/11.1.0/bits/alloc_traits.h:746
    #16 0x55fcfab6d0ce in std::vector<osg::ref_ptr<osg::Shader::PerContextShader>, std::allocator<osg::ref_ptr<osg::Shader::PerContextShader> > >::~vector() /usr/include/c++/11.1.0/bits/stl_vector.h:680
    #17 0x55fcfab6d0ce in osg::Shader::ShaderObjects::~ShaderObjects() /home/elsid/dev/OpenSceneGraph/include/osg/Shader:264
    #18 0x55fcfab6d0ce in osg::Shader::ShaderObjects::~ShaderObjects() /home/elsid/dev/OpenSceneGraph/include/osg/Shader:264
    #19 0x55fcfab4a3f3 in osg::Referenced::signalObserversAndDelete(bool, bool) const /home/elsid/dev/OpenSceneGraph/src/osg/Referenced.cpp:292
    #20 0x55fcfab6c532 in osg::Referenced::unref() const /home/elsid/dev/OpenSceneGraph/include/osg/Referenced:201
    #21 0x55fcfab6c532 in osg::ref_ptr<osg::Shader::ShaderObjects>::~ref_ptr() /home/elsid/dev/OpenSceneGraph/include/osg/ref_ptr:44
    #22 0x55fcfab6c532 in void std::_Destroy<osg::ref_ptr<osg::Shader::ShaderObjects> >(osg::ref_ptr<osg::Shader::ShaderObjects>*) /usr/include/c++/11.1.0/bits/stl_construct.h:140
    #23 0x55fcfab6c532 in void std::_Destroy_aux<false>::__destroy<osg::ref_ptr<osg::Shader::ShaderObjects>*>(osg::ref_ptr<osg::Shader::ShaderObjects>*, osg::ref_ptr<osg::Shader::ShaderObjects>*) /usr/include/c++/11.1.0/bits/stl_construct.h:152
    #24 0x55fcfab6c532 in void std::_Destroy<osg::ref_ptr<osg::Shader::ShaderObjects>*>(osg::ref_ptr<osg::Shader::ShaderObjects>*, osg::ref_ptr<osg::Shader::ShaderObjects>*) /usr/include/c++/11.1.0/bits/stl_construct.h:185
    #25 0x55fcfab6c532 in void std::_Destroy<osg::ref_ptr<osg::Shader::ShaderObjects>*, osg::ref_ptr<osg::Shader::ShaderObjects> >(osg::ref_ptr<osg::Shader::ShaderObjects>*, osg::ref_ptr<osg::Shader::ShaderObjects>*, std::allocator<osg::ref_ptr<osg::Shader::ShaderObjects> >&) /usr/include/c++/11.1.0/bits/alloc_traits.h:746
    #26 0x55fcfab6c532 in std::vector<osg::ref_ptr<osg::Shader::ShaderObjects>, std::allocator<osg::ref_ptr<osg::Shader::ShaderObjects> > >::~vector() /usr/include/c++/11.1.0/bits/stl_vector.h:680
    #27 0x55fcfab6c532 in osg::buffered_value<osg::ref_ptr<osg::Shader::ShaderObjects> >::~buffered_value() /home/elsid/dev/OpenSceneGraph/include/osg/buffered_value:26
    #28 0x55fcfab6c532 in osg::Shader::~Shader() /home/elsid/dev/OpenSceneGraph/src/osg/Shader.cpp:271
    #29 0x55fcfab6c80a in osg::Shader::~Shader() /home/elsid/dev/OpenSceneGraph/src/osg/Shader.cpp:271
    #30 0x55fcfab4a3f3 in osg::Referenced::signalObserversAndDelete(bool, bool) const /home/elsid/dev/OpenSceneGraph/src/osg/Referenced.cpp:292
    #31 0x55fcfab185bd in osg::Referenced::unref() const /home/elsid/dev/OpenSceneGraph/include/osg/Referenced:201
    #32 0x55fcfab185bd in osg::ref_ptr<osg::Shader>::~ref_ptr() /home/elsid/dev/OpenSceneGraph/include/osg/ref_ptr:44
    #33 0x55fcfab185bd in void std::_Destroy<osg::ref_ptr<osg::Shader> >(osg::ref_ptr<osg::Shader>*) /usr/include/c++/11.1.0/bits/stl_construct.h:140
    #34 0x55fcfab185bd in void std::_Destroy_aux<false>::__destroy<osg::ref_ptr<osg::Shader>*>(osg::ref_ptr<osg::Shader>*, osg::ref_ptr<osg::Shader>*) /usr/include/c++/11.1.0/bits/stl_construct.h:152
    #35 0x55fcfab185bd in void std::_Destroy<osg::ref_ptr<osg::Shader>*>(osg::ref_ptr<osg::Shader>*, osg::ref_ptr<osg::Shader>*) /usr/include/c++/11.1.0/bits/stl_construct.h:185
    #36 0x55fcfab185bd in void std::_Destroy<osg::ref_ptr<osg::Shader>*, osg::ref_ptr<osg::Shader> >(osg::ref_ptr<osg::Shader>*, osg::ref_ptr<osg::Shader>*, std::allocator<osg::ref_ptr<osg::Shader> >&) /usr/include/c++/11.1.0/bits/alloc_traits.h:746
    #37 0x55fcfab185bd in std::vector<osg::ref_ptr<osg::Shader>, std::allocator<osg::ref_ptr<osg::Shader> > >::~vector() /usr/include/c++/11.1.0/bits/stl_vector.h:680
    #38 0x55fcfab185bd in osg::Program::~Program() /home/elsid/dev/OpenSceneGraph/src/osg/Program.cpp:147
    #39 0x55fcfab18ae0 in osg::Program::~Program() /home/elsid/dev/OpenSceneGraph/src/osg/Program.cpp:147
    #40 0x55fcfab4a3f3 in osg::Referenced::signalObserversAndDelete(bool, bool) const /home/elsid/dev/OpenSceneGraph/src/osg/Referenced.cpp:292
    #41 0x55fcf8582cfa in osg::Referenced::unref() const /home/elsid/dev/OpenSceneGraph/build/gcc/asan/install/include/osg/Referenced:201
    #42 0x55fcf8582cfa in osg::ref_ptr<osg::StateAttribute>::~ref_ptr() /home/elsid/dev/OpenSceneGraph/build/gcc/asan/install/include/osg/ref_ptr:44
    #43 0x55fcf8582cfa in std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int>::~pair() /usr/include/c++/11.1.0/bits/stl_pair.h:211
    #44 0x55fcf8582cfa in std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> >::~pair() /usr/include/c++/11.1.0/bits/stl_pair.h:211
    #45 0x55fcf8582cfa in void __gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > > >::destroy<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > >(std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> >*) /usr/include/c++/11.1.0/ext/new_allocator.h:162
    #46 0x55fcf8582cfa in void std::allocator_traits<std::allocator<std::_Rb_tree_node<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > > > >::destroy<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > >(std::allocator<std::_Rb_tree_node<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > > >&, std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> >*) /usr/include/c++/11.1.0/bits/alloc_traits.h:531
    #47 0x55fcf8582cfa in std::_Rb_tree<std::pair<osg::StateAttribute::Type, unsigned int>, std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> >, std::_Select1st<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > >, std::less<std::pair<osg::StateAttribute::Type, unsigned int> >, std::allocator<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > > >::_M_destroy_node(std::_Rb_tree_node<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > >*) /usr/include/c++/11.1.0/bits/stl_tree.h:623
    #48 0x55fcf8582cfa in std::_Rb_tree<std::pair<osg::StateAttribute::Type, unsigned int>, std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> >, std::_Select1st<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > >, std::less<std::pair<osg::StateAttribute::Type, unsigned int> >, std::allocator<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > > >::_M_drop_node(std::_Rb_tree_node<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > >*) /usr/include/c++/11.1.0/bits/stl_tree.h:631
    #49 0x55fcf8582cfa in std::_Rb_tree<std::pair<osg::StateAttribute::Type, unsigned int>, std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> >, std::_Select1st<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > >, std::less<std::pair<osg::StateAttribute::Type, unsigned int> >, std::allocator<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > > >::_M_erase(std::_Rb_tree_node<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > >*) /usr/include/c++/11.1.0/bits/stl_tree.h:1889
    #50 0x55fcfac1f281 in std::_Rb_tree<std::pair<osg::StateAttribute::Type, unsigned int>, std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> >, std::_Select1st<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > >, std::less<std::pair<osg::StateAttribute::Type, unsigned int> >, std::allocator<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > > >::clear() /usr/include/c++/11.1.0/bits/stl_tree.h:1254
    #51 0x55fcfac1f281 in std::map<std::pair<osg::StateAttribute::Type, unsigned int>, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int>, std::less<std::pair<osg::StateAttribute::Type, unsigned int> >, std::allocator<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > > >::clear() /usr/include/c++/11.1.0/bits/stl_map.h:1134
    #52 0x55fcfac1f281 in osg::StateSet::clear() /home/elsid/dev/OpenSceneGraph/src/osg/StateSet.cpp:738
    #53 0x55fcfac2079e in osg::StateSet::~StateSet() /home/elsid/dev/OpenSceneGraph/src/osg/StateSet.cpp:285
    #54 0x55fcfac20d3e in osg::StateSet::~StateSet() /home/elsid/dev/OpenSceneGraph/src/osg/StateSet.cpp:286
    #55 0x55fcfab4a3f3 in osg::Referenced::signalObserversAndDelete(bool, bool) const /home/elsid/dev/OpenSceneGraph/src/osg/Referenced.cpp:292
    #56 0x55fcfb20dcac in osg::Referenced::unref() const /home/elsid/dev/OpenSceneGraph/build/gcc/asan/install/include/osg/Referenced:201
    #57 0x55fcfb20dcac in osg::ref_ptr<osg::StateSet>::~ref_ptr() /home/elsid/dev/OpenSceneGraph/build/gcc/asan/install/include/osg/ref_ptr:44
    #58 0x55fcfb20dcac in std::array<osg::ref_ptr<osg::StateSet>, 8ul>::~array() /usr/include/c++/11.1.0/array:95
    #59 0x55fcfb20dcac in SceneUtil::ShadowsBin::~ShadowsBin() /home/elsid/dev/openmw/components/sceneutil/shadowsbin.hpp:16
    #60 0x55fcfb20dcac in SceneUtil::ShadowsBin::~ShadowsBin() /home/elsid/dev/openmw/components/sceneutil/shadowsbin.hpp:16
    #61 0x55fcfab4a3f3 in osg::Referenced::signalObserversAndDelete(bool, bool) const /home/elsid/dev/OpenSceneGraph/src/osg/Referenced.cpp:292
    #62 0x55fcfa6cc17f in osg::Referenced::unref() const /home/elsid/dev/OpenSceneGraph/include/osg/Referenced:201
    #63 0x55fcfa6cc17f in osg::ref_ptr<osgUtil::RenderBin>::~ref_ptr() /home/elsid/dev/OpenSceneGraph/include/osg/ref_ptr:44
    #64 0x55fcfa6cc17f in std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> >::~pair() /usr/include/c++/11.1.0/bits/stl_pair.h:211
    #65 0x55fcfa6cc17f in void __gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > > >::destroy<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > >(std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> >*) /usr/include/c++/11.1.0/ext/new_allocator.h:162
    #66 0x55fcfa6cc17f in void std::allocator_traits<std::allocator<std::_Rb_tree_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > > > >::destroy<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > >(std::allocator<std::_Rb_tree_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > > >&, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> >*) /usr/include/c++/11.1.0/bits/alloc_traits.h:531
    #67 0x55fcfa6cc17f in std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> >, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > > >::_M_destroy_node(std::_Rb_tree_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > >*) /usr/include/c++/11.1.0/bits/stl_tree.h:623
    #68 0x55fcfa6cc17f in std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> >, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > > >::_M_drop_node(std::_Rb_tree_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > >*) /usr/include/c++/11.1.0/bits/stl_tree.h:631
    #69 0x55fcfa6cc17f in std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> >, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > > >::_M_erase(std::_Rb_tree_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > >*) /usr/include/c++/11.1.0/bits/stl_tree.h:1889
    #70 0x55fcfa6cc122 in std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> >, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > > >::_M_erase(std::_Rb_tree_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > >*) /usr/include/c++/11.1.0/bits/stl_tree.h:1887
    #71 0x55fcfa6cc122 in std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> >, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > > >::_M_erase(std::_Rb_tree_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > >*) /usr/include/c++/11.1.0/bits/stl_tree.h:1887
    #72 0x55fcfa6cc245 in std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> >, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > > >::~_Rb_tree() /usr/include/c++/11.1.0/bits/stl_tree.h:984
    #73 0x55fcfa6cc245 in std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, osg::ref_ptr<osgUtil::RenderBin>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > > >::~map() /usr/include/c++/11.1.0/bits/stl_map.h:302
    #74 0x55fcfa6cc245 in RenderBinPrototypeList::~RenderBinPrototypeList() /home/elsid/dev/OpenSceneGraph/src/osgUtil/RenderBin.cpp:48
    #75 0x55fcfa6cc245 in RenderBinPrototypeList::~RenderBinPrototypeList() /home/elsid/dev/OpenSceneGraph/src/osgUtil/RenderBin.cpp:48
    #76 0x55fcfab4a3f3 in osg::Referenced::signalObserversAndDelete(bool, bool) const /home/elsid/dev/OpenSceneGraph/src/osg/Referenced.cpp:292
    #77 0x55fcfa6cbcc1 in osg::Referenced::unref() const /home/elsid/dev/OpenSceneGraph/include/osg/Referenced:201
    #78 0x55fcfa6cbcc1 in osg::ref_ptr<RenderBinPrototypeList>::~ref_ptr() /home/elsid/dev/OpenSceneGraph/include/osg/ref_ptr:44
    #79 0x7f3977bd04a6 in __run_exit_handlers (/usr/lib/libc.so.6+0x3f4a6)
    #80 0x7f3977bd064d in exit (/usr/lib/libc.so.6+0x3f64d)
    #81 0x7f3977bb8b2b in __libc_start_main (/usr/lib/libc.so.6+0x27b2b)
    #82 0x55fcf81ea12d in _start (/home/elsid/dev/openmw/build/gcc/asan/openmw+0xa4412d)

0x6040000ca1b0 is located 32 bytes inside of 48-byte region [0x6040000ca190,0x6040000ca1c0)
freed by thread T0 here:
    #0 0x7f397a633d69 in operator delete(void*, unsigned long) /build/gcc/src/gcc/libsanitizer/asan/asan_new_delete.cpp:172
    #1 0x55fcfa8d1824 in __gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >::deallocate(std::_Rb_tree_node<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >*, unsigned long) /usr/include/c++/11.1.0/ext/new_allocator.h:139
    #2 0x55fcfa8d1824 in std::allocator_traits<std::allocator<std::_Rb_tree_node<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > > >::deallocate(std::allocator<std::_Rb_tree_node<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >&, std::_Rb_tree_node<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >*, unsigned long) /usr/include/c++/11.1.0/bits/alloc_traits.h:492
    #3 0x55fcfa8d1824 in std::_Rb_tree<unsigned int, std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> >, std::_Select1st<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >::_M_put_node(std::_Rb_tree_node<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >*) /usr/include/c++/11.1.0/bits/stl_tree.h:565
    #4 0x55fcfa8d1824 in std::_Rb_tree<unsigned int, std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> >, std::_Select1st<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >::_M_drop_node(std::_Rb_tree_node<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >*) /usr/include/c++/11.1.0/bits/stl_tree.h:632
    #5 0x55fcfa8d1824 in std::_Rb_tree<unsigned int, std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> >, std::_Select1st<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >::_M_erase(std::_Rb_tree_node<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >*) /usr/include/c++/11.1.0/bits/stl_tree.h:1889
    #6 0x55fcfa8d18da in std::_Rb_tree<unsigned int, std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> >, std::_Select1st<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >::~_Rb_tree() /usr/include/c++/11.1.0/bits/stl_tree.h:984
    #7 0x55fcfa8d18da in std::map<unsigned int, osg::ref_ptr<osg::ContextData>, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >::~map() /usr/include/c++/11.1.0/bits/stl_map.h:302
    #8 0x7f3977bd04a6 in __run_exit_handlers (/usr/lib/libc.so.6+0x3f4a6)

previously allocated by thread T0 here:
    #0 0x7f397a632ca1 in operator new(unsigned long) /build/gcc/src/gcc/libsanitizer/asan/asan_new_delete.cpp:99
    #1 0x55fcfa8d3aa1 in __gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >::allocate(unsigned long, void const*) /usr/include/c++/11.1.0/ext/new_allocator.h:121
    #2 0x55fcfa8d3aa1 in std::allocator_traits<std::allocator<std::_Rb_tree_node<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > > >::allocate(std::allocator<std::_Rb_tree_node<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >&, unsigned long) /usr/include/c++/11.1.0/bits/alloc_traits.h:460
    #3 0x55fcfa8d3aa1 in std::_Rb_tree<unsigned int, std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> >, std::_Select1st<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >::_M_get_node() /usr/include/c++/11.1.0/bits/stl_tree.h:561
    #4 0x55fcfa8d3aa1 in std::_Rb_tree_node<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >* std::_Rb_tree<unsigned int, std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> >, std::_Select1st<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >::_M_create_node<std::piecewise_construct_t const&, std::tuple<unsigned int const&>, std::tuple<> >(std::piecewise_construct_t const&, std::tuple<unsigned int const&>&&, std::tuple<>&&) /usr/include/c++/11.1.0/bits/stl_tree.h:611
    #5 0x55fcfa8d3aa1 in std::_Rb_tree_iterator<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > std::_Rb_tree<unsigned int, std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> >, std::_Select1st<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >::_M_emplace_hint_unique<std::piecewise_construct_t const&, std::tuple<unsigned int const&>, std::tuple<> >(std::_Rb_tree_const_iterator<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >, std::piecewise_construct_t const&, std::tuple<unsigned int const&>&&, std::tuple<>&&) /usr/include/c++/11.1.0/bits/stl_tree.h:2429
    #6 0x55fcfa8cfd91 in std::map<unsigned int, osg::ref_ptr<osg::ContextData>, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >::operator[](unsigned int const&) /usr/include/c++/11.1.0/bits/stl_map.h:501
    #7 0x55fcfa8cfd91 in osg::ContextData::createNewContextID() /home/elsid/dev/OpenSceneGraph/src/osg/ContextData.cpp:171
    #8 0x55fcfa9be218 in osg::GraphicsContext::createNewContextID() /home/elsid/dev/OpenSceneGraph/src/osg/GraphicsContext.cpp:320
    #9 0x55fcfb68d1ef in SDLUtil::GraphicsWindowSDL2::GraphicsWindowSDL2(osg::GraphicsContext::Traits*) /home/elsid/dev/openmw/components/sdlutil/sdlgraphicswindow.cpp:39
    #10 0x55fcfa17f93a in OMW::Engine::createWindow(Settings::Manager&) /home/elsid/dev/openmw/apps/openmw/engine.cpp:611
    #11 0x55fcfa18398f in OMW::Engine::prepareEngine(Settings::Manager&) /home/elsid/dev/openmw/apps/openmw/engine.cpp:679
    #12 0x55fcfa18c4f2 in OMW::Engine::go() /home/elsid/dev/openmw/apps/openmw/engine.cpp:949
    #13 0x55fcfa13c9ff in runApplication(int, char**) /home/elsid/dev/openmw/apps/openmw/main.cpp:316
    #14 0x55fcfb49f562 in wrapApplication(int (*)(int, char**), int, char**, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/elsid/dev/openmw/components/debug/debugging.cpp:205
    #15 0x55fcfa133114 in main /home/elsid/dev/openmw/apps/openmw/main.cpp:328
    #16 0x7f3977bb8b24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)

SUMMARY: AddressSanitizer: heap-use-after-free /usr/include/c++/11.1.0/bits/stl_function.h:386 in std::less<unsigned int>::operator()(unsigned int const&, unsigned int const&) const
Shadow bytes around the buggy address:
  0x0c08800113e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c08800113f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0880011400: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0880011410: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0880011420: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0c0880011430: fa fa fd fd fd fd[fd]fd fa fa fa fa fa fa fa fa
  0x0c0880011440: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0880011450: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0880011460: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0880011470: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0880011480: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==7733==ABORTING
3 years ago
elsid 590a340e6e
Remove redundant ShadowsBin::sCastingPrograms
This variable is only used in ShadowsBin constructor and it's initialized each
time before constructor call so required value can be just passed into
ShadowsBin ctor.

Make ShadowsBin default constructor private because it is required by osg even
it's not actually called.
3 years ago
elsid 9d1b7c4a30
Use type alias to avoid long type names and length redefinition for array 3 years ago
elsid 6cfabe252d
Remove redundant ShadowsBinAdder 3 years ago
Dan Church 42bd10f356
Fix FTBFS against older versions of osg
Bring back osg version guard.

Drawable::dirtyGLObjects wasn't available until OpenSceneGraph-3.5.10.
3 years ago
Bo Svensson b0132be53f
do not dirty unchanged arrays (#3164)
This PR proposes a simple change to `RigGeometry` `dirtyGLObjects` logic.

1. We will avoid dirtying unmodified arrays.
2. We can drop an osg version guard since `Drawable::dirtyGLObjects` is not nearly as harmful as `Geometry::dirtyGLObjects`.
3. We will avoid crashes in an as yet unfinished future PR concerning `Array` sharing improvements.
3 years ago
Bo Svensson 93848ef01c
avoids virtual function calls in ComputeLightSpaceBounds (#3167)
osg::NodeVisitor is designed to recursively call virtual apply signatures until we find an implemented signature. Encountered nodes that we do not explicitely handle will trigger additional virtual function calls. With this PR we avoid these additional virtual function calls in the particularly costly ComputeLightSpaceBounds by adding some explicit signatures.
3 years ago
Bo Svensson 98f8295765
allows to skip ComputeLightSpaceBounds traversal (#3152)
Currently, we always traverse the scene graph an additional time with a ComputeLightSpaceBounds visitor during shadow casting. ComputeLightSpaceBounds is only useful when the shadow casting mask allows us to shrink the bounds of the rendered scene, so we guard its traversal with a check against getCastsShadowTraversalMask. In practice, this guard never works because we build the traversal mask inclusively.

With this PR we limit the getCastsShadowTraversalMask check to relevant masks. This new check allows us to skip a superfluous ComputeLightSpaceBounds traversal with most settings.
3 years ago
psi29a f9124ccea6 Merge branch 'recast_mesh_slope' into 'master'
Use different colors for walkable and non-walkable recast mesh triangles

See merge request OpenMW/openmw!1277
3 years ago
Bo Svensson c2d836c6c4
optimises riggeometry.cpp (#3165)
We skip this during node path iterations. this is not a node we are interested in.
We avoid allocating a new mGeomToSkelMatrix per frame and avoid a ref_ptr associated with its update.
We speed up a search for the Skeleton node by adding a continue; condition prior to an expensive dynamic_cast.
3 years ago
Bo Svensson 031871cd48
speeds up optimizer (#3162)
We can expect marginally improved loading times with this PR. Drawable, Transform and Node counts in stats panels are expected to remain unchanged - this PR does not add new scene graph optimisations, it just increases the speed with which we apply existing ones.

1. We add explicit `NodeVisitor::apply` overrides for commonly encountered node types to avoid additional virtual function calls per node associated with the default `apply` implementation.
2. We skip pushing `StateSet`s when  `_mergeAlphaBlending` is enabled or the `StateSet` contains no relevant state.
3. We add a specialised variant of `CollectLowestTransformsVisitor::addTransform` accepting `MatrixTransform` to avoid matrix copies and multiplications.
3 years ago
elsid daff7aba01
Use different colors for walkable and non-walkable triangles 3 years ago
Bo Svensson b61140b8ba
optimises skeleton.cpp (#3158)
With this PR we optimise a function that is called quite often when loading new cells.

We remove avoidable dynamic_casts.
We remove an unused pair.second element.
We convert a map to an unordered_map because its ordering is irrelevant in this case.
We avoid adding the root Skeleton node to the bones' node path.
3 years ago
Bo Svensson 5242e2695c
avoids memory allocations within ComputeLightSpaceBounds (#3156)
Currently, we create a new ComputeLightSpaceBounds visitor per frame. Within this visitor, we require excessive memory allocations, mainly a new osg::RefMatrix per encountered Transform node.

With this PR we reuse a single ComputeLightSpaceBounds visitor across frames and enable the createOrReuseMatrix functionality to avoid allocating new matrices every frame. osgUtil::CullVisitor internally uses the same approach.
3 years ago
Bo Svensson 08608da62c
optimizer.cpp 3 years ago
Bo Svensson cd4d76f8c5
discard off-screen lights (#3120)
Currently, we run culling tests against all lights in the scene during LightListCallback::pushLightState. We can avoid most of these tests by removing off-screen lights at an earlier stage. We should benchmark the cumulative time spent within LightListCallback::pushLightState before and after this PR.
3 years ago
Bo Svensson 787f91211d resets state updater to apply light settings (#3141)
resets state updater to apply light settings

With this PR we achieve the same effect with fewer lines of code.
3 years ago
Bo Svensson b2af81bc18
converts remaining osg::NodeCallback (#3147)
With this PR we convert remaining instantiations of the deprecated osg::NodeCallback in Open MW to SceneUtil::NodeCallback.
3 years ago
Bo Svensson 14d15dcfac
cleans up osgacontroller.cpp (#3142)
`handle_stateset` is not needed because `UpdateMatrixTransform` is a `NodeCallback` only allowed to be set on a `Node`. `Geode` and `Drawable` do not need explicit logic because they are both derived from `Node`.
3 years ago
Bo Svensson aaf7b423d6
adds a replacement for osg::NodeCallback (#3144)
* nodecallback.hpp

* lightmanager.hpp

* lightmanager.cpp

* lightmanager.hpp

* nodecallback.hpp

* nodecallback.hpp

* [ci skip]

* lightmanager.hpp

* nodecallback.hpp

* nodecallback.hpp

* lightmanager.cpp

* lightmanager.cpp

* nodecallback.hpp

* [ci skip]

* [ci skip]

* controller.cpp

* [ci skip]

* osgacontroller.cpp

* keyframe.hpp

* controller.hpp

* keyframe.hpp

* [ci skip]

* keyframe.hpp

* animation.hpp

* [ci skip]

* weaponanimation.cpp

* nodecallback.hpp
3 years ago
Bo Svensson 8358418555
set the correct program link parameters (#3110)
* shadermanager.hpp setProgramTemplate

* shadermanager.hpp

* shadermanager.cpp setProgramTemplate

* shadervisitor.hpp setProgramTemplate

* shadervisitor.cpp setProgramTemplate

* scenemanager.cpp setProgramTemplate

* scenemanager.hpp setProgramTemplate

* renderingmanager.cpp

* groundcover.cpp setProgramTemplate

* groundcover.hpp

* groundcover.cpp

* shadervisitor.cpp

* util.cpp

* lightmanager.cpp

* scenemanager.cpp

* scenemanager.hpp

* lightmanager.cpp

* lightmanager.cpp

* lightmanager.cpp

* scenemanager.hpp [ci skip]

* water.cpp

* groundcover.cpp

* shadermanager.hpp
3 years ago
Andrei Kortunov fc2076db1a
Fix MSVC warnings about local variables redeclaration (#3130) 3 years ago
Bo Svensson c6f7137ee1
fixes bugs with share state (#3111)
* optimizer.cpp merge fix

* objectpaging.cpp

* optimizer.hpp setSharedStateManager

* optimizer.cpp shareState

* scenemanager.cpp shareState

* scenemanager.cpp

* optimizer.cpp

* optimizer.cpp

* scenemanager.cpp

* optimizer.cpp
3 years ago
Bret Curtis 8d86d90782 remove whitespace 3 years ago
Bo Svensson 179f91276a
lightmanager.cpp (#3121) 3 years ago
Bo Svensson 52a9b4d989
shadowsbin.cpp uniform 3 years ago
psi29a 01a8998e3b return if source is null in mergeUserData 3 years ago
Bo Svensson afba1884ab
clone.cpp remove dynamic_cast (#3097) 3 years ago
Bo Svensson 147ed39900
This PR solves a crash with Robert's bodies logged on your bugtracker. (#3095)
* attach.cpp [ci skip]

* attach.cpp [ci skip]

* attach.cpp [ci skip]

* npcanimation.cpp [ci skip]

* attach.hpp [ci skip]

* attach.cpp [ci skip]

* creatureanimation.cpp [ci skip]

* creatureanimation.cpp [ci skip]

* cellpreloader.cpp

* npcanimation.cpp

* attach.cpp

* make android adk happy

* make android adk happy

* changelog.md [ci skip]

* authors.md [ci skip]
3 years ago
psi29a ac3fda0b3d Merge branch 'string_view' into 'master'
Pass std::string_view instead of const std::string&

See merge request OpenMW/openmw!1209
3 years ago
elsid 6b7434ca69
Pass std::string_view instead of const std::string&
* Starting with Actor::getBodyPartMesh and ending with
  Misc::StringUtils::ciEqual.
* Add tests for Misc::StringUtils::ciEqual.
3 years ago
Bo Svensson d36c373cc7
visitor.cpp early out 3 years ago
glassmancody.info d63eb3325f fix coverity warning and build on some osg 3 years ago
jvoisin 5793f5cf18 Sprinkle a couple of std::move and a const 3 years ago
Alexei Dobrohotov b49f51cbfc Serialize NifOsg::MatrixTransform children properly 3 years ago
psi29a 8ad3d3d792 Merge branch 'freezeandcool' into 'master'
Don't use FreezeOnCull for any particle system (#4744)

Closes #4744

See merge request OpenMW/openmw!1103
3 years ago
Alexei Dobrohotov 1fc7cb8191 Don't use FreezeOnCull for any particle system (#4744) 3 years ago
elsid fa1fb2a6b5
Reset mIsReleased before starting threads
To fix TSAN warning:

WARNING: ThreadSanitizer: data race (pid=68597)
  Write of size 1 at 0x7b3800079234 by main thread:
    #0 SceneUtil::WorkQueue::start(unsigned long) /home/elsid/dev/openmw/components/sceneutil/workqueue.cpp:51 (openmw+0x10daa10)
    #1 SceneUtil::WorkQueue::WorkQueue(unsigned long) /home/elsid/dev/openmw/components/sceneutil/workqueue.cpp:39 (openmw+0x10dad97)
    #2 OMW::Engine::prepareEngine(Settings::Manager&) /home/elsid/dev/openmw/apps/openmw/engine.cpp:700 (openmw+0xf7cb5a)
    #3 OMW::Engine::go() /home/elsid/dev/openmw/apps/openmw/engine.cpp:949 (openmw+0xf82688)
    #4 runApplication(int, char**) /home/elsid/dev/openmw/apps/openmw/main.cpp:316 (openmw+0xf62611)
    #5 wrapApplication(int (*)(int, char**), int, char**, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/elsid/dev/openmw/components/debug/debugging.cpp:205 (openmw+0x125df1c)
    #6 main /home/elsid/dev/openmw/apps/openmw/main.cpp:328 (openmw+0x596323)

  Previous read of size 1 at 0x7b3800079234 by thread T10 (mutexes: write M19275778865205896):
    #0 SceneUtil::WorkQueue::removeWorkItem() /home/elsid/dev/openmw/components/sceneutil/workqueue.cpp:86 (openmw+0x10d9e51)
    #1 SceneUtil::WorkThread::run() /home/elsid/dev/openmw/components/sceneutil/workqueue.cpp:127 (openmw+0x10da52a)
    #2 operator() /home/elsid/dev/openmw/components/sceneutil/workqueue.cpp:114 (openmw+0x10da664)
    #3 __invoke_impl<void, SceneUtil::WorkThread::WorkThread(SceneUtil::WorkQueue&)::<lambda()> > /usr/include/c++/11.1.0/bits/invoke.h:61 (openmw+0x10da664)
    #4 __invoke<SceneUtil::WorkThread::WorkThread(SceneUtil::WorkQueue&)::<lambda()> > /usr/include/c++/11.1.0/bits/invoke.h:96 (openmw+0x10da664)
    #5 _M_invoke<0> /usr/include/c++/11.1.0/bits/std_thread.h:253 (openmw+0x10da664)
    #6 operator() /usr/include/c++/11.1.0/bits/std_thread.h:260 (openmw+0x10da664)
    #7 _M_run /usr/include/c++/11.1.0/bits/std_thread.h:211 (openmw+0x10da664)
    #8 execute_native_thread_routine /build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:82 (libstdc++.so.6+0xd33c3)

  Location is heap block of size 216 at 0x7b3800079220 allocated by main thread:
    #0 operator new(unsigned long) /build/gcc/src/gcc/libsanitizer/tsan/tsan_new_delete.cpp:64 (libtsan.so.0+0x91824)
    #1 OMW::Engine::prepareEngine(Settings::Manager&) /home/elsid/dev/openmw/apps/openmw/engine.cpp:700 (openmw+0xf7cb4c)
    #2 OMW::Engine::go() /home/elsid/dev/openmw/apps/openmw/engine.cpp:949 (openmw+0xf82688)
    #3 runApplication(int, char**) /home/elsid/dev/openmw/apps/openmw/main.cpp:316 (openmw+0xf62611)
    #4 wrapApplication(int (*)(int, char**), int, char**, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/elsid/dev/openmw/components/debug/debugging.cpp:205 (openmw+0x125df1c)
    #5 main /home/elsid/dev/openmw/apps/openmw/main.cpp:328 (openmw+0x596323)

  Mutex M19275778865205896 is already destroyed.

  Thread T10 (tid=68609, running) created by main thread at:
    #0 pthread_create /build/gcc/src/gcc/libsanitizer/tsan/tsan_interceptors_posix.cpp:969 (libtsan.so.0+0x61c3a)
    #1 std:🧵:_M_start_thread(std::unique_ptr<std:🧵:_State, std::default_delete<std:🧵:_State> >, void (*)()) /build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu/bits/gthr-default.h:663 (libstdc++.so.6+0xd36aa)
    #2 std::_MakeUniq<SceneUtil::WorkThread>::__single_object std::make_unique<SceneUtil::WorkThread, SceneUtil::WorkQueue&>(SceneUtil::WorkQueue&) /usr/include/c++/11.1.0/bits/unique_ptr.h:962 (openmw+0x10da987)
    #3 SceneUtil::WorkQueue::start(unsigned long) /home/elsid/dev/openmw/components/sceneutil/workqueue.cpp:50 (openmw+0x10da987)
    #4 SceneUtil::WorkQueue::WorkQueue(unsigned long) /home/elsid/dev/openmw/components/sceneutil/workqueue.cpp:39 (openmw+0x10dad97)
    #5 OMW::Engine::prepareEngine(Settings::Manager&) /home/elsid/dev/openmw/apps/openmw/engine.cpp:700 (openmw+0xf7cb5a)
    #6 OMW::Engine::go() /home/elsid/dev/openmw/apps/openmw/engine.cpp:949 (openmw+0xf82688)
    #7 runApplication(int, char**) /home/elsid/dev/openmw/apps/openmw/main.cpp:316 (openmw+0xf62611)
    #8 wrapApplication(int (*)(int, char**), int, char**, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/elsid/dev/openmw/components/debug/debugging.cpp:205 (openmw+0x125df1c)
    #9 main /home/elsid/dev/openmw/apps/openmw/main.cpp:328 (openmw+0x596323)
3 years ago
glassmancody.info cdf5b315c3 fix mac runner undefined macro 3 years ago
glassmancody.info 09e03fde2e refactor and fix wobbly shores 3 years ago
glassmancody.info cad0b151cb enable shaders path and dehardcode depth formats 3 years ago
glassmancody.info b457dfd8b8 fix water RTTs and minor math error in non-infinite projection matrix 3 years ago
glassmancody.info 70fac33940 initial reverse-z depth implementation 3 years ago
glassmancody.info 1e52ca2b64 properly initialize light settings 3 years ago
psi29a 8c36eb56cf Merge branch 'stereo_friendly_water' into 'master'
Stereo friendly water and statesetupdater

See merge request OpenMW/openmw!563
3 years ago
madsbuvi 41c08b1c3b Stereo friendly StateSetUpdater
(cherry picked from commit 496b3aef88b8fd867dcdd23a6ca43144573b1b2f)

Stereo friendly water

(cherry picked from commit 0e22c55e48a7f965367d3d430c1bef5357b22748)

Option to disable per view mapping.

Include memory header

De-hardcode settings and buffers.

formatting error

Update water.cpp (whitespace)

Update water.cpp (more whitespace)

include render order

c array -> c++ array
3 years ago
elsid 9a5ec5fd03
Store heightfields as array of heights instead of triangles
To reduce size of RecastMesh and therefore cache size.
3 years ago
elsid d60edb36aa
Make RecastMesh independent from recast scale factor
To avoid scaling until it's required by delaying coordinates conversion until
navmesh generation.
3 years ago
elsid af7059373c
Make RecastMesh independent from the order of RecastMeshBuilder calls
To make sure RecastMesh objects are equal if built with the same data but in
different order. Will be used later when there will be more than one place
building RecasMesh objects.
3 years ago
elsid d4a2dab9d9
Remove redundant else 4 years ago
elsid eece47f70e
Avoid copying osg::ref_ptr when adding or removing item from work queue
Copy constructor does refcounting, and move constructor doesn't.
4 years ago
elsid b8fcd6d3ba
Manage work item lifetime on the client side
Instead of explicit work queue stop before any possibly used engine manager
is destructed. Based on an assumption that any engine manager can be destructed
independently from the work queue destruction. This model is already used in
CellPreloader that conflicts with explicit work queue stop.

After the work queue is requested to be stopped, any client waiting for a not
started work item to be done will wait forever because the work item is dropped
from the queue. Therefore either clients should not wait for own work items to
be completed in destructor or the work queue should not drop items before
clients are destructed. Other approaches are possible but are not considered
due to increasing complexity.

CellPreloader already tries to wait for all created work items to be done so
keep it that way and extend the model to AsyncScreenCaptureOperation and Scene.
Additionally abort all scheduled work items when owner is destructed. This
prevents a long exit when multiple screenshots are scheduled right before
exiting the game.
4 years ago
elsid 5103120eef
Notify about saved screenshot
Show message about saved screenshot via schedule message box. Since screenshot
saving happens not in the main thread calling messageBox directly is unsafe.
WindowManager::scheduleMessageBox delays message box showing until next update
in the main thread.
4 years ago
elsid f7a6be053d
Stop engine work queue before destructing environment
To avoid access to null and dangling pointers from active work items on
quitting.
4 years ago
elsid f8e02000ec
Write screenshots to file asynchronously 4 years ago
elsid 33aa4d0822
Move WriteScreenshotToFileOperation to components 4 years ago
AnyOldName3 84a9facedf Disable coverage adjustment for blended objects 4 years ago
Evil Eye 2be27da791 Merge branch 'const_refs' into 'master'
Add a ton of const refs

See merge request OpenMW/openmw!954
4 years ago
Evil Eye 9f7980ecd7 Merge branch 'refenreces' into 'master'
Sprinkle some references where it makes sense

See merge request OpenMW/openmw!952
4 years ago
jvoisin cf11870b1c Sprinkle some references where it makes sense 4 years ago
jvoisin 895864099c Simplify NodeMapVisitor::apply
No need to run a find() before a std::replace
4 years ago
jvoisin 1123dc46ee Add a ton of const refs 4 years ago
Bret Curtis 868a5b35e3 workaround shadow issue on macOS, https://gitlab.com/OpenMW/openmw/-/issues/6057 4 years ago
jvoisin 7f4f2c042e Use sizeof(GLfloat) instead of sizeof(GL_FLOAT)
GL_FLOAT is an enum, with the value 0x1406, while GLFloat is the actual type.
Source: https://www.khronos.org/opengl/wiki/OpenGL_Type
4 years ago
elsid d4f28ac979
Avoid resetting buffer object when configuring light buffer layout
Otherwise this casues RaceSelectionPreview to have no light until first change.
4 years ago
Andrei Kortunov 11c57978b6 Fix crashes on exit in the LightManager (bug #6044) 4 years ago
Andrei Kortunov c54ef55ebb Revert "Replace raw pointer by observer_ptr to avoid dangling pointer dereferencing"
This reverts commit 5373cf1cd5.
4 years ago
elsid d520b440aa
Copy LightBuffer data into a new object when changing layout
Before this change LightBuffer copy constructor copied only mData pointer into
a new object. Then memcpy was applied to an overlapping source and destination
that is UB.

Replace configureLayout function by a special constructor. That copies all
mData values and a pointer to a buffer object into a newly allocated object.
4 years ago
elsid 5373cf1cd5
Replace raw pointer by observer_ptr to avoid dangling pointer dereferencing
When game exit is requests when initial loading screen is active LightManager
can be destructed in the main thread before LightManagerStateAttribute::apply
is completed by different thread. Given that it uses raw pointer at some point
it becomes dangling because object is destructed this leads to UB and eventual
SIGSEGV.
4 years ago
Andrei Kortunov 2e8873af51 Add new scene nodes to scene graph serializer blacklist 4 years ago
jvoisin d45184a730 Sprinkle some const-ref to avoid unnecessary copies 4 years ago
Chris Djali f0cef87cd8
Merge pull request #3069 from akortunov/msvc_warnings
Rework warnings settings
4 years ago
Andrei Kortunov 18a4c81b5c Merge branch 'fix_toggleborders' into 'master'
Fix ToggleBorders debug view with 'Shaders' lighting method

See merge request OpenMW/openmw!792
4 years ago
AnyOldName3 ceb6a280ff Fix typo
Hopefully this will actually let us make better use of shadow bounds,
but I wouldn't count on it.
4 years ago
glassmancody.info 9f314d1d6f Fix ToggleBorders 4 years ago
Andrei Kortunov 6d351b2bdd Fix MSVC 4706 warnings 4 years ago
Bret Curtis 50d6cd2a34
Merge pull request #3070 from akortunov/coverity
Fix an another portion of Coverity warnings
4 years ago
Bret Curtis c6c92b5712
Merge pull request #3071 from akortunov/master
Fix an another batch of MSVC complaints
4 years ago
AnyOldName3 ff46eceabe Merge branch 'maybe-reintroduce-5904' into 'master'
Fix crash on startup

See merge request OpenMW/openmw!709
4 years ago
Andrei Kortunov d10399e083 Cast double constant to float explicitely 4 years ago
Andrei Kortunov 7d5c5f8a24 Do not assign negative values to unsigned variables 4 years ago
Andrei Kortunov 987b231fdd Fix an another portion of Coverity warnings 4 years ago
psi29a d0883f9a0d Merge branch 'light_settings_tweak' into 'master'
Lighting patch

Closes #5957 and #5959

See merge request OpenMW/openmw!752
4 years ago
glassmancody.info 16856d45c5 Lighting Patch
Fixes build errors with older OSG builds and some issues with 'shared' layout.
Bring back ambient in inventory through lightmodel instead of sun ambient, mirrors scene ambient/sunlight relationship.
Forces shaders when certain lighting methods are enabled and finalize settings.
Correctly override sun for localmap.
4 years ago
Andrei Kortunov 0c7ddd3938 Remove redundant qualifiers 4 years ago
Andrei Kortunov bce6effe95 Fix uninitialized variables in the LightManager 4 years ago
glassmancody.info 531a6e1979 Code review fixes, remove implicit GLSL casts 4 years ago
glassmancody.info 92033bca64 Fixed error in calculating viewspace sun dir, minor cleanup 4 years ago
glassmancody.info 9e80091aff clear up force shaders and make it less convoluted 4 years ago
glassmancody.info 8ce65232ff fix race condition with sun uniform 4 years ago
glassmancody.info d4e7d25d14 Make life not suck for whoever wants to edit lighting shaders 4 years ago
glassmancody.info eecb9886a9 Shader cleanup, fix indicies 4 years ago
glassmancody.info 4ba473b684 Finalize settings, torch fix 4 years ago
glassmancody.info 71c30a31df in-game settings, some require restart 4 years ago
glassmancody.info 3d713e8602 Fix incorrect minimum ambient 4 years ago
glassmancody.info 280fd2b162 Merge remote-tracking branch 'upstream/master' into why_are_the_christmas_lights_still_up 4 years ago
glassmancody.info d195602a9d Switch to shared layout, some rewording 4 years ago
glassmancody.info 690995988b More formatting, OpenCS cells are unbroken 4 years ago
glassmancody.info 328ec85757 Code review cleanup, add setting documentation 4 years ago
glassmancody.info 05a5cee132 Brighter point lights and light fade 4 years ago
glassmancody.info 43ac32921c Rewrite, support different lighting methods 4 years ago
glassmancody.info 9d9074c244 Add shared UBO 4 years ago
glassmancody.info dda735c54a initial commit 4 years ago
AnyOldName3 168f26fc80 Fix crash on startup 4 years ago
AnyOldName3 c6033b4de6 Fix #5904 4 years ago
AnyOldName3 0431ba4c87 Merge branch 'alpha-meddling-shader-side-mip-meddling' into alpha-meddling 4 years ago
AnyOldName3 46a1715d8a Actually return something 4 years ago
AnyOldName3 f5a87ee46d Refactor out duplicated RTT setup code 4 years ago
AnyOldName3 153ab57ae3 Make assignment in while loop condition obviously intentional 4 years ago
AnyOldName3 4f510d85ba Merge remote-tracking branch 'upstream/master' into alpha-meddling 4 years ago
psi29a c33b2e0100 Merge branch 'dehardcodebaseanim' into 'master'
Dehardcode Base_animation and improve Collada support

See merge request OpenMW/openmw!510
4 years ago
AnyOldName3 3e273a759a Clarify method name now we're using it differently 4 years ago
Nelsson Huotari bae27e8199 dynamic_cast to static_cast 4 years ago
Nelsson Huotari b28d8251aa Clone animation tracks 4 years ago
Nelsson Huotari 1221889cf7 Limit conversion of underscores to nodes origating from osgAnimation library 4 years ago
Nelsson Huotari 5b88d16a50 Clean-up 4 years ago
Nelsson Huotari 2162b97fef Handle case in osgAnimation bone names 4 years ago
Nelsson Huotari 7d3f2bc113 Convert underscores in bone names to whitespaces 4 years ago
madsbuvi 7edaa50195 another approach 4 years ago
Nelsson Huotari 3194520dcd Move base_anim settings to settings-default.cfg 4 years ago
Andrei Kortunov f175beb304 Define template ref classes in components 4 years ago
Andrei Kortunov 801e2d6ad0 Avoid to use uninitialized variables 4 years ago
AnyOldName3 4ed3252001 Check for EXT_gpu_shader4 CPU-side
Mesa lies and always defines GL_EXT_gpu_shader4 even when the extension
isn't present.
4 years ago
AnyOldName3 8f4b856b44 Initial A2C implementation 4 years ago
AnyOldName3 11b4af49ce Allow shadowsbin to optimise clockwise-wound meshes when face culling is off 4 years ago
AnyOldName3 a36ed5f129 Optimise out redundant call
We already had the results
4 years ago
AnyOldName3 657da50d99 Ensure GL_BLEND is disabled when drawing shadow maps 4 years ago
AnyOldName3 cc2ce9fa3e Explicitly default-construct array
The docs seem to imply this is automatic when the array contains a
class-type, which osg::ref_ptr is, but I got a crash log that doesn't
make sense if that's true.
4 years ago
AnyOldName3 0b5d5eab4c Move is faster 4 years ago
AnyOldName3 05ad44d0b1 Set correct array size 4 years ago
AnyOldName3 ce2bcba5d4 Replace deprecated alpha test in shader visitor 4 years ago
Nelsson Huotari 8b2bf12e8f Use bip01 for root bone name 4 years ago
Nelsson Huotari 6c1f6169c0 Fix root movement glitch 4 years ago
Nelsson Huotari 256aa5e71d Use const auto& 4 years ago
AnyOldName3 5ad297e6ff Guarantee glow updater regenerates shaders on completion
Previously, it would edit the odd numbered stateset, then regenerate
shaders for the even-numbered one, then edit the even numbered one, and
regenerate shaders for the odd numbered one (or vice versa if it
finished during an even numbered frame). This would leave one of the
shader programs still trying to use the state that had been removed.
4 years ago
Andrei Kortunov 8084a336b5 Replace zeroes and nulls by nullptrs 4 years ago
Nelsson Huotari 55dcc6582a Don't duplicate getFileExtension, use OpenMW's namespaces 4 years ago
Nelsson Huotari 3232faa703 Use const ref instead of value 4 years ago
Nelsson Huotari 32d4344803 Don't copy osga-data in base class keyframecontroller, fix warnings. 4 years ago
Nelsson Huotari 6e77ad1f6a OSG-Collada animation support 4 years ago
Nelsson Huotari f78a5d795c Separate keyframes logic to provide basis for osgAnimation integration. 4 years ago
AnyOldName3 37661bffea Merge branch 'shadowdisable-fix' into 'master'
Make disableShadowsForStateSet a no-op when shadows are disabled

See merge request OpenMW/openmw!205
4 years ago
AnyOldName3 7768556ce6 Set dummy state when disabling shadows indoors
As we don't reconfigure all shaders without shadows when we disable them
indoors (as it'd probably add a hitch to transitioning in and out) we
need to set up dummy state so the shaders don't do anything illegal.

This hadn't had symptoms for most objects as when indoors, nearly
everything would be drawn first in one of the water RTTs, which had
dummy state to disable shadows already. This wasn't true of the water
plane itself, though, yet somehow it took until just now for anyone to
report that.

This resolves vtastek's issue where the water would be invisible indoors
4 years ago
AnyOldName3 1e0df23d14 Merge branch 'shadows-bin' into 'master'
Use a custom renderbin to avoid pointless OpenGL state switches

See merge request OpenMW/openmw!402
4 years ago
AnyOldName3 fcfd340c69 Actually copy alpha blended drawables to the new stategraph 4 years ago
AnyOldName3 55f65752fd Don't bind unnecessary colour buffer when drawing shadow maps 4 years ago
AnyOldName3 cdbf19a508 Tidy up run-on lines 4 years ago
AnyOldName3 296dce470a Spelling fix 4 years ago
AnyOldName3 72f7e6a702 Handle all shadow alpha uniforms in shadowsbin 4 years ago
AnyOldName3 5d046bc95d Mark override 4 years ago
Alexei Dobrohotov 53f91a3aa5
Merge pull request #3018 from akortunov/emplace
Use emplace_back instead of push_back
4 years ago
AnyOldName3 449506fef1 Attempt to explain what shadowsbin is doing 4 years ago
Alexei Dobrohotov 4fc5e22e9e NIF fixes and cleanup
Get rid of NodeIndexHolder
Use unsigned 32-bit type for NIF record index
Fix calculation of the number of UV sets
4 years ago
AnyOldName3 f7dddb8857 Merge branch '3' of https://gitlab.com/bzzt/openmw into shadows-bin
This won't actually work.
4 years ago
Andrei Kortunov 065ed5138e Use emplace_back instead of push_back 4 years ago
Andrei Kortunov 8ca3c3b123 Mark overrided methods by override keyword 4 years ago
Alexei Dobrohotov 9f08dc9968 Revert "Merge branch 'skinning' into 'master'"
This reverts merge request !327
4 years ago
Alexei Dobrohotov 6be808e301 RigGeometry: convert some pairs to structs 4 years ago
AnyOldName3 fd14dad789 const osg::ref_ptf reference should be faster than value as constructor and destructor are non-trivial
I played around in GodBolt and got into an argument to determine this. The difference will be immeasurably small, but my curiosity has been satisfied.
4 years ago
AnyOldName3 707204133d Double-buffer shadow uniforms that change each frame 4 years ago
AnyOldName3 ce98d7053b Double buffer view-dependent data stateset 4 years ago
AnyOldName3 98b2d5d921 Make shadow debug HUD thread-safe
* Double buffer the frustum uniforms.
* Don't mess with the debug geometry's StateSet.
* Change two-element vectors to arrays so the size is explicit.
4 years ago
Andrei Kortunov 215ddb9106 Do not print warnings for VisController 4 years ago
Capostrophic 46825e8a4d Move NIF record index back to a separate user object
This makes sure it's never erroneously optimized out. NodeIndexHolders don't need to be cloned as their record index is never supposed to be changed.
4 years ago
Capostrophic cc791af0f5 Serialization fixes
Make sure NifOsg::MatrixTransform serialization behaves as intended
Add a dummy serializer for NifOsg::UVController
4 years ago
Capostrophic 3b55d657e5 CopyRigVisitor: Log the number of parents in multiple parents error 4 years ago
Capostrophic a61267f57d Replace NodeUserData with a custom transform node 4 years ago
Capostrophic 4c9cefefdd Get rid of NifOsg::CollisionSwitch 4 years ago
Bret Curtis 0c2fea8254
Merge pull request #2932 from elsid/replace_open_threads
Replace OpenThreads by std types
5 years ago
Andrei Kortunov ef6fe8d52a Fix crash in the stateset updater (regression #5478) 5 years ago
elsid 40ad87bc4d
Replace OpenThreads by std types 5 years ago
elsid 3251687a3d
Use std types for WorkQueue 5 years ago
psi29a f94ca28dbe #5463: Optimizer fix, problem was indeed related to tangents not being transformd properly. 5 years ago
psi29a 66b5cf9f1d Merge branch 'master' into 'near_far_mode_in_launcher'
# Conflicts:
#   files/settings-default.cfg
5 years ago
bzzt lost a hitlab login 26ab176389 profiling
Signed-off-by: Bret Curtis <psi29a@gmail.com>
5 years ago
bzzt lost a hitlab login daa2761c2d alphablending & billboardfix
Signed-off-by: Bret Curtis <psi29a@gmail.com>
5 years ago
bzzt lost a hitlab login f12879a04c allow statesetupdater as cullcallback = faster + works in paging
Signed-off-by: Bret Curtis <psi29a@gmail.com>
5 years ago
bzzt lost a hitlab login 9f0398c021 intersection by refnum tag + enable paging for acti,door,cont
Signed-off-by: Bret Curtis <psi29a@gmail.com>
5 years ago
bzzt lost a hitlab login ce505a9bb3 crashfix + optimiziation
Signed-off-by: Bret Curtis <psi29a@gmail.com>
5 years ago
bzzt d684f1a78f terrainbased objectpaging
Signed-off-by: Bret Curtis <psi29a@gmail.com>
5 years ago
Icecream95 f14db21745
Make disableShadowsForStateSet a no-op when shadows are disabled
Otherwise the GPU has to do useless shadow comparisons when shadows
are disabled.
5 years ago
Capostrophic 78b1bbe130 Remove unnecessary null check 5 years ago
Capostrophic 72e5043eda CopyRigVisitor fixes
Make sure it copies all relevant drawable parent nodes (e.g. including the node with the environment map effect)
Make sure it doesn't copy nodes multiple times
5 years ago
psi29a b72720f357 Merge branch 'shadow-transparency-rework' into 'master'
Only alpha-test shadows when necessary

See merge request OpenMW/openmw!170
5 years ago
Bret Curtis aaa8990006
Merge pull request #2799 from Capostrophic/simplewaterfog
Fix simple water with radial fog enabled
5 years ago
Bret Curtis f51476a3c5
Merge pull request #2816 from Capostrophic/switchlod
CollisionSwitch and Switch/LOD node fixes
5 years ago
Bret Curtis 5f0f2f0f16 rename to better reflect what is going on per AnyOldName3 comment; added none option 5 years ago
Bret Curtis bf6daa7269
Merge pull request #2811 from Capostrophic/emitter
Allow particle emitters to be attached to an arbitrary node
5 years ago
Capostrophic 957d2a890f Ignore empty children of osg::LOD and osg::Switch like in OSG 5 years ago
Capostrophic 63fe02b1ba CollisionSwitch and Switch/LOD node fixes
Properly apply transformations to both switch and LOD nodes
Allow both NiSwitchNode and NiLODNode to be the root node
Properly add CollisionSwitch into the scene graph
5 years ago
psi29a bb5fe13e13 Make sure it is either one or the other with the default to bounding volumes. 5 years ago
Bret Curtis d38c3e971c remove extra line 5 years ago
Bret Curtis ae729a1ac7 add ability to set the type of near far method to be used in shadow calculation; default to bounding volumes; cleaned up code while there and re-ordered items 5 years ago
Capostrophic 6b874e397b Make particle system cloning map names more sensible 5 years ago
Capostrophic f516178ec9 Fix particle processor cloning
Extend emitter handling comment in NIF loader
5 years ago
psi29a 476a74c2d3 Merge branch 'bzzt_5_tight_scene_bound' into 'master'
Allow use of OSG's Bounding Volumes

See merge request OpenMW/openmw!189
5 years ago
Bret Curtis 31a75a962a Add 3 additional classes to be ignored who dumping "showscenegraph" debug output; less spammy 5 years ago
Bret Curtis ca0adc25bb add two additional classes we do not need to serialize; less pam during `showscenegraph` debug dump. 5 years ago
Bret Curtis 886b9813ad Something changed in OSG 3.6 that makes the command "showscenegraph" less useful; it writes out raw data of images to the debug output file openmw.ogst. This commit adds the hint and restores default behaviour found in OSG 3.4 5 years ago
bzzt dc33eeadf1 tightscenebound is uncessary after water bbfix 5 years ago
elsid c59c8ae1f4
Remove unused macro 5 years ago
Capostrophic 688e804548 Fix simple water with radial fog enabled 5 years ago
Bret Curtis 8a8107e837 as it says; revert vismask and uncomplicate openmw 5 years ago
AnyOldName3 1cf2036386 Don't add empty PrimitiveSets (prevent undefined behaviour) 5 years ago
AnyOldName3 12044a607b Only alpha-test shadows when necessary
Previously we always discarded shadow map fragments if the alpha channel of the output would have been low, but there were some (modded) assets that have non-one alpha but have testing or blending disabled so end up opaque anyway. This lets the shadows of those objects match.
5 years ago
Andrei Kortunov 02d7b13075
Merge pull request #2529 from akortunov/nodecopy
Copy transformations data when we clone node
5 years ago
elsid 7ae7cb181d
Support recast mesh rendering 5 years ago
Andrei Kortunov 84979fa8b7 Move VisMask to components 5 years ago
bzzt d340224c95 shadowsbin for gl state reduction 5 years ago
elsid 2e1d8a5e55
Remove unused virtual modifiers in DebugHUD
/home/elsid/dev/openmw/components/sceneutil/mwshadowtechnique.cpp:3127:9: warning: Call to virtual function during construction [clang-analyzer-optin.cplusplus.VirtualCall]
        addAnotherShadowMap();
        ^
/home/elsid/dev/openmw/components/sceneutil/mwshadowtechnique.cpp:3094:5: note: Loop condition is true.  Entering loop body
    for (int i = 0; i < 2; ++i)
    ^
/home/elsid/dev/openmw/components/sceneutil/mwshadowtechnique.cpp:3094:5: note: Loop condition is true.  Entering loop body
/home/elsid/dev/openmw/components/sceneutil/mwshadowtechnique.cpp:3094:5: note: Loop condition is false. Execution continues on line 3102
/home/elsid/dev/openmw/components/sceneutil/mwshadowtechnique.cpp:3126:21: note: Assuming 'i' is < 'numberOfShadowMapsPerLight'
    for (int i = 0; i < numberOfShadowMapsPerLight; ++i)
                    ^
/home/elsid/dev/openmw/components/sceneutil/mwshadowtechnique.cpp:3126:5: note: Loop condition is true.  Entering loop body
    for (int i = 0; i < numberOfShadowMapsPerLight; ++i)
    ^
/home/elsid/dev/openmw/components/sceneutil/mwshadowtechnique.cpp:3127:9: note: This constructor of an object of type 'DebugHUD' has not returned when the virtual method was called
        addAnotherShadowMap();
        ^
/home/elsid/dev/openmw/components/sceneutil/mwshadowtechnique.cpp:3127:9: note: Call to virtual function during construction
5 years ago
elsid bd149b909f
Remove unused virtual modifiers in ShadowManager
/home/elsid/dev/openmw/components/sceneutil/shadow.cpp💯9: warning: Call to virtual function during construction [clang-analyzer-optin.cplusplus.VirtualCall]
        setupShadowSettings();
        ^
/home/elsid/dev/openmw/components/sceneutil/shadow.cpp💯9: note: This constructor of an object of type 'ShadowManager' has not returned when the virtual method was called
/home/elsid/dev/openmw/components/sceneutil/shadow.cpp💯9: note: Call to virtual function during construction
/home/elsid/dev/openmw/components/sceneutil/shadow.cpp:104:9: warning: Call to virtual function during construction [clang-analyzer-optin.cplusplus.VirtualCall]
        enableOutdoorMode();
        ^
/home/elsid/dev/openmw/components/sceneutil/shadow.cpp:104:9: note: This constructor of an object of type 'ShadowManager' has not returned when the virtual method was called
/home/elsid/dev/openmw/components/sceneutil/shadow.cpp:104:9: note: Call to virtual function during construction
5 years ago
Andrei Kortunov f09d20434c Clamp number of shadow maps 5 years ago
Andrei Kortunov 7074baa1c2 Clamp number of shadow maps, as described in docs 5 years ago
bzzt b6ed2f1718 Add optional shadow map max distance and fading 5 years ago
Andrei Kortunov e568ad30ea Copy transformations data when we clone node (bug #5163) 5 years ago
Andrei Kortunov d4a8023e1a
Merge pull request #2485 from Capostrophic/lighting
Add support for QuadraticMethod/LinearMethod setup (bug #4965, continuation)
5 years ago
capostrophic 62fd2d47a5 Rewrite flickering/pulsing to work more like vanilla (bug #4952) 5 years ago
capostrophic c0d5cbdc8b Add support for QuadraticMethod/LinearMethod setup (bug #4965) 5 years ago
Andrei Kortunov 8557346fbd Use glow for enchanted arrows (feature #5122) 5 years ago
Capostrophic 6622e36226 Only merge pure osg::Groups in the optimizer 6 years ago
Alexei Dobrohotov 1444ef6f43
Merge pull request #2298 from akortunov/optimize
Do not allocate eight dummy LightStateAttribute's for every stateset
6 years ago
Capostrophic 05d94d35f9 Make disabled shadow defines map static 6 years ago
Capostrophic 85e99182ce Revise light source configuration (bug #4965)
Set up attenuation less awkwardly
Use global attenuation settings for magic light source
Use constant attenuation settings
6 years ago
bzzt 1a65adacdd Do not allocate dummy LightStateAttribute's for every stateset 6 years ago
Andrei Kortunov b466bfee40 Enable light sources directly to avoid virtual calls 6 years ago
Andrei Kortunov b2fca46206 Fix a couple of minor issues in shadows 6 years ago
Capostrophic de572226e4 Update optimizer with upstream improvements 6 years ago
Bret Curtis 7917f1fc84
Merge pull request #2252 from akortunov/terrain
Do not allocate empty callbacks in the RigGeometry
6 years ago
bzzt 4ab93aeffe Do not allocate empty callbacks in the RigGeometry 6 years ago
elsid 8e09468f45
Don't set display list usage for navmesh 6 years ago
elsid 4395a92c35
Use display list to render navmesh
Slightly improves performance of massive navmesh rendering.
6 years ago
Andrei Kortunov bacaa1f789 Get rid of C-style limits in the shadows code 6 years ago
Bret Curtis 551563cbfb Merge branch 'clsb-warning' into 'master'
Hopefully fix Clang warning about hiding overloaded virtual functions

See merge request OpenMW/openmw!82
6 years ago
elsid 47e87cc2bd
Fix ODR violation for VDSMCameraCullCallback
This class is also defined in OpenSceneGraph at global namespace.
6 years ago
AnyOldName3 d34724a3c4 Hopefully fix Clang warning about hiding overloaded virtual functions 6 years ago
Grigory Latyshev 3872d7476b Move makeOsgVec3f() to settingsutils.hpp
Remove all other makeOsgVec3f() implementations
6 years ago
bzzt 8c649f05e6 Don't reallocate light list vector unnecessarily 6 years ago
bzzt a567111400 Use emplace instead of find-assign 6 years ago
Andrei Kortunov 3032b177a1 Remove redundant includes 6 years ago