code: boolean optimizePathTopology(NavMeshQuery navquery, QueryFilter filter) {
          if (m_path.size() < 3) {
              return false;
          }
  
          final int MAX_ITER = 32;
  
          navquery.initSlicedFindPath(m_path.get(0), m_path.get(m_path.size() - 1), m_pos, m_target, filter, 0);
          navquery.updateSlicedFindPath(MAX_ITER);
          Result<List<Long>> fpr = navquery.finalizeSlicedFindPathPartial(m_path);
  
          if (fpr.succeeded() && fpr.result.size() > 0) {
              m_path = mergeCorridorStartShortcut(m_path, fpr.result);
              return true;
          }
  
          return false;
      }
docs: Attempts to optimize the path using a local area search. (Partial replanning.)
  
  Inaccurate locomotion or dynamic obstacle avoidance can force the agent position significantly outside the
  original corridor. Over time this can result in the formation of a non-optimal corridor. This function will use a
  local area path search to try to re-optimize the corridor.
  
  The more inaccurate the agent movement, the more beneficial this function becomes. Simply adjust the frequency of
  the call to match the needs to the agent.
  
  @param navquery
  The query object used to build the corridor.
  @param filter
  The filter to apply to the operation.