diff --git a/include/selectable.h b/include/selectable.h index fa63d447..08dd0c92 100644 --- a/include/selectable.h +++ b/include/selectable.h @@ -299,8 +299,8 @@ STRING_CONSTANT( Name, "PlaneSelectable" ); virtual void selectPlanes( Selector& selector, SelectionTest& test, const PlaneCallback& selectedPlaneCallback ) = 0; virtual void selectReversedPlanes( Selector& selector, const SelectedPlanes& selectedPlanes ) = 0; -virtual void bestPlaneDirect( SelectionTest& test, Plane3& plane, SelectionIntersection& intersection ) = 0; -virtual void bestPlaneIndirect( SelectionTest& test, Plane3& plane, Vector3& intersection, float& dist ) = 0; +virtual void bestPlaneDirect( SelectionTest& test, Plane3& plane, SelectionIntersection& intersection ) const = 0; +virtual void bestPlaneIndirect( SelectionTest& test, Plane3& plane, Vector3& intersection, float& dist ) const = 0; virtual void selectByPlane( const Plane3& plane ) = 0; virtual void gatherPolygonsByPlane( const Plane3& plane, std::vector>& polygons ) const = 0; }; diff --git a/libs/dragplanes.h b/libs/dragplanes.h index dc00413f..a3eeb1f9 100644 --- a/libs/dragplanes.h +++ b/libs/dragplanes.h @@ -86,7 +86,7 @@ class DragPlanes { ObservedSelectable m_selectables[6]; public: -AABB m_bounds; +mutable AABB m_bounds; DragPlanes( const SelectionChangeCallback& onchanged ) : m_selectables{ ObservedSelectable( onchanged ), ObservedSelectable( onchanged ), ObservedSelectable( onchanged ), @@ -163,7 +163,7 @@ void selectReversedPlanes( const AABB& aabb, Selector& selector, const SelectedP Selector_add( selector, m_selectables[i] ); } -void bestPlaneDirect( const AABB& aabb, SelectionTest& test, Plane3& plane, SelectionIntersection& intersection, const Matrix4& rotation = g_matrix4_identity ){ +void bestPlaneDirect( const AABB& aabb, SelectionTest& test, Plane3& plane, SelectionIntersection& intersection, const Matrix4& rotation = g_matrix4_identity ) const { AABB aabb_ = aabb; for( std::size_t i = 0; i < 3; ++i ) /* make sides of flat patches more selectable */ if( aabb_.extents[i] < 1 ) @@ -195,7 +195,7 @@ void bestPlaneDirect( const AABB& aabb, SelectionTest& test, Plane3& plane, Sele } m_bounds = aabb; } -void bestPlaneIndirect( const AABB& aabb, SelectionTest& test, Plane3& plane, Vector3& intersection, float& dist, const Matrix4& rotation = g_matrix4_identity ){ +void bestPlaneIndirect( const AABB& aabb, SelectionTest& test, Plane3& plane, Vector3& intersection, float& dist, const Matrix4& rotation = g_matrix4_identity ) const { Vector3 corners[8]; aabb_corners_oriented( aabb, rotation, corners ); diff --git a/plugins/entity/light.cpp b/plugins/entity/light.cpp index d11d6116..99094f05 100644 --- a/plugins/entity/light.cpp +++ b/plugins/entity/light.cpp @@ -1874,13 +1874,13 @@ void selectReversedPlanes( Selector& selector, const SelectedPlanes& selectedPla } } -void bestPlaneDirect( SelectionTest& test, Plane3& plane, SelectionIntersection& intersection ){ +void bestPlaneDirect( SelectionTest& test, Plane3& plane, SelectionIntersection& intersection ) const { if ( g_lightType == LIGHTTYPE_DOOM3 ) { test.BeginMesh( localToWorld() ); m_dragPlanes.bestPlaneDirect( m_contained.aabb(), test, plane, intersection, rotation() ); } } -void bestPlaneIndirect( SelectionTest& test, Plane3& plane, Vector3& intersection, float& dist ){ +void bestPlaneIndirect( SelectionTest& test, Plane3& plane, Vector3& intersection, float& dist ) const { if ( g_lightType == LIGHTTYPE_DOOM3 ) { test.BeginMesh( localToWorld() ); m_dragPlanes.bestPlaneIndirect( m_contained.aabb(), test, plane, intersection, dist, rotation() ); diff --git a/radiant/brush.h b/radiant/brush.h index 6b5e3cbe..cf3ff39b 100644 --- a/radiant/brush.h +++ b/radiant/brush.h @@ -3930,24 +3930,24 @@ void selectReversedPlanes( Selector& selector, const SelectedPlanes& selectedPla } } -void bestPlaneDirect( SelectionTest& test, Plane3& plane, SelectionIntersection& intersection ){ +void bestPlaneDirect( SelectionTest& test, Plane3& plane, SelectionIntersection& intersection ) const { test.BeginMesh( localToWorld() ); - for ( FaceInstances::iterator i = m_faceInstances.begin(); i != m_faceInstances.end(); ++i ) + for ( const FaceInstance& fi : m_faceInstances ) { SelectionIntersection intersection_new; - ( *i ).testSelect( test, intersection_new ); + fi.testSelect( test, intersection_new ); if( SelectionIntersection_closer( intersection_new, intersection ) ){ intersection = intersection_new; - plane = ( *i ).getFace().plane3(); + plane = fi.getFace().plane3(); } } } -void bestPlaneIndirect( SelectionTest& test, Plane3& plane, Vector3& intersection, float& dist ){ +void bestPlaneIndirect( SelectionTest& test, Plane3& plane, Vector3& intersection, float& dist ) const { test.BeginMesh( localToWorld() ); float dot = 1; - for ( EdgeInstances::iterator i = m_edgeInstances.begin(); i != m_edgeInstances.end(); ++i ) + for ( const EdgeInstance& ei : m_edgeInstances ) { - ( *i ).bestPlaneIndirect( test, plane, intersection, dist, dot ); + ei.bestPlaneIndirect( test, plane, intersection, dist, dot ); } } void selectByPlane( const Plane3& plane ){ diff --git a/radiant/patch.h b/radiant/patch.h index 1b2ca3af..b0c8ce56 100644 --- a/radiant/patch.h +++ b/radiant/patch.h @@ -1649,11 +1649,11 @@ void selectReversedPlanes( Selector& selector, const SelectedPlanes& selectedPla m_dragPlanes.selectReversedPlanes( m_patch.localAABB(), selector, selectedPlanes ); } -void bestPlaneDirect( SelectionTest& test, Plane3& plane, SelectionIntersection& intersection ){ +void bestPlaneDirect( SelectionTest& test, Plane3& plane, SelectionIntersection& intersection ) const { test.BeginMesh( localToWorld() ); m_dragPlanes.bestPlaneDirect( m_patch.localAABB(), test, plane, intersection ); } -void bestPlaneIndirect( SelectionTest& test, Plane3& plane, Vector3& intersection, float& dist ){ +void bestPlaneIndirect( SelectionTest& test, Plane3& plane, Vector3& intersection, float& dist ) const { test.BeginMesh( localToWorld() ); m_dragPlanes.bestPlaneIndirect( m_patch.localAABB(), test, plane, intersection, dist ); }