mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-18 13:12:50 +00:00
Merge branch 'revert_navmesh_cull' into 'master'
Revert "Cull navmesh objects by scene bounds" (#6580) See merge request OpenMW/openmw!1613
This commit is contained in:
commit
93b3b9df90
@ -36,7 +36,6 @@
|
||||
Bug #5788: Texture editing parses the selected indexes wrongly
|
||||
Bug #5801: A multi-effect spell with the intervention effects and recall always favors Almsivi intervention
|
||||
Bug #5842: GetDisposition adds temporary disposition change from different actors
|
||||
Bug #5858: Animated model freezes the game
|
||||
Bug #5863: GetEffect should return true after the player has teleported
|
||||
Bug #5913: Failed assertion during Ritual of Trees quest
|
||||
Bug #5928: Glow in the Dahrk functionality used without mod installed
|
||||
|
@ -819,8 +819,6 @@ namespace MWWorld
|
||||
|
||||
loadingListener->setProgressRange(cell->count());
|
||||
|
||||
mNavigator.updatePlayerPosition(position.asVec3());
|
||||
|
||||
// Load cell.
|
||||
mPagedRefs.clear();
|
||||
loadCell(cell, loadingListener, changeEvent);
|
||||
@ -854,8 +852,6 @@ namespace MWWorld
|
||||
if (changeEvent)
|
||||
MWBase::Environment::get().getWindowManager()->fadeScreenOut(0.5);
|
||||
|
||||
mNavigator.updatePlayerPosition(position.asVec3());
|
||||
|
||||
changeCellGrid(position.asVec3(), x, y, changeEvent);
|
||||
|
||||
CellStore* current = MWBase::Environment::get().getWorld()->getExterior(x, y);
|
||||
|
@ -90,10 +90,6 @@ namespace
|
||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||
const btTransform transform(btMatrix3x3::getIdentity(), btVector3(getTileSize(mSettings) / mSettings.mRecastScaleFactor, 0, 0));
|
||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||
TileBounds bounds;
|
||||
bounds.mMin = osg::Vec2f(-1000, -1000);
|
||||
bounds.mMax = osg::Vec2f(1000, 1000);
|
||||
manager.setBounds(bounds);
|
||||
manager.addObject(ObjectId(&boxShape), shape, transform, AreaType::AreaType_ground);
|
||||
EXPECT_TRUE(manager.updateObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground,
|
||||
[&] (const auto& v) { onChangedTile(v); }));
|
||||
@ -141,10 +137,6 @@ namespace
|
||||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, get_mesh_for_moved_object_should_return_recast_mesh_for_each_used_tile)
|
||||
{
|
||||
TileCachedRecastMeshManager manager(mSettings);
|
||||
TileBounds bounds;
|
||||
bounds.mMin = osg::Vec2f(-1000, -1000);
|
||||
bounds.mMax = osg::Vec2f(1000, 1000);
|
||||
manager.setBounds(bounds);
|
||||
manager.setWorldspace("worldspace");
|
||||
|
||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||
|
@ -2,7 +2,6 @@
|
||||
#include "settings.hpp"
|
||||
#include "settingsutils.hpp"
|
||||
#include "tileposition.hpp"
|
||||
#include "tilebounds.hpp"
|
||||
|
||||
#include <components/misc/convert.hpp>
|
||||
|
||||
@ -33,15 +32,12 @@ namespace DetourNavigator
|
||||
}
|
||||
|
||||
TilesPositionsRange makeTilesPositionsRange(const btCollisionShape& shape, const btTransform& transform,
|
||||
const TileBounds& bounds, const RecastSettings& settings)
|
||||
const RecastSettings& settings)
|
||||
{
|
||||
btVector3 aabbMin;
|
||||
btVector3 aabbMax;
|
||||
shape.getAabb(transform, aabbMin, aabbMax);
|
||||
aabbMin.setX(std::max<btScalar>(aabbMin.x(), bounds.mMin.x()));
|
||||
aabbMin.setY(std::max<btScalar>(aabbMin.y(), bounds.mMin.y()));
|
||||
aabbMax.setX(std::min<btScalar>(aabbMax.x(), bounds.mMax.x()));
|
||||
aabbMax.setY(std::min<btScalar>(aabbMax.y(), bounds.mMax.y()));
|
||||
|
||||
return makeTilesPositionsRange(Misc::Convert::toOsg(aabbMin), Misc::Convert::toOsg(aabbMax), settings);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_GETTILESPOSITIONS_H
|
||||
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_GETTILESPOSITIONS_H
|
||||
|
||||
#include "tilebounds.hpp"
|
||||
#include "tileposition.hpp"
|
||||
|
||||
class btVector3;
|
||||
@ -27,7 +26,7 @@ namespace DetourNavigator
|
||||
const osg::Vec3f& aabbMax, const RecastSettings& settings);
|
||||
|
||||
TilesPositionsRange makeTilesPositionsRange(const btCollisionShape& shape,
|
||||
const btTransform& transform, const TileBounds& bounds, const RecastSettings& settings);
|
||||
const btTransform& transform, const RecastSettings& settings);
|
||||
|
||||
TilesPositionsRange makeTilesPositionsRange(const int cellSize, const btVector3& shift,
|
||||
const RecastSettings& settings);
|
||||
|
@ -42,18 +42,6 @@ namespace
|
||||
|
||||
namespace DetourNavigator
|
||||
{
|
||||
namespace
|
||||
{
|
||||
TileBounds makeBounds(const RecastSettings& settings, const osg::Vec2f& center, int maxTiles)
|
||||
{
|
||||
const float radius = fromNavMeshCoordinates(settings, std::ceil(std::sqrt(static_cast<float>(maxTiles) / osg::PIf) + 1) * getTileSize(settings));
|
||||
TileBounds result;
|
||||
result.mMin = center - osg::Vec2f(radius, radius);
|
||||
result.mMax = center + osg::Vec2f(radius, radius);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
NavMeshManager::NavMeshManager(const Settings& settings, std::unique_ptr<NavMeshDb>&& db)
|
||||
: mSettings(settings)
|
||||
, mRecastMeshManager(settings.mRecast)
|
||||
@ -217,7 +205,6 @@ namespace DetourNavigator
|
||||
}
|
||||
}
|
||||
const auto maxTiles = std::min(mSettings.mMaxTilesNumber, navMesh.getParams()->maxTiles);
|
||||
mRecastMeshManager.setBounds(makeBounds(mSettings.mRecast, osg::Vec2f(playerPosition.x(), playerPosition.y()), maxTiles));
|
||||
mRecastMeshManager.forEachTile([&] (const TilePosition& tile, CachedRecastMeshManager& recastMeshManager)
|
||||
{
|
||||
if (tilesToPost.count(tile))
|
||||
@ -276,7 +263,7 @@ namespace DetourNavigator
|
||||
void NavMeshManager::addChangedTiles(const btCollisionShape& shape, const btTransform& transform,
|
||||
const ChangeType changeType)
|
||||
{
|
||||
getTilesPositions(makeTilesPositionsRange(shape, transform, mRecastMeshManager.getBounds(), mSettings.mRecast),
|
||||
getTilesPositions(makeTilesPositionsRange(shape, transform, mSettings.mRecast),
|
||||
[&] (const TilePosition& v) { addChangedTile(v, changeType); });
|
||||
}
|
||||
|
||||
|
@ -37,11 +37,6 @@ namespace DetourNavigator
|
||||
};
|
||||
}
|
||||
|
||||
inline float fromNavMeshCoordinates(const RecastSettings& settings, float value)
|
||||
{
|
||||
return value / settings.mRecastScaleFactor;
|
||||
}
|
||||
|
||||
inline osg::Vec3f fromNavMeshCoordinates(const RecastSettings& settings, osg::Vec3f position)
|
||||
{
|
||||
const auto factor = 1.0f / settings.mRecastScaleFactor;
|
||||
|
@ -8,28 +8,13 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <limits>
|
||||
|
||||
namespace DetourNavigator
|
||||
{
|
||||
TileCachedRecastMeshManager::TileCachedRecastMeshManager(const RecastSettings& settings)
|
||||
: mSettings(settings)
|
||||
, mBounds {osg::Vec2f(-std::numeric_limits<float>::max(), -std::numeric_limits<float>::max()),
|
||||
osg::Vec2f(std::numeric_limits<float>::max(), std::numeric_limits<float>::max())}
|
||||
{}
|
||||
|
||||
TileBounds TileCachedRecastMeshManager::getBounds() const
|
||||
{
|
||||
const std::lock_guard lock(mMutex);
|
||||
return mBounds;
|
||||
}
|
||||
|
||||
void TileCachedRecastMeshManager::setBounds(const TileBounds& bounds)
|
||||
{
|
||||
const std::lock_guard lock(mMutex);
|
||||
mBounds = bounds;
|
||||
}
|
||||
|
||||
std::string TileCachedRecastMeshManager::getWorldspace() const
|
||||
{
|
||||
const std::lock_guard lock(mMutex);
|
||||
@ -51,7 +36,7 @@ namespace DetourNavigator
|
||||
std::vector<TilePosition> tilesPositions;
|
||||
{
|
||||
const std::lock_guard lock(mMutex);
|
||||
getTilesPositions(makeTilesPositionsRange(shape.getShape(), transform, mBounds, mSettings),
|
||||
getTilesPositions(makeTilesPositionsRange(shape.getShape(), transform, mSettings),
|
||||
[&] (const TilePosition& tilePosition)
|
||||
{
|
||||
if (addTile(id, shape, transform, areaType, tilePosition, mTiles))
|
||||
|
@ -20,10 +20,6 @@ namespace DetourNavigator
|
||||
public:
|
||||
explicit TileCachedRecastMeshManager(const RecastSettings& settings);
|
||||
|
||||
TileBounds getBounds() const;
|
||||
|
||||
void setBounds(const TileBounds& bounds);
|
||||
|
||||
std::string getWorldspace() const;
|
||||
|
||||
void setWorldspace(std::string_view worldspace);
|
||||
@ -61,7 +57,7 @@ namespace DetourNavigator
|
||||
changed = true;
|
||||
}
|
||||
};
|
||||
getTilesPositions(makeTilesPositionsRange(shape.getShape(), transform, mBounds, mSettings), onTilePosition);
|
||||
getTilesPositions(makeTilesPositionsRange(shape.getShape(), transform, mSettings), onTilePosition);
|
||||
std::sort(newTiles.begin(), newTiles.end());
|
||||
for (const auto& tile : currentTiles)
|
||||
{
|
||||
@ -113,7 +109,6 @@ namespace DetourNavigator
|
||||
|
||||
const RecastSettings& mSettings;
|
||||
mutable std::mutex mMutex;
|
||||
TileBounds mBounds;
|
||||
std::string mWorldspace;
|
||||
TilesMap mTiles;
|
||||
std::unordered_map<ObjectId, std::vector<TilePosition>> mObjectsTilesPositions;
|
||||
|
Loading…
x
Reference in New Issue
Block a user