Commit 9e455664 authored by Jan Möbius's avatar Jan Möbius
Browse files

Fixed unittests for bsp change

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@15243 383ad7c9-94d9-4d36-a494-682f7c89f535
parent fcccdb0d
......@@ -322,13 +322,12 @@ TEST_F(BSP_CUBE_BASE, RayIntersectionAboveSurface_NonDirectionalFunction_1 ) {
Mesh::Point p1(-0.5,-2.0,0.0);
BSP::RayCollision rc = bsp_->raycollision(p1,yDirection);
EXPECT_EQ(2u, rc.hit_handles.size() ) << "Wrong number of hit faces in ray collision test 1";
if ( rc.hit_handles.size() == 2u ) { // Don't crash on wrong size
EXPECT_EQ(4, rc.hit_handles[0].idx() ) << "Wrong handle of first face in ray collision test 1";
EXPECT_EQ(9, rc.hit_handles[1].idx() ) << "Wrong handle of second face in ray collision test 1";
EXPECT_EQ(2u, rc.size() ) << "Wrong number of hit faces in ray collision test 1";
if ( rc.size() == 2u ) { // Don't crash on wrong size
EXPECT_EQ(4, rc[0].first.idx() ) << "Wrong handle of first face in ray collision test 1";
EXPECT_EQ(9, rc[1].first.idx() ) << "Wrong handle of second face in ray collision test 1";
}
EXPECT_EQ(4, rc.handle.idx() ) << "Wrong handle of closest face in ray collision test 1";
}
TEST_F(BSP_CUBE_BASE, RayIntersectionAboveSurface_NonDirectionalFunction_NegativeDirection_1 ) {
......@@ -356,13 +355,11 @@ TEST_F(BSP_CUBE_BASE, RayIntersectionAboveSurface_NonDirectionalFunction_Negativ
Mesh::Point p1(-0.5,-2.0,0.0);
BSP::RayCollision rc = bsp_->raycollision(p1,nyDirection);
EXPECT_EQ(2u, rc.hit_handles.size() ) << "Wrong number of hit faces in ray collision test 1";
if ( rc.hit_handles.size() == 2u ) { // Don't crash on wrong size
EXPECT_EQ(4, rc.hit_handles[0].idx() ) << "Wrong handle of first face in ray collision test 1";
EXPECT_EQ(9, rc.hit_handles[1].idx() ) << "Wrong handle of second face in ray collision test 1";
EXPECT_EQ(2u, rc.size() ) << "Wrong number of hit faces in ray collision test 1";
if ( rc.size() == 2u ) { // Don't crash on wrong size
EXPECT_EQ(4, rc[0].first.idx() ) << "Wrong handle of first face in ray collision test 1";
EXPECT_EQ(9, rc[1].first.idx() ) << "Wrong handle of second face in ray collision test 1";
}
EXPECT_EQ(4, rc.handle.idx() ) << "Wrong handle of closest face in ray collision test 1";
}
TEST_F(BSP_CUBE_BASE, RayIntersectionAboveSurface_NonDirectionalFunction_2 ) {
......@@ -386,13 +383,12 @@ TEST_F(BSP_CUBE_BASE, RayIntersectionAboveSurface_NonDirectionalFunction_2 ) {
Mesh::Point p1(0.5,-2.0,0.0);
BSP::RayCollision rc = bsp_->raycollision(p1,yDirection);
EXPECT_EQ(2u, rc.hit_handles.size() ) << "Wrong number of hit faces in ray collision test 2";
if ( rc.hit_handles.size() == 2u ) { // Don't crash on wrong size
EXPECT_EQ(5, rc.hit_handles[0].idx() ) << "Wrong handle of first face in ray collision test 2";
EXPECT_EQ(8, rc.hit_handles[1].idx() ) << "Wrong handle of second face in ray collision test 2";
EXPECT_EQ(2u, rc.size() ) << "Wrong number of hit faces in ray collision test 2";
if ( rc.size() == 2u ) { // Don't crash on wrong size
EXPECT_EQ(5, rc[0].first.idx() ) << "Wrong handle of first face in ray collision test 2";
EXPECT_EQ(8, rc[1].first.idx() ) << "Wrong handle of second face in ray collision test 2";
}
EXPECT_EQ(5, rc.handle.idx() ) << "Wrong handle of closest face in ray collision test 2";
}
TEST_F(BSP_CUBE_BASE, RayIntersectionAboveSurface_NonDirectionalFunction_NegativeDirection_2 ) {
......@@ -417,13 +413,12 @@ TEST_F(BSP_CUBE_BASE, RayIntersectionAboveSurface_NonDirectionalFunction_Negativ
Mesh::Point p1(0.5,-2.0,0.0);
BSP::RayCollision rc = bsp_->raycollision(p1,nyDirection);
EXPECT_EQ(2u, rc.hit_handles.size() ) << "Wrong number of hit faces in ray collision test 2";
if ( rc.hit_handles.size() == 2u ) { // Don't crash on wrong size
EXPECT_EQ(5, rc.hit_handles[0].idx() ) << "Wrong handle of first face in ray collision test 2";
EXPECT_EQ(8, rc.hit_handles[1].idx() ) << "Wrong handle of second face in ray collision test 2";
EXPECT_EQ(2u, rc.size() ) << "Wrong number of hit faces in ray collision test 2";
if ( rc.size() == 2u ) { // Don't crash on wrong size
EXPECT_EQ(5, rc[0].first.idx() ) << "Wrong handle of first face in ray collision test 2";
EXPECT_EQ(8, rc[1].first.idx() ) << "Wrong handle of second face in ray collision test 2";
}
EXPECT_EQ(5, rc.handle.idx() ) << "Wrong handle of closest face in ray collision test 2";
}
......@@ -455,14 +450,14 @@ TEST_F(BSP_CUBE_BASE, RayIntersectionAboveSurface_DirectionalFunction_1 ) {
Mesh::Point origin(-0.5,-2.0,0.0);
BSP::RayCollision rc = bsp_->directionalRaycollision(origin,yDirection);
EXPECT_EQ(2u, rc.hit_handles.size() ) << "Wrong number of hit faces in ray collision test 1";
if ( rc.hit_handles.size() == 2u ) { // Don't crash on wrong size
EXPECT_EQ(4, rc.hit_handles[0].idx() ) << "Wrong handle of first face in ray collision test 1";
EXPECT_EQ(9, rc.hit_handles[1].idx() ) << "Wrong handle of second face in ray collision test 1";
EXPECT_EQ(2u, rc.size() ) << "Wrong number of hit faces in ray collision test 1";
if ( rc.size() == 2u ) { // Don't crash on wrong size
EXPECT_EQ(4, rc[0].first.idx() ) << "Wrong handle of first face in ray collision test 1";
EXPECT_EQ(9, rc[1].first.idx() ) << "Wrong handle of second face in ray collision test 1";
// Some intersection test to see, if we really have something usefull here:
Mesh::FaceVertexIter fv_it = Mesh::FaceVertexIter(mesh_, rc.hit_handles[0]);
Mesh::FaceVertexIter fv_it = Mesh::FaceVertexIter(mesh_, rc[0].first);
float distance,u,v;
Mesh::Point p1 = mesh_.point(fv_it);
......@@ -484,8 +479,6 @@ TEST_F(BSP_CUBE_BASE, RayIntersectionAboveSurface_DirectionalFunction_1 ) {
}
EXPECT_EQ(4, rc.handle.idx() ) << "Wrong handle of closest face in ray collision test 1";
}
TEST_F(BSP_CUBE_BASE, RayIntersectionAboveSurface_DirectionalFunction_NegativeDirection_1 ) {
......@@ -513,8 +506,8 @@ TEST_F(BSP_CUBE_BASE, RayIntersectionAboveSurface_DirectionalFunction_NegativeDi
Mesh::Point p1(-0.5,-2.0,0.0);
BSP::RayCollision rc = bsp_->directionalRaycollision(p1,nyDirection);
EXPECT_EQ(0u, rc.hit_handles.size() ) << "Wrong number of hit faces in ray collision test 1";
EXPECT_FALSE( rc.handle.is_valid() ) << "Wrong handle of closest face in ray collision test 1";
EXPECT_EQ(0u, rc.size() ) << "Wrong number of hit faces in ray collision test 1";
EXPECT_FALSE( rc[0].first.is_valid() ) << "Wrong handle of closest face in ray collision test 1";
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment