1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 19:19:55 +00:00
openmw-tes3mp/apps/openmw_test_suite/detournavigator/recastmeshobject.cpp

82 lines
3.3 KiB
C++
Raw Normal View History

2018-05-26 14:44:25 +00:00
#include "operators.hpp"
#include <components/detournavigator/recastmeshobject.hpp>
#include <BulletCollision/CollisionShapes/btBoxShape.h>
#include <BulletCollision/CollisionShapes/btCompoundShape.h>
#include <gtest/gtest.h>
namespace
{
using namespace testing;
using namespace DetourNavigator;
struct DetourNavigatorRecastMeshObjectTest : Test
{
btBoxShape mBoxShapeImpl {btVector3(1, 2, 3)};
CollisionShape mBoxShape {nullptr, mBoxShapeImpl};
btCompoundShape mCompoundShapeImpl {true};
CollisionShape mCompoundShape {nullptr, mCompoundShapeImpl};
2018-05-26 14:44:25 +00:00
btTransform mTransform {btQuaternion(btVector3(1, 2, 3), 1), btVector3(1, 2, 3)};
DetourNavigatorRecastMeshObjectTest()
{
mCompoundShapeImpl.addChildShape(mTransform, std::addressof(mBoxShapeImpl));
2018-05-26 14:44:25 +00:00
}
};
TEST_F(DetourNavigatorRecastMeshObjectTest, constructed_object_should_have_shape_and_transform)
{
2018-07-18 19:09:50 +00:00
const RecastMeshObject object(mBoxShape, mTransform, AreaType_ground);
EXPECT_EQ(std::addressof(object.getShape()), std::addressof(mBoxShapeImpl));
2018-05-26 14:44:25 +00:00
EXPECT_EQ(object.getTransform(), mTransform);
}
TEST_F(DetourNavigatorRecastMeshObjectTest, update_with_same_transform_for_not_compound_shape_should_return_false)
{
2018-07-18 19:09:50 +00:00
RecastMeshObject object(mBoxShape, mTransform, AreaType_ground);
EXPECT_FALSE(object.update(mTransform, AreaType_ground));
2018-05-26 14:44:25 +00:00
}
TEST_F(DetourNavigatorRecastMeshObjectTest, update_with_different_transform_should_return_true)
{
2018-07-18 19:09:50 +00:00
RecastMeshObject object(mBoxShape, mTransform, AreaType_ground);
EXPECT_TRUE(object.update(btTransform::getIdentity(), AreaType_ground));
2018-07-12 08:44:11 +00:00
}
TEST_F(DetourNavigatorRecastMeshObjectTest, update_with_different_flags_should_return_true)
{
2018-07-18 19:09:50 +00:00
RecastMeshObject object(mBoxShape, mTransform, AreaType_ground);
EXPECT_TRUE(object.update(mTransform, AreaType_null));
2018-05-26 14:44:25 +00:00
}
TEST_F(DetourNavigatorRecastMeshObjectTest, update_for_compound_shape_with_same_transform_and_not_changed_child_transform_should_return_false)
{
2018-07-18 19:09:50 +00:00
RecastMeshObject object(mCompoundShape, mTransform, AreaType_ground);
EXPECT_FALSE(object.update(mTransform, AreaType_ground));
2018-05-26 14:44:25 +00:00
}
TEST_F(DetourNavigatorRecastMeshObjectTest, update_for_compound_shape_with_same_transform_and_changed_child_transform_should_return_true)
{
2018-07-18 19:09:50 +00:00
RecastMeshObject object(mCompoundShape, mTransform, AreaType_ground);
mCompoundShapeImpl.updateChildTransform(0, btTransform::getIdentity());
2018-07-18 19:09:50 +00:00
EXPECT_TRUE(object.update(mTransform, AreaType_ground));
2018-05-26 14:44:25 +00:00
}
TEST_F(DetourNavigatorRecastMeshObjectTest, repeated_update_for_compound_shape_without_changes_should_return_false)
{
2018-07-18 19:09:50 +00:00
RecastMeshObject object(mCompoundShape, mTransform, AreaType_ground);
mCompoundShapeImpl.updateChildTransform(0, btTransform::getIdentity());
2018-07-18 19:09:50 +00:00
object.update(mTransform, AreaType_ground);
EXPECT_FALSE(object.update(mTransform, AreaType_ground));
2018-05-26 14:44:25 +00:00
}
2019-03-03 12:51:02 +00:00
TEST_F(DetourNavigatorRecastMeshObjectTest, update_for_changed_local_scaling_should_return_true)
{
RecastMeshObject object(mBoxShape, mTransform, AreaType_ground);
mBoxShapeImpl.setLocalScaling(btVector3(2, 2, 2));
2019-03-03 12:51:02 +00:00
EXPECT_TRUE(object.update(mTransform, AreaType_ground));
}
2018-05-26 14:44:25 +00:00
}