1 /* 2 Copyright (C) 2010-2014 Kristian Duske 3 4 This file is part of TrenchBroom. 5 6 TrenchBroom is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 TrenchBroom is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #include "Hit.h" 21 #include "HitFilter.h" 22 23 #include <algorithm> 24 #include <limits> 25 26 namespace TrenchBroom { 27 namespace Model { 28 const Hit::HitType Hit::NoType = 0; 29 const Hit::HitType Hit::AnyType = 0xFFFFFFFF; 30 freeHitType()31 Hit::HitType Hit::freeHitType() { 32 static HitType currentType = 1; 33 const HitType result = currentType; 34 currentType = currentType << 1; 35 return result; 36 } 37 38 const Hit Hit::NoHit = Hit(NoType, 0.0, Vec3::Null, false); 39 isMatch() const40 bool Hit::isMatch() const { 41 return m_type != NoType; 42 } 43 type() const44 Hit::HitType Hit::type() const { 45 return m_type; 46 } 47 hasType(const HitType typeMask) const48 bool Hit::hasType(const HitType typeMask) const { 49 return (m_type & typeMask) != 0; 50 } 51 distance() const52 FloatType Hit::distance() const { 53 return m_distance; 54 } 55 hitPoint() const56 const Vec3& Hit::hitPoint() const { 57 return m_hitPoint; 58 } 59 error() const60 FloatType Hit::error() const { 61 return m_error; 62 } 63 } 64 } 65