Commit Graph

341 Commits (master)

Author SHA1 Message Date
Andrei Kortunov bfcbc2350d Handle UTF-8 in Qt streams in the Qt6-compatible way 2 years ago
elsid 755067f0f3
Remove redundant ESM::RefId member functions 2 years ago
florent.teppe dc21df97c8 Fixed issue with getSummonedCreature( that returned a reference to a non const static value
Fix compile, and apply review comment

Fixed greater vs more typo.

getCellname is back to a string view.

Because in most cases was used as a strong not a refId.
and there was a fundamental issue with region names used as a cellname
2 years ago
florent.teppe d49f60d2d6 To change fewer things with the master implementation, the Id isn't changed to lower case on creation
lower case utility functions used in comparison functions
2 years ago
florent.teppe 65cdd489fb create a specific esm reader function for RefID to avoid allocation for string and then again for RefId
Fixed some types

removed useless header

applied clang format

fixed compile tests

fixed clang tidy, and closer to logic before this MR

Removed hardcoded refids

unless there is a returned value we don't use static RefIds
can use == between RefId and hardcoded string

Fix clang format

Fixed a few instances where std::string was used, when only const std::string& was needed

removed unused variable
2 years ago
fteppe 7da38113be Changed more hardcoded RefId to be static to avoid multiple runtime creations
adresses multiple review comments
2 years ago
fteppe 2f2e401559 is Hidden marker now takes a const RefId& instead of a string_view 2 years ago
Cédric Mocquillon 7e77e69a3c Use a wider type when converting to a signed type 2 years ago
elsid 843753da14
Remove unused includes 2 years ago
elsid dd63a1602f
Handle localtime errors 2 years ago
AnyOldName3 581b333386 Add missing include 2 years ago
Project579 6fe89ff22b Fix dumb regression, initialize "std::filesystem::file_time_type" with "clock::now()". 2 years ago
Project579 5cf2a958eb Make conversions between std::chrono time_point and string safer by not using "localtime" directly. 2 years ago
clang-format-bot ddb0522bbf
Apply clang-format to code base 2 years ago
elsid 409f83a149
Use raw string literal for error marker definition 2 years ago
psi29a 29f3de30c2 Merge branch 'master' into 'cellstore_refactor'
# Conflicts:
#   apps/openmw/mwworld/scene.cpp
2 years ago
Project579 5456ef1d50 Add new functions and overloads to support std::u8string and std::filesystem::path. 2 years ago
florent.teppe 10899ed680 typo 2 years ago
Project579 35fe214588 Updated components/misc/timeconvert.hpp to fix the Android build. 2 years ago
Project579 4bb07282c9 Replace all remaining occurrences of boost::filesystem with std::filesystem. 2 years ago
florent.teppe cdc7864863 missing file 2 years ago
florent.teppe 256d8a699a moves one function from tuplemeta.hpp to newly created tuplehelpers.hpp 2 years ago
florent.teppe 65bd007baa simplified some big switch/case 2 years ago
ζeh Matt aa65df8872
Rename meta.hpp to tuplemeta.hpp 2 years ago
ζeh Matt c856095562
Use compile time generated indices for tuples types 2 years ago
ζeh Matt 8f7703d5c8
Rename HasMember to TupleHasType and move code into misc/meta.hpp 2 years ago
jvoisin 9f62f0c292 Reserve the output buffer in lowerCaseUtf8
Since lowercasing an utf8 string shouldn't change its size very much,
it does make sense to reserve the output buffer, to reduce
memory allocations.
2 years ago
Cédric Mocquillon 83ee25711e Use the pattern according to the esm version 2 years ago
Cédric Mocquillon 6a3d27ce82 Add a dictionary to retrieve the LOD mesh name of a mesh cache 2 years ago
Evil Eye 02bbb0be45 Improve format workaround and add unit tests 2 years ago
Evil Eye 4e2e5ad002 Revert format change and ensure string_view args are null-terminated 2 years ago
Evil Eye 1d21330fcc Return string_view from getGameSettingString 2 years ago
psi29a 1f5277349c Merge branch 'span' into 'master'
Replace Misc::Span by std::span

See merge request OpenMW/openmw!2324
2 years ago
psi29a 9c24d6b390 Merge branch 'ci_starts_with' into 'master'
Replace ciCompareLen with ciStartsWith where possible

See merge request OpenMW/openmw!2325
2 years ago
Evil Eye 150d1840d6 Use more string_view and const string& 2 years ago
elsid 5dc612aa54
Replace ciCompareLen with ciStartsWith where possible
`ciCompareLen(a, b, b.size()) == 0` expression is an equivalent of checking for
equality of `a` prefix with size `b.size()` with `b`.

`ciCompareLen(a, b, a.size()) == 0` is also the same thing but `a` is a prefix
`b` should start with.
2 years ago
elsid e4a254deb7
Replace Misc::Span by std::span 2 years ago
psi29a bf40f9b287 Merge branch 'name_view' into 'master'
Make Class::getName return string_view

See merge request OpenMW/openmw!2289
2 years ago
Evil Eye 4ff12d8945 Make Class::getName return string_view 2 years ago
elsid cc8c7002ea
Cleanup components includes 2 years ago
Matt e6868fd211 Allow constexpr hashing 2 years ago
Evil Eye de8d9b8db3 Use Fowler-Noll-Vo hash instead of std::hash 2 years ago
Evil Eye de51525c76 Allow string_view lookups in MWWorld::Store and get some use out of that 2 years ago
elsid f99ed6f1db
Split components/misc/stringops.hpp into multiple headers
Replace all ciEqual overloads with one having std::string_view as argument.
2 years ago
Andrei Kortunov de58c9dff3 Get rid of obsolete osg::Geode where it is possible 2 years ago
Andrei Kortunov 6f6b5ba04b Some refactoring 2 years ago
elsid 22ed6d5c1e
Use unsigned to define number of threads 3 years ago
Andrei Kortunov fe785ea788 Don't cast away const when we can avoid it 3 years ago
glassmancody.info b09411d396 allow soft particles on meshes and add extra data extensions 3 years ago
elsid 6abb963bd9
Use string_view for StringUtils functions 3 years ago
uramer 1fb136a417 Correct icon and mesh paths in Lua records 3 years ago
psi29a a737b05d84 Merge branch 'faster_toLower' into 'master'
Improve the speed of toLower

See merge request OpenMW/openmw!1889
3 years ago
jvoisin 998f1c960e Improve the speed of toLower
This significantly improves the speed of my fuzzer,
by something like 15%.
3 years ago
Evil Eye e79f803402 Change includes 3 years ago
Evil Eye c6ca0e78c9 Make getStringLiteral return a string_view 3 years ago
cody glassman 0cb63ca4e6 experimental point light bindings 3 years ago
elsid 79676aee15
Make Environment a storage of referencing pointers instead of owned
Engine controls lifetime of managers therefore it should own them. Environment
is only access provider.

This allows to avoid redundant virtual calls and also some functions from
managers base classes can be removed if they are used only by Engine.
3 years ago
elsid 0dcb1f5aac
Fix build on Windows
Use wrapper header over Windows.h to undefine far and near in a single place.
3 years ago
elsid 39da3bfef8
Ignore player when checking whether AiTravel destination is occupied by other actor 3 years ago
elsid 2d5ccc804b
Exchange binary messages between navmeshtool and launcher 3 years ago
ζeh Matt d7de17a1ac
Add a comment explaining the pick of the prng 3 years ago
ζeh Matt 5df76f5051
Remove unnecessary debug output 3 years ago
ζeh Matt f8f3bb2421
Use std::minstd_rand and split serialization from save/load 3 years ago
ζeh Matt 151770ccf1
Separate global vs world rng functions and use custom prng 3 years ago
ζeh Matt 08fae7be6e
Pass the prng from world where appropriate 3 years ago
ζeh Matt d83a381f79
Refactor and rename some things around Misc::Rng 3 years ago
Bret Curtis 6601274992 constify weakcache overloaded operators 3 years ago
elsid 42d6032c8b
Support compilation with c++20 3 years ago
elsid 1b2954f2db
Remove unused z coordinate 3 years ago
elsid b0f192d878
Fix warning: maybe-uninitialized
../../components/misc/color.cpp: In static member function 'static Misc::Color Misc::Color::fromHex(std::string_view)':
../../components/misc/color.cpp:36:24: error: 'v' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   36 |             rgb[i] = v / 255.0f;
      |                      ~~^~~~~~~~
3 years ago
psi29a 7bab714825 Merge branch 'fix_circling_fargoth' into 'master'
Remove unnecessary loops from path (#6510)

Closes #6510

See merge request OpenMW/openmw!1584
3 years ago
elsid 7ec7c57879
Remove unnecessary loops from path
This prevents actors going back when a new shortest path includes a point
behind them where they were right before. Such situation can happen when path
includes off mesh connection. Resulting cost of such path can be lower than
the real one because off mesh connections are straight lines and walking
surface usually is not a plane but a surface.

Skip to path point where distance from current position to the line between
previous and this point is less than point tolerance. Which means actor is
standing very close to the edge between those points. Additionally check by
navmesh raycasting to make sure there is actually a valid path.
3 years ago
Bret Curtis 74e7cfc023 remove unused includes: part1
remove unused imports: part2

revert one tidy we will keep for c++20
3 years ago
Bret Curtis d1fb854521 move most of the files from esm to esm3, keep common code in esm; this is make space for a future with esm4
esm typo

esm typo
3 years ago
elsid a2002bc983
Support frequency of ProgressReporter calls lower than interval 3 years ago
uramer d1d8f058ac Lua bindings for Colours 3 years ago
elsid aaf6c82e33
Do not write shapes to navmeshdb when writing is disabled 3 years ago
elsid 5a6b39f8e0
Store mesh source data in recast mesh 3 years ago
psi29a adc3bab51e Merge branch 'Embedded-error-marker' into 'master'
Embed marker error

See merge request OpenMW/openmw!1383
3 years ago
Cédric Mocquillon 40656b3135 Embed error marker in osgt format inside a string defined in misc/errorMarker.hpp.
Use the embed error marker we fail to load a mesh.
3 years ago
Evil Eye 6daefe3ddc Cast to the unsigned char expected by cctype functions 3 years ago
Evil Eye f23bd51175 Don't check bounds when the type is unambiguously a char 3 years ago
Evil Eye c6470f33d3 Use string_view 3 years ago
Evil Eye 751e8cf76b Do a bounds check before calling functions defined in cctype 3 years ago
Evil Eye 8f48a1f030 Handle non-ASCII characters while saving without triggering an assertion 3 years ago
elsid 08a25c2b1f
Support seed type different from std::size_t for hashCombine 3 years ago
psi29a 41bd20e358 Merge branch 'bullet_shape_hash' into 'master'
Store BulletShape source file name and content hash

See merge request OpenMW/openmw!1379
3 years ago
elsid d7041613ef
Store BulletShape source file name and content hash 3 years ago
Cédric Mocquillon 512d64e514 Extract correctSoundPath method to avoid code duplication. Add unit test for the new method 3 years ago
elsid 3f80725ebe
Remove duplicated implementation of Misc::Convert::toOsg 3 years ago
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 0371072631
removes lowerCaseInPlace (#3217)
This PR removes unneeded `lowerCaseInPlace` calls in in a hot path of `objectpaging.cpp` that are no longer necessary after PR #3197. In addition, I have been informed that these changes should by coincidence address a compiler specific compilation error we currently experience.
3 years ago
Petr Mikheev 33d71be81f Add LuaUtil::ScriptsConfiguration 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
elsid e5413c0664
Add functions to compress/decompress vector of bytes 3 years ago
elsid bb26ba30b6
Add progress reporter type
To log/report progress of long duration operations using given time period.
3 years ago
psi29a 207a7245bc Merge branch 'navigator_settings' into 'master'
Initialize navigator max climb and max slope settings in makeSettingsFromSettingsManager

See merge request OpenMW/openmw!1283
3 years ago
elsid 405e814190
Move btCollisionObject creation for MWPhysics::Object into components 3 years ago
elsid 6986feb81b
Initialize navigator max climb and max slope settings in makeSettingsFromSettingsManager
To avoid having multiple places to initialize them when they will be required
by multiple binaries.
3 years ago
fredzio 21dbe314bf Use common function for sync and async case. Now both cases follow the
same flow, synchronous simulation is just a special case.
3 years ago
Cédric Mocquillon 6817282097 Move getFileExtension to common header and use instead of repeating same code 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
elsid 3caf45807f
Use common implementation to filter hidden markers 3 years ago
jvoisin 9db7d0278a Sprinkle some const ref 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 5840279f16 Use `default` instead of empty constructors/destructors
See https://pvs-studio.com/en/docs/warnings/v832/ for details
4 years ago
jvoisin 1123dc46ee Add a ton of const refs 4 years ago
jvoisin e51669c05d Don't assign a variable passed by value 4 years ago
elsid 1e2aae8095
Use stable sort+unique to collect RefIDs for ESMStore records counting
The idea is to avoid std::map lookup for each CellRef. Instead generate a
sequence of added and removed RefNums into a vector then order them by RefNum
using a stable sort that preserves relative order of elements with the same
RefNum. RefIDs are stored in a different vector to avoid std::string move ctor
calls when swapping elements while sorting. Reversed iteration over added and
removed RefNums for each unique RefNum is an equivalent to what map-based
algorithm produces. The main benefit from sorting a vector is a data locality
that means less cache misses for each access. Reduces ESMStore::countRecords
perf cycles by 25%.
4 years ago
psi29a fd89582e0c Merge branch 'navmesh_wait' into 'master'
Wait until navmesh is generated within given distance around player (#5500)

Closes #5500

See merge request OpenMW/openmw!819
4 years ago
elsid 626e032931
Do not store callback inside Misc::Barrier
The only wait method can be provided with it so pass it as a template
parameter there.
4 years ago
elsid f169f8e6f0
Wait until navmesh is generated for interior cells
Add special loading progress bar.

It should be fast enough to not keep loading screen for noticably long but
will provide better pathfinding for actors inside interior cells.
4 years ago
Andrei Kortunov f308dde254 Clean up MSVC warnings 4 years ago
fredzio 16b288f53c Re-add dropped struct keyword to fix build.
rtprio is both a struct and a function, so we need to be explicit.

../../../components/misc/thread.cpp:53:9: error: must use 'struct' tag
to refer to type 'rtprio' in this scope
rtprio prio;
^
struct
/usr/include/sys/rtprio.h:91:5: note: struct 'rtprio' is hidden by a
non-type declaration of 'rtprio' here
int     rtprio(int, pid_t, struct rtprio *);
^
1 error generated.
4 years ago
psi29a c686dd05d0 Merge branch 'thread_idle_priority' into 'master'
Set idle priority for navmesh generation thread

See merge request OpenMW/openmw!632
4 years ago
elsid ab8d1c02d4
Set idle priority for navmesh generation thread
Support Linux, Windows, FreeBSD.
4 years ago
glassmancody.info 582f7b52cf Merge remote-tracking branch 'upstream/master' into why_are_the_christmas_lights_still_up 4 years ago
glassmancody.info 9e80091aff clear up force shaders and make it less convoluted 4 years ago
Andrei Kortunov 124a33d8a3 Fix uninitialized variables 4 years ago
Max 2cd96e56d5 create constant and use constant in other parts of the code base 4 years ago
psi29a 415591b7ed Merge branch 'ai_reaction_deviation' into 'master'
Distribute AI reactions and engage combat calls over time

See merge request OpenMW/openmw!674
4 years ago
wareya 63f01d8c5f Prevent physics death spiral by falling back to true delta time when needed 4 years ago
elsid 675c0ab72f
Apply uniform random deviation to AI reaction timer
This allows to distribute AI reaction calls over time.

Before this change actors appearing at the same frame will react in the same
frame over and over because AI reaction period is constant. It creates a
non-uniform CPU usage over frames. If a single frame has too many AI reactions
it may cause stuttering when there are too many actors on a scene for current
system.

Another concern is a synchronization of actions between creatures and NPC.
They start to go or hit at the same frame that is unnatural.
4 years ago
elsid 8ab5fd9b40
Fix frame rate limit
Measure time at the computation end but before sleep. This allows to adjust
sleep interval for the next frame in case sleep is not precise due to syscall
overhead or too low timer resolution.

Remove old frame limiting mechanism.
4 years ago
Sergey Fukanchik f3271cb66b Add unit test for swapEndiannessInplace(). Part of Bug #5837 4 years ago
Petr Mikheev 31b5150e0d Fix implementation of Misc::swapEndiannessInplace 4 years ago
Petr Mikheev 14dd11372f Utility functions for little-endian <-> big-endian conversion. 4 years ago
fredzio 1357bba0a0 Use some C++17 where it makes the code more readable
Also replace boost::optional
4 years ago
Bret Curtis 82431b752d removed unnessary bits that cmake should be doing for us; replace Misc::gcd with std::gcd 4 years ago
AnyOldName3 df178ed97c Merge branch 'container-regressions' into 'master'
Fix container regressions

See merge request OpenMW/openmw!346

(cherry picked from commit b0aee6f83d4cddb0116284b197913f9687dd9cee)

95e7a22d fix container regressions
4 years ago
fredzio 3c2504b442 Process movement queue in one or several background threads
Before movement calculation, the main thread prepare a
vector of ActorFrameData, which contains all data necessary to perform
the simulation, and feed it to the solver. At the same time it fetches
the result from the previous background simulation, which in turn is
used by the game mechanics.
Other functions of the physics system (weapon hit for instance)
interrupt the background simulation, with some exceptions described
below.

The number of threads is controlled by the numeric setting

[Physics]
async num threads

In case 'async num threads' > 1 and Bullet doesn't support multiple threads,
1 async thread will be used. 0 means synchronous solver.
Additional settings (will be silently switched off if async num threads = 0)

[Physics]
defer aabb update

Update AABBs of actors and objects in the background thread(s). It is not an especially
costly operation, but it needs exclusive access to the collision world, which blocks
other operations. Since AABB needs to be updated for collision detection, one can queue
them to defer update before start of the movement solver. Extensive tests on as much
as one installation (mine) show no drawback having that switched on.

[Physics]
lineofsight keep inactive cache

Control for how long (how many frames) the line of sight (LOS) request will be kept updated.
When a request for LOS is made for the first time, the background threads are stopped to
service it. From now on, the LOS will be refreshed preemptively as part of the background
routine until it is not required for lineofsight keep inactive cache frames. This mean
that subsequent request will not interrupt the background computation.
4 years ago
Assumeru 72549651e0
Rework container resolution (#3006)
* Rework container resolution

* add optional argument to getCount

* remove now-redundant changes

* undo worldimp changes

* move save-fixing code to InventoryState

* replace Rng instances with Seeds
4 years ago
psi29a f90a049702 Merge branch 'movement_refactoring' into 'master'
Refactoring related to "smooth movement"

See merge request OpenMW/openmw!285

(cherry picked from commit 6eaf0a389d5aed3b74ab1a7cf89574612f964bdf)

e847b4c8 Split getSpeed() to getMaxSpeed() and getCurrentSpeed()
a96c46bc Refactor calculation of movement.mSpeedFactor
03ee9090 Use getMaxSpeed instead of getCurrentSpeed where it makes sense.
a178af5c Create helper functions `normalizeAngle` and `rotateVec2f`
4 years ago
elsid 02f9b44f01
Use RAII for object ptr from pool 5 years ago
elsid 6ca29c6107
Use common type for pool of sounds and streams 5 years ago
Andrei Kortunov d1a3cc98ff Get rid of ECLD and dependencies 5 years ago
elsid c4cd3b2c4f
Add pathgrid to navmesh as off mesh connection 5 years ago
elsid bd1ef4dd6d
Add detournavigator test for multiple worker threads 5 years ago
Frederic Chardon 513ac8986d Add link to opencs documentation on readthedocs, available through
context menu.
The documentation opens in default browser.

There are 3 contexts:
- global: opens the OpenMW CS User Manual main page
- when a record is selected: opens the "Tables" page
- when the filter field is selected: opens the "Record Filters" page

There is also a link to the OpenCS tutorial in the help menu.
5 years ago
Andrei Kortunov a250a405b4 An attempt to fix the MSVC2017 build 5 years ago
Andrei Kortunov 1cdd33b434 Implement additional stringops to avoid Boost functions 5 years ago
Andrei Kortunov e679190f31 Introduce a custom format() function to get rid of boost::format() and hackish replace() 6 years ago
Andrei Kortunov 861d41f4a4 Native graphics herbalism support (feature #5010) 6 years ago
elsid ccc709a316
Store guarded navmesh cache item in shared_ptr
Remove useless SharedGuarded type.
6 years ago
Andrei Kortunov bf5f68a4d8 Replace boost GCD to the homebrew implementation 6 years ago
Grigory Latyshev 3872d7476b Move makeOsgVec3f() to settingsutils.hpp
Remove all other makeOsgVec3f() implementations
6 years ago
Grigory af7b6a09a8 Simplify Misc::StringUtils::toLower 6 years ago
elsid 33f6fb258d
Option to set specific random seed for random number generator 6 years ago