router: remove some old cruft from the WALKAROUND class

This commit is contained in:
Tomasz Wlostowski 2022-06-03 23:18:42 +02:00
parent 0bd7f603a3
commit c8b93c39b6
4 changed files with 28 additions and 50 deletions

View File

@ -821,7 +821,6 @@ bool LINE_PLACER::rhShoveOnly( const VECTOR2I& aP, LINE& aNewHead )
walkaround.SetWorld( m_currentNode );
walkaround.SetSolidsOnly( false );
walkaround.SetIterationLimit( 10 );
walkaround.SetApproachCursor( true, aP );
walkaround.Route( initTrack, l2 );
aNewHead = l2.ClipToNearestObstacle( m_shove->CurrentNode() );

View File

@ -710,12 +710,10 @@ SHOVE::SHOVE_STATUS SHOVE::onCollidingSolid( LINE& aCurrent, ITEM* aObstacle, OB
{
nextRank = currentRank - 1;
walkaround.SetSingleDirection( true );
}
else
{
nextRank = currentRank + 10000;
walkaround.SetSingleDirection( false );
}

View File

@ -28,6 +28,8 @@
#include "pns_utils.h"
#include "pns_router.h"
#include "pns_debug_decorator.h"
#include "pns_solid.h"
namespace PNS {
@ -53,6 +55,25 @@ NODE::OPT_OBSTACLE WALKAROUND::nearestObstacle( const LINE& aPath )
}
void WALKAROUND::RestrictToSet( bool aEnabled, const std::set<ITEM*>& aSet )
{
m_restrictedVertices.clear();
if( aEnabled )
m_restrictedSet = aSet;
else
m_restrictedSet.clear();
for( auto item : aSet )
{
if( auto solid = dyn_cast<SOLID*>( item ) )
{
m_restrictedVertices.push_back( solid->Anchor( 0 ) );
}
}
}
WALKAROUND::WALKAROUND_STATUS WALKAROUND::singleStep( LINE& aPath, bool aWindingDirection )
{
OPT<OBSTACLE>& current_obs =
@ -111,7 +132,6 @@ const WALKAROUND::RESULT WALKAROUND::Route( const LINE& aInitialPath )
start( aInitialPath );
m_currentObstacle[0] = m_currentObstacle[1] = nearestObstacle( aInitialPath );
m_recursiveBlockageCount = 0;
result.lineCw = aInitialPath;
result.lineCcw = aInitialPath;
@ -120,11 +140,6 @@ const WALKAROUND::RESULT WALKAROUND::Route( const LINE& aInitialPath )
{
s_cw = m_forceCw ? IN_PROGRESS : STUCK;
s_ccw = m_forceCw ? STUCK : IN_PROGRESS;
m_forceSingleDirection = true;
}
else
{
m_forceSingleDirection = false;
}
// In some situations, there isn't a trivial path (or even a path at all). Hitting the
@ -198,6 +213,9 @@ const WALKAROUND::RESULT WALKAROUND::Route( const LINE& aInitialPath )
result.statusCcw = ALMOST_DONE;
}
result.lineCw.ClearLinks();
result.lineCcw.ClearLinks();
return result;
}
@ -223,7 +241,6 @@ WALKAROUND::WALKAROUND_STATUS WALKAROUND::Route( const LINE& aInitialPath, LINE&
start( aInitialPath );
m_currentObstacle[0] = m_currentObstacle[1] = nearestObstacle( aInitialPath );
m_recursiveBlockageCount = 0;
aWalkPath = aInitialPath;
@ -231,11 +248,6 @@ WALKAROUND::WALKAROUND_STATUS WALKAROUND::Route( const LINE& aInitialPath, LINE&
{
s_cw = m_forceCw ? IN_PROGRESS : STUCK;
s_ccw = m_forceCw ? STUCK : IN_PROGRESS;
m_forceSingleDirection = true;
}
else
{
m_forceSingleDirection = false;
}
while( m_iteration < m_iterationLimit )

View File

@ -42,18 +42,13 @@ public:
m_world( aWorld ),
m_iterationLimit( DefaultIterationLimit )
{
m_forceSingleDirection = false;
m_forceLongerPath = false;
m_forceWinding = false;
m_cursorApproachMode = false;
m_itemMask = ITEM::ANY_T;
// Initialize other members, to avoid uninitialized variables.
m_recursiveBlockageCount = 0;
m_recursiveCollision[0] = m_recursiveCollision[1] = false;
m_iteration = 0;
m_forceCw = false;
m_forceUniqueWindingDirection = false;
m_forceLongerPath = false;
}
~WALKAROUND() {};
@ -103,36 +98,13 @@ public:
m_itemMask = aMask;
}
void SetSingleDirection( bool aForceSingleDirection )
{
m_forceSingleDirection = aForceSingleDirection;
m_forceLongerPath = aForceSingleDirection;
}
void SetSingleDirection2( bool aForceSingleDirection )
{
m_forceSingleDirection = aForceSingleDirection;
}
void SetApproachCursor( bool aEnabled, const VECTOR2I& aPos )
{
m_cursorPos = aPos;
m_cursorApproachMode = aEnabled;
}
void SetForceWinding ( bool aEnabled, bool aCw )
{
m_forceCw = aCw;
m_forceWinding = aEnabled;
}
void RestrictToSet( bool aEnabled, const std::set<ITEM*>& aSet )
{
if( aEnabled )
m_restrictedSet = aSet;
else
m_restrictedSet.clear();
}
void RestrictToSet( bool aEnabled, const std::set<ITEM*>& aSet );
WALKAROUND_STATUS Route( const LINE& aInitialPath, LINE& aWalkPath,
bool aOptimize = true );
@ -147,19 +119,16 @@ private:
NODE* m_world;
int m_recursiveBlockageCount;
int m_iteration;
int m_iterationLimit;
int m_itemMask;
bool m_forceSingleDirection, m_forceLongerPath;
bool m_cursorApproachMode;
bool m_forceWinding;
bool m_forceCw;
bool m_forceUniqueWindingDirection;
VECTOR2I m_cursorPos;
NODE::OPT_OBSTACLE m_currentObstacle[2];
bool m_recursiveCollision[2];
std::set<ITEM*> m_restrictedSet;
std::vector<VECTOR2I> m_restrictedVertices;
bool m_forceLongerPath;
};
}