diff --git a/radiant/selection.cpp b/radiant/selection.cpp index f77469d4..2cce6aa1 100644 --- a/radiant/selection.cpp +++ b/radiant/selection.cpp @@ -2335,8 +2335,6 @@ public: Vector3 corners[8]; aabb_corners( m_bounds_draw, corners ); - for ( Vector3* i = corners; i != corners + 8; ++i ) - *i = vector3_subtracted( line_closest_point( line, *i ), *i ); const int indices[24] = { 3, 7, 4, 0, //-x @@ -2354,11 +2352,14 @@ public: for ( int i = 0; i < 3; ++i ){ for ( int j = 0; j < 2; ++j ){ const Vector3 normal = j? g_vector3_axes[i] : -g_vector3_axes[i]; + const Vector3 centroid = m_bounds.origin + m_bounds.extents * normal; + const Vector3 closest_point = line_closest_point( line, centroid ); + const int index = i * 8 + j * 4; - if( vector3_dot( normal, corners[indices[index]] ) > 0 - && vector3_dot( normal, corners[indices[index + 1]] ) > 0 - && vector3_dot( normal, corners[indices[index + 2]] ) > 0 - && vector3_dot( normal, corners[indices[index + 3]] ) > 0 ) + if( vector3_dot( normal, closest_point - corners[indices[index]] ) > 0 + && vector3_dot( normal, closest_point - corners[indices[index + 1]] ) > 0 + && vector3_dot( normal, closest_point - corners[indices[index + 2]] ) > 0 + && vector3_dot( normal, closest_point - corners[indices[index + 3]] ) > 0 ) { const double dot = fabs( vector3_dot( normal, viewdir ) ); const double diff = bestDot - dot;