1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 18:59:57 +00:00
Commit graph

436 commits

Author SHA1 Message Date
elsid
ce5fbd6b68
Write separator between Detour status flags 2023-06-10 13:14:52 +02:00
elsid
a90aa7d8b2
Count navmeshdb reads for each reading job 2023-05-17 10:08:34 +02:00
elsid
5ae8b9cae1
Report raw navmesh cache counters 2023-05-17 10:08:33 +02:00
elsid
04d439485b
Log more info about navmesh shapes and jobs 2023-05-14 18:34:31 +02:00
elsid
7a7c20d49e
Define single UpdateGuard type in a separate file 2023-04-22 13:22:07 +02:00
elsid
472a36d92a
Cleanup detournavigator includes 2023-04-22 13:21:59 +02:00
elsid
3e99deb0e8
Use typed settings storage for detournavigator 2023-03-28 20:47:34 +02:00
elsid
28f7a89530
Reuse dtNavMeshQuery
To avoid redundant allocations.
2023-02-17 15:05:25 +01:00
elsid
996153f78d
Convert RefId to class 2023-02-15 23:20:44 +01:00
florent.teppe
63e44eddc9 Navigator doesn't use RefId anymore 2023-01-21 18:39:57 +01:00
florent.teppe
150e2ba885 Revert "Use ESM::RefId for worldspace in detournavigator"
This reverts commit b4ab153418.

# Conflicts:
#	apps/navmeshtool/worldspacedata.cpp
2023-01-21 18:39:57 +01:00
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.
2023-01-18 12:00:48 +01:00
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.
2023-01-15 04:46:29 +01:00
Petr Mikheev
8c7d347179 Reorganize l10n files 2023-01-02 13:21:05 +01:00
elsid
c71862a8df
Reset rcPolyMeshDetail members after rcFree
To avoid double free causing by later recastnavigation versions.
2022-12-30 19:26:48 +01:00
elsid
b4ab153418
Use ESM::RefId for worldspace in detournavigator 2022-12-29 23:49:49 +01:00
florent.teppe
1ef1de974d script blacklist => RefId
Applies changes from review

Fixed clang format

Clang format + review.
2022-12-27 19:16:21 +01:00
florent.teppe
2c30575b3b CellName is now a RefId, makes more sense that way. 2022-12-27 19:16:21 +01:00
psi29a
14afde4689 Merge branch 'recast_context' into 'master'
Check input and report errors via RecastContext (#7093)

Closes #7093

See merge request OpenMW/openmw!2544
2022-12-20 09:31:31 +00:00
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.
2022-12-19 19:46:45 +01:00
Evil Eye
d40c09c18c Ignore non-3D agents in the navigator 2022-12-09 16:43:15 +01:00
elsid
843753da14
Remove unused includes 2022-10-09 16:44:18 +02:00
elsid
624d8bc931
Support unsigned settings values 2022-10-04 01:34:53 +02:00
elsid
1b9b61b60b
Format navmesh water vertices and indices 2022-09-27 00:46:34 +02:00
clang-format-bot
ddb0522bbf
Apply clang-format to code base 2022-09-22 21:35:26 +03:00
Project579
a13709c510 Replace implicit convertions from std::filesystem::path to std::string with correctly converting functions. 2022-09-11 14:41:20 +02:00
Project579
e5c417c968 Make sure all paths are passed as std::filesystem::path instead of std::string where possible. 2022-09-11 14:41:15 +02:00
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.
2022-09-08 11:06:35 +02:00
elsid
d15e1dca84
Use R-tree for objects to be used for navmesh generation
Instead of storing a set of objects per tile.
2022-09-07 22:51:56 +02:00
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.
2022-09-06 21:51:48 +02:00
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.
2022-09-06 21:51:48 +02:00
elsid
de80b86cc1
Use proper type to cast enum value 2022-09-06 21:51:48 +02:00
elsid
204ab6fea3
Use version instead of generation and revision for recast mesh 2022-09-06 21:51:48 +02:00
elsid
914edd1194
Make frequently called oneliners inline 2022-09-06 21:51:48 +02:00
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.
2022-09-06 21:51:48 +02:00
elsid
e2d566b89d
Store changed tiles in TileCachedRecastMeshManager 2022-09-05 11:49:39 +02:00
elsid
c15848932b
Separate reading navigator stats and reporting 2022-08-28 14:52:34 +02:00
elsid
e9be8b5efe
Show stats for writing and reading navmesh db queue jobs 2022-08-28 14:14:43 +02:00
elsid
ab1ddc690e
Do not check getPolyHeight status
It may fail in some cases depending on a platform without obvious reason.
2022-08-24 23:30:36 +02:00
elsid
aea4614240
Fix clang tidy warning 2022-08-20 19:17:45 +02:00
elsid
8147d49178
Remove redundant lock
mGeneration is const and mRevision is changed only from the same thread.
2022-08-20 19:15:58 +02:00
elsid
2885885331
Increase mutex scope in TileCachedRecastMeshManager functions
Which are called from the main thread.
2022-08-20 19:15:57 +02:00
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.
2022-08-20 19:15:55 +02:00
elsid
b1fb42a28c
Cleanup detournavigator includes 2022-08-15 19:46:10 +02:00
Andrei Kortunov
e3ad30a517 Do not copy data when it is not needed 2022-08-15 11:52:09 +04:00
elsid
f99ed6f1db
Split components/misc/stringops.hpp into multiple headers
Replace all ciEqual overloads with one having std::string_view as argument.
2022-08-03 22:06:24 +02:00
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.
2022-07-30 14:28:21 +02:00
elsid
27cc901e76
Add bindings for navigator utils functions 2022-07-21 00:04:26 +02:00
Andrei Kortunov
ccbb5e03fb Use YAML files to translate MyGUI's localization tags 2022-07-12 08:20:40 +04:00
psi29a
510a9b9a5e Merge branch 'navmeshtilescache_find' into 'master'
Avoid redundant copy when finding item in NavMeshTilesCache

See merge request OpenMW/openmw!2109
2022-07-06 13:48:24 +00:00
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.
2022-07-06 14:23:07 +02:00
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));
                              ~~~~~~~~~~~~^~~~~~~~~~~~
