make bestPlaneDirect, bestPlaneIndirect const

This commit is contained in:
Garux 2020-05-05 19:49:01 +03:00
parent 002f45d6d9
commit ef2fdfa127
5 changed files with 16 additions and 16 deletions

View File

@ -299,8 +299,8 @@ STRING_CONSTANT( Name, "PlaneSelectable" );
virtual void selectPlanes( Selector& selector, SelectionTest& test, const PlaneCallback& selectedPlaneCallback ) = 0; virtual void selectPlanes( Selector& selector, SelectionTest& test, const PlaneCallback& selectedPlaneCallback ) = 0;
virtual void selectReversedPlanes( Selector& selector, const SelectedPlanes& selectedPlanes ) = 0; virtual void selectReversedPlanes( Selector& selector, const SelectedPlanes& selectedPlanes ) = 0;
virtual void bestPlaneDirect( SelectionTest& test, Plane3& plane, SelectionIntersection& intersection ) = 0; virtual void bestPlaneDirect( SelectionTest& test, Plane3& plane, SelectionIntersection& intersection ) const = 0;
virtual void bestPlaneIndirect( SelectionTest& test, Plane3& plane, Vector3& intersection, float& dist ) = 0; virtual void bestPlaneIndirect( SelectionTest& test, Plane3& plane, Vector3& intersection, float& dist ) const = 0;
virtual void selectByPlane( const Plane3& plane ) = 0; virtual void selectByPlane( const Plane3& plane ) = 0;
virtual void gatherPolygonsByPlane( const Plane3& plane, std::vector<std::vector<Vector3>>& polygons ) const = 0; virtual void gatherPolygonsByPlane( const Plane3& plane, std::vector<std::vector<Vector3>>& polygons ) const = 0;
}; };

View File

@ -86,7 +86,7 @@ class DragPlanes
{ {
ObservedSelectable m_selectables[6]; ObservedSelectable m_selectables[6];
public: public:
AABB m_bounds; mutable AABB m_bounds;
DragPlanes( const SelectionChangeCallback& onchanged ) : m_selectables{ ObservedSelectable( onchanged ), DragPlanes( const SelectionChangeCallback& onchanged ) : m_selectables{ ObservedSelectable( onchanged ),
ObservedSelectable( onchanged ), 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] ); 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; AABB aabb_ = aabb;
for( std::size_t i = 0; i < 3; ++i ) /* make sides of flat patches more selectable */ for( std::size_t i = 0; i < 3; ++i ) /* make sides of flat patches more selectable */
if( aabb_.extents[i] < 1 ) if( aabb_.extents[i] < 1 )
@ -195,7 +195,7 @@ void bestPlaneDirect( const AABB& aabb, SelectionTest& test, Plane3& plane, Sele
} }
m_bounds = aabb; 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]; Vector3 corners[8];
aabb_corners_oriented( aabb, rotation, corners ); aabb_corners_oriented( aabb, rotation, corners );

View File

@ -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 ) { if ( g_lightType == LIGHTTYPE_DOOM3 ) {
test.BeginMesh( localToWorld() ); test.BeginMesh( localToWorld() );
m_dragPlanes.bestPlaneDirect( m_contained.aabb(), test, plane, intersection, rotation() ); 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 ) { if ( g_lightType == LIGHTTYPE_DOOM3 ) {
test.BeginMesh( localToWorld() ); test.BeginMesh( localToWorld() );
m_dragPlanes.bestPlaneIndirect( m_contained.aabb(), test, plane, intersection, dist, rotation() ); m_dragPlanes.bestPlaneIndirect( m_contained.aabb(), test, plane, intersection, dist, rotation() );

View File

@ -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() ); test.BeginMesh( localToWorld() );
for ( FaceInstances::iterator i = m_faceInstances.begin(); i != m_faceInstances.end(); ++i ) for ( const FaceInstance& fi : m_faceInstances )
{ {
SelectionIntersection intersection_new; SelectionIntersection intersection_new;
( *i ).testSelect( test, intersection_new ); fi.testSelect( test, intersection_new );
if( SelectionIntersection_closer( intersection_new, intersection ) ){ if( SelectionIntersection_closer( intersection_new, intersection ) ){
intersection = intersection_new; 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() ); test.BeginMesh( localToWorld() );
float dot = 1; 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 ){ void selectByPlane( const Plane3& plane ){

View File

@ -1649,11 +1649,11 @@ void selectReversedPlanes( Selector& selector, const SelectedPlanes& selectedPla
m_dragPlanes.selectReversedPlanes( m_patch.localAABB(), selector, selectedPlanes ); 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() ); test.BeginMesh( localToWorld() );
m_dragPlanes.bestPlaneDirect( m_patch.localAABB(), test, plane, intersection ); 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() ); test.BeginMesh( localToWorld() );
m_dragPlanes.bestPlaneIndirect( m_patch.localAABB(), test, plane, intersection, dist ); m_dragPlanes.bestPlaneIndirect( m_patch.localAABB(), test, plane, intersection, dist );
} }