Commit Graph

431 Commits (7d9d377575ff6aac58561c670c8716314386700a)

Author SHA1 Message Date
elsid 472a36d92a
Cleanup detournavigator includes 2 years ago
elsid 3e99deb0e8
Use typed settings storage for detournavigator 2 years ago
elsid 28f7a89530
Reuse dtNavMeshQuery
To avoid redundant allocations.
2 years ago
elsid 996153f78d
Convert RefId to class 2 years ago
florent.teppe 63e44eddc9 Navigator doesn't use RefId anymore 2 years ago
florent.teppe 150e2ba885 Revert "Use ESM::RefId for worldspace in detournavigator"
This reverts commit b4ab153418.

# Conflicts:
#	apps/navmeshtool/worldspacedata.cpp
2 years ago
elsid cf1d8544e3
Check agent bounds on adding agent to navigator
Do not add agent bounds which are not supported by recastnavigation with given
settings and log such events.

To avoid reaching navmesh tile generation to find out it can't be generated for
such agent bounds.
2 years ago
elsid 44429f0393
Limit NavMeshManager update range by player tile and max tiles
Object AABB may be much larger than area currently covered by navmesh. In this
case all tiles beyond covered range should be ignored. Attempt to iterate over
them will not result in any new tile updates but can take quite a while. At
maximum this can be pow(INT_MAX - INT_MIN, 2) iterations.

Use arbitrary time limit to check for update call to finish in the test.
2 years ago
Petr Mikheev 8c7d347179 Reorganize l10n files 2 years ago
elsid c71862a8df
Reset rcPolyMeshDetail members after rcFree
To avoid double free causing by later recastnavigation versions.
2 years ago
elsid b4ab153418
Use ESM::RefId for worldspace in detournavigator 2 years ago
florent.teppe 1ef1de974d script blacklist => RefId
Applies changes from review

Fixed clang format

