Ticket #3785: shortPathfinder.patch

File shortPathfinder.patch, 1.2 KB (added by mimo, 8 years ago)
  • source/simulation2/components/CCmpPathfinder_Vertex.cpp

     
    656656
    657657        if (i >= staticShapesNb)
    658658            pathfindClearance = clearance - entity_pos_t::FromInt(1)/2;
    659        
     659
    660660        // Expand the vertexes by the moving unit's collision radius, to find the
    661661        // closest we can get to it
    662662
     
    838838            else
    839839            {
    840840                npos = vertexes[n].p;
     841                // hack to fix cases where a path along an obstruction will end up in an impassable region
     842                // TODO fix it properly
     843                int i = (npos.X >> Pathfinding::NAVCELL_SIZE_LOG2).ToInt_RoundToNegInfinity();
     844                int j = (npos.Y >> Pathfinding::NAVCELL_SIZE_LOG2).ToInt_RoundToNegInfinity();
     845                if (!IS_PASSABLE(m_Grid->get(i, j), passClass))
     846                    continue;
    841847            }
    842848
    843849            // Work out which quadrant(s) we're approaching the new vertex from
     
    853859                // Hack: Always head towards the goal if possible, to avoid missing it if it's
    854860                // inside another unit
    855861                if (n != GOAL_VERTEX_ID)
    856                 {
    857862                    continue;
    858                 }
    859863            }
    860864
    861865            bool visible =