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

Renamed the hit_vertices in tree to hit_handles

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@15200 383ad7c9-94d9-4d36-a494-682f7c89f535
parent ae033d7f
......@@ -134,10 +134,10 @@ raycollision(const Point& _p, const Point& _r) const
data.ref = _p;
data.dist = FLT_MAX;
data.ray = _r;
data.hit_vertices.clear();
data.hit_handles.clear();
_raycollision_non_directional(this->root_, data);
return RayCollision(data.nearest, data.dist, data.hit_vertices);
return RayCollision(data.nearest, data.dist, data.hit_handles);
}
template <class BSPCore>
......@@ -150,10 +150,10 @@ directionalRaycollision(const Point& _p, const Point& _r) const {
data.ref = _p;
data.dist = FLT_MAX;
data.ray = _r;
data.hit_vertices.clear();
data.hit_handles.clear();
_raycollision_directional(this->root_, data);
return RayCollision(data.nearest, data.dist, data.hit_vertices);
return RayCollision(data.nearest, data.dist, data.hit_handles);
}
......@@ -178,7 +178,7 @@ _raycollision_non_directional(Node* _node, RayCollisionData& _data) const
this->traits_.points(*it, v0, v1, v2);
if (ACG::Geometry::triangleIntersection(_data.ref, _data.ray, v0, v1, v2, dist, u, v)) {
_data.hit_vertices.push_back(*it);
_data.hit_handles.push_back(*it);
// face intersects with ray. But is it closer than any that we have found so far?
if ( fabs(dist) < _data.dist)
......@@ -229,7 +229,7 @@ _raycollision_directional(Node* _node, RayCollisionData& _data) const
if ( dist <= 0.0 )
continue;
_data.hit_vertices.push_back(*it);
_data.hit_handles.push_back(*it);
// face intersects with ray. But is it closer than any that we have found so far?
// Note as we rely on the direction of the hit, so we will never get negative directions here
......
......@@ -96,10 +96,10 @@ public: //---------------------------------------------------------------------
struct RayCollision
{
RayCollision() {}
RayCollision(Handle _h, Scalar _d, std::vector<Handle> _v) : handle(_h), dist(_d), hit_vertices(_v) {}
Handle handle;
Scalar dist;
std::vector<Handle> hit_vertices;
RayCollision(Handle _h, Scalar _d, std::vector<Handle> _v) : handle(_h), dist(_d), hit_handles(_v) {}
Handle handle; //!< Handle of the closest object
Scalar dist; //!< Distance to the closest handle
std::vector<Handle> hit_handles; //!< Vector of all handles that have been hit
};
/// Return handle of the nearest neighbor face
......@@ -154,7 +154,7 @@ private: //---------------------------------------------------------------------
Point ray;
Scalar dist;
Handle nearest;
std::vector<Handle> hit_vertices;
std::vector<Handle> hit_handles;
};
......
......@@ -321,10 +321,10 @@ 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_vertices.size() ) << "Wrong number of hit faces in ray collision test 1";
if ( rc.hit_vertices.size() == 2u ) { // Don't crash on wrong size
EXPECT_EQ(4, rc.hit_vertices[0].idx() ) << "Wrong handle of first face in ray collision test 1";
EXPECT_EQ(9, rc.hit_vertices[1].idx() ) << "Wrong handle of second face in ray collision test 1";
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(4, rc.handle.idx() ) << "Wrong handle of closest face in ray collision test 1";
......@@ -355,10 +355,10 @@ 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_vertices.size() ) << "Wrong number of hit faces in ray collision test 1";
if ( rc.hit_vertices.size() == 2u ) { // Don't crash on wrong size
EXPECT_EQ(4, rc.hit_vertices[0].idx() ) << "Wrong handle of first face in ray collision test 1";
EXPECT_EQ(9, rc.hit_vertices[1].idx() ) << "Wrong handle of second face in ray collision test 1";
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(4, rc.handle.idx() ) << "Wrong handle of closest face in ray collision test 1";
......@@ -385,10 +385,10 @@ 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_vertices.size() ) << "Wrong number of hit faces in ray collision test 2";
if ( rc.hit_vertices.size() == 2u ) { // Don't crash on wrong size
EXPECT_EQ(5, rc.hit_vertices[0].idx() ) << "Wrong handle of first face in ray collision test 2";
EXPECT_EQ(8, rc.hit_vertices[1].idx() ) << "Wrong handle of second face in ray collision test 2";
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(5, rc.handle.idx() ) << "Wrong handle of closest face in ray collision test 2";
......@@ -416,10 +416,10 @@ 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_vertices.size() ) << "Wrong number of hit faces in ray collision test 2";
if ( rc.hit_vertices.size() == 2u ) { // Don't crash on wrong size
EXPECT_EQ(5, rc.hit_vertices[0].idx() ) << "Wrong handle of first face in ray collision test 2";
EXPECT_EQ(8, rc.hit_vertices[1].idx() ) << "Wrong handle of second face in ray collision test 2";
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(5, rc.handle.idx() ) << "Wrong handle of closest face in ray collision test 2";
......@@ -454,10 +454,10 @@ TEST_F(BSP_CUBE_BASE, RayIntersectionAboveSurface_DirectionalFunction_1 ) {
Mesh::Point p1(-0.5,-2.0,0.0);
BSP::RayCollision rc = bsp_->directionalRaycollision(p1,yDirection);
EXPECT_EQ(2u, rc.hit_vertices.size() ) << "Wrong number of hit faces in ray collision test 1";
if ( rc.hit_vertices.size() == 2u ) { // Don't crash on wrong size
EXPECT_EQ(4, rc.hit_vertices[0].idx() ) << "Wrong handle of first face in ray collision test 1";
EXPECT_EQ(9, rc.hit_vertices[1].idx() ) << "Wrong handle of second face in ray collision test 1";
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(4, rc.handle.idx() ) << "Wrong handle of closest face in ray collision test 1";
......@@ -488,7 +488,7 @@ 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_vertices.size() ) << "Wrong number of hit faces in ray collision test 1";
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";
}
Markdown is supported
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