2022-07-06 13:52:28 +02:00
Andrei Kortunov
124db67496 Add an assert to detect possible nullptr dereference 2022-07-03 15:44:50 +04:00
elsid
8544aa481c
Fix C4459 msvc warning
declaration of 'navMeshVersion' hides global declaration
2022-07-01 18:47:40 +02:00
elsid
1a5932a669
Move std::ostream& operator<< to .cpp 2022-06-26 22:43:53 +02:00
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.
2022-06-21 12:57:32 +02:00
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.
2022-06-15 01:11:11 +02:00
jvoisin
72a6d1f69f Clean up bullet includes 2022-06-04 20:15:10 +02:00
jvoisin
4e4debb1cb Remove even more of boost::filesystem 2022-05-25 18:29:02 +00:00
elsid
5b592e09e6
Log more information when navmeshtool fails on not enough space 2022-05-23 13:01:30 +02:00
ζeh Matt
18f16eac4c
Refactor DetourNavigator to pass prng along, use world prng for AiWander 2022-05-17 20:37:15 +03:00
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.
2022-05-09 22:54:46 +02:00
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.
2022-03-18 19:08:46 +01:00
elsid
42d6032c8b
Support compilation with c++20 2022-02-24 00:49:40 +01:00
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
2022-02-19 13:56:44 +00:00
elsid
8b4362ece7
Disable navmesh disk cache when db is failed to open 2022-02-18 22:41:45 +01:00
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.
2022-02-18 21:57:23 +01:00
elsid
67741402b5
Replace reference to const std::string by std::string_view for navmeshdb related arguments 2022-02-18 21:45:50 +01:00
elsid
0b644a897e
Explicitly bind TileCachedRecastMeshManager with mutex 2022-02-03 22:24:26 +01:00
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.
2022-02-03 22:09:37 +01:00
elsid
563f3f87dd
Reduce critical sections size 2022-02-03 21:44:37 +01:00
elsid
a5b078e9a7
Allow to represent empty range with TilesPositionsRange 2022-02-03 21:43:56 +01:00
elsid
1b2954f2db
Remove unused z coordinate 2022-02-03 21:43:53 +01:00
elsid
1a52a2a029
Clamp tile position 2022-02-03 02:44:04 +01:00
elsid
542717394a
Remove objects, water and heightfields when no longer required 2022-02-03 02:43:35 +01:00
elsid
7ea5aa250b
Revert "Cull navmesh objects by scene bounds"
This reverts commit b0ef20c303.
2022-01-30 21:43:23 +01:00
psi29a
6f7a067e0c Merge branch 'esmrename' into 'master'
esm refactor work

See merge request OpenMW/openmw!1575
2022-01-27 17:52:42 +00:00
elsid
9069e97dce
Filter out triangles with NaN coordinates
Sorting a vector with such values gives invalid result because comparison with
NaN is always false.
2022-01-25 17:08:52 +01:00
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.
2022-01-25 17:08:45 +01:00
elsid
bba7beb0c5
Split tiles position range creation and iteration over 2022-01-25 16:34:03 +01:00
elsid
12ce82980c
Revert "Limit and filter navmesh input (#5858)"
This reverts commit ecc654a369.
2022-01-25 16:33:53 +01:00
elsid
ecc654a369 Limit and filter navmesh input (#5858) 2022-01-25 14:06:53 +00:00
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
2022-01-23 17:04:48 +01:00
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.
2022-01-04 20:42:09 +01:00
elsid
aaf6c82e33
Do not write shapes to navmeshdb when writing is disabled 2021-12-16 22:57:35 +01:00
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.
2021-12-11 00:22:04 +01:00
elsid
c9b8ba7b46
Read navmesh tile data from database
When tile is not found in memory cache try to find it in the database.
2021-12-11 00:22:04 +01:00
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.
2021-12-11 00:21:56 +01:00
elsid
5325495f46
Move serialization detournavigator/ -> components/ 2021-12-10 23:55:04 +01:00
elsid
01c712d5f1
Split navigator settings into subtypes
Mostly to distinguish settings that affect properties of the generated navmesh.
2021-12-10 23:55:03 +01:00
elsid
33bb18850d
Move operator<< to debug.hpp 2021-12-10 23:55:03 +01:00
elsid
5a6b39f8e0
Store mesh source data in recast mesh 2021-12-10 23:55:02 +01:00
elsid
7dcb219ecf
Add raw heightfield data to navigator 2021-12-03 01:16:15 +01:00
elsid
8571c317d8
Add raw water data to navigator 2021-12-03 01:16:15 +01:00
elsid
f4f4458d01
Calculate recast mesh bounds when building navmesh 2021-12-03 01:16:15 +01:00
elsid
e10bbb9ad7
Shift heightfield and water in navigator tests 2021-12-03 01:16:15 +01:00
psi29a
7256654f29 Merge branch 'navmesh_render' into 'master'
Rework navmesh render (#6187)

See merge request OpenMW/openmw!1338
2021-12-02 10:34:41 +00:00
elsid
3c41d0efc3
Render each navmesh tile independently 2021-11-21 17:42:27 +01:00
elsid
6b7363bd59
Replace generation and revision by version 2021-11-21 17:40:54 +01:00
elsid
ce7f8c90f8
Fix unity build 2021-11-21 14:24:18 +01:00