Clang format + review.
2 years ago
florent.teppe 2c30575b3b CellName is now a RefId, makes more sense that way. 2 years ago
psi29a 14afde4689 Merge branch 'recast_context' into 'master'
Check input and report errors via RecastContext (#7093)

Closes #7093

See merge request OpenMW/openmw!2544
2 years ago
elsid 15e8f0b53c
Check input and report errors via RecastContext
Recast functions have preconditions for arguments they don't validate. This may
produce garbage data which may lead to crash. Check arguments and log when they
are invalid.

Do not throw exceptions when these function calls fail, capture Recast reported
errors via RecastContext inherited from rcContext and log them.
2 years ago
Evil Eye d40c09c18c Ignore non-3D agents in the navigator 2 years ago
elsid 843753da14
Remove unused includes 2 years ago
elsid 624d8bc931
Support unsigned settings values 2 years ago
elsid 1b9b61b60b
Format navmesh water vertices and indices 2 years ago
clang-format-bot ddb0522bbf
Apply clang-format to code base 2 years ago
Project579 a13709c510 Replace implicit convertions from std::filesystem::path to std::string with correctly converting functions. 2 years ago
Project579 e5c417c968 Make sure all paths are passed as std::filesystem::path instead of std::string where possible. 2 years ago
elsid 22ee592dd3
Lock TileCachedRecastMeshManager once per changing a cell
To save time on locking mutex and prevent AsyncNavMeshUpdater to use RecastMesh
for a tile in the middle of objects loading.
2 years ago
elsid d15e1dca84
Use R-tree for objects to be used for navmesh generation
Instead of storing a set of objects per tile.
2 years ago
elsid 180d609e0d
Check "wait until min distance to player" only for requiredTilesPresent wait condition
allJobsDone should wait even if "wait until min distance to player" is 0.
2 years ago
elsid 98ddc31902
Fix calculating min distance to nearest absent tile
Tile can be present in either mPushed (waiting in a queue), mProcessingTiles (
being processed or waiting in db queue), mPresentTiles (added to navmesh). It's
not enough to walk over mPushed tiles to find all not present. Need also to
check mProcessingTiles.

Otherwise if all tiles are in mProcessingTiles only
waitUntilJobsDoneForNotPresentTiles may return too early because there are none
in mPushed and therefore none tiles are considered to be absent on navmesh which
is not true.
2 years ago
elsid de80b86cc1
Use proper type to cast enum value 2 years ago
elsid 204ab6fea3
Use version instead of generation and revision for recast mesh 2 years ago
elsid 914edd1194
Make frequently called oneliners inline 2 years ago
elsid d1a294664e
Do not try to update tile to post
changedTiles contains unique set of positions and tilesToPost is empty initially
therefore it's not possible to add the same position twice.
2 years ago
elsid e2d566b89d
Store changed tiles in TileCachedRecastMeshManager 2 years ago
elsid c15848932b
Separate reading navigator stats and reporting 2 years ago
elsid e9be8b5efe
Show stats for writing and reading navmesh db queue jobs 2 years ago
elsid ab1ddc690e
Do not check getPolyHeight status
It may fail in some cases depending on a platform without obvious reason.
2 years ago
elsid aea4614240
Fix clang tidy warning 2 years ago
elsid 8147d49178
Remove redundant lock
mGeneration is const and mRevision is changed only from the same thread.
2 years ago
elsid 2885885331
Increase mutex scope in TileCachedRecastMeshManager functions
Which are called from the main thread.
2 years ago
elsid e1bed86d7e
Do single navigator update per frame
Primarily for crossing cell border case. Each Navigator::update call has a cost.
Doing it multiple times per frame increased frame duration on cell loading.

Call Navigator::wait only when cell has changed but do not use
Scene::hasCellChanged because it doesn't always indicates it.
2 years ago
elsid b1fb42a28c
Cleanup detournavigator includes 2 years ago
Andrei Kortunov e3ad30a517 Do not copy data when it is not needed 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
elsid 8b8e4f78b6
Support cylinder and rotating box collision shape types for actors
Cylinder collision shape should give the best consistency between physics
simulation and pathfinding. Rotating box is already used by some actors, so
add it to have the same collision shape type for all actors.
2 years ago
elsid 27cc901e76
Add bindings for navigator utils functions 2 years ago
Andrei Kortunov ccbb5e03fb Use YAML files to translate MyGUI's localization tags 3 years ago
psi29a 510a9b9a5e Merge branch 'navmeshtilescache_find' into 'master'
Avoid redundant copy when finding item in NavMeshTilesCache

See merge request OpenMW/openmw!2109
3 years ago
elsid 6fb7af3b63
Avoid redundant copy when finding item in NavMeshTilesCache
std::make_tuple returns a tuple for types with removed references which makes it
to copy arguments. std::tie leaves references.
3 years ago
elsid 5b9ca3b979
Avoid possible division by zero
components/detournavigator/navmeshdb.cpp:183:43: warning: Division by zero [clang-analyzer-core.DivideZero]
        setMaxPageCount(*mDb, maxFileSize / dbPageSize + static_cast<std::uint64_t>((maxFileSize % dbPageSize) != 0));
                              ~~~~~~~~~~~~^~~~~~~~~~~~
components/detournavigator/navmeshdb.cpp:182:33: note: Calling 'getPageSize'
        const auto dbPageSize = getPageSize(*mDb);
                                ^~~~~~~~~~~~~~~~~
components/detournavigator/navmeshdb.cpp:144:13: note: 'value' initialized to 0
            std::uint64_t value = 0;
            ^~~~~~~~~~~~~~~~~~~
components/detournavigator/navmeshdb.cpp:145:13: note: Calling 'request<DetourNavigator::(anonymous namespace)::GetPageSize, unsigned long *, >'
            request(db, statement, &value, 1);
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
components/sqlite3/request.hpp:254:64: note: Left side of '&&' is false
            for (std::size_t i = 0; executeStep(db, statement) && i < max; ++i)
                                                               ^
components/detournavigator/navmeshdb.cpp:145:13: note: Returning from 'request<DetourNavigator::(anonymous namespace)::GetPageSize, unsigned long *, >'
            request(db, statement, &value, 1);
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
components/detournavigator/navmeshdb.cpp:146:13: note: Returning zero (loaded from 'value')
            return value;
            ^~~~~~~~~~~~
components/detournavigator/navmeshdb.cpp:182:33: note: Returning from 'getPageSize'
        const auto dbPageSize = getPageSize(*mDb);
                                ^~~~~~~~~~~~~~~~~
components/detournavigator/navmeshdb.cpp:182:9: note: 'dbPageSize' initialized to 0
        const auto dbPageSize = getPageSize(*mDb);
        ^~~~~~~~~~~~~~~~~~~~~
components/detournavigator/navmeshdb.cpp:183:43: note: Division by zero
        setMaxPageCount(*mDb, maxFileSize / dbPageSize + static_cast<std::uint64_t>((maxFileSize % dbPageSize) != 0));
                              ~~~~~~~~~~~~^~~~~~~~~~~~
3 years ago
Andrei Kortunov 124db67496 Add an assert to detect possible nullptr dereference 3 years ago
elsid 8544aa481c
Fix C4459 msvc warning
declaration of 'navMeshVersion' hides global declaration
3 years ago
elsid 1a5932a669
Move std::ostream& operator<< to .cpp 3 years ago
elsid 1a12c453d6
Support different agent collision shape type for pathfinding
Actors may have different collision shapes. Currently there are axis-aligned
bounding boxes and rotating bounding boxes. With AABB it's required to use
bounding cylinder for navmesh agent to avoid providing paths where actor can't
pass. But for rotating bounding boxes cylinder with diameter equal to the front
face width should be used to not reduce of available paths. For example rats
have rotating bounding box as collision shape because of the difference between
front and side faces width.

* Add agent bounds to navmesh tile db cache key. This is required to distinguish
  tiles for agents with different bounds.
* Increase navmesh version because navmesh tile db cache key and data has changed.
* Move navmesh version to the code to avoid misconfiguration by users.
* Fix all places where wrong half extents were used for pathfinding.
3 years ago
elsid fdd84265b3
Use proper agent height and radius when render actor path
That are based on half extents used to find path over navmesh which is different
for interior and exterior cells.

Use common functions to get agent height and radius for actor path rendering and
navmesh generation.
3 years ago
jvoisin 72a6d1f69f Clean up bullet includes 3 years ago
jvoisin 4e4debb1cb Remove even more of boost::filesystem 3 years ago
elsid 5b592e09e6
Log more information when navmeshtool fails on not enough space 3 years ago
ζeh Matt 18f16eac4c
Refactor DetourNavigator to pass prng along, use world prng for AiWander 3 years ago
elsid a75c7c49f0
Disable writes to navmeshdb on database is locked error
Simultaneously writing to sqlite3 database is not possible. Process exclusively
locks the database for this. Another process will fail to perform any request
when database is locked. Alternatively it can wait. Handling this situation
properly requires complexity that is not really needed. Users are not expected
to run multiple openmw processes simultaneously using the same navmeshdb.

Before this change running multiple openmw processes using the same navmeshdb
can lead to a crash when first transaction fails to start because there is
exception thrown and not catched.

Remove use of explicit transactions from DbWorker. Handling all possible
transaction states due to different errors brings unnecessary complexity.
Initially they were introduced to increase time between flushes to disk. This
makes sense for navmeshtool because of massive number of writes but for the
engine this is not an issue.
3 years ago
elsid 5b9dd10cbe
Limit max navmeshdb file size
Use "pragma max_page_count" to define max allowed file size in combination with
"pragma page_size" based on a new setting "max navmeshdb file size".

* Stop navmeshtool on the first db error.
* Disable writes to db in the engine on first "database or disk is full"
  SQLite3 error. There is no special error code for this error.
* Change default "write to navmeshdb" to true.
* Use time intervals for transaction duration instead of number of changes.
3 years ago
elsid 42d6032c8b
Support compilation with c++20 3 years ago
psi29a b03f9e430c Merge branch 'navmesh_disk_rm_unused_tiles' into 'master'
Add navmeshtool flag to remove unused tiles from navmesh disk cache

See merge request OpenMW/openmw!1671
3 years ago
elsid 8b4362ece7
Disable navmesh disk cache when db is failed to open 3 years ago
elsid ab1a6e034e
Add navmeshtool flag to remove unused tiles from navmesh disk cache
* Remove tiles outside processing range. Useful when new content profile map
  has different bounds.
* Remove ignored tiles. For a case when content profile maps have intersection
  but there is no more data for navmesh.
* Remove older tiles at the same worldspace position. If navmesh tile data has
  changed with new content, the old ones unlikely to be used.
* Vacuum the database when there are modifications. SQLite leaves empty pages
  in the file on database modification. Vacuum cleans up unused pages reducing
  the file size.
3 years ago
elsid 67741402b5
Replace reference to const std::string by std::string_view for navmeshdb related arguments 3 years ago
elsid 0b644a897e
Explicitly bind TileCachedRecastMeshManager with mutex 3 years ago
elsid 05b54cbfb8
Cull navmesh objects by scene bounds
If object is too big iteration over all tiles covering it can take too much
time. Limit bounds to a square around a player position to cover only tiles
that will be present in navmesh based on max tiles number option.

Each object is associated with a set of tiles its present in. Culling can
reduce this set but it has to be update when bounds change position. Do this
in TileCachedRecastMeshManager::setBounds updating the set and adding/removing
objects to the corresponding CachedRecastMeshManagers.
3 years ago
elsid 563f3f87dd
Reduce critical sections size 3 years ago
elsid a5b078e9a7
Allow to represent empty range with TilesPositionsRange 3 years ago
elsid 1b2954f2db
Remove unused z coordinate 3 years ago
elsid 1a52a2a029
Clamp tile position 3 years ago
elsid 542717394a
Remove objects, water and heightfields when no longer required 3 years ago
elsid 7ea5aa250b
Revert "Cull navmesh objects by scene bounds"
This reverts commit b0ef20c303.
3 years ago
psi29a 6f7a067e0c Merge branch 'esmrename' into 'master'
esm refactor work

See merge request OpenMW/openmw!1575
3 years ago
elsid 9069e97dce
Filter out triangles with NaN coordinates
Sorting a vector with such values gives invalid result because comparison with
NaN is always false.
3 years ago
elsid b0ef20c303
Cull navmesh objects by scene bounds
If object is too big iteration over all tiles covering it can take too much
time. Limit bounds to a square around a player position to cover only tiles
that will be present in navmesh based on max tiles number option.
3 years ago
elsid bba7beb0c5
Split tiles position range creation and iteration over 3 years ago
elsid 12ce82980c
Revert "Limit and filter navmesh input (#5858)"
This reverts commit ecc654a369.
3 years ago
elsid ecc654a369 Limit and filter navmesh input (#5858) 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
jvoisin 421e6629ad Fix unnecessary-copy-initialization
> warning: the variable 'key' is copy-constructed from a const reference but is
only used as const reference; consider making it a const reference
[performance-unnecessary-copy-initialization]

Found by clang-tidy.
3 years ago
elsid aaf6c82e33
Do not write shapes to navmeshdb when writing is disabled 3 years ago
elsid 96eb8d7be9
Write generated navmesh to navmeshdb
Perform all request to db in a single thread to avoid blocking navmesh
generator threads due to slow write operations.

Write to db navmesh for all changes except update as it done for memory cache.

Batch multiple db operations into a single transaction to speed up writing by
not executing fsync after each insert/update query. All reads are performed in
the same transaction so they see uncommited data.
3 years ago
elsid c9b8ba7b46
Read navmesh tile data from database
When tile is not found in memory cache try to find it in the database.
3 years ago
elsid 953a4c5550
Add a binary to generate navmesh from content files
Load content files based on the engine config files. Generate navmesh per cell
for all cells and store into SQLite database.
3 years ago
elsid 5325495f46
Move serialization detournavigator/ -> components/ 3 years ago
elsid 01c712d5f1
Split navigator settings into subtypes
Mostly to distinguish settings that affect properties of the generated navmesh.
3 years ago
elsid 33bb18850d
Move operator<< to debug.hpp 3 years ago
elsid 5a6b39f8e0
Store mesh source data in recast mesh 3 years ago
elsid 7dcb219ecf
Add raw heightfield data to navigator 3 years ago
elsid 8571c317d8
Add raw water data to navigator 3 years ago
elsid f4f4458d01
Calculate recast mesh bounds when building navmesh 3 years ago
elsid e10bbb9ad7
Shift heightfield and water in navigator tests 3 years ago
psi29a 7256654f29 Merge branch 'navmesh_render' into 'master'
Rework navmesh render (#6187)

See merge request OpenMW/openmw!1338
3 years ago
elsid 3c41d0efc3
Render each navmesh tile independently 3 years ago
elsid 6b7363bd59
Replace generation and revision by version 3 years ago
elsid ce7f8c90f8
Fix unity build 3 years ago
Brian Kelley ee41b94a73 Enable compilation on apple silicon 3 years ago
elsid 3b6184dcda
Add missing include
In file included from /<<BUILDDIR>>/openmw-0.47.0+git202111080927~ubuntu18.04.1/components/detournavigator/findsmoothpath.cpp:1:0:
/<<BUILDDIR>>/openmw-0.47.0+git202111080927~ubuntu18.04.1/components/detournavigator/findsmoothpath.hpp:93:48: error: field ‘mSettings’ has incomplete type ‘std::reference_wrapper<const DetourNavigator::Settings>’
         std::reference_wrapper<const Settings> mSettings;
                                                ^~~~~~~~~
In file included from /usr/include/c++/7/bits/move.h:54:0,
                 from /usr/include/c++/7/bits/nested_exception.h:40,
                 from /usr/include/c++/7/exception:143,
                 from /usr/include/c++/7/ios:39,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /<<BUILDDIR>>/openmw-0.47.0+git202111080927~ubuntu18.04.1/components/detournavigator/dtstatus.hpp:6,
                 from /<<BUILDDIR>>/openmw-0.47.0+git202111080927~ubuntu18.04.1/components/detournavigator/findsmoothpath.hpp:4,
                 from /<<BUILDDIR>>/openmw-0.47.0+git202111080927~ubuntu18.04.1/components/detournavigator/findsmoothpath.cpp:1:
/usr/include/c++/7/type_traits:2125:11: note: declaration of ‘class std::reference_wrapper<const DetourNavigator::Settings>’
     class reference_wrapper;
3 years ago
elsid 5972520b1a
Make sure areas size is 2 for rectangle 3 years ago
elsid 671e1e5424
Avoid copy when adding heightfield to vector 3 years ago
elsid 5f5163905a
Remove unused operator< for RecastMesh 3 years ago