1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-11-29 15:34:30 +00:00

Fix conversion warnings in components_tests

This commit is contained in:
Evil Eye 2025-09-20 12:12:31 +02:00
parent cb82d37992
commit 71fa8c9f7d
3 changed files with 17 additions and 11 deletions

View file

@ -104,7 +104,7 @@ namespace
surface.mHeights = values.data(); surface.mHeights = values.data();
surface.mMinHeight = -greater; surface.mMinHeight = -greater;
surface.mMaxHeight = greater; surface.mMaxHeight = greater;
surface.mSize = static_cast<int>(std::sqrt(size)); surface.mSize = static_cast<std::size_t>(std::sqrt(size));
return surface; return surface;
} }
@ -331,7 +331,7 @@ namespace
TEST_F(DetourNavigatorNavigatorTest, only_one_heightfield_per_cell_is_allowed) TEST_F(DetourNavigatorNavigatorTest, only_one_heightfield_per_cell_is_allowed)
{ {
const HeightfieldSurface surface1 = makeSquareHeightfieldSurface(defaultHeightfieldData); const HeightfieldSurface surface1 = makeSquareHeightfieldSurface(defaultHeightfieldData);
const int cellSize1 = heightfieldTileSize * (surface1.mSize - 1); const int cellSize1 = heightfieldTileSize * static_cast<int>(surface1.mSize - 1);
const std::array<float, 5 * 5> heightfieldData2{ { const std::array<float, 5 * 5> heightfieldData2{ {
-25, -25, -25, -25, -25, // row 0 -25, -25, -25, -25, -25, // row 0
@ -341,7 +341,7 @@ namespace
-25, -25, -25, -25, -25, // row 4 -25, -25, -25, -25, -25, // row 4
} }; } };
const HeightfieldSurface surface2 = makeSquareHeightfieldSurface(heightfieldData2); const HeightfieldSurface surface2 = makeSquareHeightfieldSurface(heightfieldData2);
const int cellSize2 = heightfieldTileSize * (surface2.mSize - 1); const int cellSize2 = heightfieldTileSize * static_cast<int>(surface2.mSize - 1);
ASSERT_TRUE(mNavigator->addAgent(mAgentBounds)); ASSERT_TRUE(mNavigator->addAgent(mAgentBounds));
mNavigator->addHeightfield(mCellPosition, cellSize1, surface1, nullptr); mNavigator->addHeightfield(mCellPosition, cellSize1, surface1, nullptr);
@ -639,8 +639,9 @@ namespace
for (std::size_t i = 0; i < boxes.size(); ++i) for (std::size_t i = 0; i < boxes.size(); ++i)
{ {
const btScalar diameter = static_cast<btScalar>(i) * 10;
const btTransform transform( const btTransform transform(
btMatrix3x3::getIdentity(), btVector3(shift.x() + i * 10, shift.y() + i * 10, i * 10)); btMatrix3x3::getIdentity(), btVector3(shift.x() + diameter, shift.y() + diameter, diameter));
mNavigator->addObject( mNavigator->addObject(
ObjectId(&boxes[i].shape()), ObjectShapes(boxes[i].instance(), mObjectTransform), transform, nullptr); ObjectId(&boxes[i].shape()), ObjectShapes(boxes[i].instance(), mObjectTransform), transform, nullptr);
} }
@ -649,8 +650,9 @@ namespace
for (std::size_t i = 0; i < boxes.size(); ++i) for (std::size_t i = 0; i < boxes.size(); ++i)
{ {
const btScalar diameter = static_cast<btScalar>(i) * 10 + 1;
const btTransform transform( const btTransform transform(
btMatrix3x3::getIdentity(), btVector3(shift.x() + i * 10 + 1, shift.y() + i * 10 + 1, i * 10 + 1)); btMatrix3x3::getIdentity(), btVector3(shift.x() + diameter, shift.y() + diameter, diameter));
mNavigator->updateObject( mNavigator->updateObject(
ObjectId(&boxes[i].shape()), ObjectShapes(boxes[i].instance(), mObjectTransform), transform, nullptr); ObjectId(&boxes[i].shape()), ObjectShapes(boxes[i].instance(), mObjectTransform), transform, nullptr);
} }
@ -680,7 +682,8 @@ namespace
for (std::size_t i = 0; i < shapes.size(); ++i) for (std::size_t i = 0; i < shapes.size(); ++i)
{ {
const btTransform transform(btMatrix3x3::getIdentity(), btVector3(i * 32, i * 32, i * 32)); const btScalar diameter = static_cast<btScalar>(i) * 32;
const btTransform transform(btMatrix3x3::getIdentity(), btVector3(diameter, diameter, diameter));
mNavigator->addObject( mNavigator->addObject(
ObjectId(&shapes[i].shape()), ObjectShapes(shapes[i].instance(), mObjectTransform), transform, nullptr); ObjectId(&shapes[i].shape()), ObjectShapes(shapes[i].instance(), mObjectTransform), transform, nullptr);
} }
@ -690,7 +693,8 @@ namespace
const auto start = std::chrono::steady_clock::now(); const auto start = std::chrono::steady_clock::now();
for (std::size_t i = 0; i < shapes.size(); ++i) for (std::size_t i = 0; i < shapes.size(); ++i)
{ {
const btTransform transform(btMatrix3x3::getIdentity(), btVector3(i * 32 + 1, i * 32 + 1, i * 32 + 1)); const btScalar diameter = static_cast<btScalar>(i) * 32 + 1;
const btTransform transform(btMatrix3x3::getIdentity(), btVector3(diameter, diameter, diameter));
mNavigator->updateObject( mNavigator->updateObject(
ObjectId(&shapes[i].shape()), ObjectShapes(shapes[i].instance(), mObjectTransform), transform, nullptr); ObjectId(&shapes[i].shape()), ObjectShapes(shapes[i].instance(), mObjectTransform), transform, nullptr);
} }
@ -699,7 +703,8 @@ namespace
for (std::size_t i = 0; i < shapes.size(); ++i) for (std::size_t i = 0; i < shapes.size(); ++i)
{ {
const btTransform transform(btMatrix3x3::getIdentity(), btVector3(i * 32 + 2, i * 32 + 2, i * 32 + 2)); const btScalar diameter = static_cast<btScalar>(i) * 32 + 2;
const btTransform transform(btMatrix3x3::getIdentity(), btVector3(diameter, diameter, diameter));
mNavigator->updateObject( mNavigator->updateObject(
ObjectId(&shapes[i].shape()), ObjectShapes(shapes[i].instance(), mObjectTransform), transform, nullptr); ObjectId(&shapes[i].shape()), ObjectShapes(shapes[i].instance(), mObjectTransform), transform, nullptr);
} }

View file

@ -21,7 +21,7 @@ namespace
using namespace DetourNavigator::Tests; using namespace DetourNavigator::Tests;
template <class T, class Random> template <class T, class Random>
void generateRecastArray(T*& values, int size, Random& random) void generateRecastArray(T*& values, size_t size, Random& random)
{ {
values = static_cast<T*>(permRecastAlloc(size * sizeof(T))); values = static_cast<T*>(permRecastAlloc(size * sizeof(T)));
generateRange(values, values + static_cast<std::ptrdiff_t>(size), random); generateRange(values, values + static_cast<std::ptrdiff_t>(size), random);

View file

@ -300,10 +300,11 @@ namespace
void copy(const btTransform& src, Nif::NiTransform& dst) void copy(const btTransform& src, Nif::NiTransform& dst)
{ {
dst.mTranslation = osg::Vec3f(src.getOrigin().x(), src.getOrigin().y(), src.getOrigin().z()); dst.mTranslation = osg::Vec3f(static_cast<float>(src.getOrigin().x()), static_cast<float>(src.getOrigin().y()),
static_cast<float>(src.getOrigin().z()));
for (int row = 0; row < 3; ++row) for (int row = 0; row < 3; ++row)
for (int column = 0; column < 3; ++column) for (int column = 0; column < 3; ++column)
dst.mRotation.mValues[row][column] = src.getBasis().getRow(row)[column]; dst.mRotation.mValues[row][column] = static_cast<float>(src.getBasis().getRow(row)[column]);
} }
struct TestBulletNifLoader : Test struct TestBulletNifLoader : Test