mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-23 15:40:42 +00:00
Merge branch 'c++20_fixes' into 'master'
Support compilation with c++20 See merge request OpenMW/openmw!1698
This commit is contained in:
commit
58e794414a
@ -137,7 +137,7 @@ namespace NavMeshTool
|
|||||||
{
|
{
|
||||||
std::lock_guard lock(mMutex);
|
std::lock_guard lock(mMutex);
|
||||||
mDb.insertTile(mNextTileId, worldspace, tilePosition, TileVersion {version}, input, serialize(data));
|
mDb.insertTile(mNextTileId, worldspace, tilePosition, TileVersion {version}, input, serialize(data));
|
||||||
++mNextTileId.t;
|
++mNextTileId;
|
||||||
}
|
}
|
||||||
++mInserted;
|
++mInserted;
|
||||||
report();
|
report();
|
||||||
|
@ -163,7 +163,7 @@ bool Actor::setPosition(const osg::Vec3f& position)
|
|||||||
{
|
{
|
||||||
std::scoped_lock lock(mPositionMutex);
|
std::scoped_lock lock(mPositionMutex);
|
||||||
applyOffsetChange();
|
applyOffsetChange();
|
||||||
bool hasChanged = (mPosition != position && !mSkipSimulation) || mWorldPositionChanged;
|
bool hasChanged = (mPosition.operator!=(position) && !mSkipSimulation) || mWorldPositionChanged;
|
||||||
if (!mSkipSimulation)
|
if (!mSkipSimulation)
|
||||||
{
|
{
|
||||||
mPreviousPosition = mPosition;
|
mPreviousPosition = mPosition;
|
||||||
|
@ -156,7 +156,7 @@ namespace
|
|||||||
for (int y = -2; y <= 2; ++y)
|
for (int y = -2; y <= 2; ++y)
|
||||||
{
|
{
|
||||||
ASSERT_EQ(mDb.insertTile(tileId, worldspace, TilePosition {x, y}, version, input, data), 1);
|
ASSERT_EQ(mDb.insertTile(tileId, worldspace, TilePosition {x, y}, version, input, data), 1);
|
||||||
++tileId.t;
|
++tileId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const TilesPositionsRange range {TilePosition {-1, -1}, TilePosition {2, 2}};
|
const TilesPositionsRange range {TilePosition {-1, -1}, TilePosition {2, 2}};
|
||||||
|
@ -17,9 +17,18 @@ namespace
|
|||||||
|
|
||||||
namespace bpo = boost::program_options;
|
namespace bpo = boost::program_options;
|
||||||
|
|
||||||
std::vector<std::string> generateSupportedCharacters(std::vector<std::string>&& base = {})
|
template <class T, std::size_t size>
|
||||||
|
std::string makeString(const T (&range)[size])
|
||||||
{
|
{
|
||||||
std::vector<std::string> result = std::move(base);
|
static_assert(size > 0);
|
||||||
|
return std::string(std::begin(range), std::end(range) - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class ... Args>
|
||||||
|
std::vector<std::string> generateSupportedCharacters(Args&& ... args)
|
||||||
|
{
|
||||||
|
std::vector<std::string> result;
|
||||||
|
(result.emplace_back(makeString(args)) , ...);
|
||||||
for (int i = 1; i <= std::numeric_limits<char>::max(); ++i)
|
for (int i = 1; i <= std::numeric_limits<char>::max(); ++i)
|
||||||
if (i != '&' && i != '"' && i != ' ' && i != '\n')
|
if (i != '&' && i != '"' && i != ' ' && i != '\n')
|
||||||
result.push_back(std::string(1, i));
|
result.push_back(std::string(1, i));
|
||||||
@ -193,7 +202,7 @@ namespace
|
|||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
SupportedCharacters,
|
SupportedCharacters,
|
||||||
OpenMWOptionsFromArgumentsStrings,
|
OpenMWOptionsFromArgumentsStrings,
|
||||||
ValuesIn(generateSupportedCharacters({u8"👍", u8"Ъ", u8"Ǽ", "\n"}))
|
ValuesIn(generateSupportedCharacters(u8"👍", u8"Ъ", u8"Ǽ", "\n"))
|
||||||
);
|
);
|
||||||
|
|
||||||
TEST(OpenMWOptionsFromConfig, should_support_single_word_load_savegame_path)
|
TEST(OpenMWOptionsFromConfig, should_support_single_word_load_savegame_path)
|
||||||
@ -381,6 +390,6 @@ namespace
|
|||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
SupportedCharacters,
|
SupportedCharacters,
|
||||||
OpenMWOptionsFromConfigStrings,
|
OpenMWOptionsFromConfigStrings,
|
||||||
ValuesIn(generateSupportedCharacters({u8"👍", u8"Ъ", u8"Ǽ"}))
|
ValuesIn(generateSupportedCharacters(u8"👍", u8"Ъ", u8"Ǽ"))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -733,7 +733,7 @@ namespace DetourNavigator
|
|||||||
{
|
{
|
||||||
Stats result;
|
Stats result;
|
||||||
result.mJobs = mQueue.size();
|
result.mJobs = mQueue.size();
|
||||||
result.mGetTileCount = mGetTileCount.load(std::memory_order::memory_order_relaxed);
|
result.mGetTileCount = mGetTileCount.load(std::memory_order_relaxed);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -857,6 +857,6 @@ namespace DetourNavigator
|
|||||||
Log(Debug::Debug) << "Insert db tile by job " << job->mId;
|
Log(Debug::Debug) << "Insert db tile by job " << job->mId;
|
||||||
mDb->insertTile(mNextTileId, job->mWorldspace, job->mChangedTile,
|
mDb->insertTile(mNextTileId, job->mWorldspace, job->mChangedTile,
|
||||||
mVersion, job->mInput, serialize(*job->mGeneratedNavMeshData));
|
mVersion, job->mInput, serialize(*job->mGeneratedNavMeshData));
|
||||||
++mNextTileId.t;
|
++mNextTileId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,13 @@
|
|||||||
#include "tileposition.hpp"
|
#include "tileposition.hpp"
|
||||||
|
|
||||||
#include <components/detournavigator/tilespositionsrange.hpp>
|
#include <components/detournavigator/tilespositionsrange.hpp>
|
||||||
|
#include <components/misc/strongtypedef.hpp>
|
||||||
|
|
||||||
#include <components/sqlite3/db.hpp>
|
#include <components/sqlite3/db.hpp>
|
||||||
#include <components/sqlite3/statement.hpp>
|
#include <components/sqlite3/statement.hpp>
|
||||||
#include <components/sqlite3/transaction.hpp>
|
#include <components/sqlite3/transaction.hpp>
|
||||||
#include <components/sqlite3/types.hpp>
|
#include <components/sqlite3/types.hpp>
|
||||||
|
|
||||||
#include <boost/serialization/strong_typedef.hpp>
|
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@ -28,10 +27,10 @@ struct sqlite3_stmt;
|
|||||||
|
|
||||||
namespace DetourNavigator
|
namespace DetourNavigator
|
||||||
{
|
{
|
||||||
BOOST_STRONG_TYPEDEF(std::int64_t, TileId)
|
using TileId = Misc::StrongTypedef<std::int64_t, struct TiledIdTag>;
|
||||||
BOOST_STRONG_TYPEDEF(std::int64_t, TileRevision)
|
using TileRevision = Misc::StrongTypedef<std::int64_t, struct TileRevisionTag>;
|
||||||
BOOST_STRONG_TYPEDEF(std::int64_t, TileVersion)
|
using TileVersion = Misc::StrongTypedef<std::int64_t, struct TileVersionTag>;
|
||||||
BOOST_STRONG_TYPEDEF(std::int64_t, ShapeId)
|
using ShapeId = Misc::StrongTypedef<std::int64_t, struct ShapeIdTag>;
|
||||||
|
|
||||||
struct Tile
|
struct Tile
|
||||||
{
|
{
|
||||||
|
@ -28,7 +28,7 @@ namespace DetourNavigator
|
|||||||
const ShapeId newShapeId = nextShapeId;
|
const ShapeId newShapeId = nextShapeId;
|
||||||
db.insertShape(newShapeId, name, type, hashData);
|
db.insertShape(newShapeId, name, type, hashData);
|
||||||
Log(Debug::Verbose) << "Added " << name << " " << type << " shape to navmeshdb with id " << newShapeId;
|
Log(Debug::Verbose) << "Added " << name << " " << type << " shape to navmeshdb with id " << newShapeId;
|
||||||
++nextShapeId.t;
|
++nextShapeId;
|
||||||
return newShapeId;
|
return newShapeId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
38
components/misc/strongtypedef.hpp
Normal file
38
components/misc/strongtypedef.hpp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#ifndef OPENMW_COMPONENTS_MISC_STRONGTYPEDEF_H
|
||||||
|
#define OPENMW_COMPONENTS_MISC_STRONGTYPEDEF_H
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
namespace Misc
|
||||||
|
{
|
||||||
|
template <class T, class>
|
||||||
|
struct StrongTypedef
|
||||||
|
{
|
||||||
|
T mValue;
|
||||||
|
|
||||||
|
StrongTypedef() = default;
|
||||||
|
|
||||||
|
explicit StrongTypedef(const T& value) : mValue(value) {}
|
||||||
|
|
||||||
|
explicit StrongTypedef(T&& value) : mValue(std::move(value)) {}
|
||||||
|
|
||||||
|
operator const T&() const { return mValue; }
|
||||||
|
|
||||||
|
operator T&() { return mValue; }
|
||||||
|
|
||||||
|
StrongTypedef& operator++()
|
||||||
|
{
|
||||||
|
++mValue;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
StrongTypedef operator++(int)
|
||||||
|
{
|
||||||
|
StrongTypedef copy(*this);
|
||||||
|
operator++();
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -493,7 +493,7 @@ void MWShadowTechnique::LightData::setLightData(osg::RefMatrix* lm, const osg::L
|
|||||||
lightDir.set(-lightPos.x(), -lightPos.y(), -lightPos.z());
|
lightDir.set(-lightPos.x(), -lightPos.y(), -lightPos.z());
|
||||||
lightDir.normalize();
|
lightDir.normalize();
|
||||||
OSG_INFO<<" Directional light, lightPos="<<lightPos<<", lightDir="<<lightDir<<std::endl;
|
OSG_INFO<<" Directional light, lightPos="<<lightPos<<", lightDir="<<lightDir<<std::endl;
|
||||||
if (lightMatrix.valid() && *lightMatrix != osg::Matrixf(modelViewMatrix))
|
if (lightMatrix.valid() && lightMatrix->operator==(osg::Matrixf(modelViewMatrix)))
|
||||||
{
|
{
|
||||||
OSG_INFO<<" Light matrix "<<*lightMatrix<<std::endl;
|
OSG_INFO<<" Light matrix "<<*lightMatrix<<std::endl;
|
||||||
osg::Matrix lightToLocalMatrix(*lightMatrix * osg::Matrix::inverse(modelViewMatrix) );
|
osg::Matrix lightToLocalMatrix(*lightMatrix * osg::Matrix::inverse(modelViewMatrix) );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user